@bevel-software/platform-core-backend 0.11.1 → 0.11.2

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 (312) hide show
  1. package/dist/core/create-core-services.d.ts +1 -1
  2. package/dist/core/create-core-services.d.ts.map +1 -1
  3. package/dist/core/create-core-services.js +2 -2
  4. package/dist/core/create-core-services.js.map +1 -1
  5. package/dist/modules/access/access-control.service.d.ts +1 -253
  6. package/dist/modules/access/access-control.service.d.ts.map +1 -1
  7. package/dist/modules/access/access-control.service.js +3 -632
  8. package/dist/modules/access/access-control.service.js.map +1 -1
  9. package/dist/modules/access/access-declarations.d.ts +2 -2
  10. package/dist/modules/access/access-declarations.d.ts.map +1 -1
  11. package/dist/modules/access/access-declarations.js +2 -2
  12. package/dist/modules/access/access-declarations.js.map +1 -1
  13. package/dist/modules/access/access-mutation.service.d.ts +3 -3
  14. package/dist/modules/access/access-mutation.service.d.ts.map +1 -1
  15. package/dist/modules/access/access-mutation.service.js +3 -3
  16. package/dist/modules/access/access-mutation.service.js.map +1 -1
  17. package/dist/modules/access/access.routes.js +4 -4
  18. package/dist/modules/access/access.routes.js.map +1 -1
  19. package/dist/modules/access/admin-locked-commit.d.ts +2 -2
  20. package/dist/modules/access/admin-locked-commit.d.ts.map +1 -1
  21. package/dist/modules/access/admin-locked-commit.js +2 -2
  22. package/dist/modules/access/admin-locked-commit.js.map +1 -1
  23. package/dist/modules/access/admin-route-helpers.js +1 -1
  24. package/dist/modules/access/admin-route-helpers.js.map +1 -1
  25. package/dist/modules/access/capability-registry.js +1 -1
  26. package/dist/modules/access/capability-registry.js.map +1 -1
  27. package/dist/modules/access/creator-access.d.ts +1 -45
  28. package/dist/modules/access/creator-access.d.ts.map +1 -1
  29. package/dist/modules/access/creator-access.js +4 -24
  30. package/dist/modules/access/creator-access.js.map +1 -1
  31. package/dist/modules/access/groups-admin.routes.js +1 -1
  32. package/dist/modules/access/groups-admin.routes.js.map +1 -1
  33. package/dist/modules/access/groups-admin.service.d.ts +1 -1
  34. package/dist/modules/access/groups-admin.service.d.ts.map +1 -1
  35. package/dist/modules/access/groups-admin.service.js +6 -5
  36. package/dist/modules/access/groups-admin.service.js.map +1 -1
  37. package/dist/modules/access/groups-edit.js +2 -2
  38. package/dist/modules/access/groups-edit.js.map +1 -1
  39. package/dist/modules/access/reference-scan.js +1 -1
  40. package/dist/modules/access/reference-scan.js.map +1 -1
  41. package/dist/modules/access/roles-admin.service.d.ts +1 -1
  42. package/dist/modules/access/roles-admin.service.d.ts.map +1 -1
  43. package/dist/modules/access/roles-admin.service.js +8 -7
  44. package/dist/modules/access/roles-admin.service.js.map +1 -1
  45. package/dist/modules/access/roles-edit.js +1 -1
  46. package/dist/modules/access/roles-edit.js.map +1 -1
  47. package/dist/modules/access/synced-groups-committer.js +4 -4
  48. package/dist/modules/access/synced-groups-committer.js.map +1 -1
  49. package/dist/modules/access/synced-groups-writer.js +2 -2
  50. package/dist/modules/access/synced-groups-writer.js.map +1 -1
  51. package/dist/modules/access-model/access-errors.d.ts +34 -0
  52. package/dist/modules/access-model/access-errors.d.ts.map +1 -0
  53. package/dist/modules/access-model/access-errors.js +40 -0
  54. package/dist/modules/access-model/access-errors.js.map +1 -0
  55. package/dist/modules/access-model/access-grammar.d.ts +266 -0
  56. package/dist/modules/access-model/access-grammar.d.ts.map +1 -0
  57. package/dist/modules/access-model/access-grammar.js +644 -0
  58. package/dist/modules/access-model/access-grammar.js.map +1 -0
  59. package/dist/modules/access-model/access-splice.d.ts +140 -0
  60. package/dist/modules/access-model/access-splice.d.ts.map +1 -0
  61. package/dist/modules/access-model/access-splice.js +389 -0
  62. package/dist/modules/access-model/access-splice.js.map +1 -0
  63. package/dist/modules/access-model/creator.d.ts +54 -0
  64. package/dist/modules/access-model/creator.d.ts.map +1 -0
  65. package/dist/modules/access-model/creator.js +30 -0
  66. package/dist/modules/access-model/creator.js.map +1 -0
  67. package/dist/modules/access-model/group-files.d.ts +83 -0
  68. package/dist/modules/access-model/group-files.d.ts.map +1 -0
  69. package/dist/modules/access-model/group-files.js +167 -0
  70. package/dist/modules/access-model/group-files.js.map +1 -0
  71. package/dist/modules/access-model/kb-read-filter.d.ts +41 -0
  72. package/dist/modules/access-model/kb-read-filter.d.ts.map +1 -0
  73. package/dist/modules/access-model/kb-read-filter.js +60 -0
  74. package/dist/modules/access-model/kb-read-filter.js.map +1 -0
  75. package/dist/modules/access-model/render-roles-yaml.d.ts +22 -0
  76. package/dist/modules/access-model/render-roles-yaml.d.ts.map +1 -0
  77. package/dist/modules/access-model/render-roles-yaml.js +56 -0
  78. package/dist/modules/access-model/render-roles-yaml.js.map +1 -0
  79. package/dist/modules/access-model/roles-yaml-guard.d.ts +56 -0
  80. package/dist/modules/access-model/roles-yaml-guard.d.ts.map +1 -0
  81. package/dist/modules/access-model/roles-yaml-guard.js +79 -0
  82. package/dist/modules/access-model/roles-yaml-guard.js.map +1 -0
  83. package/dist/modules/admin/admin-access.service.d.ts.map +1 -1
  84. package/dist/modules/admin/admin-access.service.js +1 -1
  85. package/dist/modules/admin/admin-access.service.js.map +1 -1
  86. package/dist/modules/diff/diff.routes.js +4 -4
  87. package/dist/modules/diff/diff.routes.js.map +1 -1
  88. package/dist/modules/diff/diff.service.d.ts +1 -1
  89. package/dist/modules/diff/diff.service.d.ts.map +1 -1
  90. package/dist/modules/kb-fs/branch-name.d.ts +10 -0
  91. package/dist/modules/kb-fs/branch-name.d.ts.map +1 -0
  92. package/dist/modules/kb-fs/branch-name.js +76 -0
  93. package/dist/modules/kb-fs/branch-name.js.map +1 -0
  94. package/dist/modules/kb-fs/clone-config.d.ts +61 -0
  95. package/dist/modules/kb-fs/clone-config.d.ts.map +1 -0
  96. package/dist/modules/kb-fs/clone-config.js +69 -0
  97. package/dist/modules/kb-fs/clone-config.js.map +1 -0
  98. package/dist/modules/kb-fs/file-change-notifier.d.ts +38 -0
  99. package/dist/modules/kb-fs/file-change-notifier.d.ts.map +1 -0
  100. package/dist/modules/kb-fs/file-change-notifier.js +22 -0
  101. package/dist/modules/kb-fs/file-change-notifier.js.map +1 -0
  102. package/dist/modules/kb-fs/locking-filesystem.d.ts +137 -0
  103. package/dist/modules/kb-fs/locking-filesystem.d.ts.map +1 -0
  104. package/dist/modules/kb-fs/locking-filesystem.js +553 -0
  105. package/dist/modules/kb-fs/locking-filesystem.js.map +1 -0
  106. package/dist/modules/kb-fs/mutex.d.ts +11 -0
  107. package/dist/modules/kb-fs/mutex.d.ts.map +1 -0
  108. package/dist/modules/kb-fs/mutex.js +23 -0
  109. package/dist/modules/kb-fs/mutex.js.map +1 -0
  110. package/dist/modules/kb-fs/read-only-filesystem.d.ts +24 -0
  111. package/dist/modules/kb-fs/read-only-filesystem.d.ts.map +1 -0
  112. package/dist/modules/kb-fs/read-only-filesystem.js +39 -0
  113. package/dist/modules/kb-fs/read-only-filesystem.js.map +1 -0
  114. package/dist/modules/plugins/join-proposals.d.ts +1 -1
  115. package/dist/modules/plugins/join-proposals.d.ts.map +1 -1
  116. package/dist/modules/plugins/join-proposals.js +1 -1
  117. package/dist/modules/plugins/join-proposals.js.map +1 -1
  118. package/dist/modules/plugins/join-requests.service.d.ts.map +1 -1
  119. package/dist/modules/plugins/join-requests.service.js +1 -1
  120. package/dist/modules/plugins/join-requests.service.js.map +1 -1
  121. package/dist/modules/plugins/plugin-provision.service.js +3 -3
  122. package/dist/modules/plugins/plugin-provision.service.js.map +1 -1
  123. package/dist/modules/plugins/plugins.routes.js +2 -2
  124. package/dist/modules/plugins/plugins.routes.js.map +1 -1
  125. package/dist/modules/plugins/plugins.service.js +1 -1
  126. package/dist/modules/plugins/plugins.service.js.map +1 -1
  127. package/dist/modules/secrets-vault/secrets-vault.routes.js +1 -1
  128. package/dist/modules/secrets-vault/secrets-vault.routes.js.map +1 -1
  129. package/dist/modules/skills/pending-skills.service.d.ts.map +1 -1
  130. package/dist/modules/skills/pending-skills.service.js +1 -1
  131. package/dist/modules/skills/pending-skills.service.js.map +1 -1
  132. package/dist/modules/skills/skills.service.js +1 -1
  133. package/dist/modules/skills/skills.service.js.map +1 -1
  134. package/dist/modules/tool-helpers/tool-context.d.ts +2 -2
  135. package/dist/modules/tool-helpers/tool-context.d.ts.map +1 -1
  136. package/dist/modules/tool-helpers/tool-context.js +4 -4
  137. package/dist/modules/tool-helpers/tool-context.js.map +1 -1
  138. package/dist/modules/tool-manuals/mcp-server-edit.service.d.ts +1 -1
  139. package/dist/modules/tool-manuals/mcp-server-edit.service.d.ts.map +1 -1
  140. package/dist/modules/tool-manuals/mcp-server-edit.service.js +1 -1
  141. package/dist/modules/tool-manuals/mcp-server-edit.service.js.map +1 -1
  142. package/dist/modules/tool-manuals/tool-manuals.routes.d.ts +1 -1
  143. package/dist/modules/tool-manuals/tool-manuals.routes.d.ts.map +1 -1
  144. package/dist/modules/tool-manuals/tool-manuals.routes.js +1 -1
  145. package/dist/modules/tool-manuals/tool-manuals.routes.js.map +1 -1
  146. package/dist/modules/tool-manuals/tool-manuals.service.js +1 -1
  147. package/dist/modules/tool-manuals/tool-manuals.service.js.map +1 -1
  148. package/dist/modules/tool-manuals/tool-manuals.tools.js +1 -1
  149. package/dist/modules/tool-manuals/tool-manuals.tools.js.map +1 -1
  150. package/dist/modules/workflow/agent-tools/workflow.tools.js +1 -1
  151. package/dist/modules/workflow/agent-tools/workflow.tools.js.map +1 -1
  152. package/dist/modules/workflow/file-lock.service.js +1 -1
  153. package/dist/modules/workflow/file-lock.service.js.map +1 -1
  154. package/dist/modules/workflow/git/git.service.d.ts +2 -2
  155. package/dist/modules/workflow/git/git.service.d.ts.map +1 -1
  156. package/dist/modules/workflow/git/git.service.js +5 -5
  157. package/dist/modules/workflow/git/git.service.js.map +1 -1
  158. package/dist/modules/workflow/git/pull-request.service.js +1 -1
  159. package/dist/modules/workflow/git/pull-request.service.js.map +1 -1
  160. package/dist/modules/workflow/review-workflow/review-workflow.service.js +2 -2
  161. package/dist/modules/workflow/review-workflow/review-workflow.service.js.map +1 -1
  162. package/dist/modules/workflow/session-ontology.service.js +1 -1
  163. package/dist/modules/workflow/session-ontology.service.js.map +1 -1
  164. package/dist/modules/workflow/workflow.routes.js +2 -2
  165. package/dist/modules/workflow/workflow.routes.js.map +1 -1
  166. package/dist/modules/workflow/workflow.service.d.ts +1 -1
  167. package/dist/modules/workflow/workflow.service.d.ts.map +1 -1
  168. package/dist/modules/workflow/workflow.service.js +4 -4
  169. package/dist/modules/workflow/workflow.service.js.map +1 -1
  170. package/dist/modules/workspace/startup/kb-startup-runner.js +1 -1
  171. package/dist/modules/workspace/startup/kb-startup-runner.js.map +1 -1
  172. package/dist/modules/workspace/startup/steps/groups-to-plugins.step.js +1 -1
  173. package/dist/modules/workspace/startup/steps/groups-to-plugins.step.js.map +1 -1
  174. package/dist/modules/workspace/startup/steps/roles-yaml.step.d.ts +1 -1
  175. package/dist/modules/workspace/startup/steps/roles-yaml.step.js +2 -2
  176. package/dist/modules/workspace/startup/steps/roles-yaml.step.js.map +1 -1
  177. package/dist/modules/workspace/startup/steps/seed-tree.js +1 -1
  178. package/dist/modules/workspace/startup/steps/seed-tree.js.map +1 -1
  179. package/dist/modules/workspace/workspace.routes.d.ts +1 -1
  180. package/dist/modules/workspace/workspace.routes.d.ts.map +1 -1
  181. package/dist/modules/workspace/workspace.routes.js +5 -4
  182. package/dist/modules/workspace/workspace.routes.js.map +1 -1
  183. package/dist/modules/workspace/workspace.service.d.ts +2 -9
  184. package/dist/modules/workspace/workspace.service.d.ts.map +1 -1
  185. package/dist/modules/workspace/workspace.service.js +14 -15
  186. package/dist/modules/workspace/workspace.service.js.map +1 -1
  187. package/dist/modules/workspace/workspace.tools.js +3 -3
  188. package/dist/modules/workspace/workspace.tools.js.map +1 -1
  189. package/dist/shared/domain-errors.d.ts +202 -0
  190. package/dist/shared/domain-errors.d.ts.map +1 -0
  191. package/dist/shared/domain-errors.js +303 -0
  192. package/dist/shared/domain-errors.js.map +1 -0
  193. package/dist/shared/workspace-id.d.ts +27 -0
  194. package/dist/shared/workspace-id.d.ts.map +1 -0
  195. package/dist/shared/workspace-id.js +36 -0
  196. package/dist/shared/workspace-id.js.map +1 -0
  197. package/package.json +3 -3
  198. package/src/core/create-core-services.ts +2 -2
  199. package/src/modules/access/__tests__/access-control.service.test.ts +1 -1
  200. package/src/modules/access/__tests__/access-groups.test.ts +6 -5
  201. package/src/modules/access/__tests__/access-md-format.test.ts +3 -3
  202. package/src/modules/access/__tests__/access-mutation.service.test.ts +1 -1
  203. package/src/modules/access/__tests__/admin-locked-commit.test.ts +1 -1
  204. package/src/modules/access/__tests__/admin-route-helpers.test.ts +1 -1
  205. package/src/modules/access/__tests__/roles-admin.service.test.ts +2 -2
  206. package/src/modules/access/__tests__/roles-edit.test.ts +1 -1
  207. package/src/modules/access/__tests__/synced-groups-committer.test.ts +1 -1
  208. package/src/modules/access/__tests__/synced-groups-writer.test.ts +1 -1
  209. package/src/modules/access/access-control.service.ts +23 -768
  210. package/src/modules/access/access-declarations.ts +2 -2
  211. package/src/modules/access/access-mutation.service.ts +3 -3
  212. package/src/modules/access/access.routes.ts +5 -5
  213. package/src/modules/access/admin-locked-commit.ts +2 -2
  214. package/src/modules/access/admin-route-helpers.ts +1 -1
  215. package/src/modules/access/capability-registry.ts +1 -1
  216. package/src/modules/access/creator-access.ts +9 -72
  217. package/src/modules/access/groups-admin.routes.ts +1 -1
  218. package/src/modules/access/groups-admin.service.ts +6 -7
  219. package/src/modules/access/groups-edit.ts +2 -2
  220. package/src/modules/access/reference-scan.ts +1 -1
  221. package/src/modules/access/roles-admin.service.ts +8 -8
  222. package/src/modules/access/roles-edit.ts +1 -1
  223. package/src/modules/access/synced-groups-committer.ts +4 -4
  224. package/src/modules/access/synced-groups-writer.ts +2 -2
  225. package/src/modules/access-model/__tests__/access-grammar.test.ts +31 -0
  226. package/src/modules/{access → access-model}/__tests__/access-splice.test.ts +268 -268
  227. package/src/modules/{access → access-model}/access-errors.ts +1 -1
  228. package/src/modules/access-model/access-grammar.ts +778 -0
  229. package/src/modules/{access → access-model}/access-splice.ts +1 -1
  230. package/src/modules/access-model/creator.ts +79 -0
  231. package/src/modules/{access → access-model}/group-files.ts +1 -1
  232. package/src/modules/{access → access-model}/render-roles-yaml.ts +1 -1
  233. package/src/modules/{access → access-model}/roles-yaml-guard.ts +2 -2
  234. package/src/modules/admin/admin-access.service.ts +2 -1
  235. package/src/modules/diff/__tests__/diff.routes.rejectPathsLocked.test.ts +2 -2
  236. package/src/modules/diff/__tests__/diff.service.seed-atomicity.test.ts +3 -2
  237. package/src/modules/diff/__tests__/diff.service.test.ts +3 -2
  238. package/src/modules/diff/diff.routes.ts +4 -4
  239. package/src/modules/diff/diff.service.ts +1 -1
  240. package/src/modules/{workflow/git → kb-fs}/__tests__/branch-name.test.ts +1 -1
  241. package/src/modules/{workflow → kb-fs}/__tests__/locking-filesystem.test.ts +1 -1
  242. package/src/modules/{workflow/git → kb-fs}/branch-name.ts +1 -1
  243. package/src/modules/{workflow → kb-fs}/locking-filesystem.ts +2 -2
  244. package/src/modules/plugins/__tests__/join-requests.service.test.ts +2 -4
  245. package/src/modules/plugins/__tests__/plugin-index.service.test.ts +1 -1
  246. package/src/modules/plugins/__tests__/plugins.routes.test.ts +1 -1
  247. package/src/modules/plugins/join-proposals.ts +1 -1
  248. package/src/modules/plugins/join-requests.service.ts +2 -1
  249. package/src/modules/plugins/plugin-provision.service.ts +3 -3
  250. package/src/modules/plugins/plugins.routes.ts +2 -2
  251. package/src/modules/plugins/plugins.service.ts +1 -1
  252. package/src/modules/secrets-vault/secrets-vault.routes.ts +1 -1
  253. package/src/modules/skills/__tests__/skills.service.test.ts +1 -1
  254. package/src/modules/skills/pending-skills.service.ts +2 -1
  255. package/src/modules/skills/skills.service.ts +1 -1
  256. package/src/modules/tool-helpers/tool-context.ts +6 -5
  257. package/src/modules/tool-manuals/__tests__/mcp-server-edit.service.test.ts +1 -1
  258. package/src/modules/tool-manuals/__tests__/tool-manuals.archive.route.test.ts +1 -1
  259. package/src/modules/tool-manuals/__tests__/tool-manuals.detail.route.test.ts +1 -1
  260. package/src/modules/tool-manuals/__tests__/tool-manuals.mcp-oauth.test.ts +1 -1
  261. package/src/modules/tool-manuals/__tests__/tool-manuals.service.test.ts +1 -1
  262. package/src/modules/tool-manuals/mcp-server-edit.service.ts +2 -1
  263. package/src/modules/tool-manuals/tool-manuals.routes.ts +2 -1
  264. package/src/modules/tool-manuals/tool-manuals.service.ts +1 -1
  265. package/src/modules/tool-manuals/tool-manuals.tools.ts +1 -1
  266. package/src/modules/workflow/__tests__/preserve-roles-yaml.test.ts +1 -1
  267. package/src/modules/workflow/__tests__/workflow.service.commitFileWhileLocked.test.ts +1 -1
  268. package/src/modules/workflow/__tests__/workflow.service.facade.test.ts +1 -1
  269. package/src/modules/workflow/__tests__/workflow.service.releaseLock.test.ts +1 -1
  270. package/src/modules/workflow/agent-tools/workflow.tools.ts +1 -1
  271. package/src/modules/workflow/file-lock.service.ts +1 -1
  272. package/src/modules/workflow/git/__tests__/git.service.accessGating.test.ts +1 -1
  273. package/src/modules/workflow/git/__tests__/git.service.deleteBranch.test.ts +1 -1
  274. package/src/modules/workflow/git/__tests__/git.service.diffFileAtCommit.test.ts +1 -1
  275. package/src/modules/workflow/git/__tests__/git.service.diffFileBetweenBranches.test.ts +1 -1
  276. package/src/modules/workflow/git/__tests__/git.service.pull.test.ts +1 -1
  277. package/src/modules/workflow/git/git.service.ts +5 -5
  278. package/src/modules/workflow/git/pull-request.service.ts +1 -1
  279. package/src/modules/workflow/review-workflow/__tests__/cancel-pr.test.ts +1 -1
  280. package/src/modules/workflow/review-workflow/review-workflow.service.ts +2 -2
  281. package/src/modules/workflow/session-ontology.service.ts +1 -1
  282. package/src/modules/workflow/workflow.routes.ts +2 -2
  283. package/src/modules/workflow/workflow.service.ts +5 -5
  284. package/src/modules/workspace/__tests__/workspace.routes.create-grant.test.ts +1 -1
  285. package/src/modules/workspace/__tests__/workspace.routes.delete.test.ts +1 -1
  286. package/src/modules/workspace/__tests__/workspace.routes.download.test.ts +2 -2
  287. package/src/modules/workspace/__tests__/workspace.routes.read-gate.test.ts +1 -1
  288. package/src/modules/workspace/__tests__/workspace.service.read-filter.test.ts +2 -5
  289. package/src/modules/workspace/__tests__/workspace.service.test.ts +13 -1
  290. package/src/modules/workspace/__tests__/workspace.tools.test.ts +1 -1
  291. package/src/modules/workspace/startup/kb-startup-runner.ts +1 -1
  292. package/src/modules/workspace/startup/steps/__tests__/steps.test.ts +1 -1
  293. package/src/modules/workspace/startup/steps/groups-to-plugins.step.ts +1 -1
  294. package/src/modules/workspace/startup/steps/roles-yaml.step.ts +2 -2
  295. package/src/modules/workspace/startup/steps/seed-tree.ts +1 -1
  296. package/src/modules/workspace/workspace.routes.ts +6 -5
  297. package/src/modules/workspace/workspace.service.ts +14 -18
  298. package/src/modules/workspace/workspace.tools.ts +3 -3
  299. package/src/shared/__tests__/join-request.test.ts +1 -1
  300. package/src/shared/__tests__/workspace-id.test.ts +17 -0
  301. package/src/{modules/workflow/workflow.errors.ts → shared/domain-errors.ts} +6 -1
  302. package/src/shared/workspace-id.ts +36 -0
  303. /package/src/modules/{access → access-model}/__tests__/kb-read-filter.test.ts +0 -0
  304. /package/src/modules/{access → access-model}/__tests__/roles-yaml-guard.test.ts +0 -0
  305. /package/src/modules/{access → access-model}/kb-read-filter.ts +0 -0
  306. /package/src/modules/{workflow/git → kb-fs}/__tests__/clone-config.test.ts +0 -0
  307. /package/src/modules/{workflow → kb-fs}/__tests__/file-change-notifier.test.ts +0 -0
  308. /package/src/modules/{workflow/git → kb-fs}/__tests__/mutex.test.ts +0 -0
  309. /package/src/modules/{workflow/git → kb-fs}/clone-config.ts +0 -0
  310. /package/src/modules/{workflow → kb-fs}/file-change-notifier.ts +0 -0
  311. /package/src/modules/{workflow/git → kb-fs}/mutex.ts +0 -0
  312. /package/src/modules/{workflow → kb-fs}/read-only-filesystem.ts +0 -0
