@vellumai/assistant 0.11.9 → 0.11.10-dev.202609091114.7b6342c

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 (433) hide show
  1. package/ARCHITECTURE.md +2 -2
  2. package/Dockerfile +6 -12
  3. package/docs/architecture/memory.md +17 -9
  4. package/docs/guardian-request-flow.md +7 -4
  5. package/docs/runbook-trusted-contacts.md +13 -2
  6. package/node_modules/@vellumai/ces-client/node_modules/@vellumai/service-contracts/package.json +3 -1
  7. package/node_modules/@vellumai/ces-client/node_modules/@vellumai/service-contracts/src/__tests__/plan-credit.test.ts +51 -0
  8. package/node_modules/@vellumai/ces-client/node_modules/@vellumai/service-contracts/src/__tests__/secret-detection.test.ts +2 -0
  9. package/node_modules/@vellumai/ces-client/node_modules/@vellumai/service-contracts/src/desktop-presence.ts +11 -0
  10. package/node_modules/@vellumai/ces-client/node_modules/@vellumai/service-contracts/src/index.ts +1 -0
  11. package/node_modules/@vellumai/ces-client/node_modules/@vellumai/service-contracts/src/plan-credit.ts +66 -0
  12. package/node_modules/@vellumai/ces-client/node_modules/@vellumai/service-contracts/src/secret-detection.ts +7 -0
  13. package/node_modules/@vellumai/gateway-client/node_modules/@vellumai/service-contracts/package.json +3 -1
  14. package/node_modules/@vellumai/gateway-client/node_modules/@vellumai/service-contracts/src/__tests__/plan-credit.test.ts +51 -0
  15. package/node_modules/@vellumai/gateway-client/node_modules/@vellumai/service-contracts/src/__tests__/secret-detection.test.ts +2 -0
  16. package/node_modules/@vellumai/gateway-client/node_modules/@vellumai/service-contracts/src/desktop-presence.ts +11 -0
  17. package/node_modules/@vellumai/gateway-client/node_modules/@vellumai/service-contracts/src/index.ts +1 -0
  18. package/node_modules/@vellumai/gateway-client/node_modules/@vellumai/service-contracts/src/plan-credit.ts +66 -0
  19. package/node_modules/@vellumai/gateway-client/node_modules/@vellumai/service-contracts/src/secret-detection.ts +7 -0
  20. package/node_modules/@vellumai/gateway-client/src/gateway-ipc-contracts.ts +72 -0
  21. package/node_modules/@vellumai/service-contracts/package.json +3 -1
  22. package/node_modules/@vellumai/service-contracts/src/__tests__/plan-credit.test.ts +51 -0
  23. package/node_modules/@vellumai/service-contracts/src/__tests__/secret-detection.test.ts +2 -0
  24. package/node_modules/@vellumai/service-contracts/src/desktop-presence.ts +11 -0
  25. package/node_modules/@vellumai/service-contracts/src/index.ts +1 -0
  26. package/node_modules/@vellumai/service-contracts/src/plan-credit.ts +66 -0
  27. package/node_modules/@vellumai/service-contracts/src/secret-detection.ts +7 -0
  28. package/openapi.yaml +729 -63
  29. package/package.json +1 -1
  30. package/src/__tests__/agent-loop-mutable-latest-user-message.test.ts +19 -21
  31. package/src/__tests__/assistant-event-hub-machine-name.test.ts +40 -0
  32. package/src/__tests__/assistant-event-hub.test.ts +45 -0
  33. package/src/__tests__/cli-memory-v2-reembed-skills.test.ts +0 -1
  34. package/src/__tests__/compactor-assistant-tail-preview.test.ts +111 -0
  35. package/src/__tests__/compactor-tail-resolution.test.ts +116 -0
  36. package/src/__tests__/computer-use-native-history.test.ts +30 -0
  37. package/src/__tests__/computer-use-window-schema.test.ts +24 -0
  38. package/src/__tests__/config-get-vision-flag.test.ts +36 -0
  39. package/src/__tests__/config-loader-validation-reset-notice.test.ts +47 -15
  40. package/src/__tests__/context-search-conversations-source.test.ts +27 -5
  41. package/src/__tests__/conversation-agent-loop-overflow.test.ts +189 -195
  42. package/src/__tests__/conversation-agent-loop.test.ts +690 -50
  43. package/src/__tests__/conversation-fork-crud.test.ts +132 -45
  44. package/src/__tests__/conversation-fork-retrospective.test.ts +9 -7
  45. package/src/__tests__/conversation-lifecycle.test.ts +684 -10
  46. package/src/__tests__/conversation-pairing.test.ts +10 -9
  47. package/src/__tests__/conversation-runtime-assembly.test.ts +288 -1
  48. package/src/__tests__/conversation-surfaces-history-restored-completion.test.ts +21 -4
  49. package/src/__tests__/conversation-surfaces-point-at-budget.test.ts +150 -0
  50. package/src/__tests__/conversation-surfaces-point-at-capability.test.ts +161 -0
  51. package/src/__tests__/copy-composer-tc-templates.test.ts +2 -2
  52. package/src/__tests__/credential-security-invariants.test.ts +1 -0
  53. package/src/__tests__/delivered-post-record.test.ts +107 -0
  54. package/src/__tests__/guardian-action-service-scope.test.ts +53 -0
  55. package/src/__tests__/guardian-question-mode.test.ts +88 -138
  56. package/src/__tests__/headless-browser-mode.test.ts +63 -13
  57. package/src/__tests__/heartbeat-disk-pressure.test.ts +2 -0
  58. package/src/__tests__/heartbeat-service.test.ts +118 -27
  59. package/src/__tests__/host-cu-proxy.test.ts +159 -1
  60. package/src/__tests__/host-proxy-interface.test.ts +15 -0
  61. package/src/__tests__/host-proxy-preactivation.test.ts +61 -0
  62. package/src/__tests__/injector-chain.test.ts +3 -3
  63. package/src/__tests__/injector-registry-order-guard.test.ts +1 -1
  64. package/src/__tests__/injector-v3-suppression.test.ts +587 -45
  65. package/src/__tests__/llm-schema.test.ts +70 -2
  66. package/src/__tests__/logger.test.ts +33 -32
  67. package/src/__tests__/mcp-config-secret-boundary.test.ts +2 -0
  68. package/src/__tests__/memory-config-file-parity.test.ts +18 -0
  69. package/src/__tests__/memory-retrieval-hook.test.ts +53 -3
  70. package/src/__tests__/messages-read-boundary-guard.test.ts +0 -1
  71. package/src/__tests__/messaging-send-tool.test.ts +251 -128
  72. package/src/__tests__/messaging-shared.test.ts +19 -0
  73. package/src/__tests__/notification-decision-fallback.test.ts +98 -76
  74. package/src/__tests__/notification-decision-strategy.test.ts +10 -38
  75. package/src/__tests__/notification-events-source-context-probe.test.ts +211 -0
  76. package/src/__tests__/openai-responses-prompt-cache.test.ts +7 -2
  77. package/src/__tests__/openai-responses-provider.test.ts +42 -0
  78. package/src/__tests__/outlook-messaging-provider.test.ts +9 -0
  79. package/src/__tests__/platform-callback-registration.test.ts +162 -3
  80. package/src/__tests__/plugin-api-webhook-url.test.ts +66 -4
  81. package/src/__tests__/plugin-import-boundary-guard.test.ts +1 -0
  82. package/src/__tests__/pricing.test.ts +29 -0
  83. package/src/__tests__/prompt-cache-cross-turn-stability.test.ts +63 -3
  84. package/src/__tests__/scheduler-result-notification.test.ts +209 -0
  85. package/src/__tests__/strip-memory-injections.test.ts +75 -27
  86. package/src/__tests__/tool-approval-seed-content-blocks.test.ts +4 -13
  87. package/src/acp/auto-install.test.ts +35 -1
  88. package/src/acp/resolve-agent.test.ts +3 -3
  89. package/src/agent/loop.ts +116 -45
  90. package/src/api/constants/personality-sliders.test.ts +21 -0
  91. package/src/api/constants/personality-sliders.ts +64 -0
  92. package/src/api/events/contact-record-request.ts +16 -4
  93. package/src/api/events/contact-request.ts +10 -1
  94. package/src/api/index.ts +12 -0
  95. package/src/api/responses/memory-v3-selection-log.ts +64 -13
  96. package/src/api/surfaces.ts +6 -5
  97. package/src/background-wake/next-wake.test.ts +13 -0
  98. package/src/background-wake/next-wake.ts +4 -2
  99. package/src/calls/__tests__/voice-session-bridge.test.ts +166 -0
  100. package/src/calls/__tests__/voice-turn-sight-hold.test.ts +301 -0
  101. package/src/calls/voice-session-bridge.ts +162 -1
  102. package/src/calls/voice-triage-escalate.ts +1 -1
  103. package/src/channels/types.ts +14 -0
  104. package/src/cli/__tests__/catalog-search-help.test.ts +1 -0
  105. package/src/cli/__tests__/contacts-address-prompt-cli.test.ts +701 -0
  106. package/src/cli/__tests__/contacts-record-prompt-cli.test.ts +276 -15
  107. package/src/cli/__tests__/roadmap-cli.test.ts +313 -0
  108. package/src/cli/__tests__/run-assistant-command.ts +59 -20
  109. package/src/cli/commands/__tests__/conversations-slack.test.ts +12 -0
  110. package/src/cli/commands/__tests__/plugins-search.test.ts +81 -0
  111. package/src/cli/commands/config.help.ts +3 -1
  112. package/src/cli/commands/contacts.help.ts +179 -12
  113. package/src/cli/commands/contacts.ts +442 -47
  114. package/src/cli/commands/memory/worker.ts +1 -1
  115. package/src/cli/commands/platform/__tests__/credits-format.test.ts +152 -0
  116. package/src/cli/commands/platform/__tests__/credits.test.ts +20 -0
  117. package/src/cli/commands/platform/credits-format.ts +108 -0
  118. package/src/cli/commands/platform/index.help.ts +33 -11
  119. package/src/cli/commands/platform/index.ts +7 -18
  120. package/src/cli/commands/plugins.help.ts +4 -1
  121. package/src/cli/commands/plugins.ts +2 -1
  122. package/src/cli/commands/roadmap.help.ts +171 -0
  123. package/src/cli/commands/roadmap.ts +358 -0
  124. package/src/cli/index.help.ts +2 -0
  125. package/src/cli/lib/__tests__/cli-output.test.ts +5 -0
  126. package/src/cli/lib/cli-output.ts +6 -6
  127. package/src/cli/program.ts +2 -0
  128. package/src/config/__tests__/webhook-routing.test.ts +42 -0
  129. package/src/config/acp-defaults.test.ts +3 -3
  130. package/src/config/acp-defaults.ts +5 -5
  131. package/src/config/bundled-skills/acp/SKILL.md +8 -11
  132. package/src/config/bundled-skills/computer-use/SKILL.md +21 -0
  133. package/src/config/bundled-skills/computer-use/TOOLS.json +6 -0
  134. package/src/config/bundled-skills/contacts/SKILL.md +61 -11
  135. package/src/config/bundled-skills/messaging/SKILL.md +2 -0
  136. package/src/config/bundled-skills/messaging/TOOLS.json +4 -4
  137. package/src/config/bundled-skills/messaging/tools/messaging-send.ts +160 -36
  138. package/src/config/bundled-skills/messaging/tools/shared.ts +6 -0
  139. package/src/config/bundled-skills/schedule/SKILL.md +10 -2
  140. package/src/config/bundled-skills/screen-annotation/SKILL.md +80 -0
  141. package/src/config/bundled-skills/screen-annotation/TOOLS.json +73 -0
  142. package/src/config/bundled-skills/screen-annotation/tools/screen-annotation.test.ts +74 -0
  143. package/src/config/bundled-skills/screen-annotation/tools/screen-clear-marks.ts +33 -0
  144. package/src/config/bundled-skills/screen-annotation/tools/screen-point-at.ts +25 -0
  145. package/src/config/env-registry.ts +2 -0
  146. package/src/config/feature-flag-registry.json +39 -7
  147. package/src/config/input-modalities.test.ts +71 -0
  148. package/src/config/input-modalities.ts +95 -0
  149. package/src/config/loader.ts +2 -0
  150. package/src/config/schemas/__tests__/memory-v3.test.ts +58 -15
  151. package/src/config/schemas/heartbeat.ts +3 -3
  152. package/src/config/schemas/llm.ts +47 -10
  153. package/src/config/schemas/memory-storage.test.ts +39 -0
  154. package/src/config/schemas/memory-storage.ts +21 -0
  155. package/src/config/schemas/memory-v3.ts +73 -46
  156. package/src/config/schemas/services.ts +18 -0
  157. package/src/config/webhook-routing.ts +12 -2
  158. package/src/context/compactor.ts +12 -13
  159. package/src/context/strip-injections.ts +29 -25
  160. package/src/context/token-estimator.ts +2 -2
  161. package/src/daemon/__tests__/embedding-reconcile.test.ts +77 -0
  162. package/src/daemon/__tests__/lifecycle-embedding-reconcile.test.ts +3 -0
  163. package/src/daemon/__tests__/turn-actor.test.ts +68 -0
  164. package/src/daemon/conversation-agent-loop-handlers.ts +152 -22
  165. package/src/daemon/conversation-agent-loop.ts +19 -3
  166. package/src/daemon/conversation-messaging.ts +3 -2
  167. package/src/daemon/conversation-runtime-assembly.ts +191 -69
  168. package/src/daemon/conversation-surfaces.ts +32 -62
  169. package/src/daemon/conversation.ts +153 -46
  170. package/src/daemon/embedding-reconcile.ts +64 -1
  171. package/src/daemon/handlers/config-embeddings.ts +31 -0
  172. package/src/daemon/host-cu-proxy.ts +66 -50
  173. package/src/daemon/host-cu-target.ts +139 -0
  174. package/src/daemon/host-proxy-preactivation.ts +29 -1
  175. package/src/daemon/mcp-reload-service.ts +6 -0
  176. package/src/daemon/providers-setup.ts +5 -26
  177. package/src/daemon/trust-context.ts +1 -1
  178. package/src/daemon/turn-actor.ts +46 -0
  179. package/src/heartbeat/heartbeat-service.ts +72 -13
  180. package/src/inbound/platform-callback-registration.ts +77 -11
  181. package/src/inbound/pod-webhook-claim.ts +35 -0
  182. package/src/inbound/velay-webhooks-gate.ts +20 -0
  183. package/src/ipc/gateway-client.ts +91 -0
  184. package/src/live-voice/__tests__/live-voice-photo.test.ts +174 -0
  185. package/src/live-voice/__tests__/live-voice-session-guardian.test.ts +127 -0
  186. package/src/live-voice/__tests__/live-voice-session-telemetry.test.ts +42 -2
  187. package/src/live-voice/__tests__/live-voice-sight-frame.test.ts +81 -0
  188. package/src/live-voice/__tests__/protocol.test.ts +67 -0
  189. package/src/live-voice/live-voice-connection.ts +14 -1
  190. package/src/live-voice/live-voice-photo.ts +109 -4
  191. package/src/live-voice/live-voice-session-manager.ts +10 -1
  192. package/src/live-voice/live-voice-session.ts +196 -31
  193. package/src/live-voice/protocol.ts +134 -1
  194. package/src/mcp/__tests__/reload-signal-emission.test.ts +54 -0
  195. package/src/mcp/__tests__/reload-signal.test.ts +57 -0
  196. package/src/mcp/__tests__/startup.test.ts +150 -0
  197. package/src/mcp/reload-signal.ts +50 -0
  198. package/src/mcp/startup.ts +101 -0
  199. package/src/messaging/providers/outlook/adapter.ts +2 -13
  200. package/src/messaging/providers/outlook/client.ts +13 -1
  201. package/src/messaging/providers/outlook/types.ts +3 -0
  202. package/src/messaging/providers/telegram-bot/adapter.ts +9 -2
  203. package/src/messaging/providers/telegram-bot/client.ts +8 -2
  204. package/src/messaging/providers/whatsapp/adapter.ts +9 -2
  205. package/src/messaging/providers/whatsapp/client.ts +8 -2
  206. package/src/notifications/AGENTS.md +5 -0
  207. package/src/notifications/README.md +21 -7
  208. package/src/notifications/__tests__/assistant-reply-producer.test.ts +3 -10
  209. package/src/notifications/__tests__/background-failure-signal.test.ts +96 -0
  210. package/src/notifications/__tests__/broadcaster.test.ts +171 -7
  211. package/src/notifications/__tests__/decision-engine.test.ts +79 -6
  212. package/src/notifications/__tests__/edit-notification.test.ts +59 -0
  213. package/src/notifications/__tests__/resolve-visible-in-source.test.ts +96 -0
  214. package/src/notifications/__tests__/schedule-result-producer.test.ts +397 -0
  215. package/src/notifications/access-request-copy.ts +5 -5
  216. package/src/notifications/approval-card-data.ts +29 -13
  217. package/src/notifications/assistant-reply-producer.ts +0 -4
  218. package/src/notifications/background-failure-signal.ts +13 -1
  219. package/src/notifications/broadcaster.ts +65 -2
  220. package/src/notifications/conversation-pairing.ts +263 -155
  221. package/src/notifications/copy-composer.ts +38 -22
  222. package/src/notifications/decision-engine.ts +89 -61
  223. package/src/notifications/delivered-post-record.ts +81 -0
  224. package/src/notifications/deliveries-store.ts +8 -1
  225. package/src/notifications/edit-notification.ts +16 -0
  226. package/src/notifications/events-store.ts +68 -2
  227. package/src/notifications/guardian-question-mode.ts +24 -232
  228. package/src/notifications/home-feed-side-effect.ts +1 -0
  229. package/src/notifications/notification-utils.ts +13 -5
  230. package/src/notifications/resolve-visible-in-source.ts +56 -0
  231. package/src/notifications/schedule-result-producer.ts +275 -0
  232. package/src/notifications/signal.ts +5 -0
  233. package/src/oauth/__tests__/seed-providers-managed.test.ts +82 -0
  234. package/src/oauth/seed-providers.ts +201 -3
  235. package/src/onboarding/onboarding-events-store.ts +14 -8
  236. package/src/persistence/conversation-crud.ts +68 -19
  237. package/src/persistence/embeddings/embedding-backend.test.ts +162 -0
  238. package/src/persistence/embeddings/embedding-backend.ts +148 -11
  239. package/src/persistence/embeddings/embedding-gemini.test.ts +328 -9
  240. package/src/persistence/embeddings/embedding-gemini.ts +211 -27
  241. package/src/persistence/embeddings/embedding-openai.test.ts +113 -0
  242. package/src/persistence/embeddings/embedding-openai.ts +55 -4
  243. package/src/persistence/embeddings/embedding-types.test.ts +24 -0
  244. package/src/persistence/embeddings/embedding-types.ts +25 -1
  245. package/src/persistence/job-utils.ts +6 -2
  246. package/src/persistence/message-metadata.ts +20 -0
  247. package/src/persistence/migrations/283-memory-v3-selections-message-id-and-sections.ts +2 -1
  248. package/src/persistence/migrations/376-notification-deliveries-canonical-message-id.ts +37 -0
  249. package/src/persistence/schema/memory-injection.ts +31 -9
  250. package/src/persistence/schema/notifications.ts +8 -0
  251. package/src/persistence/steps.ts +2 -0
  252. package/src/plugin-api/index.ts +2 -1
  253. package/src/plugin-api/vision-support.test.ts +81 -0
  254. package/src/plugin-api/vision-support.ts +57 -10
  255. package/src/plugin-api/webhook-url.ts +18 -4
  256. package/src/plugins/AGENTS.md +1 -1
  257. package/src/plugins/defaults/channel/injectors.ts +3 -1
  258. package/src/plugins/defaults/injector-order.ts +2 -2
  259. package/src/plugins/defaults/memory/AGENTS.md +263 -30
  260. package/src/plugins/defaults/memory/__tests__/conversation-memory-orphan-sweep.test.ts +4 -0
  261. package/src/plugins/defaults/memory/__tests__/conversation-memory-purge.test.ts +6 -0
  262. package/src/plugins/defaults/memory/__tests__/db-memory-attach.test.ts +9 -3
  263. package/src/plugins/defaults/memory/__tests__/memory-log-stores-degraded.test.ts +3 -7
  264. package/src/plugins/defaults/memory/__tests__/relocated-memory-test-rows.ts +18 -0
  265. package/src/plugins/defaults/memory/context-search/sources/conversations.ts +16 -2
  266. package/src/plugins/defaults/memory/conversation-memory-purge.ts +2 -0
  267. package/src/plugins/defaults/memory/fork-conversation-memory.ts +13 -13
  268. package/src/plugins/defaults/memory/graph/__tests__/conversation-graph-memory-v2-routing.test.ts +19 -12
  269. package/src/plugins/defaults/memory/graph/conversation-graph-memory.ts +17 -15
  270. package/src/plugins/defaults/memory/graph-topology/build-memory-graph.ts +1 -1
  271. package/src/plugins/defaults/memory/hooks/__tests__/post-compact.test.ts +121 -0
  272. package/src/plugins/defaults/memory/hooks/init.ts +10 -0
  273. package/src/plugins/defaults/memory/hooks/injection-metadata.ts +100 -0
  274. package/src/plugins/defaults/memory/hooks/post-compact.ts +19 -7
  275. package/src/plugins/defaults/memory/hooks/user-prompt-submit.ts +11 -83
  276. package/src/plugins/defaults/memory/injectors.ts +4 -4
  277. package/src/plugins/defaults/memory/job-handlers.ts +4 -1
  278. package/src/plugins/defaults/memory/jobs/__tests__/embed-concept-page.test.ts +1 -0
  279. package/src/plugins/defaults/memory/jobs/embed-concept-page.ts +11 -3
  280. package/src/plugins/defaults/memory/memory-db.ts +4 -0
  281. package/src/plugins/defaults/memory/memory-marker.ts +28 -17
  282. package/src/plugins/defaults/memory/src/__tests__/memory-v2-simulate-route.test.ts +0 -1
  283. package/src/plugins/defaults/memory/src/__tests__/memory-worker-routes.test.ts +20 -0
  284. package/src/plugins/defaults/memory/src/memory-item-routes.test.ts +0 -1
  285. package/src/plugins/defaults/memory/src/memory-worker-routes.ts +3 -1
  286. package/src/plugins/defaults/memory/substrate/__tests__/cli-command-store.test.ts +1 -1
  287. package/src/plugins/defaults/memory/substrate/__tests__/consolidation-job.test.ts +66 -0
  288. package/src/plugins/defaults/memory/substrate/__tests__/injected-block-slugs.test.ts +345 -0
  289. package/src/plugins/defaults/memory/substrate/__tests__/page-index.test.ts +0 -1
  290. package/src/plugins/defaults/memory/substrate/__tests__/prompts-consolidation.test.ts +170 -1
  291. package/src/plugins/defaults/memory/substrate/__tests__/reembed-job.test.ts +1 -0
  292. package/src/plugins/defaults/memory/substrate/capability-slugs.ts +53 -0
  293. package/src/plugins/defaults/memory/substrate/cli-command-store.ts +4 -18
  294. package/src/plugins/defaults/memory/substrate/consolidation-job.ts +40 -1
  295. package/src/plugins/defaults/memory/substrate/ingest.ts +11 -9
  296. package/src/plugins/defaults/memory/substrate/injected-block-slugs.ts +426 -42
  297. package/src/plugins/defaults/memory/substrate/page-index.ts +5 -4
  298. package/src/plugins/defaults/memory/substrate/prompts/consolidation.ts +127 -14
  299. package/src/plugins/defaults/memory/substrate/skill-store.ts +1 -18
  300. package/src/plugins/defaults/memory/v2/__tests__/backfill-jobs.test.ts +1 -0
  301. package/src/plugins/defaults/memory/v2/__tests__/injection.test.ts +2 -8
  302. package/src/plugins/defaults/memory/v2/__tests__/router.test.ts +0 -1
  303. package/src/plugins/defaults/memory/v2/injection.ts +4 -4
  304. package/src/plugins/defaults/memory/v3/__tests__/capabilities.test.ts +16 -0
  305. package/src/plugins/defaults/memory/v3/__tests__/carry-integration.test.ts +1004 -319
  306. package/src/plugins/defaults/memory/v3/__tests__/dense.test.ts +227 -4
  307. package/src/plugins/defaults/memory/v3/__tests__/injection.test.ts +836 -263
  308. package/src/plugins/defaults/memory/v3/__tests__/live-integration.test.ts +65 -38
  309. package/src/plugins/defaults/memory/v3/__tests__/maintain-job.test.ts +354 -3
  310. package/src/plugins/defaults/memory/v3/__tests__/orchestrate.test.ts +688 -104
  311. package/src/plugins/defaults/memory/v3/__tests__/overlong-sections.test.ts +109 -0
  312. package/src/plugins/defaults/memory/v3/__tests__/page-content.test.ts +144 -0
  313. package/src/plugins/defaults/memory/v3/__tests__/plugin-schema.test.ts +534 -0
  314. package/src/plugins/defaults/memory/v3/__tests__/pool-log-store.test.ts +449 -0
  315. package/src/plugins/defaults/memory/v3/__tests__/pool-select.test.ts +265 -27
  316. package/src/plugins/defaults/memory/v3/__tests__/render-injection.test.ts +34 -117
  317. package/src/plugins/defaults/memory/v3/__tests__/section-dense-store.test.ts +491 -4
  318. package/src/plugins/defaults/memory/v3/__tests__/section-needle.test.ts +124 -1
  319. package/src/plugins/defaults/memory/v3/__tests__/sections.test.ts +264 -4
  320. package/src/plugins/defaults/memory/v3/__tests__/selection-log-store.test.ts +560 -22
  321. package/src/plugins/defaults/memory/v3/__tests__/shadow-integration.test.ts +40 -33
  322. package/src/plugins/defaults/memory/v3/__tests__/shadow-plugin.test.ts +718 -63
  323. package/src/plugins/defaults/memory/v3/__tests__/types.test.ts +83 -2
  324. package/src/plugins/defaults/memory/v3/candidate-match.ts +1 -1
  325. package/src/plugins/defaults/memory/v3/capabilities.ts +90 -14
  326. package/src/plugins/defaults/memory/v3/card.test.ts +15 -16
  327. package/src/plugins/defaults/memory/v3/card.ts +16 -15
  328. package/src/plugins/defaults/memory/v3/dense.ts +10 -0
  329. package/src/plugins/defaults/memory/v3/ever-injected-store.test.ts +643 -140
  330. package/src/plugins/defaults/memory/v3/ever-injected-store.ts +462 -212
  331. package/src/plugins/defaults/memory/v3/hot-set.test.ts +2 -2
  332. package/src/plugins/defaults/memory/v3/injector.ts +366 -278
  333. package/src/plugins/defaults/memory/v3/learned-edges.test.ts +2 -2
  334. package/src/plugins/defaults/memory/v3/maintain-job.ts +299 -73
  335. package/src/plugins/defaults/memory/v3/orchestrate.ts +327 -214
  336. package/src/plugins/defaults/memory/v3/overlong-sections.ts +83 -0
  337. package/src/plugins/defaults/memory/v3/page-content.ts +72 -92
  338. package/src/plugins/defaults/memory/v3/plugin-schema.ts +346 -0
  339. package/src/plugins/defaults/memory/v3/pool-log-store.ts +291 -0
  340. package/src/plugins/defaults/memory/v3/pool-select.test.ts +2 -2
  341. package/src/plugins/defaults/memory/v3/pool-select.ts +160 -60
  342. package/src/plugins/defaults/memory/v3/prune.test.ts +1042 -329
  343. package/src/plugins/defaults/memory/v3/prune.ts +433 -270
  344. package/src/plugins/defaults/memory/v3/rare-term-lane.test.ts +269 -0
  345. package/src/plugins/defaults/memory/v3/rare-term-lane.ts +141 -0
  346. package/src/plugins/defaults/memory/v3/render-injection.ts +43 -82
  347. package/src/plugins/defaults/memory/v3/section-dense-store.ts +316 -28
  348. package/src/plugins/defaults/memory/v3/section-needle.ts +145 -11
  349. package/src/plugins/defaults/memory/v3/sections.ts +103 -16
  350. package/src/plugins/defaults/memory/v3/selection-log-store.ts +243 -78
  351. package/src/plugins/defaults/memory/v3/shadow-plugin.ts +189 -68
  352. package/src/plugins/defaults/memory/v3/tuning-profile.ts +6 -0
  353. package/src/plugins/defaults/memory/v3/types.ts +169 -23
  354. package/src/plugins/defaults/memory/v3-eval/__tests__/eval-packets.test.ts +21 -4
  355. package/src/plugins/defaults/memory/v3-eval/eval-packets.ts +77 -26
  356. package/src/plugins/types.ts +14 -0
  357. package/src/providers/__tests__/connection-model-compat.test.ts +1 -0
  358. package/src/providers/__tests__/provider-secret-catalog.test.ts +4 -0
  359. package/src/providers/__tests__/xml-tool-call-salvage.test.ts +172 -0
  360. package/src/providers/inline-audio-support.test.ts +34 -0
  361. package/src/providers/inline-audio-support.ts +27 -0
  362. package/src/providers/model-catalog.ts +102 -0
  363. package/src/providers/openai/__tests__/chat-completions-extra-body.test.ts +51 -0
  364. package/src/providers/openai/__tests__/chat-completions-provider-xml-salvage.test.ts +291 -0
  365. package/src/providers/openai/chat-completions-provider.ts +114 -14
  366. package/src/providers/openai/codex-models.ts +1 -0
  367. package/src/providers/openai/responses-provider.ts +65 -15
  368. package/src/providers/opencode/client.test.ts +24 -0
  369. package/src/providers/opencode/client.ts +6 -1
  370. package/src/providers/provider-secret-catalog.ts +11 -1
  371. package/src/providers/retry.ts +6 -0
  372. package/src/providers/vellum/client.ts +14 -1
  373. package/src/providers/vellum/personality-directions.test.ts +163 -0
  374. package/src/providers/vellum/personality-directions.ts +120 -0
  375. package/src/providers/xml-tool-call-salvage.ts +212 -0
  376. package/src/runtime/AGENTS.md +7 -2
  377. package/src/runtime/__tests__/background-job-runner.test.ts +115 -0
  378. package/src/runtime/__tests__/guardian-form-registry.test.ts +0 -32
  379. package/src/runtime/__tests__/host-observe.test.ts +44 -0
  380. package/src/runtime/assistant-event-hub.ts +14 -9
  381. package/src/runtime/auth/__tests__/guard-tests.test.ts +1 -4
  382. package/src/runtime/auth/__tests__/route-policy.test.ts +65 -0
  383. package/src/runtime/auth/same-actor.ts +4 -3
  384. package/src/runtime/background-job-runner.ts +10 -0
  385. package/src/runtime/channel-reply-delivery.ts +1 -162
  386. package/src/runtime/guardian-action-service.ts +20 -1
  387. package/src/runtime/host-observe.ts +56 -6
  388. package/src/runtime/http-server.ts +35 -0
  389. package/src/runtime/outbound-post-reconciliation.ts +183 -0
  390. package/src/runtime/routes/__tests__/contact-address-prompt-route.test.ts +231 -0
  391. package/src/runtime/routes/__tests__/contact-record-prompt-route.test.ts +59 -3
  392. package/src/runtime/routes/__tests__/guardian-form-routes.test.ts +85 -0
  393. package/src/runtime/routes/__tests__/heartbeat-routes.test.ts +24 -0
  394. package/src/runtime/routes/__tests__/platform-credits-routes.test.ts +239 -0
  395. package/src/runtime/routes/__tests__/roadmap-routes.test.ts +469 -0
  396. package/src/runtime/routes/__tests__/watch-routes.test.ts +70 -1
  397. package/src/runtime/routes/__tests__/webhook-routes.test.ts +83 -0
  398. package/src/runtime/routes/contact-prompt-routes.ts +177 -28
  399. package/src/runtime/routes/conversation-query-routes.ts +53 -11
  400. package/src/runtime/routes/events-routes.ts +13 -3
  401. package/src/runtime/routes/guardian-action-routes.ts +7 -0
  402. package/src/runtime/routes/guardian-form-routes.ts +6 -4
  403. package/src/runtime/routes/heartbeat-routes.ts +41 -53
  404. package/src/runtime/routes/index.ts +2 -2
  405. package/src/runtime/routes/integrations/a2a.ts +12 -3
  406. package/src/runtime/routes/integrations/vercel.ts +13 -3
  407. package/src/runtime/routes/platform-routes.ts +175 -23
  408. package/src/runtime/routes/roadmap-routes.ts +744 -0
  409. package/src/runtime/routes/watch-routes.ts +50 -0
  410. package/src/runtime/routes/webhook-routes.ts +24 -2
  411. package/src/runtime/web-presence.ts +13 -9
  412. package/src/schedule/__tests__/schedule-timezone.test.ts +21 -3
  413. package/src/schedule/__tests__/worker-mcp-tools.test.ts +88 -0
  414. package/src/schedule/schedule-timezone.ts +25 -0
  415. package/src/schedule/scheduler.ts +19 -0
  416. package/src/schedule/worker.ts +119 -2
  417. package/src/telemetry/__tests__/live-voice-funnel.test.ts +32 -0
  418. package/src/telemetry/live-voice-funnel.ts +33 -0
  419. package/src/tools/acp/list-agents.test.ts +1 -1
  420. package/src/tools/browser/__tests__/browser-status.test.ts +3 -0
  421. package/src/tools/browser/browser-execution.ts +117 -53
  422. package/src/tools/browser/browser-status-constants.ts +6 -6
  423. package/src/tools/capability-offer.test.ts +87 -0
  424. package/src/tools/capability-offer.ts +93 -0
  425. package/src/tools/computer-use/definitions.ts +6 -0
  426. package/src/tools/computer-use/skill-proxy-bridge.ts +10 -0
  427. package/src/tools/terminal/safe-env.ts +2 -0
  428. package/src/watch/__tests__/watch-retro.test.ts +11 -10
  429. package/src/watch/__tests__/watch-session-manager.test.ts +75 -1
  430. package/src/watch/watch-retro.ts +10 -9
  431. package/src/watch/watch-session-manager.ts +17 -0
  432. package/src/runtime/routes/__tests__/sight-frame-routes.test.ts +0 -487
  433. package/src/runtime/routes/sight-frame-routes.ts +0 -136
