@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
@@ -85,7 +85,6 @@ export function buildDeferredFinalizeEffect(params: {
85
85
  role: "assistant",
86
86
  content: contentJson,
87
87
  createdAt: finalizedRow.createdAt,
88
- scopeId: "default",
89
88
  provenanceTrustClass: metadata?.provenanceTrustClass,
90
89
  automated: metadata?.automated,
91
90
  },
@@ -156,8 +156,7 @@ export interface ConversationCreateOptions {
156
156
 
157
157
  /**
158
158
  * Optional explicit model override (provider/model string) for this
159
- * conversation's agent loop. Used by the auto-analyze loop to pin the
160
- * analysis agent to a specific model.
159
+ * conversation's agent loop.
161
160
  */
162
161
  modelOverride?: string;
163
162
  /**
@@ -1,13 +1,10 @@
1
1
  /**
2
- * Transcript formatter for conversation analysis.
3
- *
4
- * Builds a markdown transcript of a conversation, including inline
5
- * subagent conversation sections when present in message metadata.
2
+ * Markdown transcript formatting for conversation messages, including
3
+ * inline subagent conversation sections when present in message metadata.
6
4
  */
7
5
 
8
6
  import { formatLocalTimestamp } from "../daemon/date-context.js";
9
7
  import {
10
- getConversation,
11
8
  getMessages,
12
9
  parseMessageMetadata,
13
10
  } from "../persistence/conversation-crud.js";
@@ -24,7 +21,7 @@ interface ContentBlock {
24
21
  source?: { media_type?: string; filename?: string };
25
22
  }
26
23
 
27
- function extractAnalysisText(blocks: ContentBlock[]): string {
24
+ function extractTranscriptText(blocks: ContentBlock[]): string {
28
25
  const parts: string[] = [];
29
26
  for (const block of blocks) {
30
27
  switch (block.type) {
@@ -97,7 +94,7 @@ function formatSubagentMessages(
97
94
  const role = formatRole(msg.role, options);
98
95
  const time = formatLocalTimestamp(msg.createdAt, options.timeZone);
99
96
  const content = parseContent(msg.content);
100
- const text = extractAnalysisText(content);
97
+ const text = extractTranscriptText(content);
101
98
  if (text) {
102
99
  lines.push(`> **${role}** (${time})`);
103
100
  for (const line of text.split("\n")) {
@@ -123,14 +120,10 @@ type TranscriptMessage = ReturnType<typeof getMessages>[number];
123
120
  * Format a slice of messages as a transcript body (no top-of-conversation
124
121
  * header). Used by background jobs that process incremental slices — the
125
122
  * memory-retrospective job re-renders only the messages added since its
126
- * last successful run rather than the whole conversation. The per-message
127
- * structural shape matches `buildAnalysisTranscript` (header line, body,
128
- * optional subagent block) so downstream agents see consistent framing.
129
- * The participant *labels*, however, intentionally diverge: this function
130
- * honors `TranscriptFormatOptions` so the memory-retrospective prompt can
131
- * render the conversation under the assistant and user display names,
132
- * while `buildAnalysisTranscript` always uses generic "User"/"Assistant"
133
- * labels for the analyze-conversation flow.
123
+ * last successful run rather than the whole conversation. Each message
124
+ * renders as a header line, body, and optional subagent block; participant
125
+ * labels honor `TranscriptFormatOptions` so the memory-retrospective prompt
126
+ * can render the conversation under the assistant and user display names.
134
127
  */
135
128
  export function formatMessageSliceForTranscript(
136
129
  messages: TranscriptMessage[],
@@ -190,7 +183,7 @@ function appendMessageBlock(
190
183
  const role = formatRole(msg.role, options);
191
184
  const time = formatLocalTimestamp(msg.createdAt, options.timeZone);
192
185
  const content = parseContent(msg.content);
193
- const text = extractAnalysisText(content);
186
+ const text = extractTranscriptText(content);
194
187
 
195
188
  lines.push(`## ${role} (${time})`);
196
189
  lines.push(text);
@@ -198,26 +191,3 @@ function appendMessageBlock(
198
191
 
199
192
  appendSubagentSection(lines, msg, { timeZone: options.timeZone });
200
193
  }
201
-
202
- export function buildAnalysisTranscript(conversationId: string): string {
203
- const conversation = getConversation(conversationId);
204
- if (!conversation) {
205
- return `# Conversation not found: ${conversationId}\n`;
206
- }
207
-
208
- const title = conversation.title ?? "Untitled";
209
- const lines: string[] = [];
210
-
211
- lines.push(`# Conversation: ${title}`);
212
- lines.push(`Created: ${formatLocalTimestamp(conversation.createdAt)}`);
213
- lines.push("");
214
-
215
- // Analyze-conversation flow renders under generic "User"/"Assistant" labels,
216
- // so no options are threaded through (see `formatMessageSliceForTranscript`
217
- // for the display-name variant).
218
- for (const msg of getMessages(conversationId)) {
219
- appendMessageBlock(lines, msg);
220
- }
221
-
222
- return lines.join("\n");
223
- }
@@ -17,8 +17,13 @@ export const CK_BATCH = "conversation_starters:generation_batch";
17
17
  export const CK_LAST_GEN_AT = "conversation_starters:last_gen_at";
18
18
  export const CK_LAST_ATTEMPT_AT = "conversation_starters:last_attempt_at";
19
19
 
20
- export function checkpointKey(base: string, scopeId: string): string {
21
- return `${base}:${scopeId}`;
20
+ /**
21
+ * Build a conversation-starter checkpoint key. The `:default` suffix is a
22
+ * stable persisted key format — existing checkpoint rows are keyed this way,
23
+ * so it is emitted verbatim.
24
+ */
25
+ export function checkpointKey(base: string): string {
26
+ return `${base}:default`;
22
27
  }
23
28
 
24
29
  export function parseCheckpointInt(value: string | undefined): number | null {
@@ -54,12 +59,11 @@ export function upsertCheckpoint(
54
59
 
55
60
  // ── Queries ──────────────────────────────────────────────────────
56
61
 
57
- export function countActiveMemoryNodes(scopeId: string): number {
62
+ export function countActiveMemoryNodes(): number {
58
63
  return (
59
64
  rawGet<{ c: number }>(
60
65
  "starters:countActiveMemoryNodes",
61
- `SELECT COUNT(*) AS c FROM memory_graph_nodes WHERE fidelity != 'gone' AND scope_id = ?`,
62
- scopeId,
66
+ `SELECT COUNT(*) AS c FROM memory_graph_nodes WHERE fidelity != 'gone'`,
63
67
  )?.c ?? 0
64
68
  );
65
69
  }
@@ -5,12 +5,11 @@
5
5
  * suggestion chips shown on the empty conversation page.
6
6
  */
7
7
 
8
- import { and, desc, eq, sql } from "drizzle-orm";
8
+ import { desc, sql } from "drizzle-orm";
9
9
  import { v4 as uuid } from "uuid";
10
10
 
11
11
  import { loadSkillCatalog } from "../../config/skills.js";
12
12
  import { getDb } from "../../persistence/db-connection.js";
13
- import { asString } from "../../persistence/job-utils.js";
14
13
  import type { MemoryJob } from "../../persistence/jobs-store.js";
15
14
  import { rawAll } from "../../persistence/raw-query.js";
16
15
  import {
@@ -46,7 +45,7 @@ const log = getLogger("conversation-starters-gen");
46
45
 
47
46
  // ── Rollup construction ───────────────────────────────────────────
48
47
 
49
- function buildMemoryRollup(scopeId: string): string {
48
+ function buildMemoryRollup(): string {
50
49
  let rows: Array<{
51
50
  type: string;
52
51
  content: string;
@@ -61,12 +60,7 @@ function buildMemoryRollup(scopeId: string): string {
61
60
  significance: memoryGraphNodes.significance,
62
61
  })
63
62
  .from(memoryGraphNodes)
64
- .where(
65
- and(
66
- sql`${memoryGraphNodes.fidelity} != 'gone'`,
67
- eq(memoryGraphNodes.scopeId, scopeId),
68
- ),
69
- )
63
+ .where(sql`${memoryGraphNodes.fidelity} != 'gone'`)
70
64
  .orderBy(desc(memoryGraphNodes.significance))
71
65
  .limit(60)
72
66
  .all();
@@ -97,11 +91,9 @@ function buildMemoryRollup(scopeId: string): string {
97
91
  return truncate(rollup, 6000, "");
98
92
  }
99
93
 
100
- function buildNewItemsDiff(scopeId: string): string {
94
+ function buildNewItemsDiff(): string {
101
95
  const lastGenAt =
102
- parseCheckpointInt(
103
- getCheckpointValue(checkpointKey(CK_LAST_GEN_AT, scopeId)),
104
- ) ?? 0;
96
+ parseCheckpointInt(getCheckpointValue(checkpointKey(CK_LAST_GEN_AT))) ?? 0;
105
97
 
106
98
  if (lastGenAt === 0) return ""; // No previous generation — skip diff
107
99
 
@@ -111,9 +103,8 @@ function buildNewItemsDiff(scopeId: string): string {
111
103
  }>(
112
104
  "starters:buildNewItemsDiff",
113
105
  `SELECT type AS kind, content FROM memory_graph_nodes
114
- WHERE fidelity != 'gone' AND scope_id = ? AND created > ?
106
+ WHERE fidelity != 'gone' AND created > ?
115
107
  ORDER BY created DESC LIMIT 20`,
116
- scopeId,
117
108
  lastGenAt,
118
109
  );
119
110
 
@@ -176,19 +167,19 @@ interface GeneratedStarter {
176
167
  category: string;
177
168
  }
178
169
 
179
- async function generateStarters(scopeId: string): Promise<GeneratedStarter[]> {
170
+ async function generateStarters(): Promise<GeneratedStarter[]> {
180
171
  const provider = await getConfiguredProvider("conversationStarters");
181
172
  if (!provider) {
182
173
  log.info("No configured provider for conversation starters generation");
183
174
  return [];
184
175
  }
185
176
 
186
- const rollup = buildMemoryRollup(scopeId);
177
+ const rollup = buildMemoryRollup();
187
178
  if (!rollup) {
188
179
  log.info("No memory items to generate conversation starters from");
189
180
  return [];
190
181
  }
191
- const diff = buildNewItemsDiff(scopeId);
182
+ const diff = buildNewItemsDiff();
192
183
  const skills = buildSkillsSummary();
193
184
 
194
185
  const now = new Date();
@@ -395,38 +386,29 @@ Bad → Good (incomplete phrase → complete):
395
386
  // ── Job handler ───────────────────────────────────────────────────
396
387
 
397
388
  export async function generateConversationStartersJob(
398
- job: MemoryJob,
389
+ _job: MemoryJob,
399
390
  ): Promise<void> {
400
- const scopeId = asString(job.payload.scopeId) ?? "default";
401
391
  const db = getDb();
402
392
  const now = Date.now();
403
393
 
404
394
  // Record attempt time so the route handler's cooldown prevents rapid retries
405
395
  // even when generation produces 0 valid starters.
406
- upsertCheckpoint(
407
- checkpointKey(CK_LAST_ATTEMPT_AT, scopeId),
408
- String(now),
409
- now,
410
- );
396
+ upsertCheckpoint(checkpointKey(CK_LAST_ATTEMPT_AT), String(now), now);
411
397
 
412
- const starters = await generateStarters(scopeId);
398
+ const starters = await generateStarters();
413
399
  if (starters.length === 0) {
414
- log.info({ scopeId }, "No conversation starters generated");
400
+ log.info("No conversation starters generated");
415
401
 
416
402
  // Sync the item count checkpoint so `checkpointAhead` clears, but do NOT
417
403
  // update `CK_LAST_GEN_AT` — the stale TTL should trigger a retry on the
418
404
  // next GET rather than blocking retries for the full TTL window.
419
- const totalActive = countActiveMemoryNodes(scopeId);
420
- upsertCheckpoint(
421
- checkpointKey(CK_ITEM_COUNT, scopeId),
422
- String(totalActive),
423
- now,
424
- );
405
+ const totalActive = countActiveMemoryNodes();
406
+ upsertCheckpoint(checkpointKey(CK_ITEM_COUNT), String(totalActive), now);
425
407
  return;
426
408
  }
427
409
 
428
410
  // Determine next batch number
429
- const prevBatch = getCheckpointValue(checkpointKey(CK_BATCH, scopeId));
411
+ const prevBatch = getCheckpointValue(checkpointKey(CK_BATCH));
430
412
  const nextBatch = prevBatch ? parseInt(prevBatch, 10) + 1 : 1;
431
413
 
432
414
  // Collect the memory types that informed this batch
@@ -435,12 +417,7 @@ export async function generateConversationStartersJob(
435
417
  const kindRows = db
436
418
  .select({ kind: memoryGraphNodes.type })
437
419
  .from(memoryGraphNodes)
438
- .where(
439
- and(
440
- sql`${memoryGraphNodes.fidelity} != 'gone'`,
441
- eq(memoryGraphNodes.scopeId, scopeId),
442
- ),
443
- )
420
+ .where(sql`${memoryGraphNodes.fidelity} != 'gone'`)
444
421
  .groupBy(memoryGraphNodes.type)
445
422
  .all();
446
423
  sourceKinds = kindRows.map((r) => r.kind).join(",");
@@ -448,10 +425,8 @@ export async function generateConversationStartersJob(
448
425
  // Table may have been dropped (migration 203)
449
426
  }
450
427
 
451
- // Remove previous starters for this scope before inserting the new batch
452
- db.delete(conversationStarters)
453
- .where(eq(conversationStarters.scopeId, scopeId))
454
- .run();
428
+ // Remove previous starters before inserting the new batch
429
+ db.delete(conversationStarters).run();
455
430
 
456
431
  for (const starter of starters) {
457
432
  db.insert(conversationStarters)
@@ -462,24 +437,19 @@ export async function generateConversationStartersJob(
462
437
  category: starter.category,
463
438
  cardType: "chip",
464
439
  generationBatch: nextBatch,
465
- scopeId,
466
440
  sourceMemoryKinds: sourceKinds,
467
441
  createdAt: now,
468
442
  })
469
443
  .run();
470
444
  }
471
445
 
472
- const totalActive = countActiveMemoryNodes(scopeId);
473
- upsertCheckpoint(
474
- checkpointKey(CK_ITEM_COUNT, scopeId),
475
- String(totalActive),
476
- now,
477
- );
478
- upsertCheckpoint(checkpointKey(CK_BATCH, scopeId), String(nextBatch), now);
479
- upsertCheckpoint(checkpointKey(CK_LAST_GEN_AT, scopeId), String(now), now);
446
+ const totalActive = countActiveMemoryNodes();
447
+ upsertCheckpoint(checkpointKey(CK_ITEM_COUNT), String(totalActive), now);
448
+ upsertCheckpoint(checkpointKey(CK_BATCH), String(nextBatch), now);
449
+ upsertCheckpoint(checkpointKey(CK_LAST_GEN_AT), String(now), now);
480
450
 
481
451
  log.info(
482
- { scopeId, batch: nextBatch, count: starters.length },
452
+ { batch: nextBatch, count: starters.length },
483
453
  "Generated conversation starters",
484
454
  );
485
455
  }
@@ -122,8 +122,8 @@ export interface UserPromptSubmitInputContext {
122
122
  * `requestId` instead. Every path that starts an agent loop persists the
123
123
  * triggering user message under the turn's request ID before running, so
124
124
  * the message row id and the request's correlation ID are the same UUID.
125
- * This holds for the standard submit, queue-drain, subagent, voice, wake,
126
- * and conversation-analysis paths alike. This field will be removed in a
125
+ * This holds for the standard submit, queue-drain, subagent, voice, and
126
+ * wake paths alike. This field will be removed in a
127
127
  * future API version.
128
128
  */
129
129
  readonly userMessageId: string;
@@ -31,12 +31,11 @@ const enqueueCalls: Array<{
31
31
  }> = [];
32
32
  let nextJobId = 0;
33
33
 
34
- // Spread the real module's exports so transitive importers (e.g.
35
- // memory/auto-analysis-enqueue.ts pulled in via the CLI program → memory
36
- // indexer chain) get every named export they bind to at module-load time;
37
- // only `enqueueMemoryJob` is overridden so the route under test forwards
38
- // to the test stub. jobs-store.ts has no side-effecting top-level
39
- // statements, so loading it for the spread is safe.
34
+ // Spread the real module's exports so transitive importers (pulled in via
35
+ // the CLI program → memory indexer chain) get every named export they bind
36
+ // to at module-load time; only `enqueueMemoryJob` is overridden so the
37
+ // route under test forwards to the test stub. jobs-store.ts has no
38
+ // side-effecting top-level statements, so loading it for the spread is safe.
40
39
  mock.module("../../../persistence/jobs-store.js", () => ({
41
40
  ...realJobsStore,
42
41
  enqueueMemoryJob: (type: string, payload: Record<string, unknown>) => {
@@ -44,7 +43,6 @@ mock.module("../../../persistence/jobs-store.js", () => ({
44
43
  nextJobId += 1;
45
44
  return `test-job-${nextJobId}`;
46
45
  },
47
- upsertAutoAnalysisJob: () => {},
48
46
  upsertDebouncedJob: () => `test-debounced-${++nextJobId}`,
49
47
  hasActiveJobOfType: () => false,
50
48
  enqueuePruneOldLlmRequestLogsJob: () => `test-prune-${++nextJobId}`,
@@ -0,0 +1,165 @@
1
+ import { rmSync } from "node:fs";
2
+ import { tmpdir } from "node:os";
3
+ import { join } from "node:path";
4
+ import { describe, expect, mock, test } from "bun:test";
5
+
6
+ import { assertNotLiveDb } from "../../__tests__/assert-not-live-db.js";
7
+ import { makeMockLogger } from "../../__tests__/helpers/mock-logger.js";
8
+
9
+ mock.module("../../util/logger.js", () => ({
10
+ getLogger: () => makeMockLogger(),
11
+ }));
12
+
13
+ import { bulkWriteGateHolder, withBulkWriteGate } from "../bulk-write-gate.js";
14
+ import { deleteConversationRowsInBatches } from "../conversation-row-batch-delete.js";
15
+ import { copyForkMessagesViaSubprocess } from "../fork-message-copy.js";
16
+
17
+ /** A promise whose resolution the test controls. */
18
+ function deferred(): { promise: Promise<void>; release: () => void } {
19
+ let release!: () => void;
20
+ const promise = new Promise<void>((resolve) => {
21
+ release = resolve;
22
+ });
23
+ return { promise, release };
24
+ }
25
+
26
+ describe("withBulkWriteGate", () => {
27
+ test("runs callers FIFO, one at a time", async () => {
28
+ const events: string[] = [];
29
+ const first = deferred();
30
+
31
+ const run = (id: string, block?: Promise<void>) =>
32
+ withBulkWriteGate(id, async () => {
33
+ events.push(`${id}:start`);
34
+ if (block) {
35
+ await block;
36
+ }
37
+ events.push(`${id}:end`);
38
+ });
39
+
40
+ const p1 = run("a", first.promise);
41
+ const p2 = run("b");
42
+ const p3 = run("c");
43
+
44
+ await Bun.sleep(20);
45
+ expect(events).toEqual(["a:start"]);
46
+
47
+ first.release();
48
+ await Promise.all([p1, p2, p3]);
49
+ expect(events).toEqual([
50
+ "a:start",
51
+ "a:end",
52
+ "b:start",
53
+ "b:end",
54
+ "c:start",
55
+ "c:end",
56
+ ]);
57
+ });
58
+
59
+ test("releases on throw and propagates the error", async () => {
60
+ const failing = withBulkWriteGate("boom", async () => {
61
+ throw new Error("kaput");
62
+ });
63
+ await expect(failing).rejects.toThrow("kaput");
64
+
65
+ const after = await withBulkWriteGate("after", async () => 42);
66
+ expect(after).toBe(42);
67
+ });
68
+
69
+ test("returns the wrapped value and reports the holder label", async () => {
70
+ const holdersWhileRunning: Array<string | null> = [];
71
+ const value = await withBulkWriteGate("labelled", async () => {
72
+ holdersWhileRunning.push(bulkWriteGateHolder());
73
+ return "ok";
74
+ });
75
+ expect(value).toBe("ok");
76
+ expect(holdersWhileRunning).toEqual(["labelled"]);
77
+ expect(bulkWriteGateHolder()).toBeNull();
78
+ });
79
+ });
80
+
81
+ describe("gated bulk writers", () => {
82
+ test("fork message-copy queues behind a held gate", async () => {
83
+ const holder = deferred();
84
+ const holding = withBulkWriteGate("holder", () => holder.promise);
85
+
86
+ let copySettled = false;
87
+ const copy = copyForkMessagesViaSubprocess({
88
+ forkConversationId: "fork-1",
89
+ idPairs: [{ oldId: "old-1", newId: "new-1" }],
90
+ forceInProcess: true,
91
+ }).then((result) => {
92
+ copySettled = true;
93
+ return result;
94
+ });
95
+
96
+ await Bun.sleep(20);
97
+ expect(copySettled).toBe(false);
98
+
99
+ holder.release();
100
+ await holding;
101
+ await copy;
102
+ expect(copySettled).toBe(true);
103
+ });
104
+
105
+ test("empty fork message-copy skips the gate entirely", async () => {
106
+ const holder = deferred();
107
+ const holding = withBulkWriteGate("holder", () => holder.promise);
108
+
109
+ const result = await copyForkMessagesViaSubprocess({
110
+ forkConversationId: "fork-1",
111
+ idPairs: [],
112
+ });
113
+ expect(result.ok).toBe(true);
114
+
115
+ holder.release();
116
+ await holding;
117
+ });
118
+
119
+ test("main-DB batched delete queues behind a held gate", async () => {
120
+ const holder = deferred();
121
+ const holding = withBulkWriteGate("holder", () => holder.promise);
122
+
123
+ let deleteSettled = false;
124
+ const del = deleteConversationRowsInBatches({
125
+ conversationId: "conv-1",
126
+ table: "messages",
127
+ forceInProcess: true,
128
+ }).then((result) => {
129
+ deleteSettled = true;
130
+ return result;
131
+ });
132
+
133
+ await Bun.sleep(20);
134
+ expect(deleteSettled).toBe(false);
135
+
136
+ holder.release();
137
+ await holding;
138
+ await del;
139
+ expect(deleteSettled).toBe(true);
140
+ });
141
+
142
+ test("dedicated-file batched delete bypasses the gate", async () => {
143
+ const dbPath = join(tmpdir(), `bulk-write-gate-test-${Date.now()}.db`);
144
+ const holder = deferred();
145
+ const holding = withBulkWriteGate("holder", () => holder.promise);
146
+
147
+ try {
148
+ // Must settle while the gate is still held — a dedicated file has its
149
+ // own write lock, so its drain never queues behind main-DB streams.
150
+ const result = await deleteConversationRowsInBatches({
151
+ conversationId: "conv-1",
152
+ table: "some_table",
153
+ dbPath,
154
+ forceInProcess: true,
155
+ });
156
+ expect(bulkWriteGateHolder()).toBe("holder");
157
+ expect(result.backend).toBe("in-process-blocking");
158
+ } finally {
159
+ holder.release();
160
+ await holding;
161
+ assertNotLiveDb(dbPath);
162
+ rmSync(dbPath, { force: true });
163
+ }
164
+ });
165
+ });
@@ -0,0 +1,70 @@
1
+ import { rmSync } from "node:fs";
2
+ import { tmpdir } from "node:os";
3
+ import { join } from "node:path";
4
+ import { Database } from "bun:sqlite";
5
+ import { expect, test } from "bun:test";
6
+
7
+ import { drizzle } from "drizzle-orm/bun-sqlite";
8
+
9
+ import { assertNotLiveDb } from "../../__tests__/assert-not-live-db.js";
10
+
11
+ // Guard for the driver contract `forkConversationForRetrospective`'s phase-3
12
+ // transaction relies on: drizzle's bun-sqlite driver must map
13
+ // `db.transaction(cb, { behavior: "immediate" })` onto BEGIN IMMEDIATE, i.e.
14
+ // acquire the write lock at BEGIN rather than at the first write. If a
15
+ // drizzle upgrade silently dropped the behavior config, the phase-3
16
+ // SQLITE_BUSY_SNAPSHOT fix would regress to a deferred read→write upgrade.
17
+ test("bun-sqlite drizzle transaction honors behavior: 'immediate'", () => {
18
+ const dbPath = join(tmpdir(), `immediate-txn-guard-${Date.now()}.db`);
19
+ const writer = new Database(dbPath);
20
+ const probe = new Database(dbPath);
21
+ try {
22
+ writer.exec("PRAGMA journal_mode=WAL");
23
+ writer.exec("CREATE TABLE t (x INTEGER)");
24
+ // Fail immediately instead of waiting when the write lock is taken.
25
+ probe.exec("PRAGMA busy_timeout=0");
26
+ const probeDb = drizzle(probe);
27
+
28
+ writer.exec("BEGIN IMMEDIATE");
29
+ try {
30
+ // A DEFERRED empty transaction acquires no locks, so it succeeds even
31
+ // while the writer holds the write lock — the baseline that proves the
32
+ // failure below comes from the behavior config, not the environment.
33
+ const ran: string[] = [];
34
+ probeDb.transaction(() => {
35
+ ran.push("deferred");
36
+ });
37
+ expect(ran).toEqual(["deferred"]);
38
+
39
+ // An IMMEDIATE transaction must take the write lock at BEGIN and fail
40
+ // fast (busy_timeout=0) while the writer holds it.
41
+ expect(() =>
42
+ probeDb.transaction(
43
+ () => {
44
+ /* never reached: BEGIN IMMEDIATE itself must throw */
45
+ },
46
+ { behavior: "immediate" },
47
+ ),
48
+ ).toThrow(/SQLITE_BUSY|database is locked/i);
49
+ } finally {
50
+ writer.exec("COMMIT");
51
+ }
52
+
53
+ // With the write lock free, the immediate transaction runs normally.
54
+ const value = probeDb.transaction(
55
+ () => {
56
+ probe.exec("INSERT INTO t (x) VALUES (1)");
57
+ return "committed";
58
+ },
59
+ { behavior: "immediate" },
60
+ );
61
+ expect(value).toBe("committed");
62
+ } finally {
63
+ writer.close();
64
+ probe.close();
65
+ assertNotLiveDb(dbPath);
66
+ rmSync(dbPath, { force: true });
67
+ rmSync(`${dbPath}-wal`, { force: true });
68
+ rmSync(`${dbPath}-shm`, { force: true });
69
+ }
70
+ });
@@ -1,17 +1,8 @@
1
- /**
2
- * Constants extracted from auto-analysis-guard.ts to break the
3
- * conversation-crud ↔ auto-analysis-guard cycle.
4
- */
5
-
6
1
  /**
7
2
  * Sentinel value for the `source` column of auto-analysis conversations.
8
- * Used both when creating them and when querying "all except auto-analysis."
3
+ * The auto-analysis feature is retired, but rows with this source persist
4
+ * on existing installs — consumers use it to keep those legacy rows
5
+ * rendered correctly (feed display labels) and excluded from memory
6
+ * extraction and context search.
9
7
  */
10
8
  export const AUTO_ANALYSIS_SOURCE = "auto-analysis";
11
-
12
- /**
13
- * Dedicated `group_id` value for auto-analysis rolling conversations.
14
- * Placed in the `system:background` group alongside heartbeat and filing
15
- * conversations, rendered as a "Reflections" sub-group in the sidebar.
16
- */
17
- export const AUTO_ANALYSIS_GROUP_ID = "system:background";