@vellumai/assistant 0.10.7-dev.202607092332.9deedf4 → 0.10.7-dev.202607100313.fffdfea

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.
Files changed (249) hide show
  1. package/ARCHITECTURE.md +1 -2
  2. package/docs/architecture/memory.md +1 -3
  3. package/node_modules/@vellumai/ces-client/node_modules/@vellumai/service-contracts/package.json +0 -2
  4. package/node_modules/@vellumai/ces-client/node_modules/@vellumai/service-contracts/src/__tests__/contracts.test.ts +0 -2
  5. package/node_modules/@vellumai/ces-client/node_modules/@vellumai/service-contracts/src/credential-rpc.ts +3 -5
  6. package/node_modules/@vellumai/ces-client/node_modules/@vellumai/service-contracts/src/index.ts +2 -4
  7. package/node_modules/@vellumai/ces-client/node_modules/@vellumai/service-contracts/src/rpc.ts +4 -447
  8. package/node_modules/@vellumai/gateway-client/node_modules/@vellumai/service-contracts/package.json +0 -2
  9. package/node_modules/@vellumai/gateway-client/node_modules/@vellumai/service-contracts/src/__tests__/contracts.test.ts +0 -2
  10. package/node_modules/@vellumai/gateway-client/node_modules/@vellumai/service-contracts/src/credential-rpc.ts +3 -5
  11. package/node_modules/@vellumai/gateway-client/node_modules/@vellumai/service-contracts/src/index.ts +2 -4
  12. package/node_modules/@vellumai/gateway-client/node_modules/@vellumai/service-contracts/src/rpc.ts +4 -447
  13. package/node_modules/@vellumai/service-contracts/package.json +0 -2
  14. package/node_modules/@vellumai/service-contracts/src/__tests__/contracts.test.ts +0 -2
  15. package/node_modules/@vellumai/service-contracts/src/credential-rpc.ts +3 -5
  16. package/node_modules/@vellumai/service-contracts/src/index.ts +2 -4
  17. package/node_modules/@vellumai/service-contracts/src/rpc.ts +4 -447
  18. package/openapi.yaml +1 -222
  19. package/package.json +1 -1
  20. package/scripts/memory-inspect.ts +2 -8
  21. package/src/__tests__/approval-routes-http.test.ts +0 -8
  22. package/src/__tests__/background-workers-disk-pressure.test.ts +4 -2
  23. package/src/__tests__/compaction-events.test.ts +0 -4
  24. package/src/__tests__/context-search-memory-source.test.ts +0 -1
  25. package/src/__tests__/conversation-agent-loop-disk-pressure.test.ts +0 -1
  26. package/src/__tests__/conversation-agent-loop-inference-profile.test.ts +0 -2
  27. package/src/__tests__/conversation-agent-loop-overflow.test.ts +0 -2
  28. package/src/__tests__/conversation-agent-loop.test.ts +0 -4
  29. package/src/__tests__/conversation-app-control-lifecycle.test.ts +0 -4
  30. package/src/__tests__/conversation-fork-crud.test.ts +18 -5
  31. package/src/__tests__/conversation-fork-retrospective.test.ts +483 -0
  32. package/src/__tests__/conversation-routes-disk-view.test.ts +0 -4
  33. package/src/__tests__/conversation-store.test.ts +0 -10
  34. package/src/__tests__/conversation-summarize-up-to.test.ts +0 -4
  35. package/src/__tests__/credential-execution-api-key-propagation.test.ts +0 -40
  36. package/src/__tests__/credential-execution-client.test.ts +3 -3
  37. package/src/__tests__/credential-execution-managed-contract.test.ts +8 -104
  38. package/src/__tests__/file-write-tool.test.ts +9 -13
  39. package/src/__tests__/graph-extraction-event-date.test.ts +0 -9
  40. package/src/__tests__/injection-block.test.ts +0 -1
  41. package/src/__tests__/job-handler-registration-guard.test.ts +0 -1
  42. package/src/__tests__/lexical-index-dual-write.test.ts +2 -2
  43. package/src/__tests__/llm-resolver.test.ts +0 -1
  44. package/src/__tests__/messages-after-tiebreaker.test.ts +0 -1
  45. package/src/__tests__/playbook-execution.test.ts +2 -26
  46. package/src/__tests__/plugin-import-boundary-guard.test.ts +0 -4
  47. package/src/__tests__/plugin-import-boundary-reverse-guard.test.ts +318 -0
  48. package/src/__tests__/proxy-approval-callback.test.ts +0 -1
  49. package/src/__tests__/rebuild-index-graph-nodes.test.ts +0 -4
  50. package/src/__tests__/send-endpoint-busy.test.ts +0 -12
  51. package/src/__tests__/service-contracts-import-guard.test.ts +4 -9
  52. package/src/__tests__/subagent-fork-spawn.test.ts +0 -37
  53. package/src/__tests__/task-memory-cleanup.test.ts +0 -11
  54. package/src/__tests__/voice-scoped-grant-consumer.test.ts +0 -1
  55. package/src/__tests__/voice-session-bridge.test.ts +0 -56
  56. package/src/__tests__/workspace-migration-009-backfill-conversation-disk-view.test.ts +0 -1
  57. package/src/__tests__/workspace-migration-013-repair-conversation-disk-view.test.ts +0 -1
  58. package/src/__tests__/workspace-migration-028-recover-conversations-from-disk-view.test.ts +0 -1
  59. package/src/__tests__/workspace-migration-129-remove-analyze-conversation-config.test.ts +190 -0
  60. package/src/cli/commands/db/repair-step-conversation-backfill.ts +0 -1
  61. package/src/config/bundled-skills/messaging/tools/messaging-analyze-style.ts +0 -6
  62. package/src/config/bundled-skills/playbooks/tools/playbook-create.ts +0 -3
  63. package/src/config/bundled-skills/playbooks/tools/playbook-delete.ts +0 -3
  64. package/src/config/bundled-skills/playbooks/tools/playbook-list.ts +1 -3
  65. package/src/config/bundled-skills/playbooks/tools/playbook-update.ts +0 -4
  66. package/src/config/call-site-defaults.ts +0 -1
  67. package/src/config/feature-flag-registry.json +0 -16
  68. package/src/config/schema.ts +0 -3
  69. package/src/config/schemas/call-site-catalog.ts +0 -6
  70. package/src/config/schemas/llm.ts +0 -1
  71. package/src/conversations/job-handlers/summarization.ts +0 -2
  72. package/src/daemon/conversation-agent-loop-handlers.ts +0 -1
  73. package/src/daemon/conversation-agent-loop.ts +1 -6
  74. package/src/daemon/conversation-lifecycle.ts +0 -14
  75. package/src/daemon/conversation-turn-finalize.ts +0 -1
  76. package/src/daemon/handlers/shared.ts +1 -2
  77. package/src/export/transcript-formatter.ts +9 -39
  78. package/src/home/conversation-starter-checkpoints.ts +9 -5
  79. package/src/home/job-handlers/conversation-starters.ts +24 -54
  80. package/src/hooks/types.ts +2 -2
  81. package/src/ipc/routes/__tests__/memory-v2-backfill.test.ts +5 -7
  82. package/src/persistence/__tests__/bulk-write-gate.test.ts +165 -0
  83. package/src/persistence/__tests__/immediate-transaction-guard.test.ts +70 -0
  84. package/src/persistence/auto-analysis-constants.ts +4 -13
  85. package/src/persistence/bulk-write-gate.ts +82 -0
  86. package/src/persistence/conversation-bootstrap.ts +3 -3
  87. package/src/persistence/conversation-crud.ts +158 -80
  88. package/src/persistence/conversation-key-store.ts +0 -2
  89. package/src/persistence/conversation-row-batch-delete.ts +16 -1
  90. package/src/persistence/conversation-types.ts +12 -1
  91. package/src/persistence/db-async-query.ts +18 -9
  92. package/src/persistence/db-connection.ts +20 -4
  93. package/src/persistence/db-maintenance.ts +78 -6
  94. package/src/persistence/embeddings/qdrant-client.ts +2 -18
  95. package/src/persistence/fork-message-copy.ts +18 -4
  96. package/src/persistence/jobs-store.ts +3 -86
  97. package/src/persistence/migrations/323-delete-non-default-memory-scopes.test.ts +148 -0
  98. package/src/persistence/migrations/323-delete-non-default-memory-scopes.ts +35 -0
  99. package/src/persistence/schema/conversations.ts +0 -1
  100. package/src/persistence/schema/memory-core.ts +17 -28
  101. package/src/persistence/schema/memory-graph.ts +0 -4
  102. package/src/persistence/schema/tasks.ts +0 -1
  103. package/src/persistence/steps.ts +2 -0
  104. package/src/playbooks/playbook-compiler.ts +2 -10
  105. package/src/plugins/defaults/memory/__tests__/db-maintenance.test.ts +105 -11
  106. package/src/plugins/defaults/memory/__tests__/jobs-store-enqueue-gate.test.ts +7 -62
  107. package/src/plugins/defaults/memory/__tests__/memory-retrospective-job.test.ts +47 -5
  108. package/src/plugins/defaults/memory/__tests__/memory-retrospective-skill-card.test.ts +29 -1
  109. package/src/plugins/defaults/memory/__tests__/memory-retrospective-startup-cleanup.test.ts +133 -70
  110. package/src/plugins/defaults/memory/activation-session-store.ts +1 -1
  111. package/src/plugins/defaults/memory/config.ts +1 -1
  112. package/src/plugins/defaults/memory/context-search/sources/conversations.ts +1 -1
  113. package/src/plugins/defaults/memory/context-search/sources/memory-v2.ts +1 -1
  114. package/src/plugins/defaults/memory/context-search/sources/memory.ts +1 -1
  115. package/src/plugins/defaults/memory/filing-jobs.ts +1 -1
  116. package/src/plugins/defaults/memory/fork-conversation-memory.ts +8 -4
  117. package/src/plugins/defaults/memory/frontmatter.ts +1 -1
  118. package/src/plugins/defaults/memory/graph/__tests__/handle-remember-v2.test.ts +4 -25
  119. package/src/plugins/defaults/memory/graph/bootstrap.ts +12 -18
  120. package/src/plugins/defaults/memory/graph/capability-seed.ts +4 -18
  121. package/src/plugins/defaults/memory/graph/consolidation.ts +7 -14
  122. package/src/plugins/defaults/memory/graph/conversation-graph-memory.ts +1 -3
  123. package/src/plugins/defaults/memory/graph/decay.ts +5 -10
  124. package/src/plugins/defaults/memory/graph/extraction-job.ts +2 -3
  125. package/src/plugins/defaults/memory/graph/extraction.test.ts +1 -9
  126. package/src/plugins/defaults/memory/graph/extraction.ts +1 -8
  127. package/src/plugins/defaults/memory/graph/graph-search.ts +1 -2
  128. package/src/plugins/defaults/memory/graph/injection.test.ts +0 -1
  129. package/src/plugins/defaults/memory/graph/injection.ts +1 -1
  130. package/src/plugins/defaults/memory/graph/narrative.ts +1 -3
  131. package/src/plugins/defaults/memory/graph/pattern-scan.ts +1 -4
  132. package/src/plugins/defaults/memory/graph/retriever.test.ts +0 -19
  133. package/src/plugins/defaults/memory/graph/retriever.ts +6 -14
  134. package/src/plugins/defaults/memory/graph/scoring.test.ts +0 -1
  135. package/src/plugins/defaults/memory/graph/store.test.ts +6 -58
  136. package/src/plugins/defaults/memory/graph/store.ts +5 -43
  137. package/src/plugins/defaults/memory/graph/tool-handlers.test.ts +0 -4
  138. package/src/plugins/defaults/memory/graph/tool-handlers.ts +1 -11
  139. package/src/plugins/defaults/memory/graph/types.ts +0 -3
  140. package/src/plugins/defaults/memory/hooks/init.ts +1 -1
  141. package/src/plugins/defaults/memory/indexer.ts +2 -45
  142. package/src/plugins/defaults/memory/injectors.ts +2 -3
  143. package/src/plugins/defaults/memory/job-handler-registration.ts +0 -4
  144. package/src/plugins/defaults/memory/job-handlers/backfill.ts +0 -1
  145. package/src/plugins/defaults/memory/job-handlers/embedding.test.ts +0 -1
  146. package/src/plugins/defaults/memory/job-handlers/embedding.ts +0 -4
  147. package/src/plugins/defaults/memory/job-handlers/index-maintenance.ts +1 -1
  148. package/src/plugins/defaults/memory/job-handlers.ts +5 -9
  149. package/src/plugins/defaults/memory/jobs/embed-concept-page.ts +1 -1
  150. package/src/plugins/defaults/memory/jobs/embed-pkb-file.test.ts +41 -21
  151. package/src/plugins/defaults/memory/jobs/embed-pkb-file.ts +10 -5
  152. package/src/plugins/defaults/memory/jobs-worker.ts +21 -9
  153. package/src/plugins/defaults/memory/logging.ts +17 -0
  154. package/src/plugins/defaults/memory/memory-retrospective-constants.ts +10 -7
  155. package/src/plugins/defaults/memory/memory-retrospective-enqueue.ts +5 -6
  156. package/src/plugins/defaults/memory/memory-retrospective-fork-boundary.ts +57 -20
  157. package/src/plugins/defaults/memory/memory-retrospective-job.ts +13 -15
  158. package/src/plugins/defaults/memory/memory-retrospective-skill-card.ts +2 -2
  159. package/src/plugins/defaults/memory/memory-retrospective-startup-cleanup.ts +52 -39
  160. package/src/plugins/defaults/memory/memory-retrospective-trigger-check.ts +1 -1
  161. package/src/plugins/defaults/memory/pkb/pkb-index.test.ts +25 -38
  162. package/src/plugins/defaults/memory/pkb/pkb-index.ts +7 -19
  163. package/src/plugins/defaults/memory/pkb/pkb-reconcile.test.ts +46 -28
  164. package/src/plugins/defaults/memory/pkb/pkb-reconcile.ts +4 -9
  165. package/src/plugins/defaults/memory/pkb/pkb-search.test.ts +3 -9
  166. package/src/plugins/defaults/memory/pkb/pkb-search.ts +2 -9
  167. package/src/plugins/defaults/memory/pkb/types.ts +0 -11
  168. package/src/plugins/defaults/memory/rerank-local.ts +1 -1
  169. package/src/plugins/defaults/memory/routes/memory-eval-routes.ts +1 -1
  170. package/src/plugins/defaults/memory/routes/memory-item-routes.test.ts +0 -1
  171. package/src/plugins/defaults/memory/routes/memory-item-routes.ts +3 -11
  172. package/src/plugins/defaults/memory/routes/memory-v2-routes.ts +1 -1
  173. package/src/plugins/defaults/memory/routes/memory-v3-routes.ts +1 -1
  174. package/src/plugins/defaults/memory/startup.ts +2 -3
  175. package/src/plugins/defaults/memory/task-memory-cleanup.ts +1 -1
  176. package/src/plugins/defaults/memory/tools.test.ts +1 -9
  177. package/src/plugins/defaults/memory/tools.ts +0 -1
  178. package/src/plugins/defaults/memory/v2/backfill-jobs.ts +1 -1
  179. package/src/plugins/defaults/memory/v2/cli-command-store.ts +1 -1
  180. package/src/plugins/defaults/memory/v2/consolidation-job.ts +1 -1
  181. package/src/plugins/defaults/memory/v2/frontmatter-sweep.ts +1 -1
  182. package/src/plugins/defaults/memory/v2/injection-events.ts +1 -1
  183. package/src/plugins/defaults/memory/v2/injection.ts +1 -1
  184. package/src/plugins/defaults/memory/v2/memory-v2-startup.ts +1 -1
  185. package/src/plugins/defaults/memory/v2/migration.ts +1 -1
  186. package/src/plugins/defaults/memory/v2/page-index.ts +1 -1
  187. package/src/plugins/defaults/memory/v2/prompts/consolidation.ts +1 -1
  188. package/src/plugins/defaults/memory/v2/prompts/router.ts +1 -1
  189. package/src/plugins/defaults/memory/v2/qdrant.ts +1 -1
  190. package/src/plugins/defaults/memory/v2/reranker.ts +1 -1
  191. package/src/plugins/defaults/memory/v2/router.ts +1 -1
  192. package/src/plugins/defaults/memory/v2/skill-store.ts +1 -1
  193. package/src/plugins/defaults/memory/v2/sweep-job.ts +1 -1
  194. package/src/plugins/defaults/memory/v3/candidate-match.ts +1 -1
  195. package/src/plugins/defaults/memory/v3/dense.ts +1 -1
  196. package/src/plugins/defaults/memory/v3/injector.ts +1 -1
  197. package/src/plugins/defaults/memory/v3/maintain-job.ts +1 -1
  198. package/src/plugins/defaults/memory/v3/orchestrate.ts +1 -1
  199. package/src/plugins/defaults/memory/v3/pool-select.ts +1 -1
  200. package/src/plugins/defaults/memory/v3/prune.ts +1 -1
  201. package/src/plugins/defaults/memory/v3/section-dense-store.ts +1 -1
  202. package/src/plugins/defaults/memory/v3/shadow-plugin.ts +1 -1
  203. package/src/plugins/defaults/memory/worker.ts +1 -1
  204. package/src/runtime/capabilities.ts +1 -1
  205. package/src/runtime/routes/__tests__/bookmark-routes.test.ts +0 -1
  206. package/src/runtime/routes/__tests__/conversation-management-routes.test.ts +0 -1
  207. package/src/runtime/routes/__tests__/conversation-query-routes.test.ts +0 -1
  208. package/src/runtime/routes/conversation-starter-routes.ts +12 -23
  209. package/src/runtime/routes/index.ts +0 -2
  210. package/src/runtime/services/__tests__/auto-analysis-guard.test.ts +1 -8
  211. package/src/runtime/services/__tests__/conversation-serializer.test.ts +0 -1
  212. package/src/runtime/services/auto-analysis-guard.ts +5 -5
  213. package/src/runtime/services/conversation-serializer.ts +2 -3
  214. package/src/tasks/SPEC.md +10 -17
  215. package/src/tools/executor.ts +1 -102
  216. package/src/tools/filesystem/write.ts +0 -2
  217. package/src/tools/tool-types.ts +0 -15
  218. package/src/tools/types.ts +0 -10
  219. package/src/workspace/migrations/028-recover-conversations-from-disk-view.ts +0 -1
  220. package/src/workspace/migrations/129-remove-analyze-conversation-config.ts +59 -0
  221. package/src/workspace/migrations/registry.ts +2 -0
  222. package/node_modules/@vellumai/ces-client/node_modules/@vellumai/service-contracts/src/__tests__/grants.test.ts +0 -686
  223. package/node_modules/@vellumai/ces-client/node_modules/@vellumai/service-contracts/src/grants.ts +0 -184
  224. package/node_modules/@vellumai/ces-client/node_modules/@vellumai/service-contracts/src/rendering.ts +0 -135
  225. package/node_modules/@vellumai/gateway-client/node_modules/@vellumai/service-contracts/src/__tests__/grants.test.ts +0 -686
  226. package/node_modules/@vellumai/gateway-client/node_modules/@vellumai/service-contracts/src/grants.ts +0 -184
  227. package/node_modules/@vellumai/gateway-client/node_modules/@vellumai/service-contracts/src/rendering.ts +0 -135
  228. package/node_modules/@vellumai/service-contracts/src/__tests__/grants.test.ts +0 -686
  229. package/node_modules/@vellumai/service-contracts/src/grants.ts +0 -184
  230. package/node_modules/@vellumai/service-contracts/src/rendering.ts +0 -135
  231. package/src/__tests__/auto-analysis-end-to-end.test.ts +0 -621
  232. package/src/__tests__/auto-analysis-prompt.test.ts +0 -50
  233. package/src/__tests__/config-analysis.test.ts +0 -83
  234. package/src/__tests__/conversation-analysis-routes.test.ts +0 -156
  235. package/src/__tests__/credential-execution-approval-bridge.test.ts +0 -297
  236. package/src/config/schemas/analysis.ts +0 -32
  237. package/src/credential-execution/approval-bridge.ts +0 -320
  238. package/src/daemon/__tests__/conversation-lifecycle-auto-analyze.test.ts +0 -449
  239. package/src/plugins/defaults/memory/__tests__/find-analysis-conversation.test.ts +0 -197
  240. package/src/runtime/routes/conversation-analysis-routes.ts +0 -75
  241. package/src/runtime/services/__tests__/analyze-conversation.test.ts +0 -477
  242. package/src/runtime/services/__tests__/auto-analysis-enqueue.test.ts +0 -386
  243. package/src/runtime/services/__tests__/auto-analysis-prompt.test.ts +0 -53
  244. package/src/runtime/services/__tests__/conversation-analyze-job.test.ts +0 -213
  245. package/src/runtime/services/__tests__/manual-analysis-prompt.test.ts +0 -41
  246. package/src/runtime/services/analyze-conversation.ts +0 -334
  247. package/src/runtime/services/auto-analysis-enqueue.ts +0 -130
  248. package/src/runtime/services/auto-analysis-prompt.ts +0 -55
  249. package/src/runtime/services/conversation-analyze-job.ts +0 -53