@@ -129,6 +129,107 @@ including the v3 pair defined in `v3/injector.ts` — so `plugins/defaults/index
129
129
  imports the array and nothing else. A new tier injector is added to that array,
130
130
  never registered from the host.
131
131
 
132
+ **v3 injection invariants.** The mechanics are documented in the modules
133
+ that own them (`v3/injector.ts`, `v3/prune.ts`, `v3/ever-injected-store.ts`,
134
+ `v3/plugin-schema.ts`, `substrate/injected-block-slugs.ts`,
135
+ `hooks/injection-metadata.ts`); these are the rules an outside change must
136
+ not break.
137
+
138
+ - **The section is the unit.** Each turn the `memory-v3` injector renders
139
+ every section selected for each selected page (its lead when the page was
140
+ selected with no section; a capability slug renders its whole capability
141
+ content) into one frozen `<memory>` block, net-new only: a
142
+ `(conversation, slug, section key)` pair resident in
143
+ `memory_v3_injected_sections` is never re-rendered. The key is
144
+ `v3/types.ts`'s `sectionKey()` (`""` for the lead, the trimmed heading title
145
+ otherwise, `title#<n>` for the n-th repeat of a heading and `~<n>` appended
146
+ for the n-th chunk of an over-long section, with literal `#` and `~` in
147
+ titles doubled so the encoding is a bijection), and `sectionRefId()` there
148
+ is the one string encoding of a `(slug, key)` pair for keying maps and
149
+ sets. Do not add another.
150
+ - **The block grammar has one owner.** `substrate/injected-block-slugs.ts`
151
+ writes the `# memory/concepts/<slug>.md § <key>` section header (the bare
152
+ page header for a lead), escapes every chunk body (`escapeInjectedBody`:
153
+ one leading backslash on a line that would otherwise read as a boundary,
154
+ so page or skill text can never forge one) and parses blocks
155
+ (`parseInjectedSections`). The prune valve, the `loadFromDb` rehydration
156
+ filter, the truncated-fork seed, and the retry anchor merge all read
157
+ through it; do not add a second header matcher or chunk splitter. The one
158
+ exception is `LEGACY_CARD_HEADER_REGEX` in the same file, the pre-stamp
159
+ card grammar that `parseLegacyCards` alone reads for legacy blocks.
160
+ - **A block's format is explicit provenance, never inferred from its
161
+ content.** The persisting build stamps `memoryV3InjectedBlockFormat`
162
+ beside `memoryV3InjectedBlock`; a row is current exactly when its stamp
163
+ equals the plugin's `MEMORY_V3_INJECTED_BLOCK_FORMAT`, and a row carrying
164
+ the block without the stamp is legacy (`InjectedBlockFormat` in
165
+ `v3/types.ts`). A legacy block is read with the card grammar of the build
166
+ that rendered it (`filterLegacyCards`), each card under its lead ref
167
+ `(slug, "")`: a card whose lead is tombstoned, or whose lead a current
168
+ block re-injected after a prune, leaves; nothing else in it is parsed,
169
+ pruned, counted, indexed, or fork-seeded, and it ages out at compaction.
170
+ - **A block claims its sections only through its commit.** The section
171
+ record (`recordInjected`) and the prune-valve schedule ride the commit
172
+ callback the block carries (`memoryV3Commit`), which runtime assembly
173
+ invokes only where the block persists; re-entry, run-messages-replacement,
174
+ and post-compaction assemblies attach blocks in memory only and claim
175
+ nothing, so a turn's sections are recorded once.
176
+ - **Pointers are per message.** Sections re-selected while resident are
177
+ listed, paths only, in the `memory-v3-pointer` injector's `<memory_pointer>`
178
+ block, persisted under `memoryV3PointerBlock` on the user message that was
179
+ sent with it and rehydrated with it; a fresh pointer is spliced only onto
180
+ the new tail, no historical message is ever rewritten, and the hook's
181
+ metadata update states the turn's layout including its deletions (a retry
182
+ re-runs onto its anchor row). The legacy `memoryV3SpotlightBlock` is never
183
+ written and rehydrates verbatim.
184
+ - **Pruning is tombstones plus filters, never a metadata rewrite.** The prune
185
+ valve (`v3/prune.ts`, `memory.v3.prune`) evicts by each section row's own
186
+ `last_selected_at` (the injector stamps every section a turn selects) with
187
+ no lane exemptions, marks rows `pruned_at`, and strips the pruned sections
188
+ from the live history and at rehydration; both filter points also keep only
189
+ each section's newest persisted copy. The live strip owns a `<memory>`
190
+ block by object identity (`markV3LiveBlock` / `isV3LiveBlock` in
191
+ `v3/types.ts`), never by text, so a pre-cutover v2 block byte-identical to
192
+ a v3 entry is left alone.
193
+ - **The store resets only behind a durable strip marker.** The reset
194
+ (`clearConversation`, through `ConversationGraphMemory.onCompacted`) runs
195
+ whenever the durable history is injection-stripped, not only when a summary
196
+ lands: `resetInjectionLedgersForStrip` (in
197
+ `daemon/conversation-agent-loop-handlers.ts`) runs it from the loop's
198
+ `compaction_completed` dispatch on a run that compacted nothing and from
199
+ `applyCompactionResult` on a real compaction, `/clean` runs it the same way,
200
+ and every reset precedes the re-injection. The reset is gated on the
201
+ `historyStrippedAt` marker being durable, since a reload with no marker
202
+ rehydrates the frozen blocks the reset unclaimed: the loop's
203
+ `history_stripped` dispatch writes the marker at the strip, a write that
204
+ succeeds there counts for the pair, and when no write succeeds a run that
205
+ compacted nothing keeps the store intact and commits the injected
206
+ pre-compaction history instead (the dispatcher reports the outcome to the
207
+ loop through its run's `injectionLedgerResets`, and the loop continues from
208
+ the injected history), so residency and the live history agree either way.
209
+ A compacted result has already lost its frozen blocks to the summary, so
210
+ there, once the compaction commit has landed, the store resets even without
211
+ the marker (a reload may rehydrate the
212
+ kept tail's blocks unclaimed once, until the newest-copy filter retires them
213
+ behind a re-injected copy), and a reset whose ledger clear fails reports
214
+ that the same way a missing marker does.
215
+ - **The store is plugin-owned.** `memory_v3_injected_sections`,
216
+ `memory_v3_pools`, and the `section_key` column of `memory_v3_selections`
217
+ are created by `v3/plugin-schema.ts` (`ensureMemoryV3PluginSchema` from the
218
+ `init` hook, and each store's once-per-connection ensure on first use),
219
+ never by the global migration chain, and every read goes through its
220
+ fail-soft `memoryReader`, so an unavailable memory database degrades a
221
+ store to no-ops rather than failing a turn or readiness. The superseded
222
+ `memory_v3_ever_injected` has exactly one reader, the sections ensure's
223
+ one-time copy of its rows into the section store as zero-byte lead entries
224
+ (checkpoint `memory_v3_injected_sections:legacy_copy_done`, below), and
225
+ two writers, the compaction reset (`clearConversation`) and the
226
+ conversation purge, which delete a conversation's rows so no later copy
227
+ re-imports leads whose blocks are gone.
228
+ - **Lanes and caps.** The finder lanes surface in a fixed order and only ever
229
+ add lines; a page carries at most `memory.v3.finderSectionsPerPage` capped
230
+ lines plus its entity and rare-term lines (the lane rules are under
231
+ `memory_v3_pools` below).
232
+
132
233
  Both rules are enforced by `__tests__/memory-tier-boundary-guard.test.ts`, which
133
234
  also carries a reverse stale-exemption test: an allowlist entry whose multi-tier
134
235
  import disappears fails loudly instead of lingering. Related guards:
@@ -246,26 +347,114 @@ which outlives the v2 engine.
246
347
 
247
348
  Persisted rows; a rename orphans every existing install.
248
349
 
249
- | Table | Owner |
250
- | --------------------------------- | ----------------------------------- |
251
- | `memory_graph_nodes` | all-tier (`graph/store.ts`) |
252
- | `memory_graph_edges` | all-tier |
253
- | `memory_graph_triggers` | all-tier |
254
- | `memory_graph_node_edits` | all-tier |
255
- | `memory_segments` | v1 indexing |
256
- | `memory_summaries` | v1 indexing |
257
- | `memory_embeddings` | shared embedding cache |
258
- | `memory_checkpoints` | shared (all durable checkpoints) |
259
- | `memory_jobs` | shared job queue |
260
- | `memory_recall_logs` | shared recall audit |
261
- | `conversation_graph_memory_state` | `graph/graph-memory-state-store.ts` |
262
- | `activation_state` | v2 per-conversation activation |
263
- | `memory_v2_activation_logs` | v2 inspector/harness |
264
- | `memory_v2_injection_events` | v2 scoring feedback |
265
- | `memory_v3_selections` | v3 selection log |
266
- | `memory_v3_ever_injected` | v3 card dedup |
267
- | `memory_retrospective_state` | retrospective (tier-agnostic) |
268
- | `activation_sessions` | onboarding activation rail |
350
+ | Table | Owner |
351
+ | --------------------------------- | --------------------------------------------------------------- |
352
+ | `memory_graph_nodes` | all-tier (`graph/store.ts`) |
353
+ | `memory_graph_edges` | all-tier |
354
+ | `memory_graph_triggers` | all-tier |
355
+ | `memory_graph_node_edits` | all-tier |
356
+ | `memory_segments` | v1 indexing |
357
+ | `memory_summaries` | v1 indexing |
358
+ | `memory_embeddings` | shared embedding cache |
359
+ | `memory_checkpoints` | shared (all durable checkpoints) |
360
+ | `memory_jobs` | shared job queue |
361
+ | `memory_recall_logs` | shared recall audit |
362
+ | `conversation_graph_memory_state` | `graph/graph-memory-state-store.ts` |
363
+ | `activation_state` | v2 per-conversation activation |
364
+ | `memory_v2_activation_logs` | v2 inspector/harness |
365
+ | `memory_v2_injection_events` | v2 scoring feedback |
366
+ | `memory_v3_selections` | v3 selection log (`section_key` column plugin-added, see below) |
367
+ | `memory_v3_pools` | v3 selector pool audit (plugin-created, see below) |
368
+ | `memory_v3_injected_sections` | v3 section dedup, prune bytes + recency (plugin-created, below) |
369
+ | `memory_v3_ever_injected` | v3 card dedup (superseded, frozen) |
370
+ | `memory_retrospective_state` | retrospective (tier-agnostic) |
371
+ | `activation_sessions` | onboarding activation rail |
372
+
373
+ `memory_v3_pools` and `memory_v3_injected_sections` are the plugin's own
374
+ tables, created by the plugin rather than by the global migration chain
375
+ (`v3/plugin-schema.ts`): the memory plugin's `init` hook ensures both on every
376
+ boot, and each store ensures again on the first use of a connection in its
377
+ process (the memory worker is a separate process), idempotently and fail-open,
378
+ so a memory database that cannot be opened degrades the stores to no-ops
379
+ instead of failing database readiness. The sections ensure adds the
380
+ `last_selected_at` column (the prune valve's recency stamp) to a table created
381
+ before it existed, and copies the legacy `memory_v3_ever_injected` rows in as
382
+ zero-byte lead entries, once per database: the first ensure that finds the
383
+ legacy table copies (`INSERT OR IGNORE`) and records
384
+ `memory_v3_injected_sections:legacy_copy_done`
385
+ in `memory_checkpoints`, later ensures skip on that record, and a ledger that
386
+ cannot be read skips the copy rather than repeating it. The compaction reset
387
+ (`clearConversation`) and the conversation purge delete a conversation's
388
+ legacy rows with its section rows, so a copy can never bring back leads whose
389
+ blocks compaction stripped. `memory_v3_selections` itself is created by migration
390
+ 338, but its
391
+ `section_key` column is plugin-owned the same way: the selection log's writer
392
+ (`writeTurnLog`) and the inspector's reader (`v3/selection-log-store.ts`) add
393
+ it on the first use of a connection, and the `init` hook at boot. Every
394
+ selection row records one section per slug, the selection's first selected
395
+ section, as its `sectionKey` beside the title and ordinal (an inspector and
396
+ frecency record only; the prune valve's recency lives on the section store's
397
+ rows, see the v3 injection invariants above), and the inspector
398
+ resolves a row by that key first (exactly, so a repeated heading's other
399
+ occurrence is never substituted), falling back to title-then-ordinal only for
400
+ rows written before the column existed.
401
+
402
+ `memory_v3_pools` (`v3/pool-log-store.ts`) holds one row per turn: the
403
+ selector's full candidate pool (every stable-prefix card and finder line, in
404
+ pool order, with lane, matched section, and a per-line verdict) for the
405
+ inspector's Memory tab, plus `selector_ran`. A page carries one finder line
406
+ per distinct matched section, at most `memory.v3.finderSectionsPerPage` in
407
+ surfacing order (needle, dense, reply, span) plus its entity and rare-term
408
+ lines, and selecting a line selects that section; the selection log keeps
409
+ one row per slug, so the pool row is where the per-section verdicts live. A
410
+ turn whose selector never judged a pool (the injection gate hard-skipped it,
411
+ or nothing was pooled) persists an empty pool with `selector_ran = 0`, and a
412
+ turn that logged no selections is still reachable by its stamped
413
+ `message_id`, so the inspector shows negative verdicts too. The pool row and
414
+ the turn's `memory_v3_selections` rows are
415
+ written in one transaction (`writeTurnLog` in `v3/shadow-plugin.ts`), and a
416
+ turn observed again replaces both, so the pool's `chosen` flags and the
417
+ selection rows always describe the same observation. Rows are per-turn
418
+ diagnostics, roughly 10KB each, with no retention job; a conversation delete
419
+ purges them with the other conversation-keyed tables
420
+ (`conversation-memory-purge.ts`).
421
+
422
+ **v3 finder lanes.** The per-turn finder lanes (`v3/orchestrate.ts`) surface
423
+ candidates in a fixed order, needle, dense, reply, span, entity, rare, then
424
+ edge and learned, and each only ever adds lines. The entity lane
425
+ (`v3/entity-lane.ts`, `memory.v3.entity`) and the rare-term lane
426
+ (`v3/rare-term-lane.ts`, `memory.v3.rareTerm`) key on one strong token rather
427
+ than the whole message: a distinctive `## ` heading token the message names,
428
+ and a query word rare across the corpus, which surfaces its top `perTerm`
429
+ sections by single-term BM25F (`SectionNeedle.df` and `scoreTerm`), rarest
430
+ words first up to `cap` per turn, with no token-shape filtering (a word the
431
+ corpus does not hold has df 0 and drops out on its own; bigram terms are never
432
+ eligible). Rare is corpus-relative: a word qualifies when its df is at most
433
+ `min(maxDf, max(1, floor(sectionCount * maxDfFraction)))` (defaults 12 and
434
+ 0.002), so a corpus of 6,000 sections or more runs at `maxDf` and a corpus of
435
+ a few hundred sections counts only a word unique to one section as rare; an
436
+ absolute ceiling would make most ordinary words of a small corpus rare and
437
+ fill `cap` with noise every turn. Both are synchronous in-memory passes that
438
+ feed neither the injection gate nor the edge seeds, and pool through the same
439
+ `(page, section key)` dedupe as every other lane, so a section another lane
440
+ already pooled is a no-op. Both lanes' lines are outside the per-page cap
441
+ (`memory.v3.finderSectionsPerPage`), neither counted against it nor
442
+ displaced by it, because each lane runs after every lane that fills the cap
443
+ and a page already carrying that many bulk-theme lines would otherwise drop
444
+ exactly the line the lane exists to surface. The lanes' own caps bound what
445
+ they add instead (`entityCap` articles per turn for the entity lane,
446
+ `perTerm` and `cap` for the rare-term lane), so a page carries at most
447
+ `finderSectionsPerPage` capped lines plus its entity and rare lines,
448
+ `finderSectionsPerPage + entityCap + rareTerm.cap` in all. The entity lane runs
449
+ at every corpus size (the lean profile does not switch it off); the
450
+ rare-term lane runs only when the selector does (`v3/shadow-plugin.ts`
451
+ threads `rareTerm` only
452
+ with `selectorEnabled`), because rare lines are candidates for a judge, not
453
+ evidence strong enough to inject unjudged, and with the selector off every
454
+ pooled line is injected. A rare hit's pool line is
455
+ tagged `(rare: <word>)` with a keyword-in-context snippet centered on the
456
+ word, and its selection records `source = 'rare'`; the pool record and the
457
+ selection log carry the lane name with no other change.
269
458
 
270
459
  ### Job types (`memory_jobs.type`)
271
460
 
@@ -317,6 +506,50 @@ failure record and the section re-embed high-water:
317
506
  absent the maintain job re-embeds EVERY page, so losing or renaming it forces
318
507
  a full rebuild. Distinct from the `memory_v3_maintain_last_run` cadence key
319
508
  despite the shared prefix
509
+ - `memory_v3_maintain:section_chunker_version`
510
+ (`v3/section-dense-store.ts`'s `SECTION_CHUNKER_VERSION_KEY`, current value
511
+ `SECTION_CHUNKER_VERSION`): the chunker version the stored section vectors
512
+ were built with. `ensureSectionChunkerVersion` (run at dense lane init and
513
+ by the maintain job and the backfill before an embed pass) clears the
514
+ high-water above on a mismatch so the collection is rebuilt from every
515
+ page, since point ids and dense hits key on `(article, ordinal)`. A store
516
+ with no version on record counts as stale, not fresh, when a high-water or
517
+ the pending marker below is on record or the collection already holds
518
+ points; only an empty collection records the version with nothing to
519
+ rebuild
520
+ - `memory_v3_maintain:section_rebuild_pending`
521
+ (`v3/section-dense-store.ts`'s `SECTION_REBUILD_PENDING_KEY`): written
522
+ before that high-water reset (the marker is the only signal that survives
523
+ the reset, so an interruption between the two writes leaves the hold in
524
+ place and the next check finishes the transition) and cleared by
525
+ `commitSectionEmbedHighWater`, the commit that ends a zero-failure re-embed
526
+ pass (the maintain job's and the backfill's). While it is set the dense lane
527
+ serves no hits (`holdSectionDenseReadsUntilRebuilt` at lane init,
528
+ `sectionDenseReadsHeld` on every dense read), the check that first reports
529
+ it in this process (at lane init, or retried from the dense read path)
530
+ enqueues `memory_v3_maintain` at once instead of waiting out the
531
+ cadence key, and the maintain pass it names re-embeds every capability row
532
+ the store holds (the change delta never names one) before its commit
533
+ clears the marker: a stored row whose body renders empty in that process
534
+ holds the commit until the deleted-page prune removes it, so the marker
535
+ never clears over points built by the previous chunker. The pass runs in
536
+ the memory worker, whose skill and CLI caches are never seeded, so a
537
+ version rebuild there prunes every capability row (its page index lists
538
+ none) and commits over a store with no capability points, which
539
+ `backfill-sections` (run in the daemon, caches seeded) restores. A version
540
+ check that throws (Qdrant unreachable for the collection
541
+ probe, an unreadable ledger) holds dense reads as indeterminate: the hold
542
+ ignores the marker's absence, which is what the failed check left unproven,
543
+ and the dense read path (`settleSectionDenseReadHold`) retries the check at
544
+ most once a minute (`SECTION_VERSION_CHECK_RETRY_MS`) until one completes,
545
+ which marks the rebuild pending and kicks it, or releases the hold
546
+ - `memory_v3_injected_sections:legacy_copy_done`
547
+ (`v3/plugin-schema.ts`'s `SECTIONS_LEGACY_COPY_DONE_KEY`): the legacy
548
+ `memory_v3_ever_injected` rows were copied into
549
+ `memory_v3_injected_sections` once on this database, and every later
550
+ sections ensure skips the copy on it. Losing it repeats the copy, which is
551
+ idempotent (`INSERT OR IGNORE`) and cannot resurrect a conversation the
552
+ compaction reset or a purge cleared, since both delete its legacy rows too
320
553
  - v1: `graph_maintenance:{decay,consolidate,pattern_scan,narrative}:last_run`,
321
554
  `pkb_filing_last_run`, `pkb_compaction_last_run`,
322
555
  `graph_bootstrap:*`, `memory:backfill:*`
@@ -333,16 +566,16 @@ failure record and the section re-embed high-water:
333
566
 
334
567
  ### Wire-visible strings
335
568
 
336
- | Name | Kind | Why frozen |
337
- | --------------------------------------------------------------------------------------- | ------------------------------------- | ------------------------------------------------------------------- |
338
- | `memory_v2_consolidation` | `conversations.source` value | persisted on every consolidation run |
339
- | `memory_retrospective` | request origin / `TitleOrigin` member | the permission checker's skill-authoring auto-grant is scoped to it |
340
- | `skill-authored-card` | message kind | persisted on skill-card messages |
341
- | `memoryV2Consolidation`, `memoryRetrospective` | LLM call-site ids | logging/attribution buckets |
342
- | `memoryInjectedBlock`, `memoryV2StaticBlock`, `memoryV3InjectedBlock`, `memoryV3Commit` | message-metadata keys | persisted on messages; drives re-injection and the strip |
343
- | `memory-v2-static` | injector + block id | `daemon/conversation-runtime-assembly.ts` matches on it |
344
- | `MEMORY_V2_DISABLED` | error code | clients branch on it |
345
- | `memory.v2.sweep` | notification job identifier | surfaced in `activity.failed` |
569
+ | Name | Kind | Why frozen |
570
+ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------- | ------------------------------------------------------------------- |
571
+ | `memory_v2_consolidation` | `conversations.source` value | persisted on every consolidation run |
572
+ | `memory_retrospective` | request origin / `TitleOrigin` member | the permission checker's skill-authoring auto-grant is scoped to it |
573
+ | `skill-authored-card` | message kind | persisted on skill-card messages |
574
+ | `memoryV2Consolidation`, `memoryRetrospective` | LLM call-site ids | logging/attribution buckets |
575
+ | `memoryInjectedBlock`, `memoryV2StaticBlock`, `memoryV3InjectedBlock`, `memoryV3InjectedBlockFormat`, `memoryV3PointerBlock`, `memoryV3SpotlightBlock` (legacy, read-only), `memoryV3Commit` | message-metadata keys | persisted on messages; drives re-injection and the strip |
576
+ | `memory-v2-static` | injector + block id | `daemon/conversation-runtime-assembly.ts` matches on it |
577
+ | `MEMORY_V2_DISABLED` | error code | clients branch on it |
578
+ | `memory.v2.sweep` | notification job identifier | surfaced in `activity.failed` |
346
579
 
347
580
  ### HTTP surface
348
581
 
@@ -20,12 +20,16 @@ import {
20
20
  import { conversations } from "../../../../persistence/schema/index.js";
21
21
  import { sweepOrphanConversationMemoryTables } from "../conversation-memory-orphan-sweep.js";
22
22
  import { CONVERSATION_KEYED_MEMORY_TABLES } from "../conversation-memory-purge.js";
23
+ import { ensureMemoryV3PluginSchema } from "../v3/plugin-schema.js";
23
24
  import {
24
25
  relocatedMemoryRowCount as rowCount,
25
26
  seedRelocatedMemoryRow as seedRow,
26
27
  } from "./relocated-memory-test-rows.js";
27
28
 
28
29
  await initializeDb();
30
+ // The memory-v3 plugin creates its own tables (init hook, or a store's
31
+ // first use), not the global chain: stand them up as the init hook does.
32
+ ensureMemoryV3PluginSchema();
29
33
 
30
34
  function seedConversation(id: string): void {
31
35
  getDb()
@@ -25,12 +25,16 @@ import {
25
25
  purgeConversationMemoryTables,
26
26
  } from "../conversation-memory-purge.js";
27
27
  import conversationDeleted from "../hooks/conversation-deleted.js";
28
+ import { ensureMemoryV3PluginSchema } from "../v3/plugin-schema.js";
28
29
  import {
29
30
  relocatedMemoryRowCount as rowCount,
30
31
  seedRelocatedMemoryRow as seedRow,
31
32
  } from "./relocated-memory-test-rows.js";
32
33
 
33
34
  await initializeDb();
35
+ // The memory-v3 plugin creates its own tables (init hook, or a store's
36
+ // first use), not the global chain: stand them up as the init hook does.
37
+ ensureMemoryV3PluginSchema();
34
38
 
35
39
  async function runHook(conversationId: string): Promise<void> {
36
40
  const hook = conversationDeleted as HookFunction<ConversationDeletedContext>;
@@ -55,6 +59,8 @@ describe("conversation memory purge", () => {
55
59
  "memory_segments",
56
60
  "memory_v2_activation_logs",
57
61
  "memory_v3_ever_injected",
62
+ "memory_v3_injected_sections",
63
+ "memory_v3_pools",
58
64
  "memory_v3_selections",
59
65
  ].sort(),
60
66
  );
@@ -10,9 +10,9 @@
10
10
  * `memory` schema on its `database_list`.
11
11
  * 3. The relocated memory tables (`memory_jobs`, `memory_v2_injection_events`,
12
12
  * `memory_v2_activation_logs`, `memory_recall_logs`,
13
- * `memory_v3_selections`, `activation_sessions`, `activation_state`,
14
- * `conversation_graph_memory_state`, `memory_v3_ever_injected`,
15
- * `memory_retrospective_state`, and the graph cluster
13
+ * `memory_v3_selections`, `memory_v3_pools`, `activation_sessions`,
14
+ * `activation_state`, `conversation_graph_memory_state`,
15
+ * `memory_v3_ever_injected`, `memory_retrospective_state`, and the graph cluster
16
16
  * `memory_graph_nodes` / `memory_graph_edges` / `memory_graph_triggers` /
17
17
  * `memory_graph_node_edits`) live in the dedicated memory connection, not
18
18
  * in the main connection — proving the physical split.
@@ -25,6 +25,7 @@ import { join } from "node:path";
25
25
  import { describe, expect, test } from "bun:test";
26
26
 
27
27
  import { removeTestDbFiles } from "../../../../__tests__/assert-not-live-db.js";
28
+ import { ensureMemoryV3PluginSchema } from "../v3/plugin-schema.js";
28
29
 
29
30
  const { getSqlite, getMemorySqlite } =
30
31
  await import("../../../../persistence/db-connection.js");
@@ -35,6 +36,9 @@ const { getMemoryDbPath } = await import("../../../../util/memory-db-path.js");
35
36
  const { findSqlite3 } = await import("../../../../util/sqlite3-runtime.js");
36
37
 
37
38
  await initializeDb();
39
+ // The memory-v3 plugin creates its own tables (init hook, or a store's
40
+ // first use), not the global chain: stand them up as the init hook does.
41
+ ensureMemoryV3PluginSchema();
38
42
 
39
43
  const sqlite3Available = findSqlite3() !== undefined;
40
44
 
@@ -63,10 +67,12 @@ describe("memory database connection", () => {
63
67
  "memory_v2_activation_logs",
64
68
  "memory_recall_logs",
65
69
  "memory_v3_selections",
70
+ "memory_v3_pools",
66
71
  "activation_sessions",
67
72
  "activation_state",
68
73
  "conversation_graph_memory_state",
69
74
  "memory_v3_ever_injected",
75
+ "memory_v3_injected_sections",
70
76
  "memory_retrospective_state",
71
77
  "memory_graph_nodes",
72
78
  "memory_graph_edges",
@@ -99,7 +99,7 @@ describe("memory log stores without a memory database", () => {
99
99
  });
100
100
 
101
101
  describe("memory-v3 prune valve without a memory database", () => {
102
- // The valve's candidate accounting (`memory_v3_ever_injected`) now lives on
102
+ // The valve's candidate accounting (`memory_v3_injected_sections`) lives on
103
103
  // the memory connection too, degraded by the outer beforeEach. With no
104
104
  // resident candidates the valve cannot plan a prune, so it no-ops rather than
105
105
  // throwing.
@@ -108,18 +108,14 @@ describe("memory-v3 prune valve without a memory database", () => {
108
108
  // resident entries.
109
109
  recordInjected(
110
110
  "conv-degraded-prune",
111
- [{ slug: "domain-a/page-old", bytes: 600 }],
111
+ [{ slug: "domain-a/page-old", key: "", bytes: 600 }],
112
112
  1_000,
113
113
  );
114
114
 
115
115
  let plan: ReturnType<typeof planPrune> | undefined;
116
116
  expect(() => {
117
117
  plan = planPrune(
118
- {
119
- maxResidentBytes: 1_000,
120
- targetResidentBytes: 500,
121
- exemptSlugs: new Set(),
122
- },
118
+ { maxResidentBytes: 1_000, targetResidentBytes: 500 },
123
119
  "conv-degraded-prune",
124
120
  );
125
121
  }).not.toThrow();
@@ -43,6 +43,15 @@ export function seedRelocatedMemoryRow(
43
43
  )
44
44
  .run(conversationId, now);
45
45
  return;
46
+ case "memory_v3_pools":
47
+ raw
48
+ .query(
49
+ `INSERT INTO memory_v3_pools
50
+ (conversation_id, turn, created_at, pool_size, selected_count, candidates_json)
51
+ VALUES (?, 1, ?, 0, 0, '[]')`,
52
+ )
53
+ .run(conversationId, now);
54
+ return;
46
55
  case "activation_sessions":
47
56
  raw
48
57
  .query(
@@ -77,6 +86,15 @@ export function seedRelocatedMemoryRow(
77
86
  )
78
87
  .run(conversationId, now);
79
88
  return;
89
+ case "memory_v3_injected_sections":
90
+ raw
91
+ .query(
92
+ `INSERT INTO memory_v3_injected_sections
93
+ (conversation_id, slug, section_key, injected_at, bytes, pruned_at)
94
+ VALUES (?, 'domain/page', '', ?, 0, NULL)`,
95
+ )
96
+ .run(conversationId, now);
97
+ return;
80
98
  case "memory_retrospective_state":
81
99
  raw
82
100
  .query(
@@ -18,6 +18,14 @@ import type { RecallSearchContext, RecallSearchResult } from "../types.js";
18
18
  const log = getLogger("recall-conversations-source");
19
19
 
20
20
  const SUBAGENT_SOURCE = "subagent";
21
+ /**
22
+ * A notification conversation holds the posts the daemon delivered to a chat,
23
+ * written after the channel acknowledged them with the `providerMeta`
24
+ * envelope (`notifications/delivered-post-record.ts`). Only those rows are
25
+ * evidence: rows the pre-send pairing path wrote there carry no envelope and
26
+ * may describe a post the channel never accepted, and the lexical backfill
27
+ * indexes every finalized row regardless of how it was written.
28
+ */
21
29
  const NOTIFICATION_SOURCE = "notification";
22
30
 
23
31
  interface ConversationEvidenceRow {
@@ -36,7 +44,8 @@ interface ConversationEvidenceRow {
36
44
  * The read fetches ranked message-id candidates first and filters them in SQL
37
45
  * afterwards (Qdrant has no visibility filtering), so it must over-fetch
38
46
  * enough candidates that excluded rows (the active conversation,
39
- * subagent/auto-analysis/notification sources, private history) don't starve
47
+ * subagent/auto-analysis sources, notification rows without a delivered-post
48
+ * envelope, private history) don't starve
40
49
  * the post-filter pool. A generous candidate pool is cheap — the final
41
50
  * consumer takes top-N after the app-side scorer anyway.
42
51
  *
@@ -251,7 +260,12 @@ function searchByIds(
251
260
  FROM messages m
252
261
  JOIN conversations c ON c.id = m.conversation_id
253
262
  WHERE m.id IN (${placeholders})
254
- AND (c.source IS NULL OR c.source NOT IN (?, ?, ?))
263
+ AND (c.source IS NULL OR c.source NOT IN (?, ?))
264
+ AND (
265
+ c.source IS NULL
266
+ OR c.source != ?
267
+ OR json_extract(m.metadata, '$.providerMeta') IS NOT NULL
268
+ )
255
269
  AND c.id != ?
256
270
  AND c.conversation_type != 'private'
257
271
  ORDER BY m.created_at DESC
@@ -15,10 +15,12 @@ export const CONVERSATION_KEYED_MEMORY_TABLES: readonly string[] = [
15
15
  "memory_v2_activation_logs",
16
16
  "memory_recall_logs",
17
17
  "memory_v3_selections",
18
+ "memory_v3_pools",
18
19
  "activation_sessions",
19
20
  "activation_state",
20
21
  "conversation_graph_memory_state",
21
22
  "memory_v3_ever_injected",
23
+ "memory_v3_injected_sections",
22
24
  "memory_retrospective_state",
23
25
  // Re-derivable, but carries its conversation_id column, so a conversation
24
26
  // delete purges it here. A single-message delete (conversation survives) is
@@ -11,9 +11,10 @@ import {
11
11
  } from "./v2/activation-store.js";
12
12
  import {
13
13
  forkEverInjected,
14
- MEMORY_V3_INJECTED_BLOCK_METADATA_KEY,
15
- seedEverInjectedFromSlugs,
14
+ seedEverInjectedFromBlocks,
16
15
  } from "./v3/ever-injected-store.js";
16
+ import { persistedV3Block } from "./v3/prune.js";
17
+ import type { InjectedBlock } from "./v3/types.js";
17
18
 
18
19
  /** Inputs to {@link forkConversationMemory}. */
19
20
  export interface ForkConversationMemoryInput {
@@ -92,13 +93,14 @@ export function forkConversationMemory(
92
93
  // compaction boundary are not rendered and must stay re-injectable.
93
94
  // The v2 and v3 layers persist under separate metadata keys with the
94
95
  // same `# memory/concepts/<slug>.md` header convention, so each seeds
95
- // its own dedup record from its own blocks.
96
+ // its own dedup record from its own blocks: v2 at page grain, v3 at
97
+ // section grain (the store scans the section headers itself).
96
98
  const visibleStartIndex = Math.min(
97
99
  inheritedCompactedMessageCount,
98
100
  messagesToCopy.length,
99
101
  );
100
102
  const inheritedSlugs = new Set<string>();
101
- const inheritedV3Slugs = new Set<string>();
103
+ const inheritedV3Blocks: InjectedBlock[] = [];
102
104
  for (const message of messagesToCopy.slice(visibleStartIndex)) {
103
105
  const block = readInjectedBlock(message.metadata, "memoryInjectedBlock");
104
106
  if (block) {
@@ -106,21 +108,19 @@ export function forkConversationMemory(
106
108
  inheritedSlugs.add(slug);
107
109
  }
108
110
  }
109
- const v3Block = readInjectedBlock(
110
- message.metadata,
111
- MEMORY_V3_INJECTED_BLOCK_METADATA_KEY,
112
- );
111
+ // Each inherited block carries the format its row's metadata records
112
+ // (the copied metadata keeps the persisting build's stamp): the seeder
113
+ // scans the current ones and skips the legacy ones, which seed nothing.
114
+ const v3Block = persistedV3Block(message.metadata);
113
115
  if (v3Block) {
114
- for (const slug of extractInjectedConceptSlugs(v3Block)) {
115
- inheritedV3Slugs.add(slug);
116
- }
116
+ inheritedV3Blocks.push(v3Block);
117
117
  }
118
118
  }
119
119
  seedForkActivationState(forkId, [...inheritedSlugs]);
120
- seedEverInjectedFromSlugs(
120
+ seedEverInjectedFromBlocks(
121
121
  sourceConversationId,
122
122
  forkId,
123
- [...inheritedV3Slugs],
123
+ inheritedV3Blocks,
124
124
  Date.now(),
125
125
  );
126
126
  }