@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
@@ -0,0 +1,318 @@
1
+ import { readFileSync } from "node:fs";
2
+ import { dirname, join, relative, resolve, sep } from "node:path";
3
+ import { describe, expect, test } from "bun:test";
4
+
5
+ import { Glob } from "bun";
6
+
7
+ /**
8
+ * Reverse guard for the plugin import boundary. The forward guard
9
+ * (plugin-import-boundary-guard.test.ts) ratchets what a plugin under
10
+ * `src/plugins/defaults/<plugin>/` may reach OUT to; this file ratchets the
11
+ * other direction: host code reaching INTO a plugin's internals.
12
+ *
13
+ * Encapsulation is bidirectional. A host file that imports from
14
+ * `plugins/defaults/<plugin>/` couples the host to that plugin's
15
+ * implementation — the plugin can no longer be disabled, replaced, or
16
+ * supplied by a third party without host changes. Plugins are meant to be
17
+ * reachable only through their registered contributions (hooks, tools,
18
+ * routes, injectors, job handlers), so this baseline ratchets toward empty.
19
+ *
20
+ * Out of scope:
21
+ * - `src/plugins/defaults/index.ts` — the bundled-plugin registration
22
+ * barrel. Bundled defaults are compiled into the daemon, so the barrel is
23
+ * their loading mechanism: the in-process analog of loading an external
24
+ * plugin from its manifest.
25
+ * - Imports of modules directly under `defaults/` (e.g.
26
+ * `injector-order.js`) — those are host-level shared modules, not plugin
27
+ * internals.
28
+ * - Test files (`*.test.ts`, `__tests__/`) — the boundary guarded here is
29
+ * the shipped host runtime; test fixtures legitimately reference plugin
30
+ * paths.
31
+ *
32
+ * Baseline granularity is the IMPORTING FILE, not the imported specifier:
33
+ * entries stay stable while a plugin refactors internally, and new coupling
34
+ * almost always arrives as a new host file. The failure message prints the
35
+ * offending specifiers for context.
36
+ *
37
+ * The scan sees string-literal module references only: `import`/`export from`
38
+ * clauses, `import()`/`require()`/`import.meta.resolve()` calls, bare
39
+ * side-effect imports, and `new URL("...", import.meta.url)` process/worker
40
+ * entry points. A reference built from a non-literal string is invisible to
41
+ * it.
42
+ *
43
+ * Tests run from `assistant/`, so paths are resolved against `process.cwd()`.
44
+ */
45
+
46
+ /** `assistant/src/plugins/defaults`, relative to the `assistant/` cwd. */
47
+ const DEFAULTS_REL = join("src", "plugins", "defaults");
48
+ const DEFAULTS_ABS = join(process.cwd(), DEFAULTS_REL);
49
+
50
+ /** The bundled-plugin registration barrel — the sanctioned host→plugin edge. */
51
+ const COMPOSITION_ROOT = join(DEFAULTS_REL, "index.ts");
52
+
53
+ /**
54
+ * Allowed host→plugin reaches: plugin name → sorted list of host files (paths
55
+ * relative to `assistant/`) that import that plugin's internals.
56
+ *
57
+ * Regenerate after an intentional change with:
58
+ * UPDATE_HOST_PLUGIN_IMPORT_BASELINE=1 bun test src/__tests__/plugin-import-boundary-reverse-guard.test.ts
59
+ * and paste the printed object here. A new entry needs a justification in
60
+ * your PR: prefer routing the dependency through a registered contribution or
61
+ * `@vellumai/plugin-api` instead of adding one.
62
+ */
63
+ const BASELINE: Record<string, readonly string[]> = {
64
+ compaction: [
65
+ "src/agent/loop.ts",
66
+ "src/daemon/conversation-agent-loop-handlers.ts",
67
+ "src/daemon/conversation-history.ts",
68
+ "src/daemon/conversation-lifecycle.ts",
69
+ "src/daemon/conversation-media-retry.ts",
70
+ "src/daemon/conversation-process.ts",
71
+ "src/daemon/conversation-runtime-assembly.ts",
72
+ "src/daemon/conversation.ts",
73
+ ],
74
+ "history-repair": [
75
+ "src/daemon/conversation-error.ts",
76
+ "src/daemon/conversation.ts",
77
+ ],
78
+ "image-recovery": ["src/daemon/conversation-error.ts"],
79
+ memory: [
80
+ "src/cli/commands/memory/memory-retrospective.ts",
81
+ "src/cli/commands/memory/memory-v2-compare-render.ts",
82
+ "src/cli/commands/memory/memory-v2.ts",
83
+ "src/cli/commands/memory/memory-v3.ts",
84
+ "src/cli/commands/memory/nodes.ts",
85
+ "src/config/bundled-skills/messaging/tools/messaging-analyze-style.ts",
86
+ "src/config/bundled-skills/playbooks/tools/playbook-create.ts",
87
+ "src/config/bundled-skills/playbooks/tools/playbook-delete.ts",
88
+ "src/config/bundled-skills/playbooks/tools/playbook-update.ts",
89
+ "src/context/strip-injections.ts",
90
+ "src/daemon/conversation-agent-loop-handlers.ts",
91
+ "src/daemon/conversation-agent-loop.ts",
92
+ "src/daemon/conversation-lifecycle.ts",
93
+ "src/daemon/conversation-runtime-assembly.ts",
94
+ "src/daemon/conversation-surfaces.ts",
95
+ "src/daemon/conversation-turn-finalize.ts",
96
+ "src/daemon/conversation.ts",
97
+ "src/daemon/embedding-reconcile.ts",
98
+ "src/daemon/handlers/skills.ts",
99
+ "src/daemon/skill-memory-refresh.ts",
100
+ "src/daemon/tool-side-effects.ts",
101
+ "src/daemon/trust-context.ts",
102
+ "src/home/feed-source-enrichment.ts",
103
+ "src/permissions/checker.ts",
104
+ "src/persistence/conversation-crud.ts",
105
+ "src/persistence/steps.ts",
106
+ "src/persistence/worker-control.ts",
107
+ "src/plugins/types.ts",
108
+ "src/prompts/system-prompt.ts",
109
+ "src/runtime/routes/consolidation-routes.ts",
110
+ "src/runtime/routes/conversation-query-routes.ts",
111
+ "src/runtime/routes/conversation-routes.ts",
112
+ "src/runtime/routes/conversations-import-routes.ts",
113
+ "src/runtime/routes/filing-routes.ts",
114
+ "src/runtime/routes/global-search-routes.ts",
115
+ "src/runtime/routes/index.ts",
116
+ "src/runtime/routes/retrospective-routes.ts",
117
+ "src/runtime/routes/secret-routes.ts",
118
+ "src/schedule/scheduler.ts",
119
+ "src/skills/managed-store.ts",
120
+ "src/skills/uninstall.ts",
121
+ "src/tasks/task-runner.ts",
122
+ "src/tools/filesystem/write.ts",
123
+ "src/tools/skills/find-similar-skills.ts",
124
+ "src/tools/skills/scaffold-managed.ts",
125
+ "src/tools/tool-manifest.ts",
126
+ "src/workflows/leaf-runner.ts",
127
+ ],
128
+ "tool-result-truncate": ["src/context/tool-result-truncation.ts"],
129
+ };
130
+
131
+ function importSpecifierRegex(): RegExp {
132
+ return /(?:import|export)\b[^'"]*?from\s*['"]([^'"]+)['"]|(?:import\.meta\.resolve|import|require)\(\s*['"]([^'"]+)['"]\s*\)|^\s*import\s+['"]([^'"]+)['"]|new\s+URL\(\s*['"]([^'"]+)['"]\s*,\s*import\.meta\.url/gm;
133
+ }
134
+
135
+ interface HostFile {
136
+ /** Path relative to the `assistant/` cwd, for messages and the baseline. */
137
+ relPath: string;
138
+ /** Absolute path on disk. */
139
+ absPath: string;
140
+ source: string;
141
+ }
142
+
143
+ /**
144
+ * Production host files: everything under `src/` except plugin directories,
145
+ * the composition root, and tests.
146
+ */
147
+ function collectHostFiles(): HostFile[] {
148
+ const files: HostFile[] = [];
149
+ for (const ext of ["ts", "tsx"]) {
150
+ for (const rel of new Glob(`src/**/*.${ext}`).scanSync({
151
+ cwd: process.cwd(),
152
+ })) {
153
+ const norm = rel.split("/").join(sep);
154
+ if (norm.endsWith(".test.ts") || norm.endsWith(".test.tsx")) {
155
+ continue;
156
+ }
157
+ if (norm.split(sep).includes("__tests__")) {
158
+ continue;
159
+ }
160
+ if (norm === COMPOSITION_ROOT) {
161
+ continue;
162
+ }
163
+ // A file at least two segments below defaults/ belongs to a plugin —
164
+ // that side of the boundary is the forward guard's domain. Files
165
+ // directly under defaults/ (registry, shared host-level modules) are
166
+ // host code and stay in scope.
167
+ const underDefaults = relative(DEFAULTS_REL, norm);
168
+ if (
169
+ !underDefaults.startsWith("..") &&
170
+ underDefaults.split(sep).length >= 2
171
+ ) {
172
+ continue;
173
+ }
174
+ const absPath = join(process.cwd(), norm);
175
+ files.push({
176
+ relPath: norm,
177
+ absPath,
178
+ source: readFileSync(absPath, "utf-8"),
179
+ });
180
+ }
181
+ }
182
+ return files;
183
+ }
184
+
185
+ interface Reach {
186
+ /** Plugin directory name (first path segment under `defaults/`). */
187
+ plugin: string;
188
+ /** Importing host file, relative to the `assistant/` cwd. */
189
+ relPath: string;
190
+ specifier: string;
191
+ }
192
+
193
+ /** Every host import that resolves inside a plugin directory. */
194
+ function collectReaches(files: HostFile[]): Reach[] {
195
+ const reaches: Reach[] = [];
196
+ for (const file of files) {
197
+ const regex = importSpecifierRegex();
198
+ let match: RegExpExecArray | null;
199
+ while ((match = regex.exec(file.source)) !== null) {
200
+ const specifier = match[1] ?? match[2] ?? match[3] ?? match[4];
201
+ // Only relative specifiers can resolve into a plugin directory.
202
+ if (!specifier || !specifier.startsWith(".")) {
203
+ continue;
204
+ }
205
+ const resolved = resolve(dirname(file.absPath), specifier);
206
+ const underDefaults = relative(DEFAULTS_ABS, resolved);
207
+ if (underDefaults.startsWith("..") || underDefaults === "") {
208
+ continue;
209
+ }
210
+ const segments = underDefaults.split(sep);
211
+ // One segment = a host-level shared module directly under defaults/.
212
+ if (segments.length < 2) {
213
+ continue;
214
+ }
215
+ reaches.push({
216
+ plugin: segments[0]!,
217
+ relPath: file.relPath,
218
+ specifier,
219
+ });
220
+ }
221
+ }
222
+ return reaches;
223
+ }
224
+
225
+ /** Distinct importing host files per plugin, sorted — the ratchet's view. */
226
+ function reachesByPlugin(reaches: Reach[]): Map<string, string[]> {
227
+ const sets = new Map<string, Set<string>>();
228
+ for (const r of reaches) {
229
+ let set = sets.get(r.plugin);
230
+ if (!set) {
231
+ sets.set(r.plugin, (set = new Set()));
232
+ }
233
+ set.add(r.relPath);
234
+ }
235
+ return new Map(
236
+ [...sets].map(([plugin, set]) => [plugin, [...set].sort()] as const),
237
+ );
238
+ }
239
+
240
+ describe("plugin import boundary (reverse: host → plugin)", () => {
241
+ const files = collectHostFiles();
242
+ const reaches = collectReaches(files);
243
+ const byPlugin = reachesByPlugin(reaches);
244
+
245
+ test("no new host file imports a plugin's internals beyond the committed baseline", () => {
246
+ if (process.env.UPDATE_HOST_PLUGIN_IMPORT_BASELINE === "1") {
247
+ const regenerated: Record<string, string[]> = {};
248
+ for (const plugin of [...byPlugin.keys()].sort()) {
249
+ regenerated[plugin] = byPlugin.get(plugin)!;
250
+ }
251
+
252
+ console.log(
253
+ "Regenerated host→plugin import baseline — paste into BASELINE:\n" +
254
+ JSON.stringify(regenerated, null, 2),
255
+ );
256
+ }
257
+
258
+ const exampleSpecifiers = new Map<string, string[]>();
259
+ for (const r of reaches) {
260
+ const key = `${r.plugin} ${r.relPath}`;
261
+ const list = exampleSpecifiers.get(key) ?? [];
262
+ if (!list.includes(r.specifier)) {
263
+ list.push(r.specifier);
264
+ }
265
+ exampleSpecifiers.set(key, list);
266
+ }
267
+
268
+ const plugins = new Set([...byPlugin.keys(), ...Object.keys(BASELINE)]);
269
+ const added: string[] = [];
270
+ const stale: string[] = [];
271
+ for (const plugin of [...plugins].sort()) {
272
+ const found = new Set(byPlugin.get(plugin) ?? []);
273
+ const allowed = new Set(BASELINE[plugin] ?? []);
274
+ for (const relPath of [...found].sort()) {
275
+ if (!allowed.has(relPath)) {
276
+ const specs = exampleSpecifiers.get(`${plugin} ${relPath}`) ?? [];
277
+ added.push(
278
+ ` - ${plugin}: ${relPath} (imports ${specs.join(", ")})`,
279
+ );
280
+ }
281
+ }
282
+ for (const relPath of [...allowed].sort()) {
283
+ if (!found.has(relPath)) {
284
+ stale.push(` - ${plugin}: ${relPath}`);
285
+ }
286
+ }
287
+ }
288
+
289
+ const problems: string[] = [];
290
+ if (added.length > 0) {
291
+ problems.push(
292
+ "New host→plugin imports (host code reached into a plugin's",
293
+ "internals):",
294
+ ...added,
295
+ "",
296
+ "Host code must not depend on a specific plugin's implementation.",
297
+ "Route the dependency through a registered contribution (hook, tool,",
298
+ "route, injector, job handler) or `@vellumai/plugin-api`. If the",
299
+ "coupling is genuinely necessary, regenerate the baseline with",
300
+ "UPDATE_HOST_PLUGIN_IMPORT_BASELINE=1 and justify the new edge in",
301
+ "your PR.",
302
+ );
303
+ }
304
+ if (stale.length > 0) {
305
+ if (problems.length > 0) {
306
+ problems.push("");
307
+ }
308
+ problems.push(
309
+ "Stale baseline entries (no longer importing — tighten the baseline):",
310
+ ...stale,
311
+ "",
312
+ "Regenerate with UPDATE_HOST_PLUGIN_IMPORT_BASELINE=1 to drop them.",
313
+ );
314
+ }
315
+
316
+ expect(problems, problems.join("\n")).toEqual([]);
317
+ });
318
+ });
@@ -49,7 +49,6 @@ function makeContext(overrides?: Partial<ToolSetupContext>): ToolSetupContext {
49
49
  conversationId: "conv-test",
50
50
  workingDir: "/tmp/test-project",
51
51
  abortController: null,
52
- memoryPolicy: { scopeId: "default" },
53
52
  sendToClient: () => {},
54
53
  surfacesByAppId: new Map(),
55
54
  ...overrides,
@@ -167,7 +167,6 @@ describe("rebuildIndexJob", () => {
167
167
  stability: 14,
168
168
  reinforcementCount: 0,
169
169
  lastReinforced: now,
170
- scopeId: "default",
171
170
  },
172
171
  {
173
172
  id: "node-2",
@@ -183,7 +182,6 @@ describe("rebuildIndexJob", () => {
183
182
  stability: 14,
184
183
  reinforcementCount: 0,
185
184
  lastReinforced: now,
186
- scopeId: "default",
187
185
  },
188
186
  {
189
187
  id: "node-gone",
@@ -199,7 +197,6 @@ describe("rebuildIndexJob", () => {
199
197
  stability: 1,
200
198
  reinforcementCount: 0,
201
199
  lastReinforced: now,
202
- scopeId: "default",
203
200
  },
204
201
  ])
205
202
  .run();
@@ -240,7 +237,6 @@ describe("rebuildIndexJob", () => {
240
237
  stability: 14,
241
238
  reinforcementCount: 0,
242
239
  lastReinforced: now,
243
- scopeId: "default",
244
240
  })
245
241
  .run();
246
242
 
@@ -164,10 +164,6 @@ function makeCompletingConversation(): Conversation {
164
164
  processing = true;
165
165
  return { id: options.requestId ?? "msg-1", deduplicated: false };
166
166
  },
167
- memoryPolicy: {
168
- scopeId: "default",
169
- includeDefaultFallback: false,
170
- },
171
167
  setChannelCapabilities: () => {},
172
168
  setAssistantId: () => {},
173
169
  setTrustContext: () => {},
@@ -218,10 +214,6 @@ function makeHangingConversation(): Conversation {
218
214
  processing = true;
219
215
  return { id: options.requestId ?? "msg-1", deduplicated: false };
220
216
  },
221
- memoryPolicy: {
222
- scopeId: "default",
223
- includeDefaultFallback: false,
224
- },
225
217
  setChannelCapabilities: () => {},
226
218
  setAssistantId: () => {},
227
219
  setTrustContext: () => {},
@@ -300,10 +292,6 @@ function makePendingApprovalConversation(
300
292
  id: options.requestId ?? "msg-1",
301
293
  deduplicated: false,
302
294
  }),
303
- memoryPolicy: {
304
- scopeId: "default",
305
- includeDefaultFallback: false,
306
- },
307
295
  setChannelCapabilities: () => {},
308
296
  setAssistantId: () => {},
309
297
  trustContext: undefined as unknown,
@@ -68,7 +68,7 @@ describe("service-contracts import discipline", () => {
68
68
  [
69
69
  "grep",
70
70
  "-lE",
71
- 'from\\s+["\']@vellumai/ces-contracts|require\\s*\\(\\s*["\']@vellumai/ces-contracts',
71
+ "from\\s+[\"']@vellumai/ces-contracts|require\\s*\\(\\s*[\"']@vellumai/ces-contracts",
72
72
  "--",
73
73
  ":(glob)**/*.ts",
74
74
  ],
@@ -98,9 +98,7 @@ describe("service-contracts import discipline", () => {
98
98
  " @vellumai/service-contracts/credential-rpc",
99
99
  " @vellumai/service-contracts/trust-rules",
100
100
  " @vellumai/service-contracts/handles",
101
- " @vellumai/service-contracts/grants",
102
101
  " @vellumai/service-contracts/rpc",
103
- " @vellumai/service-contracts/rendering",
104
102
  " @vellumai/service-contracts/error",
105
103
  "",
106
104
  "Violations:",
@@ -123,8 +121,7 @@ describe("service-contracts import discipline", () => {
123
121
 
124
122
  // Match the aggregate root import: from "@vellumai/service-contracts" (with closing quote, no slash after)
125
123
  // This catches both single and double quote forms.
126
- const aggregateRootPattern =
127
- "from ['\"]@vellumai/service-contracts['\"]";
124
+ const aggregateRootPattern = "from ['\"]@vellumai/service-contracts['\"]";
128
125
 
129
126
  let grepOutput = "";
130
127
  try {
@@ -165,16 +162,14 @@ describe("service-contracts import discipline", () => {
165
162
  " @vellumai/service-contracts/credential-rpc",
166
163
  " @vellumai/service-contracts/trust-rules",
167
164
  " @vellumai/service-contracts/handles",
168
- " @vellumai/service-contracts/grants",
169
165
  " @vellumai/service-contracts/rpc",
170
- " @vellumai/service-contracts/rendering",
171
166
  " @vellumai/service-contracts/error",
172
167
  "",
173
168
  "Violations:",
174
169
  ...violations.map((f) => ` - ${f}`),
175
170
  "",
176
- "To fix: replace `from \"@vellumai/service-contracts\"` with the",
177
- "appropriate `from \"@vellumai/service-contracts/<subpath>\"` import.",
171
+ 'To fix: replace `from "@vellumai/service-contracts"` with the',
172
+ 'appropriate `from "@vellumai/service-contracts/<subpath>"` import.',
178
173
  "If this is an intentional exception, add it to AGGREGATE_ROOT_ALLOWLIST",
179
174
  "in service-contracts-import-guard.test.ts.",
180
175
  ].join("\n");
@@ -236,43 +236,6 @@ describe("SubagentManager fork spawn", () => {
236
236
  expect(resolvedSendResultToUser).toBeUndefined();
237
237
  });
238
238
 
239
- test("fork uses default memory scope, not isolated subagent scope", () => {
240
- // Validate the fork memory policy shape matches what spawn() produces.
241
- const isFork = true;
242
- const subagentId = "sub-fork-mem";
243
-
244
- const memoryPolicy = isFork
245
- ? {
246
- scopeId: "default",
247
- includeDefaultFallback: false,
248
- }
249
- : {
250
- scopeId: `subagent:${subagentId}`,
251
- includeDefaultFallback: true,
252
- };
253
-
254
- expect(memoryPolicy.scopeId).toBe("default");
255
- expect(memoryPolicy.includeDefaultFallback).toBe(false);
256
- });
257
-
258
- test("non-fork uses isolated subagent memory scope", () => {
259
- const isFork = false;
260
- const subagentId = "sub-normal-mem";
261
-
262
- const memoryPolicy = isFork
263
- ? {
264
- scopeId: "default",
265
- includeDefaultFallback: false,
266
- }
267
- : {
268
- scopeId: `subagent:${subagentId}`,
269
- includeDefaultFallback: true,
270
- };
271
-
272
- expect(memoryPolicy.scopeId).toBe(`subagent:${subagentId}`);
273
- expect(memoryPolicy.includeDefaultFallback).toBe(true);
274
- });
275
-
276
239
  test("fork defaults to general role (which has no tool allowlist)", async () => {
277
240
  const manager = new SubagentManager();
278
241
  const subagentId = "sub-fork-role";
@@ -156,7 +156,6 @@ describe("invalidateAssistantInferredItemsForConversation", () => {
156
156
  sourceType: "inferred",
157
157
  narrativeRole: null,
158
158
  partOfStory: null,
159
- scopeId: "default",
160
159
  },
161
160
  {
162
161
  id: "item-user-reported",
@@ -176,7 +175,6 @@ describe("invalidateAssistantInferredItemsForConversation", () => {
176
175
  sourceType: "direct",
177
176
  narrativeRole: null,
178
177
  partOfStory: null,
179
- scopeId: "default",
180
178
  },
181
179
  {
182
180
  id: "item-other-conv",
@@ -196,7 +194,6 @@ describe("invalidateAssistantInferredItemsForConversation", () => {
196
194
  sourceType: "inferred",
197
195
  narrativeRole: null,
198
196
  partOfStory: null,
199
- scopeId: "default",
200
197
  },
201
198
  {
202
199
  id: "item-already-gone",
@@ -216,7 +213,6 @@ describe("invalidateAssistantInferredItemsForConversation", () => {
216
213
  sourceType: "inferred",
217
214
  narrativeRole: null,
218
215
  partOfStory: null,
219
- scopeId: "default",
220
216
  },
221
217
  ])
222
218
  .run();
@@ -288,7 +284,6 @@ describe("invalidateAssistantInferredItemsForConversation", () => {
288
284
  sourceType: "inferred",
289
285
  narrativeRole: null,
290
286
  partOfStory: null,
291
- scopeId: "default",
292
287
  })
293
288
  .run();
294
289
 
@@ -433,7 +428,6 @@ describe("invalidateAssistantInferredItemsForConversation", () => {
433
428
  sourceType: "inferred",
434
429
  narrativeRole: null,
435
430
  partOfStory: null,
436
- scopeId: "default",
437
431
  })
438
432
  .run();
439
433
 
@@ -545,7 +539,6 @@ describe("invalidateAssistantInferredItemsForConversation", () => {
545
539
  sourceType: "inferred",
546
540
  narrativeRole: null,
547
541
  partOfStory: null,
548
- scopeId: "default",
549
542
  })
550
543
  .run();
551
544
 
@@ -650,7 +643,6 @@ describe("invalidateAssistantInferredItemsForConversation", () => {
650
643
  sourceType: "inferred",
651
644
  narrativeRole: null,
652
645
  partOfStory: null,
653
- scopeId: "default",
654
646
  })
655
647
  .run();
656
648
 
@@ -752,16 +744,13 @@ describe("invalidateAssistantInferredItemsForConversation", () => {
752
744
  // Enqueue graph_extract jobs for the target conversation
753
745
  enqueueMemoryJob("graph_extract", {
754
746
  conversationId: convId,
755
- scopeId: "default",
756
747
  });
757
748
  enqueueMemoryJob("graph_extract", {
758
749
  conversationId: convId,
759
- scopeId: "default",
760
750
  });
761
751
  // Enqueue a graph_extract job for a different conversation
762
752
  enqueueMemoryJob("graph_extract", {
763
753
  conversationId: otherConvId,
764
- scopeId: "default",
765
754
  });
766
755
 
767
756
  // Verify all jobs are pending
@@ -139,7 +139,6 @@ function createMockSession(opts?: {
139
139
 
140
140
  const session = {
141
141
  isProcessing: () => false,
142
- memoryPolicy: {},
143
142
  setAssistantId: () => {},
144
143
  setTrustContext: () => {},
145
144
  setCommandIntent: () => {},