@@ -39,6 +39,7 @@
39
39
  // The sweep is skipped entirely when `memory.retrospective.keepSupersededRuns`
40
40
  // is true — see the comment inside the function.
41
41
 
42
+ import { deleteConversation } from "@vellumai/plugin-api";
42
43
  import {
43
44
  and,
44
45
  eq,
@@ -51,14 +52,13 @@ import {
51
52
  sql,
52
53
  } from "drizzle-orm";
53
54
 
54
- import { deleteConversation } from "../../../persistence/conversation-crud.js";
55
55
  import { getDb, getMemoryDb } from "../../../persistence/db-connection.js";
56
56
  import {
57
57
  conversations,
58
58
  memoryJobs,
59
59
  } from "../../../persistence/schema/index.js";
60
- import { getLogger } from "../../../util/logger.js";
61
60
  import { getMemoryConfig } from "./config.js";
61
+ import { getLogger } from "./logging.js";
62
62
  import { MEMORY_RETROSPECTIVE_SOURCES } from "./memory-retrospective-constants.js";
63
63
  import { loadRetrospectiveRunMessages } from "./memory-retrospective-fork-boundary.js";
64
64
 
@@ -85,9 +85,9 @@ export interface CleanupResult {
85
85
  * deleted. Best-effort: errors deleting individual rows are logged and the
86
86
  * sweep continues.
87
87
  */
88
- export function sweepOrphanMemoryRetrospectiveConversations(
88
+ export async function sweepOrphanMemoryRetrospectiveConversations(
89
89
  now: number = Date.now(),
90
- ): CleanupResult {
90
+ ): Promise<CleanupResult> {
91
91
  // When the operator opted into retaining superseded retrospective runs
92
92
  // (`memory.retrospective.keepSupersededRuns`), skip the sweep entirely —
93
93
  // retained runs must survive restarts, and the sweep cannot distinguish a
@@ -109,28 +109,6 @@ export function sweepOrphanMemoryRetrospectiveConversations(
109
109
  return { swept: 0 };
110
110
  }
111
111
 
112
- // Job payloads encode the SOURCE conversation id (the conversation being
113
- // analyzed), not the background-conversation id of the retrospective itself.
114
- // The background conversation links back to its source via
115
- // `forkParentConversationId` (set when bootstrapped — see
116
- // memory-retrospective-job.ts). To protect in-flight jobs we therefore
117
- // compare source-id to source-id by filtering on
118
- // `conversations.forkParentConversationId`, not `conversations.id`.
119
- const activeJobSourceConversationIds = memoryDb
120
- .select({
121
- conversationId: sql<string>`json_extract(${memoryJobs.payload}, '$.conversationId')`,
122
- })
123
- .from(memoryJobs)
124
- .where(
125
- and(
126
- eq(memoryJobs.type, "memory_retrospective"),
127
- inArray(memoryJobs.status, ["pending", "running"]),
128
- ),
129
- )
130
- .all()
131
- .map((row) => row.conversationId)
132
- .filter((id): id is string => typeof id === "string" && id.length > 0);
133
-
134
112
  // Compute the preserved dedup baseline per source. Runs whose state row
135
113
  // predates the persisted `remembered_log` pull dedup context by scanning
136
114
  // the most-recent prior retro (via `findMostRecentRetrospectiveFor`);
@@ -153,7 +131,9 @@ export function sweepOrphanMemoryRetrospectiveConversations(
153
131
  const retrosPerSource = new Map<string, RetroRow[]>();
154
132
  for (const row of allRetros) {
155
133
  const parent = row.forkParentConversationId;
156
- if (parent === null) continue;
134
+ if (parent === null) {
135
+ continue;
136
+ }
157
137
  const rows = retrosPerSource.get(parent);
158
138
  if (rows) {
159
139
  rows.push(row);
@@ -163,9 +143,38 @@ export function sweepOrphanMemoryRetrospectiveConversations(
163
143
  }
164
144
  const preservedIds = new Set<string>();
165
145
  for (const rows of retrosPerSource.values()) {
166
- preservedIds.add(selectPreservedBaseline(rows));
146
+ preservedIds.add(await selectPreservedBaseline(rows));
167
147
  }
168
148
 
149
+ // Job payloads encode the SOURCE conversation id (the conversation being
150
+ // analyzed), not the background-conversation id of the retrospective itself.
151
+ // The background conversation links back to its source via
152
+ // `forkParentConversationId` (set when bootstrapped — see
153
+ // memory-retrospective-job.ts). To protect in-flight jobs we therefore
154
+ // compare source-id to source-id by filtering on
155
+ // `conversations.forkParentConversationId`, not `conversations.id`.
156
+ //
157
+ // Read in the same synchronous block as the orphan query below — AFTER the
158
+ // awaited baseline loads above. The sweep runs concurrently with worker
159
+ // ticking, and a retrospective forked while baselines were loading inherits
160
+ // the copied source prefix's old `lastMessageAt`, so the age cutoff alone
161
+ // does not protect it; its pending/running job must be in this set when the
162
+ // orphan candidates are classified.
163
+ const activeJobSourceConversationIds = memoryDb
164
+ .select({
165
+ conversationId: sql<string>`json_extract(${memoryJobs.payload}, '$.conversationId')`,
166
+ })
167
+ .from(memoryJobs)
168
+ .where(
169
+ and(
170
+ eq(memoryJobs.type, "memory_retrospective"),
171
+ inArray(memoryJobs.status, ["pending", "running"]),
172
+ ),
173
+ )
174
+ .all()
175
+ .map((row) => row.conversationId)
176
+ .filter((id): id is string => typeof id === "string" && id.length > 0);
177
+
169
178
  const orphans = db
170
179
  .select({ id: conversations.id })
171
180
  .from(conversations)
@@ -198,7 +207,7 @@ export function sweepOrphanMemoryRetrospectiveConversations(
198
207
  let swept = 0;
199
208
  for (const row of orphans) {
200
209
  try {
201
- deleteConversation(row.id);
210
+ await deleteConversation(row.id);
202
211
  swept++;
203
212
  } catch (err) {
204
213
  log.warn(
@@ -240,25 +249,29 @@ interface RetroRow {
240
249
  * Only loads messages for the newest `MAX_BASELINE_CANDIDATES_PER_SOURCE`
241
250
  * rows — never for every retro row.
242
251
  */
243
- function selectPreservedBaseline(rows: RetroRow[]): string {
252
+ async function selectPreservedBaseline(rows: RetroRow[]): Promise<string> {
244
253
  const sorted = [...rows].sort((a, b) => b.createdAt - a.createdAt);
245
- const withOutput = sorted
246
- .slice(0, MAX_BASELINE_CANDIDATES_PER_SOURCE)
247
- .find(retrospectiveHasOutput);
248
- return (withOutput ?? sorted[0]!).id;
254
+ for (const row of sorted.slice(0, MAX_BASELINE_CANDIDATES_PER_SOURCE)) {
255
+ if (await retrospectiveHasOutput(row)) {
256
+ return row.id;
257
+ }
258
+ }
259
+ return sorted[0]!.id;
249
260
  }
250
261
 
251
262
  /**
252
263
  * Whether the retrospective row produced any assistant output of its own.
253
264
  * `loadRetrospectiveRunMessages` scopes fork-kind rows to the post-fork tail
254
265
  * (the copied source prefix contains the source's own assistant turns) and
255
- * returns `null` for rows whose output cannot be determined (load failure or
256
- * no detectable fork boundary) — those rows contribute nothing to dedup
266
+ * returns `null` for rows whose output cannot be determined (load failure) —
267
+ * those rows contribute nothing to dedup
257
268
  * (`collectPriorRetrospectiveRemembers` treats them as empty), so they don't
258
269
  * qualify. Legacy-kind rows start empty, so any assistant message counts.
259
270
  */
260
- function retrospectiveHasOutput(row: RetroRow): boolean {
261
- const runMessages = loadRetrospectiveRunMessages(row.id, row.source);
262
- if (runMessages == null) return false;
271
+ async function retrospectiveHasOutput(row: RetroRow): Promise<boolean> {
272
+ const runMessages = await loadRetrospectiveRunMessages(row.id, row.source);
273
+ if (runMessages == null) {
274
+ return false;
275
+ }
263
276
  return runMessages.some((m) => m.role === "assistant");
264
277
  }
@@ -22,7 +22,7 @@
22
22
  // over the assistant's own card. See `memory-retrospective-accounting.ts`.
23
23
 
24
24
  import type { AssistantConfig } from "../../../config/types.js";
25
- import { getLogger } from "../../../util/logger.js";
25
+ import { getLogger } from "./logging.js";
26
26
  import { countRetrospectiveMessagesAfter } from "./memory-retrospective-accounting.js";
27
27
  import { enqueueMemoryRetrospectiveIfEnabled } from "./memory-retrospective-enqueue.js";
28
28
  import { getRetrospectiveState } from "./memory-retrospective-state.js";
@@ -46,7 +46,6 @@ mock.module("../../../../config/loader.js", () => ({
46
46
  const qdrantDeleteCalls: Array<{
47
47
  targetType: string;
48
48
  path: string;
49
- memoryScopeId: string;
50
49
  }> = [];
51
50
 
52
51
  // Track per-target deletes (used by write-then-cleanup in indexPkbFile).
@@ -63,18 +62,13 @@ let scrollReturnPoints: Array<{
63
62
  }> = [];
64
63
  const qdrantScrollCalls: Array<{
65
64
  targetType: string;
66
- memoryScopeId?: string;
67
65
  path?: string;
68
66
  }> = [];
69
67
 
70
68
  mock.module("../../../../persistence/embeddings/qdrant-client.js", () => ({
71
69
  getQdrantClient: () => ({
72
- deleteByTargetTypeAndPath: async (
73
- targetType: string,
74
- path: string,
75
- memoryScopeId: string,
76
- ) => {
77
- qdrantDeleteCalls.push({ targetType, path, memoryScopeId });
70
+ deleteByTargetTypeAndPath: async (targetType: string, path: string) => {
71
+ qdrantDeleteCalls.push({ targetType, path });
78
72
  },
79
73
  deleteByTarget: async (targetType: string, targetId: string) => {
80
74
  qdrantDeleteByTargetCalls.push({ targetType, targetId });
@@ -82,14 +76,12 @@ mock.module("../../../../persistence/embeddings/qdrant-client.js", () => ({
82
76
  scrollByTargetType: async (
83
77
  targetType: string,
84
78
  options?: {
85
- memoryScopeId?: string;
86
79
  path?: string;
87
80
  batchSize?: number;
88
81
  },
89
82
  ) => {
90
83
  qdrantScrollCalls.push({
91
84
  targetType,
92
- memoryScopeId: options?.memoryScopeId,
93
85
  path: options?.path,
94
86
  });
95
87
  return scrollReturnPoints;
@@ -235,17 +227,17 @@ describe("indexPkbFile", () => {
235
227
  const filePath = join(root, "doc.md");
236
228
  await writeFile(filePath, "# hello\nworld");
237
229
 
238
- await indexPkbFile(root, filePath, "scope-xyz");
230
+ await indexPkbFile(root, filePath);
239
231
 
240
232
  expect(embedAndUpsertCalls).toHaveLength(1);
241
233
  const call = embedAndUpsertCalls[0];
242
234
  expect(call.targetType).toBe("pkb_file");
243
- expect(call.targetId).toBe("scope-xyz:doc.md#0");
235
+ expect(call.targetId).toBe("doc.md#0");
244
236
  expect(call.input).toEqual({ type: "text", text: "# hello\nworld" });
245
237
  const payload = call.extraPayload as Record<string, unknown>;
246
238
  expect(payload.path).toBe("doc.md");
247
239
  expect(payload.chunk_index).toBe(0);
248
- expect(payload.memory_scope_id).toBe("scope-xyz");
240
+ expect(payload).not.toHaveProperty("memory_scope_id");
249
241
  expect(typeof payload.mtime_ms).toBe("number");
250
242
  expect(typeof payload.content_hash).toBe("string");
251
243
  expect((payload.content_hash as string).length).toBe(16);
@@ -261,40 +253,39 @@ describe("indexPkbFile", () => {
261
253
  "b".repeat(5990);
262
254
  await writeFile(filePath, content);
263
255
 
264
- await indexPkbFile(root, filePath, "scope-1");
256
+ await indexPkbFile(root, filePath);
265
257
 
266
258
  expect(embedAndUpsertCalls).toHaveLength(2);
267
- expect(embedAndUpsertCalls[0].targetId).toBe("scope-1:big.md#0");
268
- expect(embedAndUpsertCalls[1].targetId).toBe("scope-1:big.md#1");
259
+ expect(embedAndUpsertCalls[0].targetId).toBe("big.md#0");
260
+ expect(embedAndUpsertCalls[1].targetId).toBe("big.md#1");
269
261
  expect(embedAndUpsertCalls.every((c) => c.targetType === "pkb_file")).toBe(
270
262
  true,
271
263
  );
272
264
  });
273
265
 
274
- test("scope-namespaces target ids so two scopes indexing the same path do not collide", async () => {
275
- const root = await mkdtemp(join(tmpdir(), "pkb-index-scope-"));
266
+ test("re-indexing the same path regenerates identical target ids so upsert replaces in place", async () => {
267
+ const root = await mkdtemp(join(tmpdir(), "pkb-index-rerun-"));
276
268
  const filePath = join(root, "shared.md");
277
269
  await writeFile(filePath, "# shared");
278
270
 
279
- await indexPkbFile(root, filePath, "alpha");
280
- await indexPkbFile(root, filePath, "beta");
271
+ await indexPkbFile(root, filePath);
272
+ await indexPkbFile(root, filePath);
281
273
 
282
274
  expect(embedAndUpsertCalls).toHaveLength(2);
283
275
  const ids = embedAndUpsertCalls.map((c) => c.targetId);
284
- expect(ids).toEqual(["alpha:shared.md#0", "beta:shared.md#0"]);
276
+ expect(ids).toEqual(["shared.md#0", "shared.md#0"]);
285
277
  });
286
278
 
287
- test("scrolls existing chunks scoped to (target_type, scope, path) before upserting", async () => {
279
+ test("scrolls existing chunks scoped to (target_type, path) before upserting", async () => {
288
280
  const root = await mkdtemp(join(tmpdir(), "pkb-index-scroll-"));
289
281
  const filePath = join(root, "noted.md");
290
282
  await writeFile(filePath, "# one");
291
283
 
292
- await indexPkbFile(root, filePath, "scope-xyz");
284
+ await indexPkbFile(root, filePath);
293
285
 
294
286
  expect(qdrantScrollCalls).toHaveLength(1);
295
287
  expect(qdrantScrollCalls[0]).toEqual({
296
288
  targetType: "pkb_file",
297
- memoryScopeId: "scope-xyz",
298
289
  path: "noted.md",
299
290
  });
300
291
  });
@@ -308,31 +299,28 @@ describe("indexPkbFile", () => {
308
299
  scrollReturnPoints = [
309
300
  {
310
301
  id: "point-0",
311
- payload: { target_id: "scope-xyz:shrinking.md#0" },
302
+ payload: { target_id: "shrinking.md#0" },
312
303
  },
313
304
  {
314
305
  id: "point-1",
315
- payload: { target_id: "scope-xyz:shrinking.md#1" },
306
+ payload: { target_id: "shrinking.md#1" },
316
307
  },
317
308
  {
318
309
  id: "point-2",
319
- payload: { target_id: "scope-xyz:shrinking.md#2" },
310
+ payload: { target_id: "shrinking.md#2" },
320
311
  },
321
312
  ];
322
313
 
323
- await indexPkbFile(root, filePath, "scope-xyz");
314
+ await indexPkbFile(root, filePath);
324
315
 
325
316
  // Exactly one upsert for the surviving chunk.
326
317
  expect(embedAndUpsertCalls).toHaveLength(1);
327
- expect(embedAndUpsertCalls[0].targetId).toBe("scope-xyz:shrinking.md#0");
318
+ expect(embedAndUpsertCalls[0].targetId).toBe("shrinking.md#0");
328
319
 
329
320
  // The pre-delete is gone; only the two stale chunks are removed.
330
321
  expect(qdrantDeleteCalls).toHaveLength(0);
331
322
  const staleTargetIds = qdrantDeleteByTargetCalls.map((c) => c.targetId);
332
- expect(staleTargetIds.sort()).toEqual([
333
- "scope-xyz:shrinking.md#1",
334
- "scope-xyz:shrinking.md#2",
335
- ]);
323
+ expect(staleTargetIds.sort()).toEqual(["shrinking.md#1", "shrinking.md#2"]);
336
324
  });
337
325
 
338
326
  test("does not delete points whose target_id is regenerated", async () => {
@@ -342,11 +330,11 @@ describe("indexPkbFile", () => {
342
330
  scrollReturnPoints = [
343
331
  {
344
332
  id: "point-0",
345
- payload: { target_id: "scope-xyz:stable.md#0" },
333
+ payload: { target_id: "stable.md#0" },
346
334
  },
347
335
  ];
348
336
 
349
- await indexPkbFile(root, filePath, "scope-xyz");
337
+ await indexPkbFile(root, filePath);
350
338
 
351
339
  expect(embedAndUpsertCalls).toHaveLength(1);
352
340
  expect(qdrantDeleteByTargetCalls).toHaveLength(0);
@@ -358,14 +346,13 @@ describe("deletePkbFilePoints", () => {
358
346
  qdrantDeleteCalls.length = 0;
359
347
  });
360
348
 
361
- test("sends a filter with target_type, path, and memory_scope_id predicates", async () => {
362
- await deletePkbFilePoints("notes/todo.md", "scope-xyz");
349
+ test("sends a filter with target_type and path predicates", async () => {
350
+ await deletePkbFilePoints("notes/todo.md");
363
351
 
364
352
  expect(qdrantDeleteCalls).toHaveLength(1);
365
353
  expect(qdrantDeleteCalls[0]).toEqual({
366
354
  targetType: "pkb_file",
367
355
  path: "notes/todo.md",
368
- memoryScopeId: "scope-xyz",
369
356
  });
370
357
  });
371
358
  });
@@ -176,8 +176,8 @@ export function chunkPkbFile(content: string): string[] {
176
176
  * `pkbRoot`.
177
177
  *
178
178
  * Write-then-cleanup: enumerate the existing chunk target_ids for this
179
- * (scope, path), upsert every new chunk, then delete only the stale
180
- * target_ids (those the fresh content no longer produces). Upsert dedupes on
179
+ * path, upsert every new chunk, then delete only the stale target_ids
180
+ * (those the fresh content no longer produces). Upsert dedupes on
181
181
  * (target_type, target_id), so matching chunk indexes are replaced in place
182
182
  * and the prior index stays queryable if any embed/upsert call throws. A
183
183
  * pre-delete would instead leave the file unsearchable on transient failure
@@ -186,7 +186,6 @@ export function chunkPkbFile(content: string): string[] {
186
186
  export async function indexPkbFile(
187
187
  pkbRoot: string,
188
188
  absPath: string,
189
- memoryScopeId: string,
190
189
  ): Promise<void> {
191
190
  const content = await readFile(absPath, "utf8");
192
191
  const st = await stat(absPath);
@@ -198,7 +197,6 @@ export async function indexPkbFile(
198
197
  const qdrant = getQdrantClient();
199
198
  const existing = await withQdrantBreaker(() =>
200
199
  qdrant.scrollByTargetType(PKB_TARGET_TYPE, {
201
- memoryScopeId,
202
200
  path: relPath,
203
201
  }),
204
202
  );
@@ -206,11 +204,7 @@ export async function indexPkbFile(
206
204
  const newTargetIds = new Set<string>();
207
205
  for (let chunkIndex = 0; chunkIndex < chunks.length; chunkIndex++) {
208
206
  const chunk = chunks[chunkIndex];
209
- // Scope-namespace the target_id so `qdrant.upsert` — which dedupes on
210
- // (target_type, target_id) — cannot collapse distinct scopes' chunks of
211
- // the same relpath into a single point. Without the scope prefix, the
212
- // second scope to index a shared path would overwrite the first's vectors.
213
- const targetId = `${memoryScopeId}:${relPath}#${chunkIndex}`;
207
+ const targetId = `${relPath}#${chunkIndex}`;
214
208
  newTargetIds.add(targetId);
215
209
  await embedAndUpsert(
216
210
  PKB_TARGET_TYPE,
@@ -221,7 +215,6 @@ export async function indexPkbFile(
221
215
  mtime_ms: mtimeMs,
222
216
  chunk_index: chunkIndex,
223
217
  content_hash: contentHash,
224
- memory_scope_id: memoryScopeId,
225
218
  },
226
219
  );
227
220
  }
@@ -243,18 +236,13 @@ export async function indexPkbFile(
243
236
  }
244
237
 
245
238
  /**
246
- * Remove every Qdrant point belonging to a given PKB file (all chunks) within
247
- * a single memory scope. `relPath` must match the `path` payload written by
248
- * `indexPkbFile`. The `memoryScopeId` filter is required — omitting it would
249
- * wipe that relpath's chunks across every scope that indexes the same file.
239
+ * Remove every Qdrant point belonging to a given PKB file (all chunks).
240
+ * `relPath` must match the `path` payload written by `indexPkbFile`.
250
241
  */
251
- export async function deletePkbFilePoints(
252
- relPath: string,
253
- memoryScopeId: string,
254
- ): Promise<void> {
242
+ export async function deletePkbFilePoints(relPath: string): Promise<void> {
255
243
  const qdrant = getQdrantClient();
256
244
  await withQdrantBreaker(() =>
257
- qdrant.deleteByTargetTypeAndPath(PKB_TARGET_TYPE, relPath, memoryScopeId),
245
+ qdrant.deleteByTargetTypeAndPath(PKB_TARGET_TYPE, relPath),
258
246
  );
259
247
  }
260
248
 
@@ -13,15 +13,10 @@ mock.module("../../../../util/logger.js", () => ({
13
13
  const enqueuedJobs: Array<{
14
14
  pkbRoot: string;
15
15
  absPath: string;
16
- memoryScopeId: string;
17
16
  }> = [];
18
17
 
19
18
  mock.module("../jobs/embed-pkb-file.js", () => ({
20
- enqueuePkbIndexJob: (input: {
21
- pkbRoot: string;
22
- absPath: string;
23
- memoryScopeId: string;
24
- }) => {
19
+ enqueuePkbIndexJob: (input: { pkbRoot: string; absPath: string }) => {
25
20
  enqueuedJobs.push(input);
26
21
  return "job-id";
27
22
  },
@@ -29,20 +24,13 @@ mock.module("../jobs/embed-pkb-file.js", () => ({
29
24
 
30
25
  // Capture calls into the fake Qdrant client.
31
26
  let scrollPoints: Array<{ id: string; payload: Record<string, unknown> }> = [];
32
- const deleteCalls: Array<{ path: string; memoryScopeId: string }> = [];
27
+ const deleteCalls: Array<{ path: string }> = [];
33
28
 
34
29
  mock.module("../../../../persistence/embeddings/qdrant-client.js", () => ({
35
30
  getQdrantClient: () => ({
36
- scrollByTargetType: async (
37
- _targetType: string,
38
- _options?: { memoryScopeId?: string },
39
- ) => scrollPoints,
40
- deleteByTargetTypeAndPath: async (
41
- _targetType: string,
42
- path: string,
43
- memoryScopeId: string,
44
- ) => {
45
- deleteCalls.push({ path, memoryScopeId });
31
+ scrollByTargetType: async (_targetType: string) => scrollPoints,
32
+ deleteByTargetTypeAndPath: async (_targetType: string, path: string) => {
33
+ deleteCalls.push({ path });
46
34
  },
47
35
  }),
48
36
  resolveQdrantUrl: () => "http://127.0.0.1:6333",
@@ -81,6 +69,8 @@ function pkbPoint(
81
69
  path,
82
70
  chunk_index: chunkIndex,
83
71
  content_hash: contentHash,
72
+ // Pre-existing points may carry a legacy memory_scope_id key;
73
+ // reconciliation must tolerate it.
84
74
  memory_scope_id: "default",
85
75
  },
86
76
  };
@@ -120,7 +110,7 @@ describe("reconcilePkbIndex", () => {
120
110
  // Qdrant empty.
121
111
  scrollPoints = [];
122
112
 
123
- const result = await reconcilePkbIndex(root, "default");
113
+ const result = await reconcilePkbIndex(root);
124
114
 
125
115
  expect(result.enqueued).toBe(2);
126
116
  expect(result.deleted).toBe(0);
@@ -130,7 +120,6 @@ describe("reconcilePkbIndex", () => {
130
120
  expect(paths.has(join(root, "b.md"))).toBe(true);
131
121
  for (const job of enqueuedJobs) {
132
122
  expect(job.pkbRoot).toBe(root);
133
- expect(job.memoryScopeId).toBe("default");
134
123
  }
135
124
  expect(deleteCalls).toHaveLength(0);
136
125
  });
@@ -147,7 +136,7 @@ describe("reconcilePkbIndex", () => {
147
136
  pkbPoint("b.md", hashes.get("b.md")!),
148
137
  ];
149
138
 
150
- const result = await reconcilePkbIndex(root, "default");
139
+ const result = await reconcilePkbIndex(root);
151
140
 
152
141
  expect(result.enqueued).toBe(0);
153
142
  expect(result.deleted).toBe(0);
@@ -155,6 +144,37 @@ describe("reconcilePkbIndex", () => {
155
144
  expect(deleteCalls).toHaveLength(0);
156
145
  });
157
146
 
147
+ test("legacy-format points with scope-prefixed target ids do not trigger re-indexing", async () => {
148
+ const root = await mkdtemp(join(tmpdir(), "pkb-reconcile-legacy-"));
149
+ const hashes = await seedPkbAndHash(root, [
150
+ { path: "notes.md", content: "# Notes" },
151
+ ]);
152
+
153
+ // Point indexed before scope removal: `_pkb_workspace:`-prefixed
154
+ // target_id plus a legacy memory_scope_id payload key. Reconciliation
155
+ // diffs on payload path + content_hash only, so a legacy point whose
156
+ // hash matches disk must read as up to date.
157
+ scrollPoints = [
158
+ {
159
+ id: "_pkb_workspace:notes.md#0",
160
+ payload: {
161
+ target_type: "pkb_file",
162
+ target_id: "_pkb_workspace:notes.md#0",
163
+ path: "notes.md",
164
+ chunk_index: 0,
165
+ content_hash: hashes.get("notes.md")!,
166
+ memory_scope_id: "_pkb_workspace",
167
+ },
168
+ },
169
+ ];
170
+
171
+ const result = await reconcilePkbIndex(root);
172
+
173
+ expect(result).toEqual({ enqueued: 0, deleted: 0 });
174
+ expect(enqueuedJobs).toHaveLength(0);
175
+ expect(deleteCalls).toHaveLength(0);
176
+ });
177
+
158
178
  test("modified file: hash drift enqueues exactly one re-index", async () => {
159
179
  const root = await mkdtemp(join(tmpdir(), "pkb-reconcile-modified-"));
160
180
  const hashes = await seedPkbAndHash(root, [
@@ -168,7 +188,7 @@ describe("reconcilePkbIndex", () => {
168
188
  pkbPoint("b.md", hashes.get("b.md")!),
169
189
  ];
170
190
 
171
- const result = await reconcilePkbIndex(root, "default");
191
+ const result = await reconcilePkbIndex(root);
172
192
 
173
193
  expect(result.enqueued).toBe(1);
174
194
  expect(result.deleted).toBe(0);
@@ -189,13 +209,11 @@ describe("reconcilePkbIndex", () => {
189
209
  pkbPoint("gone.md", "dead00dead00dead"),
190
210
  ];
191
211
 
192
- const result = await reconcilePkbIndex(root, "default");
212
+ const result = await reconcilePkbIndex(root);
193
213
 
194
214
  expect(result.enqueued).toBe(0);
195
215
  expect(result.deleted).toBe(1);
196
- expect(deleteCalls).toEqual([
197
- { path: "gone.md", memoryScopeId: "default" },
198
- ]);
216
+ expect(deleteCalls).toEqual([{ path: "gone.md" }]);
199
217
  expect(enqueuedJobs).toHaveLength(0);
200
218
  });
201
219
 
@@ -212,7 +230,7 @@ describe("reconcilePkbIndex", () => {
212
230
  pkbPoint("notes/c.md", "cccccccccccccccc"),
213
231
  ];
214
232
 
215
- const result = await reconcilePkbIndex(missing, "default");
233
+ const result = await reconcilePkbIndex(missing);
216
234
 
217
235
  expect(result.enqueued).toBe(0);
218
236
  expect(result.deleted).toBe(0);
@@ -227,7 +245,7 @@ describe("reconcilePkbIndex", () => {
227
245
 
228
246
  scrollPoints = [pkbPoint("a.md", "aaaaaaaaaaaaaaaa")];
229
247
 
230
- const result = await reconcilePkbIndex(root, "default");
248
+ const result = await reconcilePkbIndex(root);
231
249
 
232
250
  expect(result.enqueued).toBe(0);
233
251
  expect(result.deleted).toBe(0);
@@ -246,7 +264,7 @@ describe("reconcilePkbIndex", () => {
246
264
  pkbPoint("a.md", hashes.get("a.md")!, 1),
247
265
  ];
248
266
 
249
- const result = await reconcilePkbIndex(root, "default");
267
+ const result = await reconcilePkbIndex(root);
250
268
 
251
269
  expect(result.enqueued).toBe(0);
252
270
  expect(result.deleted).toBe(0);
@@ -14,8 +14,8 @@
14
14
  import { join } from "node:path";
15
15
 
16
16
  import { getQdrantClient } from "../../../../persistence/embeddings/qdrant-client.js";
17
- import { getLogger } from "../../../../util/logger.js";
18
17
  import { enqueuePkbIndexJob } from "../jobs/embed-pkb-file.js";
18
+ import { getLogger } from "../logging.js";
19
19
  import { deletePkbFilePoints, scanPkbFiles } from "./pkb-index.js";
20
20
  import { PKB_TARGET_TYPE } from "./types.js";
21
21
 
@@ -37,7 +37,6 @@ export interface ReconcilePkbIndexResult {
37
37
  */
38
38
  export async function reconcilePkbIndex(
39
39
  pkbRoot: string,
40
- memoryScopeId: string,
41
40
  ): Promise<ReconcilePkbIndexResult> {
42
41
  // Build the on-disk view keyed by relative path. `scanPkbFiles` emits one
43
42
  // entry per chunk — every chunk of the same file shares the same
@@ -52,7 +51,7 @@ export async function reconcilePkbIndex(
52
51
  const diskEntries = await scanPkbFiles(pkbRoot);
53
52
  if (diskEntries === null) {
54
53
  log.warn(
55
- { pkbRoot, memoryScopeId },
54
+ { pkbRoot },
56
55
  "PKB root directory missing — skipping reconciliation to avoid wiping the index",
57
56
  );
58
57
  return { enqueued: 0, deleted: 0 };
@@ -72,9 +71,7 @@ export async function reconcilePkbIndex(
72
71
  // chunks remain searchable as long as the first chunk's hash happened to
73
72
  // match the current disk content.
74
73
  const qdrant = getQdrantClient();
75
- const points = await qdrant.scrollByTargetType(PKB_TARGET_TYPE, {
76
- memoryScopeId,
77
- });
74
+ const points = await qdrant.scrollByTargetType(PKB_TARGET_TYPE);
78
75
  const indexedByPath = new Map<
79
76
  string,
80
77
  { contentHash: string; mixed: boolean }
@@ -105,7 +102,6 @@ export async function reconcilePkbIndex(
105
102
  enqueuePkbIndexJob({
106
103
  pkbRoot,
107
104
  absPath: join(pkbRoot, relPath),
108
- memoryScopeId,
109
105
  });
110
106
  enqueued++;
111
107
  }
@@ -115,7 +111,7 @@ export async function reconcilePkbIndex(
115
111
  for (const relPath of indexedByPath.keys()) {
116
112
  if (!diskByPath.has(relPath)) {
117
113
  try {
118
- await deletePkbFilePoints(relPath, memoryScopeId);
114
+ await deletePkbFilePoints(relPath);
119
115
  deleted++;
120
116
  } catch (err) {
121
117
  log.warn(
@@ -130,7 +126,6 @@ export async function reconcilePkbIndex(
130
126
  log.info(
131
127
  {
132
128
  pkbRoot,
133
- memoryScopeId,
134
129
  enqueued,
135
130
  deleted,
136
131
  diskCount: diskByPath.size,