@@ -33,7 +33,7 @@ import {
33
33
  canonicalEmail,
34
34
  canonicalRoleName,
35
35
  accessMdDeclaresBodyRules,
36
- } from './access-control.service.js';
36
+ } from './access-grammar.js';
37
37
 
38
38
  /**
39
39
  * Which rule block a mutation edits.
@@ -0,0 +1,79 @@
1
+ /**
2
+ * The pure half of the creator read-grant story: the creator identity, the
3
+ * grant-plan contract the creation surfaces consume, and the splice-safe
4
+ * principal for a creator. The service that DECIDES when a creation needs a
5
+ * grant (filesystem stats, access checks) is `modules/access/creator-access.ts`;
6
+ * this file carries only the types and pure helpers so downstream modules
7
+ * (kb-fs, plugins, tool-helpers) never need an edge into the access module.
8
+ */
9
+
10
+ import type { Principal } from './access-splice.js';
11
+
12
+ /**
13
+ * How a pending creation gets its creator read grant.
14
+ * - `seed-access-md`: merge the grant into `wsRelPath` (a new directory's
15
+ * own `access.md`, workspace-relative) — BEFORE or alongside the creation,
16
+ * via the caller's own lock+commit machinery. The caller MUST re-read the
17
+ * file's CURRENT text under its lock and write `apply(current)` ('' when
18
+ * absent), never a precomputed fresh file: two concurrent creators can
19
+ * both plan a seed for the same new directory, and a blind overwrite
20
+ * would silently revoke whichever grant landed first. Skip the write when
21
+ * `apply` returns the input unchanged, and call `noteAccessFileWritten`
22
+ * after a write so the resolver cache drops.
23
+ * - `frontmatter`: run the new file's content through `apply` before
24
+ * writing it, so the grant lands atomically inside the created file.
25
+ */
26
+ export type CreationGrantPlan =
27
+ | { kind: 'seed-access-md'; wsRelPath: string; apply: (current: string) => string }
28
+ | { kind: 'frontmatter'; apply: (content: string) => string };
29
+
30
+ /** The creator identity a grant is written for. */
31
+ export interface Creator {
32
+ name: string;
33
+ email: string;
34
+ }
35
+
36
+ /**
37
+ * Injection seam for the creation surfaces (routes, lock-aware filesystem,
38
+ * upload apply). Kept as an interface so callers depend on the contract, not
39
+ * the class.
40
+ */
41
+ export interface ICreatorAccess {
42
+ planForCreate(
43
+ workspaceId: string,
44
+ creator: Creator,
45
+ wsRelPath: string,
46
+ kind: 'file' | 'dir',
47
+ ): Promise<CreationGrantPlan | null>;
48
+
49
+ grantInExtractedFile(
50
+ workspaceId: string,
51
+ creator: Creator,
52
+ wsRelPath: string,
53
+ ): Promise<string | null>;
54
+
55
+ noteAccessFileWritten(workspaceId: string): void;
56
+ }
57
+
58
+ /**
59
+ * The splice-safe principal for a creator — exported because plugin
60
+ * provisioning (`PluginProvisionService`) writes the same `Name <email>`
61
+ * entries into the access.md files it seeds, and two spellings of the same
62
+ * person would read as two people.
63
+ */
64
+ export function creatorPrincipal(creator: Creator): Principal {
65
+ return { kind: 'user', email: creator.email, displayName: safeDisplayName(creator) };
66
+ }
67
+
68
+ /**
69
+ * `Name <email>`-safe display name: `validatePrincipal` rejects control
70
+ * chars, `<`, `>`, and `#`, so strip those from the user's name and fall
71
+ * back to the email local part (which the email regex already keeps free of
72
+ * `<>`/whitespace) when nothing usable remains.
73
+ */
74
+ function safeDisplayName(creator: Creator): string {
75
+ const strip = (s: string) =>
76
+ // eslint-disable-next-line no-control-regex -- same intentional control-char guard as access-splice
77
+ s.replace(/[<>#\u0000-\u001f\u007f]/g, ' ').replace(/\s+/g, ' ').trim();
78
+ return strip(creator.name) || strip(creator.email.split('@')[0] ?? '') || 'KB user';
79
+ }
@@ -6,7 +6,7 @@ import {
6
6
  canonicalEmail,
7
7
  canonicalRoleName,
8
8
  parseYamlSubset,
9
- } from './access-control.service.js';
9
+ } from './access-grammar.js';
10
10
 
11
11
  /**
12
12
  * Group files — the "who you are" half of the roles/groups split.
@@ -1,4 +1,4 @@
1
- import { parseRolesYaml } from './access-control.service.js';
1
+ import { parseRolesYaml } from './access-grammar.js';
2
2
 
3
3
  /**
4
4
  * Render a `roles.yaml` granting Admin to each email — the ONE renderer every
@@ -22,8 +22,8 @@
22
22
  */
23
23
 
24
24
  import type { FileContent } from '@mastra/core/workspace';
25
- import { parseRolesYaml } from './access-control.service.js';
26
- import { WorkflowDomainError } from '../workflow/workflow.errors.js';
25
+ import { parseRolesYaml } from './access-grammar.js';
26
+ import { WorkflowDomainError } from '../../shared/domain-errors.js';
27
27
 
28
28
  /** Repo-relative basename of the roles file (it lives at the KB repo root). */
29
29
  export const ROLES_YAML_BASENAME = 'roles.yaml';
@@ -1,5 +1,6 @@
1
1
  import type { IAccessControl } from '../access/access-control.interface.js';
2
- import { type WorkspaceService, workspaceIdForBranch } from '../workspace/workspace.service.js';
2
+ import { type WorkspaceService } from '../workspace/workspace.service.js';
3
+ import { workspaceIdForBranch } from '../../shared/workspace-id.js';
3
4
  import type { IAdminAccessService } from './admin.interface.js';
4
5
 
5
6
  /**
@@ -4,8 +4,8 @@ import path from 'node:path';
4
4
  import os from 'node:os';
5
5
  import type { AuthUser, IWorkflowService } from '@bevel-software/platform-shared';
6
6
  import type { IDiffService } from '../diff.interface.js';
7
- import { workspaceIdForBranch } from '../../workspace/workspace.service.js';
8
- import { WorkflowValidationError } from '../../workflow/workflow.errors.js';
7
+ import { workspaceIdForBranch } from '../../../shared/workspace-id.js';
8
+ import { WorkflowValidationError } from '../../../shared/domain-errors.js';
9
9
  import { rejectPathsLocked } from '../diff.routes.js';
10
10
 
11
11
  /**
@@ -2,8 +2,9 @@ import { describe, it, expect, beforeEach, afterEach, vi } from 'vitest';
2
2
  import fs from 'node:fs/promises';
3
3
  import path from 'node:path';
4
4
  import os from 'node:os';
5
- import { WorkspaceService, workspaceIdForBranch } from '../../workspace/workspace.service.js';
6
- import { WorkspaceMutex } from '../../workflow/git/mutex.js';
5
+ import { WorkspaceService } from '../../workspace/workspace.service.js';
6
+ import { workspaceIdForBranch } from '../../../shared/workspace-id.js';
7
+ import { WorkspaceMutex } from '../../kb-fs/mutex.js';
7
8
  import { DiffService } from '../diff.service.js';
8
9
 
9
10
  /**
@@ -2,8 +2,9 @@ import { describe, it, expect, beforeEach, afterEach } from 'vitest';
2
2
  import fs from 'node:fs/promises';
3
3
  import path from 'node:path';
4
4
  import os from 'node:os';
5
- import { WorkspaceService, workspaceIdForBranch } from '../../workspace/workspace.service.js';
6
- import { WorkspaceMutex } from '../../workflow/git/mutex.js';
5
+ import { WorkspaceService } from '../../workspace/workspace.service.js';
6
+ import { workspaceIdForBranch } from '../../../shared/workspace-id.js';
7
+ import { WorkspaceMutex } from '../../kb-fs/mutex.js';
7
8
  import { DiffService } from '../diff.service.js';
8
9
 
9
10
  async function mkTmpRoot(prefix: string): Promise<string> {
@@ -3,10 +3,10 @@ import type { AuthUser, IWorkflowService } from '@bevel-software/platform-shared
3
3
  import type { IDiffService } from './diff.interface.js';
4
4
  import type { AuthService } from '../auth/auth.service.js';
5
5
  import type { IAccessControl } from '../access/access-control.interface.js';
6
- import { toKbRelative, resolveReadableMap } from '../access/kb-read-filter.js';
7
- import { WorkflowDomainError, WorkflowValidationError } from '../workflow/workflow.errors.js';
8
- import { LockingFilesystem } from '../workflow/locking-filesystem.js';
9
- import { branchForWorkspaceId } from '../workspace/workspace.service.js';
6
+ import { toKbRelative, resolveReadableMap } from '../access-model/kb-read-filter.js';
7
+ import { WorkflowDomainError, WorkflowValidationError } from '../../shared/domain-errors.js';
8
+ import { LockingFilesystem } from '../kb-fs/locking-filesystem.js';
9
+ import { branchForWorkspaceId } from '../../shared/workspace-id.js';
10
10
  import '../auth/auth.middleware.js';
11
11
 
12
12
  function toHttpError(
@@ -3,7 +3,7 @@ import path from 'node:path';
3
3
  import type { FileDiffPayload, PendingChange, ReviewSession, ChangeKind } from '@bevel-software/platform-shared';
4
4
  import type { IDiffService } from './diff.interface.js';
5
5
  import type { WorkspaceService } from '../workspace/workspace.service.js';
6
- import type { WorkspaceMutex } from '../workflow/git/mutex.js';
6
+ import type { WorkspaceMutex } from '../kb-fs/mutex.js';
7
7
  import { BevelIgnoreStack } from '../workspace/bevel-ignore.js';
8
8
  import { isDiffable } from './diff.config.js';
9
9
  import { assertWithinDirectory } from './diff-paths.js';
@@ -4,7 +4,7 @@ import {
4
4
  assertValidRelativePath,
5
5
  isProtectedBranch,
6
6
  } from '../branch-name.js';
7
- import { BranchNameError, WorkflowValidationError } from '../../workflow.errors.js';
7
+ import { BranchNameError, WorkflowValidationError } from '../../../shared/domain-errors.js';
8
8
 
9
9
  describe('assertValidBranchName', () => {
10
10
  it.each([
@@ -5,7 +5,7 @@ import os from 'node:os';
5
5
  import type { AuthUser, IWorkflowService } from '@bevel-software/platform-shared';
6
6
  import { LocalFilesystem } from '@mastra/core/workspace';
7
7
  import { LockingFilesystem } from '../locking-filesystem.js';
8
- import { PushNeedsAgentResolutionError } from '../workflow.errors.js';
8
+ import { PushNeedsAgentResolutionError } from '../../../shared/domain-errors.js';
9
9
 
10
10
  const USER: AuthUser = {
11
11
  id: 'user-1',
@@ -1,4 +1,4 @@
1
- import { BranchNameError, WorkflowValidationError } from '../workflow.errors.js';
1
+ import { BranchNameError, WorkflowValidationError } from '../../shared/domain-errors.js';
2
2
 
3
3
  // Single source of truth for the protected-branch list lives in `@bevel-software/platform-shared` so
4
4
  // the backend guard and the frontend banner/disabling logic can't drift apart.
@@ -42,9 +42,9 @@ import {
42
42
  type WriteOptions,
43
43
  } from '@mastra/core/workspace';
44
44
  import type { AuthUser, Change, IWorkflowService } from '@bevel-software/platform-shared';
45
- import { PushNeedsAgentResolutionError } from './workflow.errors.js';
45
+ import { PushNeedsAgentResolutionError } from '../../shared/domain-errors.js';
46
46
  import type { FileChangeNotifier } from './file-change-notifier.js';
47
- import type { CreationGrantPlan, ICreatorAccess } from '../access/creator-access.js';
47
+ import type { CreationGrantPlan, ICreatorAccess } from '../access-model/creator.js';
48
48
 
49
49
  /** How many times to retry a contended acquire before giving up. */
50
50
  const ACQUIRE_RETRY_ATTEMPTS = 3;
@@ -6,10 +6,8 @@ import {
6
6
  type ChangeRequest,
7
7
  type IWorkflowService,
8
8
  } from '@bevel-software/platform-shared';
9
- import {
10
- workspaceIdForBranch,
11
- type WorkspaceService,
12
- } from '../../workspace/workspace.service.js';
9
+ import { type WorkspaceService } from '../../workspace/workspace.service.js';
10
+ import { workspaceIdForBranch } from '../../../shared/workspace-id.js';
13
11
  import { JoinRequestsService } from '../join-requests.service.js';
14
12
 
15
13
  /**
@@ -4,7 +4,7 @@ import { tmpdir } from 'node:os';
4
4
  import { join } from 'node:path';
5
5
  import { DEFAULT_BRANCH } from '@bevel-software/platform-shared';
6
6
  import { PluginIndexService } from '../plugins.service.js';
7
- import { workspaceIdForBranch } from '../../workspace/workspace.service.js';
7
+ import { workspaceIdForBranch } from '../../../shared/workspace-id.js';
8
8
  import type { WorkspaceService } from '../../workspace/workspace.service.js';
9
9
  import type { IAccessControl } from '../../access/access-control.interface.js';
10
10
  import type { ISkillService, SkillSummary } from '../../skills/skills.contract.js';
@@ -8,7 +8,7 @@ import { describe, it, expect, afterEach, vi } from 'vitest';
8
8
 
9
9
  import { DEFAULT_BRANCH, joinBranchFor } from '@bevel-software/platform-shared';
10
10
  import type { ChangeRequest, IWorkflowService } from '@bevel-software/platform-shared';
11
- import { workspaceIdForBranch } from '../../workspace/workspace.service.js';
11
+ import { workspaceIdForBranch } from '../../../shared/workspace-id.js';
12
12
  import type { WorkspaceService } from '../../workspace/workspace.service.js';
13
13
  import type { IAccessControl } from '../../access/access-control.interface.js';
14
14
  import type { ISkillService, SkillSummary } from '../../skills/skills.contract.js';
@@ -3,7 +3,7 @@ import {
3
3
  parseAccessFile,
4
4
  type ParsedEntry,
5
5
  type Verb,
6
- } from '../access/access-control.service.js';
6
+ } from '../access-model/access-grammar.js';
7
7
 
8
8
  /**
9
9
  * What a join branch is PROPOSING, relative to the default branch.
@@ -5,7 +5,8 @@ import {
5
5
  type ChangeRequest,
6
6
  type IWorkflowService,
7
7
  } from '@bevel-software/platform-shared';
8
- import { workspaceIdForBranch, type WorkspaceService } from '../workspace/workspace.service.js';
8
+ import { type WorkspaceService } from '../workspace/workspace.service.js';
9
+ import { workspaceIdForBranch } from '../../shared/workspace-id.js';
9
10
  import { pendingProposals, type JoinProposal } from './join-proposals.js';
10
11
 
11
12
  /** One open join change request, with what it still proposes. */
@@ -47,9 +47,9 @@ import {
47
47
  } from '@bevel-software/platform-shared';
48
48
  import type { WorkspaceService } from '../workspace/workspace.service.js';
49
49
  import type { IAccessControl } from '../access/access-control.interface.js';
50
- import { creatorPrincipal } from '../access/creator-access.js';
51
- import { spliceGrant } from '../access/access-splice.js';
52
- import { WorkspaceMutex } from '../workflow/git/mutex.js';
50
+ import { creatorPrincipal } from '../access-model/creator.js';
51
+ import { spliceGrant } from '../access-model/access-splice.js';
52
+ import { WorkspaceMutex } from '../kb-fs/mutex.js';
53
53
 
54
54
  /** Commit machinery the provision rides — the pending-commit pipeline, run inline. */
55
55
  export interface ProvisionCommitDriver {
@@ -8,8 +8,8 @@ import {
8
8
  type IWorkflowService,
9
9
  } from '@bevel-software/platform-shared';
10
10
  import type { IAccessControl } from '../access/access-control.interface.js';
11
- import { spliceGrant } from '../access/access-splice.js';
12
- import { WorkflowDomainError } from '../workflow/workflow.errors.js';
11
+ import { spliceGrant } from '../access-model/access-splice.js';
12
+ import { WorkflowDomainError } from '../../shared/domain-errors.js';
13
13
  import type { WorkspaceService } from '../workspace/workspace.service.js';
14
14
  import { pluginsWorkspaceId } from './plugins.service.js';
15
15
  import { PluginProvisionError, type PluginProvisionService } from './plugin-provision.service.js';
@@ -8,7 +8,7 @@ import {
8
8
  isPersonalPluginFolder,
9
9
  } from '@bevel-software/platform-shared';
10
10
  import type { WorkspaceService } from '../workspace/workspace.service.js';
11
- import { workspaceIdForBranch } from '../workspace/workspace.service.js';
11
+ import { workspaceIdForBranch } from '../../shared/workspace-id.js';
12
12
  import type { IAccessControl } from '../access/access-control.interface.js';
13
13
  import type { ISkillService } from '../skills/skills.contract.js';
14
14
  import type { IToolManualService } from '../tool-manuals/tool-manuals.contract.js';
@@ -12,7 +12,7 @@ import {
12
12
  import type { IToolManualService, ToolManualSummary, ToolVariable } from '../tool-manuals/tool-manuals.contract.js';
13
13
  import { utcpNamespacedKey } from '../../shared/utcp-namespace.js';
14
14
  import type { IAccessControl } from '../access/access-control.interface.js';
15
- import { workspaceIdForBranch } from '../workspace/workspace.service.js';
15
+ import { workspaceIdForBranch } from '../../shared/workspace-id.js';
16
16
  import '../auth/auth.middleware.js'; // Express Request augmentation (req.userId / req.userEmail)
17
17
 
18
18
  export interface SecretsVaultRoutesDeps {
@@ -4,7 +4,7 @@ import { tmpdir } from 'node:os';
4
4
  import { join } from 'node:path';
5
5
  import { DEFAULT_BRANCH } from '@bevel-software/platform-shared';
6
6
  import { SkillService } from '../skills.service.js';
7
- import { workspaceIdForBranch } from '../../workspace/workspace.service.js';
7
+ import { workspaceIdForBranch } from '../../../shared/workspace-id.js';
8
8
  import type { WorkspaceService } from '../../workspace/workspace.service.js';
9
9
  import type { IAccessControl } from '../../access/access-control.interface.js';
10
10
  import { readFile as fsReadFile } from 'node:fs/promises';
@@ -4,7 +4,8 @@ import {
4
4
  type ChangeRequest,
5
5
  type IWorkflowService,
6
6
  } from '@bevel-software/platform-shared';
7
- import { workspaceIdForBranch, type WorkspaceService } from '../workspace/workspace.service.js';
7
+ import { type WorkspaceService } from '../workspace/workspace.service.js';
8
+ import { workspaceIdForBranch } from '../../shared/workspace-id.js';
8
9
  import type { IAccessControl } from '../access/access-control.interface.js';
9
10
  import { hashEmail } from '../../shared/hash-email.js';
10
11
  import { resolveDeclaredId } from '../../shared/frontmatter-id.js';
@@ -3,7 +3,7 @@ import fs from 'node:fs/promises';
3
3
  import { parseDocument } from 'yaml';
4
4
  import { DEFAULT_BRANCH, PLUGINS_DIR } from '@bevel-software/platform-shared';
5
5
  import type { WorkspaceService } from '../workspace/workspace.service.js';
6
- import { workspaceIdForBranch } from '../workspace/workspace.service.js';
6
+ import { workspaceIdForBranch } from '../../shared/workspace-id.js';
7
7
  import type { IAccessControl } from '../access/access-control.interface.js';
8
8
  import { extractFrontmatter, resolveDeclaredId, dedupeById } from '../../shared/frontmatter-id.js';
9
9
  import { walkFiles } from '../../shared/fs-walk.js';
@@ -1,10 +1,11 @@
1
1
  import { LocalFilesystem } from '@mastra/core/workspace';
2
2
  import type { IWorkflowService } from '@bevel-software/platform-shared';
3
- import { LockingFilesystem } from '../workflow/locking-filesystem.js';
4
- import { ReadOnlyFilesystem } from '../workflow/read-only-filesystem.js';
5
- import { makeRolesYamlWriteValidator } from '../access/roles-yaml-guard.js';
6
- import type { ICreatorAccess } from '../access/creator-access.js';
7
- import { branchForWorkspaceId, type WorkspaceService } from '../workspace/workspace.service.js';
3
+ import { LockingFilesystem } from '../kb-fs/locking-filesystem.js';
4
+ import { ReadOnlyFilesystem } from '../kb-fs/read-only-filesystem.js';
5
+ import { makeRolesYamlWriteValidator } from '../access-model/roles-yaml-guard.js';
6
+ import type { ICreatorAccess } from '../access-model/creator.js';
7
+ import type { WorkspaceService } from '../workspace/workspace.service.js';
8
+ import { branchForWorkspaceId } from '../../shared/workspace-id.js';
8
9
  import type { WorkflowEventBus } from '../workflow/event-bus.js';
9
10
  import type { AuthService } from '../auth/auth.service.js';
10
11
  import { ToolError, type ToolContext } from './tool.contract.js';
@@ -3,7 +3,7 @@ import fs from 'node:fs/promises';
3
3
  import os from 'node:os';
4
4
  import path from 'node:path';
5
5
  import { DEFAULT_BRANCH, type AuthUser } from '@bevel-software/platform-shared';
6
- import { workspaceIdForBranch } from '../../workspace/workspace.service.js';
6
+ import { workspaceIdForBranch } from '../../../shared/workspace-id.js';
7
7
  import type { WorkspaceService } from '../../workspace/workspace.service.js';
8
8
  import type { IAccessControl } from '../../access/access-control.interface.js';
9
9
  import type { IToolManualService, ToolManualSummary } from '../tool-manuals.contract.js';
@@ -6,7 +6,7 @@ import express from 'express';
6
6
  import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
7
7
  import { DEFAULT_BRANCH } from '@bevel-software/platform-shared';
8
8
  import { createToolManualsAgentRoutes } from '../tool-manuals.routes.js';
9
- import { workspaceIdForBranch } from '../../workspace/workspace.service.js';
9
+ import { workspaceIdForBranch } from '../../../shared/workspace-id.js';
10
10
  import type { WorkspaceService } from '../../workspace/workspace.service.js';
11
11
  import type { IAccessControl } from '../../access/access-control.interface.js';
12
12
  import type { IToolManualService } from '../tool-manuals.contract.js';
@@ -7,7 +7,7 @@ import { afterEach, describe, expect, it, test, vi } from 'vitest';
7
7
  import { DEFAULT_BRANCH } from '@bevel-software/platform-shared';
8
8
  import { createToolManualsBrowserRoutes } from '../tool-manuals.routes.js';
9
9
  import { ToolManualService } from '../tool-manuals.service.js';
10
- import { workspaceIdForBranch } from '../../workspace/workspace.service.js';
10
+ import { workspaceIdForBranch } from '../../../shared/workspace-id.js';
11
11
  import type { WorkspaceService } from '../../workspace/workspace.service.js';
12
12
  import type { IAccessControl } from '../../access/access-control.interface.js';
13
13
  import type { IToolManualService, ToolManualDetail } from '../tool-manuals.contract.js';
@@ -4,7 +4,7 @@ import { tmpdir } from 'node:os';
4
4
  import { join } from 'node:path';
5
5
  import { DEFAULT_BRANCH } from '@bevel-software/platform-shared';
6
6
  import { ToolManualService, type McpAuthDiscoveryPort } from '../tool-manuals.service.js';
7
- import { workspaceIdForBranch } from '../../workspace/workspace.service.js';
7
+ import { workspaceIdForBranch } from '../../../shared/workspace-id.js';
8
8
  import type { WorkspaceService } from '../../workspace/workspace.service.js';
9
9
  import type { IAccessControl } from '../../access/access-control.interface.js';
10
10
 
@@ -4,7 +4,7 @@ import { tmpdir } from 'node:os';
4
4
  import { join } from 'node:path';
5
5
  import { DEFAULT_BRANCH } from '@bevel-software/platform-shared';
6
6
  import { ToolManualService } from '../tool-manuals.service.js';
7
- import { workspaceIdForBranch } from '../../workspace/workspace.service.js';
7
+ import { workspaceIdForBranch } from '../../../shared/workspace-id.js';
8
8
  import type { WorkspaceService } from '../../workspace/workspace.service.js';
9
9
  import type { IAccessControl } from '../../access/access-control.interface.js';
10
10
 
@@ -8,7 +8,8 @@ import {
8
8
  PLUGIN_MCP_FILE,
9
9
  type AuthUser,
10
10
  } from '@bevel-software/platform-shared';
11
- import { workspaceIdForBranch, type WorkspaceService } from '../workspace/workspace.service.js';
11
+ import type { WorkspaceService } from '../workspace/workspace.service.js';
12
+ import { workspaceIdForBranch } from '../../shared/workspace-id.js';
12
13
  import { validatedVariables } from './mcp-json-discovery.js';
13
14
  import { assertSafeFetchUrl } from '../../shared/ssrf.js';
14
15
  import { containsVariableReference, findReservedVariableRef } from '../../shared/variable-refs.js';
@@ -3,7 +3,8 @@ import path from 'node:path';
3
3
  import fs from 'node:fs/promises';
4
4
  import AdmZip from 'adm-zip';
5
5
  import { DEFAULT_BRANCH, PLUGINS_DIR } from '@bevel-software/platform-shared';
6
- import { workspaceIdForBranch, type WorkspaceService } from '../workspace/workspace.service.js';
6
+ import type { WorkspaceService } from '../workspace/workspace.service.js';
7
+ import { workspaceIdForBranch } from '../../shared/workspace-id.js';
7
8
  import type { IAccessControl } from '../access/access-control.interface.js';
8
9
  import '@utcp/http'; // side effect: register the 'http' call-template type
9
10
  import { CallTemplateSerializer, type CallTemplate } from '@utcp/sdk';
@@ -17,7 +17,7 @@ import {
17
17
  } from '@bevel-software/platform-shared';
18
18
  import { descriptorsFromMcpJson } from './mcp-json-discovery.js';
19
19
  import type { WorkspaceService } from '../workspace/workspace.service.js';
20
- import { workspaceIdForBranch } from '../workspace/workspace.service.js';
20
+ import { workspaceIdForBranch } from '../../shared/workspace-id.js';
21
21
  import type { IAccessControl } from '../access/access-control.interface.js';
22
22
  import { assertSafeFetchUrl } from '../../shared/ssrf.js';
23
23
  import { RESERVED_VARIABLE_NAMES, findReservedVariableRef } from '../../shared/variable-refs.js';
@@ -5,7 +5,7 @@ import type { ToolContext } from '../tool-helpers/tool.contract.js';
5
5
  import { toolDef } from '../tool-helpers/tool-def.js';
6
6
  import type { ToolHandlerFactory } from '../tool-helpers/tool-handler.js';
7
7
  import type { IAccessControl } from '../access/access-control.interface.js';
8
- import { workspaceIdForBranch } from '../workspace/workspace.service.js';
8
+ import { workspaceIdForBranch } from '../../shared/workspace-id.js';
9
9
  import { utcpNamespacedKey } from '../../shared/utcp-namespace.js';
10
10
  import type { IToolManualService } from './tool-manuals.contract.js';
11
11
 
@@ -12,7 +12,7 @@ import { FileLockService } from '../file-lock.service.js';
12
12
  import { PendingCommitsService } from '../pending-commits.service.js';
13
13
  import { WorkflowService } from '../workflow.service.js';
14
14
  import type { Database } from '../../database/connection.js';
15
- import { RolesYamlPreservationError } from '../workflow.errors.js';
15
+ import { RolesYamlPreservationError } from '../../../shared/domain-errors.js';
16
16
 
17
17
  /**
18
18
  * Focused tests for the roles.yaml-preservation guard inside
@@ -10,7 +10,7 @@ import { PendingCommitsService } from '../pending-commits.service.js';
10
10
  import { WorkflowEventBus } from '../event-bus.js';
11
11
  import { WorkflowService } from '../workflow.service.js';
12
12
  import type { Database } from '../../database/connection.js';
13
- import { WorkflowValidationError } from '../workflow.errors.js';
13
+ import { WorkflowValidationError } from '../../../shared/domain-errors.js';
14
14
 
15
15
  /**
16
16
  * `commitFileWhileLocked` (autosave checkpoint) has subtler semantics
@@ -12,7 +12,7 @@ import type { IAccessControl } from '../../access/access-control.interface.js';
12
12
  import { FileLockService } from '../file-lock.service.js';
13
13
  import { PendingCommitsService } from '../pending-commits.service.js';
14
14
  import { WorkflowService } from '../workflow.service.js';
15
- import { PullRebaseConflictError } from '../workflow.errors.js';
15
+ import { PullRebaseConflictError } from '../../../shared/domain-errors.js';
16
16
  import type { Database } from '../../database/connection.js';
17
17
 
18
18
  // `deleteBranch`'s open-request guard is the only DB touch these tests
@@ -14,7 +14,7 @@ import {
14
14
  PullRebaseConflictError,
15
15
  PushNeedsAgentResolutionError,
16
16
  WorkflowValidationError,
17
- } from '../workflow.errors.js';
17
+ } from '../../../shared/domain-errors.js';
18
18
 
19
19
  /**
20
20
  * Two surfaces under test:
@@ -5,7 +5,7 @@ import { ToolError, type ToolContext, type ToolHandler } from '../../tool-helper
5
5
  import { toolDef, withBranchInput } from '../../tool-helpers/tool-def.js';
6
6
  import type { ToolHandlerFactory } from '../../tool-helpers/tool-handler.js';
7
7
  import { requireInternalSource } from '../../tool-auth/tool-auth.middleware.js';
8
- import { workspaceIdForBranch } from '../../workspace/workspace.service.js';
8
+ import { workspaceIdForBranch } from '../../../shared/workspace-id.js';
9
9
 
10
10
  // A function, not a constant: the branch model is applied during boot, and a
11
11
  // module-scope capture would freeze this at the empty set that exists before it.
@@ -21,7 +21,7 @@ import { and, eq, gt, lte } from 'drizzle-orm';
21
21
  import type { Database } from '../database/connection.js';
22
22
  import { fileLocks } from '../database/schema.js';
23
23
  import type { AcquireLockResult, AuthUser, FileLock } from '@bevel-software/platform-shared';
24
- import { WorkflowValidationError } from './workflow.errors.js';
24
+ import { WorkflowValidationError } from '../../shared/domain-errors.js';
25
25
 
26
26
  /**
27
27
  * Lock lifetime without a heartbeat. The client is expected to heartbeat
@@ -9,7 +9,7 @@ import type { WorkspaceService } from '../../../workspace/workspace.service.js';
9
9
  import { WorkflowHooks } from '../../workflow-hooks.js';
10
10
  import type { IAccessControl } from '../../../access/access-control.interface.js';
11
11
  import { GitService } from '../git.service.js';
12
- import { AccessDeniedError } from '../../../access/access-errors.js';
12
+ import { AccessDeniedError } from '../../../access-model/access-errors.js';
13
13
 
14
14
  const execFileAsync = promisify(execFile);
15
15
  const PROCESS_MAP_DIR = 'knowledge-base';
@@ -13,7 +13,7 @@ import {
13
13
  BranchAuthorshipError,
14
14
  ProtectedBranchError,
15
15
  WorkflowValidationError,
16
- } from '../../workflow.errors.js';
16
+ } from '../../../../shared/domain-errors.js';
17
17
 
18
18
  const execFileAsync = promisify(execFile);
19
19
 
@@ -7,7 +7,7 @@ import os from 'node:os';
7
7
  import type { WorkspaceService } from '../../../workspace/workspace.service.js';
8
8
  import { WorkflowHooks } from '../../workflow-hooks.js';
9
9
  import { GitService } from '../git.service.js';
10
- import { WorkflowValidationError } from '../../workflow.errors.js';
10
+ import { WorkflowValidationError } from '../../../../shared/domain-errors.js';
11
11
 
12
12
  const execFileAsync = promisify(execFile);
13
13
  const PROCESS_MAP_DIR = 'knowledge-base';
@@ -7,7 +7,7 @@ import os from 'node:os';
7
7
  import type { WorkspaceService } from '../../../workspace/workspace.service.js';
8
8
  import { WorkflowHooks } from '../../workflow-hooks.js';
9
9
  import { GitService } from '../git.service.js';
10
- import { WorkflowValidationError, BranchNameError } from '../../workflow.errors.js';
10
+ import { WorkflowValidationError, BranchNameError } from '../../../../shared/domain-errors.js';
11
11
 
12
12
  const execFileAsync = promisify(execFile);
13
13
  const PROCESS_MAP_DIR = 'knowledge-base';
@@ -3,7 +3,7 @@ import fs from 'node:fs/promises';
3
3
  import path from 'node:path';
4
4
  import os from 'node:os';
5
5
  import { GitService } from '../git.service.js';
6
- import { PullRebaseConflictError } from '../../workflow.errors.js';
6
+ import { PullRebaseConflictError } from '../../../../shared/domain-errors.js';
7
7
  import { runGit, gitOut, stubWorkflowHooks, stubWorkspaceService } from './git-test-helpers.js';
8
8
 
9
9
  /** See git.service.createBranch.test.ts — same prod-mirroring layout. */