@software-dlc/cli 0.157.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 (701) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/LICENSE +105 -0
  3. package/README.md +31 -0
  4. package/dist/checkout.d.ts +43 -0
  5. package/dist/checkout.d.ts.map +1 -0
  6. package/dist/checkout.js +92 -0
  7. package/dist/checkout.js.map +1 -0
  8. package/dist/cli-arguments.d.ts +13 -0
  9. package/dist/cli-arguments.d.ts.map +1 -0
  10. package/dist/cli-arguments.js +67 -0
  11. package/dist/cli-arguments.js.map +1 -0
  12. package/dist/cli-branch-history.d.ts +48 -0
  13. package/dist/cli-branch-history.d.ts.map +1 -0
  14. package/dist/cli-branch-history.js +319 -0
  15. package/dist/cli-branch-history.js.map +1 -0
  16. package/dist/cli-branches.d.ts +22 -0
  17. package/dist/cli-branches.d.ts.map +1 -0
  18. package/dist/cli-branches.js +59 -0
  19. package/dist/cli-branches.js.map +1 -0
  20. package/dist/cli-deploy.d.ts +14 -0
  21. package/dist/cli-deploy.d.ts.map +1 -0
  22. package/dist/cli-deploy.js +164 -0
  23. package/dist/cli-deploy.js.map +1 -0
  24. package/dist/cli-health.d.ts +3 -0
  25. package/dist/cli-health.d.ts.map +1 -0
  26. package/dist/cli-health.js +73 -0
  27. package/dist/cli-health.js.map +1 -0
  28. package/dist/cli-help.d.ts +21 -0
  29. package/dist/cli-help.d.ts.map +1 -0
  30. package/dist/cli-help.js +176 -0
  31. package/dist/cli-help.js.map +1 -0
  32. package/dist/cli-login.d.ts +76 -0
  33. package/dist/cli-login.d.ts.map +1 -0
  34. package/dist/cli-login.js +634 -0
  35. package/dist/cli-login.js.map +1 -0
  36. package/dist/cli-operation.d.ts +2 -0
  37. package/dist/cli-operation.d.ts.map +1 -0
  38. package/dist/cli-operation.js +66 -0
  39. package/dist/cli-operation.js.map +1 -0
  40. package/dist/cli-org.d.ts +12 -0
  41. package/dist/cli-org.d.ts.map +1 -0
  42. package/dist/cli-org.js +218 -0
  43. package/dist/cli-org.js.map +1 -0
  44. package/dist/cli-rebuild.d.ts +20 -0
  45. package/dist/cli-rebuild.d.ts.map +1 -0
  46. package/dist/cli-rebuild.js +29 -0
  47. package/dist/cli-rebuild.js.map +1 -0
  48. package/dist/cli-reset.d.ts +27 -0
  49. package/dist/cli-reset.d.ts.map +1 -0
  50. package/dist/cli-reset.js +44 -0
  51. package/dist/cli-reset.js.map +1 -0
  52. package/dist/cli-snapshot.d.ts +398 -0
  53. package/dist/cli-snapshot.d.ts.map +1 -0
  54. package/dist/cli-snapshot.js +45 -0
  55. package/dist/cli-snapshot.js.map +1 -0
  56. package/dist/cli-task-context.d.ts +3 -0
  57. package/dist/cli-task-context.d.ts.map +1 -0
  58. package/dist/cli-task-context.js +112 -0
  59. package/dist/cli-task-context.js.map +1 -0
  60. package/dist/cli.d.ts +3 -0
  61. package/dist/cli.d.ts.map +1 -0
  62. package/dist/cli.js +1004 -0
  63. package/dist/cli.js.map +1 -0
  64. package/dist/graph-packages-lock.d.ts +169 -0
  65. package/dist/graph-packages-lock.d.ts.map +1 -0
  66. package/dist/graph-packages-lock.js +503 -0
  67. package/dist/graph-packages-lock.js.map +1 -0
  68. package/dist/index.d.ts +2 -0
  69. package/dist/index.d.ts.map +1 -0
  70. package/dist/index.js +2 -0
  71. package/dist/index.js.map +1 -0
  72. package/dist/local/aggregate-preflight.d.ts +12 -0
  73. package/dist/local/aggregate-preflight.d.ts.map +1 -0
  74. package/dist/local/aggregate-preflight.js +22 -0
  75. package/dist/local/aggregate-preflight.js.map +1 -0
  76. package/dist/local/allow-mcp.d.ts +77 -0
  77. package/dist/local/allow-mcp.d.ts.map +1 -0
  78. package/dist/local/allow-mcp.js +394 -0
  79. package/dist/local/allow-mcp.js.map +1 -0
  80. package/dist/local/api-client.d.ts +15 -0
  81. package/dist/local/api-client.d.ts.map +1 -0
  82. package/dist/local/api-client.js +87 -0
  83. package/dist/local/api-client.js.map +1 -0
  84. package/dist/local/app-contract-readers.d.ts +229 -0
  85. package/dist/local/app-contract-readers.d.ts.map +1 -0
  86. package/dist/local/app-contract-readers.js +450 -0
  87. package/dist/local/app-contract-readers.js.map +1 -0
  88. package/dist/local/app-org-reader.d.ts +21 -0
  89. package/dist/local/app-org-reader.d.ts.map +1 -0
  90. package/dist/local/app-org-reader.js +66 -0
  91. package/dist/local/app-org-reader.js.map +1 -0
  92. package/dist/local/app-shell-readers.d.ts +96 -0
  93. package/dist/local/app-shell-readers.d.ts.map +1 -0
  94. package/dist/local/app-shell-readers.js +381 -0
  95. package/dist/local/app-shell-readers.js.map +1 -0
  96. package/dist/local/app-tasks-read.d.ts +202 -0
  97. package/dist/local/app-tasks-read.d.ts.map +1 -0
  98. package/dist/local/app-tasks-read.js +290 -0
  99. package/dist/local/app-tasks-read.js.map +1 -0
  100. package/dist/local/app-worktrees.d.ts +69 -0
  101. package/dist/local/app-worktrees.d.ts.map +1 -0
  102. package/dist/local/app-worktrees.js +554 -0
  103. package/dist/local/app-worktrees.js.map +1 -0
  104. package/dist/local/base-sync-manifest.d.ts +12 -0
  105. package/dist/local/base-sync-manifest.d.ts.map +1 -0
  106. package/dist/local/base-sync-manifest.js +57 -0
  107. package/dist/local/base-sync-manifest.js.map +1 -0
  108. package/dist/local/blast-radius.d.ts +191 -0
  109. package/dist/local/blast-radius.d.ts.map +1 -0
  110. package/dist/local/blast-radius.js +585 -0
  111. package/dist/local/blast-radius.js.map +1 -0
  112. package/dist/local/canonical.d.ts +2 -0
  113. package/dist/local/canonical.d.ts.map +1 -0
  114. package/dist/local/canonical.js +2 -0
  115. package/dist/local/canonical.js.map +1 -0
  116. package/dist/local/config.d.ts +22 -0
  117. package/dist/local/config.d.ts.map +1 -0
  118. package/dist/local/config.js +57 -0
  119. package/dist/local/config.js.map +1 -0
  120. package/dist/local/document-commands.d.ts +163 -0
  121. package/dist/local/document-commands.d.ts.map +1 -0
  122. package/dist/local/document-commands.js +620 -0
  123. package/dist/local/document-commands.js.map +1 -0
  124. package/dist/local/document-embeds.d.ts +21 -0
  125. package/dist/local/document-embeds.d.ts.map +1 -0
  126. package/dist/local/document-embeds.js +38 -0
  127. package/dist/local/document-embeds.js.map +1 -0
  128. package/dist/local/environment-context.d.ts +39 -0
  129. package/dist/local/environment-context.d.ts.map +1 -0
  130. package/dist/local/environment-context.js +193 -0
  131. package/dist/local/environment-context.js.map +1 -0
  132. package/dist/local/environment-exclude.d.ts +7 -0
  133. package/dist/local/environment-exclude.d.ts.map +1 -0
  134. package/dist/local/environment-exclude.js +82 -0
  135. package/dist/local/environment-exclude.js.map +1 -0
  136. package/dist/local/environment-sidecar.d.ts +126 -0
  137. package/dist/local/environment-sidecar.d.ts.map +1 -0
  138. package/dist/local/environment-sidecar.js +442 -0
  139. package/dist/local/environment-sidecar.js.map +1 -0
  140. package/dist/local/environment-switch.d.ts +22 -0
  141. package/dist/local/environment-switch.d.ts.map +1 -0
  142. package/dist/local/environment-switch.js +385 -0
  143. package/dist/local/environment-switch.js.map +1 -0
  144. package/dist/local/exact-remote-projection.d.ts +17 -0
  145. package/dist/local/exact-remote-projection.d.ts.map +1 -0
  146. package/dist/local/exact-remote-projection.js +53 -0
  147. package/dist/local/exact-remote-projection.js.map +1 -0
  148. package/dist/local/experimental/path-object-store.d.ts +66 -0
  149. package/dist/local/experimental/path-object-store.d.ts.map +1 -0
  150. package/dist/local/experimental/path-object-store.js +135 -0
  151. package/dist/local/experimental/path-object-store.js.map +1 -0
  152. package/dist/local/external-worktree-binding.d.ts +21 -0
  153. package/dist/local/external-worktree-binding.d.ts.map +1 -0
  154. package/dist/local/external-worktree-binding.js +56 -0
  155. package/dist/local/external-worktree-binding.js.map +1 -0
  156. package/dist/local/folder-members.d.ts +34 -0
  157. package/dist/local/folder-members.d.ts.map +1 -0
  158. package/dist/local/folder-members.js +168 -0
  159. package/dist/local/folder-members.js.map +1 -0
  160. package/dist/local/git-ref-authority.d.ts +11 -0
  161. package/dist/local/git-ref-authority.d.ts.map +1 -0
  162. package/dist/local/git-ref-authority.js +76 -0
  163. package/dist/local/git-ref-authority.js.map +1 -0
  164. package/dist/local/git.d.ts +88 -0
  165. package/dist/local/git.d.ts.map +1 -0
  166. package/dist/local/git.js +413 -0
  167. package/dist/local/git.js.map +1 -0
  168. package/dist/local/graph-read.d.ts +168 -0
  169. package/dist/local/graph-read.d.ts.map +1 -0
  170. package/dist/local/graph-read.js +360 -0
  171. package/dist/local/graph-read.js.map +1 -0
  172. package/dist/local/graph-sync.d.ts +39 -0
  173. package/dist/local/graph-sync.d.ts.map +1 -0
  174. package/dist/local/graph-sync.js +186 -0
  175. package/dist/local/graph-sync.js.map +1 -0
  176. package/dist/local/guide-commands.d.ts +79 -0
  177. package/dist/local/guide-commands.d.ts.map +1 -0
  178. package/dist/local/guide-commands.js +247 -0
  179. package/dist/local/guide-commands.js.map +1 -0
  180. package/dist/local/health-files.d.ts +24 -0
  181. package/dist/local/health-files.d.ts.map +1 -0
  182. package/dist/local/health-files.js +133 -0
  183. package/dist/local/health-files.js.map +1 -0
  184. package/dist/local/health-inspection.d.ts +12 -0
  185. package/dist/local/health-inspection.d.ts.map +1 -0
  186. package/dist/local/health-inspection.js +407 -0
  187. package/dist/local/health-inspection.js.map +1 -0
  188. package/dist/local/health-policy.d.ts +11 -0
  189. package/dist/local/health-policy.d.ts.map +1 -0
  190. package/dist/local/health-policy.js +257 -0
  191. package/dist/local/health-policy.js.map +1 -0
  192. package/dist/local/health-projection.d.ts +14 -0
  193. package/dist/local/health-projection.d.ts.map +1 -0
  194. package/dist/local/health-projection.js +102 -0
  195. package/dist/local/health-projection.js.map +1 -0
  196. package/dist/local/health-schema.d.ts +338 -0
  197. package/dist/local/health-schema.d.ts.map +1 -0
  198. package/dist/local/health-schema.js +213 -0
  199. package/dist/local/health-schema.js.map +1 -0
  200. package/dist/local/health-store.d.ts +61 -0
  201. package/dist/local/health-store.d.ts.map +1 -0
  202. package/dist/local/health-store.js +218 -0
  203. package/dist/local/health-store.js.map +1 -0
  204. package/dist/local/index.d.ts +66 -0
  205. package/dist/local/index.d.ts.map +1 -0
  206. package/dist/local/index.js +66 -0
  207. package/dist/local/index.js.map +1 -0
  208. package/dist/local/journey-commands.d.ts +65 -0
  209. package/dist/local/journey-commands.d.ts.map +1 -0
  210. package/dist/local/journey-commands.js +138 -0
  211. package/dist/local/journey-commands.js.map +1 -0
  212. package/dist/local/local-org-store.d.ts +46 -0
  213. package/dist/local/local-org-store.d.ts.map +1 -0
  214. package/dist/local/local-org-store.js +132 -0
  215. package/dist/local/local-org-store.js.map +1 -0
  216. package/dist/local/local-org.d.ts +389 -0
  217. package/dist/local/local-org.d.ts.map +1 -0
  218. package/dist/local/local-org.js +855 -0
  219. package/dist/local/local-org.js.map +1 -0
  220. package/dist/local/media-upload.d.ts +5 -0
  221. package/dist/local/media-upload.d.ts.map +1 -0
  222. package/dist/local/media-upload.js +41 -0
  223. package/dist/local/media-upload.js.map +1 -0
  224. package/dist/local/operation.d.ts +155 -0
  225. package/dist/local/operation.d.ts.map +1 -0
  226. package/dist/local/operation.js +340 -0
  227. package/dist/local/operation.js.map +1 -0
  228. package/dist/local/ownership-reader-schema.d.ts +117 -0
  229. package/dist/local/ownership-reader-schema.d.ts.map +1 -0
  230. package/dist/local/ownership-reader-schema.js +105 -0
  231. package/dist/local/ownership-reader-schema.js.map +1 -0
  232. package/dist/local/ownership-reader-worker.d.ts +2 -0
  233. package/dist/local/ownership-reader-worker.d.ts.map +1 -0
  234. package/dist/local/ownership-reader-worker.js +341 -0
  235. package/dist/local/ownership-reader-worker.js.map +1 -0
  236. package/dist/local/ownership-reader.d.ts +10 -0
  237. package/dist/local/ownership-reader.d.ts.map +1 -0
  238. package/dist/local/ownership-reader.js +93 -0
  239. package/dist/local/ownership-reader.js.map +1 -0
  240. package/dist/local/package-uses-check.d.ts +33 -0
  241. package/dist/local/package-uses-check.d.ts.map +1 -0
  242. package/dist/local/package-uses-check.js +62 -0
  243. package/dist/local/package-uses-check.js.map +1 -0
  244. package/dist/local/pending-recovery.d.ts +22 -0
  245. package/dist/local/pending-recovery.d.ts.map +1 -0
  246. package/dist/local/pending-recovery.js +171 -0
  247. package/dist/local/pending-recovery.js.map +1 -0
  248. package/dist/local/portable-commit-store.d.ts +28 -0
  249. package/dist/local/portable-commit-store.d.ts.map +1 -0
  250. package/dist/local/portable-commit-store.js +187 -0
  251. package/dist/local/portable-commit-store.js.map +1 -0
  252. package/dist/local/portable-commit.d.ts +109 -0
  253. package/dist/local/portable-commit.d.ts.map +1 -0
  254. package/dist/local/portable-commit.js +209 -0
  255. package/dist/local/portable-commit.js.map +1 -0
  256. package/dist/local/portable-remote.d.ts +432 -0
  257. package/dist/local/portable-remote.d.ts.map +1 -0
  258. package/dist/local/portable-remote.js +280 -0
  259. package/dist/local/portable-remote.js.map +1 -0
  260. package/dist/local/project-deleted.d.ts +4 -0
  261. package/dist/local/project-deleted.d.ts.map +1 -0
  262. package/dist/local/project-deleted.js +13 -0
  263. package/dist/local/project-deleted.js.map +1 -0
  264. package/dist/local/projection.d.ts +166 -0
  265. package/dist/local/projection.d.ts.map +1 -0
  266. package/dist/local/projection.js +709 -0
  267. package/dist/local/projection.js.map +1 -0
  268. package/dist/local/read-operation.d.ts +3 -0
  269. package/dist/local/read-operation.d.ts.map +1 -0
  270. package/dist/local/read-operation.js +19 -0
  271. package/dist/local/read-operation.js.map +1 -0
  272. package/dist/local/rebuild.d.ts +11 -0
  273. package/dist/local/rebuild.d.ts.map +1 -0
  274. package/dist/local/rebuild.js +42 -0
  275. package/dist/local/rebuild.js.map +1 -0
  276. package/dist/local/remote-base.d.ts +25 -0
  277. package/dist/local/remote-base.d.ts.map +1 -0
  278. package/dist/local/remote-base.js +68 -0
  279. package/dist/local/remote-base.js.map +1 -0
  280. package/dist/local/save-layout-worker.d.ts +19 -0
  281. package/dist/local/save-layout-worker.d.ts.map +1 -0
  282. package/dist/local/save-layout-worker.js +28 -0
  283. package/dist/local/save-layout-worker.js.map +1 -0
  284. package/dist/local/save-layout.d.ts +84 -0
  285. package/dist/local/save-layout.d.ts.map +1 -0
  286. package/dist/local/save-layout.js +221 -0
  287. package/dist/local/save-layout.js.map +1 -0
  288. package/dist/local/scope-impact.d.ts +31 -0
  289. package/dist/local/scope-impact.d.ts.map +1 -0
  290. package/dist/local/scope-impact.js +32 -0
  291. package/dist/local/scope-impact.js.map +1 -0
  292. package/dist/local/source-evidence/filesystem-worker.d.ts +2 -0
  293. package/dist/local/source-evidence/filesystem-worker.d.ts.map +1 -0
  294. package/dist/local/source-evidence/filesystem-worker.js +139 -0
  295. package/dist/local/source-evidence/filesystem-worker.js.map +1 -0
  296. package/dist/local/source-evidence/processes.d.ts +20 -0
  297. package/dist/local/source-evidence/processes.d.ts.map +1 -0
  298. package/dist/local/source-evidence/processes.js +133 -0
  299. package/dist/local/source-evidence/processes.js.map +1 -0
  300. package/dist/local/source-evidence/protocol.d.ts +52 -0
  301. package/dist/local/source-evidence/protocol.d.ts.map +1 -0
  302. package/dist/local/source-evidence/protocol.js +72 -0
  303. package/dist/local/source-evidence/protocol.js.map +1 -0
  304. package/dist/local/source-evidence/reader.d.ts +14 -0
  305. package/dist/local/source-evidence/reader.d.ts.map +1 -0
  306. package/dist/local/source-evidence/reader.js +308 -0
  307. package/dist/local/source-evidence/reader.js.map +1 -0
  308. package/dist/local/source-evidence/schema.d.ts +2504 -0
  309. package/dist/local/source-evidence/schema.d.ts.map +1 -0
  310. package/dist/local/source-evidence/schema.js +99 -0
  311. package/dist/local/source-evidence/schema.js.map +1 -0
  312. package/dist/local/source-policy/loader.d.ts +29 -0
  313. package/dist/local/source-policy/loader.d.ts.map +1 -0
  314. package/dist/local/source-policy/loader.js +209 -0
  315. package/dist/local/source-policy/loader.js.map +1 -0
  316. package/dist/local/source-policy/process.d.ts +7 -0
  317. package/dist/local/source-policy/process.d.ts.map +1 -0
  318. package/dist/local/source-policy/process.js +53 -0
  319. package/dist/local/source-policy/process.js.map +1 -0
  320. package/dist/local/source-policy/protocol.d.ts +27 -0
  321. package/dist/local/source-policy/protocol.d.ts.map +1 -0
  322. package/dist/local/source-policy/protocol.js +48 -0
  323. package/dist/local/source-policy/protocol.js.map +1 -0
  324. package/dist/local/source-policy/worker.d.ts +2 -0
  325. package/dist/local/source-policy/worker.d.ts.map +1 -0
  326. package/dist/local/source-policy/worker.js +100 -0
  327. package/dist/local/source-policy/worker.js.map +1 -0
  328. package/dist/local/state-directory.d.ts +17 -0
  329. package/dist/local/state-directory.d.ts.map +1 -0
  330. package/dist/local/state-directory.js +68 -0
  331. package/dist/local/state-directory.js.map +1 -0
  332. package/dist/local/store-database.d.ts +13 -0
  333. package/dist/local/store-database.d.ts.map +1 -0
  334. package/dist/local/store-database.js +187 -0
  335. package/dist/local/store-database.js.map +1 -0
  336. package/dist/local/store.d.ts +181 -0
  337. package/dist/local/store.d.ts.map +1 -0
  338. package/dist/local/store.js +585 -0
  339. package/dist/local/store.js.map +1 -0
  340. package/dist/local/sync.d.ts +47 -0
  341. package/dist/local/sync.d.ts.map +1 -0
  342. package/dist/local/sync.js +518 -0
  343. package/dist/local/sync.js.map +1 -0
  344. package/dist/local/task-context-inspection.d.ts +23 -0
  345. package/dist/local/task-context-inspection.d.ts.map +1 -0
  346. package/dist/local/task-context-inspection.js +165 -0
  347. package/dist/local/task-context-inspection.js.map +1 -0
  348. package/dist/local/task-context-observations.d.ts +9553 -0
  349. package/dist/local/task-context-observations.d.ts.map +1 -0
  350. package/dist/local/task-context-observations.js +232 -0
  351. package/dist/local/task-context-observations.js.map +1 -0
  352. package/dist/local/task-context-provider.d.ts +18 -0
  353. package/dist/local/task-context-provider.d.ts.map +1 -0
  354. package/dist/local/task-context-provider.js +231 -0
  355. package/dist/local/task-context-provider.js.map +1 -0
  356. package/dist/local/task-context-schema.d.ts +847 -0
  357. package/dist/local/task-context-schema.d.ts.map +1 -0
  358. package/dist/local/task-context-schema.js +305 -0
  359. package/dist/local/task-context-schema.js.map +1 -0
  360. package/dist/local/task-context-source.d.ts +16 -0
  361. package/dist/local/task-context-source.d.ts.map +1 -0
  362. package/dist/local/task-context-source.js +45 -0
  363. package/dist/local/task-context-source.js.map +1 -0
  364. package/dist/local/task-context.d.ts +14 -0
  365. package/dist/local/task-context.d.ts.map +1 -0
  366. package/dist/local/task-context.js +570 -0
  367. package/dist/local/task-context.js.map +1 -0
  368. package/dist/local/test-commands.d.ts +71 -0
  369. package/dist/local/test-commands.d.ts.map +1 -0
  370. package/dist/local/test-commands.js +292 -0
  371. package/dist/local/test-commands.js.map +1 -0
  372. package/dist/local/tree-save.d.ts +117 -0
  373. package/dist/local/tree-save.d.ts.map +1 -0
  374. package/dist/local/tree-save.js +615 -0
  375. package/dist/local/tree-save.js.map +1 -0
  376. package/dist/local/variants.d.ts +125 -0
  377. package/dist/local/variants.d.ts.map +1 -0
  378. package/dist/local/variants.js +267 -0
  379. package/dist/local/variants.js.map +1 -0
  380. package/dist/local/workspace-admission.d.ts +61 -0
  381. package/dist/local/workspace-admission.d.ts.map +1 -0
  382. package/dist/local/workspace-admission.js +112 -0
  383. package/dist/local/workspace-admission.js.map +1 -0
  384. package/dist/local/workspace-authority-guard.d.ts +18 -0
  385. package/dist/local/workspace-authority-guard.d.ts.map +1 -0
  386. package/dist/local/workspace-authority-guard.js +69 -0
  387. package/dist/local/workspace-authority-guard.js.map +1 -0
  388. package/dist/local/workspace-authority.d.ts +33 -0
  389. package/dist/local/workspace-authority.d.ts.map +1 -0
  390. package/dist/local/workspace-authority.js +33 -0
  391. package/dist/local/workspace-authority.js.map +1 -0
  392. package/dist/local/workspace-branch-runtime.d.ts +61 -0
  393. package/dist/local/workspace-branch-runtime.d.ts.map +1 -0
  394. package/dist/local/workspace-branch-runtime.js +216 -0
  395. package/dist/local/workspace-branch-runtime.js.map +1 -0
  396. package/dist/local/workspace-built-content.d.ts +137 -0
  397. package/dist/local/workspace-built-content.d.ts.map +1 -0
  398. package/dist/local/workspace-built-content.js +393 -0
  399. package/dist/local/workspace-built-content.js.map +1 -0
  400. package/dist/local/workspace-claim-status-read.d.ts +53 -0
  401. package/dist/local/workspace-claim-status-read.d.ts.map +1 -0
  402. package/dist/local/workspace-claim-status-read.js +118 -0
  403. package/dist/local/workspace-claim-status-read.js.map +1 -0
  404. package/dist/local/workspace-claim-status.d.ts +172 -0
  405. package/dist/local/workspace-claim-status.d.ts.map +1 -0
  406. package/dist/local/workspace-claim-status.js +721 -0
  407. package/dist/local/workspace-claim-status.js.map +1 -0
  408. package/dist/local/workspace-claim-views.d.ts +45 -0
  409. package/dist/local/workspace-claim-views.d.ts.map +1 -0
  410. package/dist/local/workspace-claim-views.js +45 -0
  411. package/dist/local/workspace-claim-views.js.map +1 -0
  412. package/dist/local/workspace-cli.d.ts +46 -0
  413. package/dist/local/workspace-cli.d.ts.map +1 -0
  414. package/dist/local/workspace-cli.js +1524 -0
  415. package/dist/local/workspace-cli.js.map +1 -0
  416. package/dist/local/workspace-commit-resolver.d.ts +19 -0
  417. package/dist/local/workspace-commit-resolver.d.ts.map +1 -0
  418. package/dist/local/workspace-commit-resolver.js +47 -0
  419. package/dist/local/workspace-commit-resolver.js.map +1 -0
  420. package/dist/local/workspace-decision-store.d.ts +184 -0
  421. package/dist/local/workspace-decision-store.d.ts.map +1 -0
  422. package/dist/local/workspace-decision-store.js +510 -0
  423. package/dist/local/workspace-decision-store.js.map +1 -0
  424. package/dist/local/workspace-environment-runtime.d.ts +107 -0
  425. package/dist/local/workspace-environment-runtime.d.ts.map +1 -0
  426. package/dist/local/workspace-environment-runtime.js +135 -0
  427. package/dist/local/workspace-environment-runtime.js.map +1 -0
  428. package/dist/local/workspace-evidence-drop.d.ts +21 -0
  429. package/dist/local/workspace-evidence-drop.d.ts.map +1 -0
  430. package/dist/local/workspace-evidence-drop.js +58 -0
  431. package/dist/local/workspace-evidence-drop.js.map +1 -0
  432. package/dist/local/workspace-evidence-sign-tool.d.ts +20 -0
  433. package/dist/local/workspace-evidence-sign-tool.d.ts.map +1 -0
  434. package/dist/local/workspace-evidence-sign-tool.js +85 -0
  435. package/dist/local/workspace-evidence-sign-tool.js.map +1 -0
  436. package/dist/local/workspace-evidence-status.d.ts +89 -0
  437. package/dist/local/workspace-evidence-status.d.ts.map +1 -0
  438. package/dist/local/workspace-evidence-status.js +141 -0
  439. package/dist/local/workspace-evidence-status.js.map +1 -0
  440. package/dist/local/workspace-evidence.d.ts +145 -0
  441. package/dist/local/workspace-evidence.d.ts.map +1 -0
  442. package/dist/local/workspace-evidence.js +347 -0
  443. package/dist/local/workspace-evidence.js.map +1 -0
  444. package/dist/local/workspace-graph-store.d.ts +32 -0
  445. package/dist/local/workspace-graph-store.d.ts.map +1 -0
  446. package/dist/local/workspace-graph-store.js +249 -0
  447. package/dist/local/workspace-graph-store.js.map +1 -0
  448. package/dist/local/workspace-handoff.d.ts +32 -0
  449. package/dist/local/workspace-handoff.d.ts.map +1 -0
  450. package/dist/local/workspace-handoff.js +144 -0
  451. package/dist/local/workspace-handoff.js.map +1 -0
  452. package/dist/local/workspace-history-journal.d.ts +70 -0
  453. package/dist/local/workspace-history-journal.d.ts.map +1 -0
  454. package/dist/local/workspace-history-journal.js +131 -0
  455. package/dist/local/workspace-history-journal.js.map +1 -0
  456. package/dist/local/workspace-history-store.d.ts +98 -0
  457. package/dist/local/workspace-history-store.d.ts.map +1 -0
  458. package/dist/local/workspace-history-store.js +632 -0
  459. package/dist/local/workspace-history-store.js.map +1 -0
  460. package/dist/local/workspace-history-types.d.ts +307 -0
  461. package/dist/local/workspace-history-types.d.ts.map +1 -0
  462. package/dist/local/workspace-history-types.js +2 -0
  463. package/dist/local/workspace-history-types.js.map +1 -0
  464. package/dist/local/workspace-integration-runtime.d.ts +48 -0
  465. package/dist/local/workspace-integration-runtime.d.ts.map +1 -0
  466. package/dist/local/workspace-integration-runtime.js +419 -0
  467. package/dist/local/workspace-integration-runtime.js.map +1 -0
  468. package/dist/local/workspace-lock.d.ts +7 -0
  469. package/dist/local/workspace-lock.d.ts.map +1 -0
  470. package/dist/local/workspace-lock.js +211 -0
  471. package/dist/local/workspace-lock.js.map +1 -0
  472. package/dist/local/workspace-merge.d.ts +77 -0
  473. package/dist/local/workspace-merge.d.ts.map +1 -0
  474. package/dist/local/workspace-merge.js +703 -0
  475. package/dist/local/workspace-merge.js.map +1 -0
  476. package/dist/local/workspace-mixed-history.d.ts +33 -0
  477. package/dist/local/workspace-mixed-history.d.ts.map +1 -0
  478. package/dist/local/workspace-mixed-history.js +107 -0
  479. package/dist/local/workspace-mixed-history.js.map +1 -0
  480. package/dist/local/workspace-overlap-allocation.d.ts +33 -0
  481. package/dist/local/workspace-overlap-allocation.d.ts.map +1 -0
  482. package/dist/local/workspace-overlap-allocation.js +69 -0
  483. package/dist/local/workspace-overlap-allocation.js.map +1 -0
  484. package/dist/local/workspace-overlap-impact.d.ts +46 -0
  485. package/dist/local/workspace-overlap-impact.d.ts.map +1 -0
  486. package/dist/local/workspace-overlap-impact.js +162 -0
  487. package/dist/local/workspace-overlap-impact.js.map +1 -0
  488. package/dist/local/workspace-overlap.d.ts +109 -0
  489. package/dist/local/workspace-overlap.d.ts.map +1 -0
  490. package/dist/local/workspace-overlap.js +327 -0
  491. package/dist/local/workspace-overlap.js.map +1 -0
  492. package/dist/local/workspace-paths.d.ts +4 -0
  493. package/dist/local/workspace-paths.d.ts.map +1 -0
  494. package/dist/local/workspace-paths.js +8 -0
  495. package/dist/local/workspace-paths.js.map +1 -0
  496. package/dist/local/workspace-pick-runtime.d.ts +70 -0
  497. package/dist/local/workspace-pick-runtime.d.ts.map +1 -0
  498. package/dist/local/workspace-pick-runtime.js +177 -0
  499. package/dist/local/workspace-pick-runtime.js.map +1 -0
  500. package/dist/local/workspace-pick-store.d.ts +33 -0
  501. package/dist/local/workspace-pick-store.d.ts.map +1 -0
  502. package/dist/local/workspace-pick-store.js +43 -0
  503. package/dist/local/workspace-pick-store.js.map +1 -0
  504. package/dist/local/workspace-pick.d.ts +73 -0
  505. package/dist/local/workspace-pick.d.ts.map +1 -0
  506. package/dist/local/workspace-pick.js +253 -0
  507. package/dist/local/workspace-pick.js.map +1 -0
  508. package/dist/local/workspace-portable-authoring.d.ts +43 -0
  509. package/dist/local/workspace-portable-authoring.d.ts.map +1 -0
  510. package/dist/local/workspace-portable-authoring.js +128 -0
  511. package/dist/local/workspace-portable-authoring.js.map +1 -0
  512. package/dist/local/workspace-prune.d.ts +63 -0
  513. package/dist/local/workspace-prune.d.ts.map +1 -0
  514. package/dist/local/workspace-prune.js +267 -0
  515. package/dist/local/workspace-prune.js.map +1 -0
  516. package/dist/local/workspace-remote-fetch.d.ts +82 -0
  517. package/dist/local/workspace-remote-fetch.d.ts.map +1 -0
  518. package/dist/local/workspace-remote-fetch.js +409 -0
  519. package/dist/local/workspace-remote-fetch.js.map +1 -0
  520. package/dist/local/workspace-remote-provider.d.ts +97 -0
  521. package/dist/local/workspace-remote-provider.d.ts.map +1 -0
  522. package/dist/local/workspace-remote-provider.js +400 -0
  523. package/dist/local/workspace-remote-provider.js.map +1 -0
  524. package/dist/local/workspace-remote-pull-request-journal.d.ts +49 -0
  525. package/dist/local/workspace-remote-pull-request-journal.d.ts.map +1 -0
  526. package/dist/local/workspace-remote-pull-request-journal.js +63 -0
  527. package/dist/local/workspace-remote-pull-request-journal.js.map +1 -0
  528. package/dist/local/workspace-remote-pull-request.d.ts +36 -0
  529. package/dist/local/workspace-remote-pull-request.d.ts.map +1 -0
  530. package/dist/local/workspace-remote-pull-request.js +158 -0
  531. package/dist/local/workspace-remote-pull-request.js.map +1 -0
  532. package/dist/local/workspace-remote-push.d.ts +88 -0
  533. package/dist/local/workspace-remote-push.d.ts.map +1 -0
  534. package/dist/local/workspace-remote-push.js +297 -0
  535. package/dist/local/workspace-remote-push.js.map +1 -0
  536. package/dist/local/workspace-remote-topic-journal.d.ts +56 -0
  537. package/dist/local/workspace-remote-topic-journal.d.ts.map +1 -0
  538. package/dist/local/workspace-remote-topic-journal.js +121 -0
  539. package/dist/local/workspace-remote-topic-journal.js.map +1 -0
  540. package/dist/local/workspace-remote-topic.d.ts +45 -0
  541. package/dist/local/workspace-remote-topic.d.ts.map +1 -0
  542. package/dist/local/workspace-remote-topic.js +204 -0
  543. package/dist/local/workspace-remote-topic.js.map +1 -0
  544. package/dist/local/workspace-remote-transfer.d.ts +76 -0
  545. package/dist/local/workspace-remote-transfer.d.ts.map +1 -0
  546. package/dist/local/workspace-remote-transfer.js +270 -0
  547. package/dist/local/workspace-remote-transfer.js.map +1 -0
  548. package/dist/local/workspace-resolution.d.ts +145 -0
  549. package/dist/local/workspace-resolution.d.ts.map +1 -0
  550. package/dist/local/workspace-resolution.js +479 -0
  551. package/dist/local/workspace-resolution.js.map +1 -0
  552. package/dist/local/workspace-resolver-provider.d.ts +72 -0
  553. package/dist/local/workspace-resolver-provider.d.ts.map +1 -0
  554. package/dist/local/workspace-resolver-provider.js +312 -0
  555. package/dist/local/workspace-resolver-provider.js.map +1 -0
  556. package/dist/local/workspace-runtime-handoff.d.ts +52 -0
  557. package/dist/local/workspace-runtime-handoff.d.ts.map +1 -0
  558. package/dist/local/workspace-runtime-handoff.js +237 -0
  559. package/dist/local/workspace-runtime-handoff.js.map +1 -0
  560. package/dist/local/workspace-runtime-lease.d.ts +26 -0
  561. package/dist/local/workspace-runtime-lease.d.ts.map +1 -0
  562. package/dist/local/workspace-runtime-lease.js +123 -0
  563. package/dist/local/workspace-runtime-lease.js.map +1 -0
  564. package/dist/local/workspace-runtime.d.ts +690 -0
  565. package/dist/local/workspace-runtime.d.ts.map +1 -0
  566. package/dist/local/workspace-runtime.js +2124 -0
  567. package/dist/local/workspace-runtime.js.map +1 -0
  568. package/dist/local/workspace-scope.d.ts +70 -0
  569. package/dist/local/workspace-scope.d.ts.map +1 -0
  570. package/dist/local/workspace-scope.js +206 -0
  571. package/dist/local/workspace-scope.js.map +1 -0
  572. package/dist/local/workspace-sources.d.ts +159 -0
  573. package/dist/local/workspace-sources.d.ts.map +1 -0
  574. package/dist/local/workspace-sources.js +570 -0
  575. package/dist/local/workspace-sources.js.map +1 -0
  576. package/dist/local/workspace-store-database.d.ts +5 -0
  577. package/dist/local/workspace-store-database.d.ts.map +1 -0
  578. package/dist/local/workspace-store-database.js +726 -0
  579. package/dist/local/workspace-store-database.js.map +1 -0
  580. package/dist/local/workspace-store.d.ts +261 -0
  581. package/dist/local/workspace-store.d.ts.map +1 -0
  582. package/dist/local/workspace-store.js +831 -0
  583. package/dist/local/workspace-store.js.map +1 -0
  584. package/dist/local/workspace-topology-runtime.d.ts +27 -0
  585. package/dist/local/workspace-topology-runtime.d.ts.map +1 -0
  586. package/dist/local/workspace-topology-runtime.js +396 -0
  587. package/dist/local/workspace-topology-runtime.js.map +1 -0
  588. package/dist/local/workspace-topology.d.ts +140 -0
  589. package/dist/local/workspace-topology.d.ts.map +1 -0
  590. package/dist/local/workspace-topology.js +359 -0
  591. package/dist/local/workspace-topology.js.map +1 -0
  592. package/dist/local/workspace-upstream-inspection.d.ts +60 -0
  593. package/dist/local/workspace-upstream-inspection.d.ts.map +1 -0
  594. package/dist/local/workspace-upstream-inspection.js +189 -0
  595. package/dist/local/workspace-upstream-inspection.js.map +1 -0
  596. package/dist/local/workspace-upstream-runtime.d.ts +91 -0
  597. package/dist/local/workspace-upstream-runtime.d.ts.map +1 -0
  598. package/dist/local/workspace-upstream-runtime.js +270 -0
  599. package/dist/local/workspace-upstream-runtime.js.map +1 -0
  600. package/dist/local/workspace-upstream-store.d.ts +51 -0
  601. package/dist/local/workspace-upstream-store.d.ts.map +1 -0
  602. package/dist/local/workspace-upstream-store.js +475 -0
  603. package/dist/local/workspace-upstream-store.js.map +1 -0
  604. package/dist/local/workspace-viewer-server.d.ts +136 -0
  605. package/dist/local/workspace-viewer-server.d.ts.map +1 -0
  606. package/dist/local/workspace-viewer-server.js +1097 -0
  607. package/dist/local/workspace-viewer-server.js.map +1 -0
  608. package/dist/local/workspace-viewer-snapshot.d.ts +49 -0
  609. package/dist/local/workspace-viewer-snapshot.d.ts.map +1 -0
  610. package/dist/local/workspace-viewer-snapshot.js +91 -0
  611. package/dist/local/workspace-viewer-snapshot.js.map +1 -0
  612. package/dist/local/worktree-projection.d.ts +76 -0
  613. package/dist/local/worktree-projection.d.ts.map +1 -0
  614. package/dist/local/worktree-projection.js +470 -0
  615. package/dist/local/worktree-projection.js.map +1 -0
  616. package/dist/mcp/client-identity.d.ts +8 -0
  617. package/dist/mcp/client-identity.d.ts.map +1 -0
  618. package/dist/mcp/client-identity.js +33 -0
  619. package/dist/mcp/client-identity.js.map +1 -0
  620. package/dist/mcp/graph-to-code.d.ts +53 -0
  621. package/dist/mcp/graph-to-code.d.ts.map +1 -0
  622. package/dist/mcp/graph-to-code.js +1624 -0
  623. package/dist/mcp/graph-to-code.js.map +1 -0
  624. package/dist/mcp/index.d.ts +3 -0
  625. package/dist/mcp/index.d.ts.map +1 -0
  626. package/dist/mcp/index.js +3 -0
  627. package/dist/mcp/index.js.map +1 -0
  628. package/dist/mcp/stdio/graph-to-code.d.ts +3 -0
  629. package/dist/mcp/stdio/graph-to-code.d.ts.map +1 -0
  630. package/dist/mcp/stdio/graph-to-code.js +55 -0
  631. package/dist/mcp/stdio/graph-to-code.js.map +1 -0
  632. package/dist/mcp/stdio/worktree.d.ts +3 -0
  633. package/dist/mcp/stdio/worktree.d.ts.map +1 -0
  634. package/dist/mcp/stdio/worktree.js +67 -0
  635. package/dist/mcp/stdio/worktree.js.map +1 -0
  636. package/dist/mcp/worktree-claim-status.d.ts +162 -0
  637. package/dist/mcp/worktree-claim-status.d.ts.map +1 -0
  638. package/dist/mcp/worktree-claim-status.js +113 -0
  639. package/dist/mcp/worktree-claim-status.js.map +1 -0
  640. package/dist/mcp/worktree-dispatch.d.ts +13 -0
  641. package/dist/mcp/worktree-dispatch.d.ts.map +1 -0
  642. package/dist/mcp/worktree-dispatch.js +52 -0
  643. package/dist/mcp/worktree-dispatch.js.map +1 -0
  644. package/dist/mcp/worktree-errors.d.ts +15 -0
  645. package/dist/mcp/worktree-errors.d.ts.map +1 -0
  646. package/dist/mcp/worktree-errors.js +17 -0
  647. package/dist/mcp/worktree-errors.js.map +1 -0
  648. package/dist/mcp/worktree-health.d.ts +12 -0
  649. package/dist/mcp/worktree-health.d.ts.map +1 -0
  650. package/dist/mcp/worktree-health.js +32 -0
  651. package/dist/mcp/worktree-health.js.map +1 -0
  652. package/dist/mcp/worktree-results.d.ts +15 -0
  653. package/dist/mcp/worktree-results.d.ts.map +1 -0
  654. package/dist/mcp/worktree-results.js +12 -0
  655. package/dist/mcp/worktree-results.js.map +1 -0
  656. package/dist/mcp/worktree-task-context.d.ts +57 -0
  657. package/dist/mcp/worktree-task-context.d.ts.map +1 -0
  658. package/dist/mcp/worktree-task-context.js +45 -0
  659. package/dist/mcp/worktree-task-context.js.map +1 -0
  660. package/dist/mcp/worktree-tools.d.ts +2648 -0
  661. package/dist/mcp/worktree-tools.d.ts.map +1 -0
  662. package/dist/mcp/worktree-tools.js +192 -0
  663. package/dist/mcp/worktree-tools.js.map +1 -0
  664. package/dist/mcp/worktree.d.ts +33 -0
  665. package/dist/mcp/worktree.d.ts.map +1 -0
  666. package/dist/mcp/worktree.js +551 -0
  667. package/dist/mcp/worktree.js.map +1 -0
  668. package/dist/own-package.d.ts +13 -0
  669. package/dist/own-package.d.ts.map +1 -0
  670. package/dist/own-package.js +32 -0
  671. package/dist/own-package.js.map +1 -0
  672. package/dist/packages-browse.d.ts +107 -0
  673. package/dist/packages-browse.d.ts.map +1 -0
  674. package/dist/packages-browse.js +646 -0
  675. package/dist/packages-browse.js.map +1 -0
  676. package/dist/packages-cli.d.ts +8 -0
  677. package/dist/packages-cli.d.ts.map +1 -0
  678. package/dist/packages-cli.js +184 -0
  679. package/dist/packages-cli.js.map +1 -0
  680. package/dist/packages-uses.d.ts +46 -0
  681. package/dist/packages-uses.d.ts.map +1 -0
  682. package/dist/packages-uses.js +737 -0
  683. package/dist/packages-uses.js.map +1 -0
  684. package/dist/portable.d.ts +7 -0
  685. package/dist/portable.d.ts.map +1 -0
  686. package/dist/portable.js +14 -0
  687. package/dist/portable.js.map +1 -0
  688. package/dist/quiet-warnings.d.ts +3 -0
  689. package/dist/quiet-warnings.d.ts.map +1 -0
  690. package/dist/quiet-warnings.js +21 -0
  691. package/dist/quiet-warnings.js.map +1 -0
  692. package/dist/view-seam.d.ts +62 -0
  693. package/dist/view-seam.d.ts.map +1 -0
  694. package/dist/view-seam.js +70 -0
  695. package/dist/view-seam.js.map +1 -0
  696. package/generated/graph-packages/index.json +5 -0
  697. package/graph-packages.lock.json +4 -0
  698. package/package.json +81 -0
  699. package/viewer/assets/index-BZKGDARF.css +1 -0
  700. package/viewer/assets/index-DWu0CbZZ.js +272 -0
  701. package/viewer/index.html +13 -0
@@ -0,0 +1,831 @@
1
+ import { randomUUID } from 'node:crypto';
2
+ import { isAbsolute, join, resolve } from 'node:path';
3
+ import { openLocalWorkspaceStoreDatabase } from './workspace-store-database.js';
4
+ import { LocalWorkspaceHistoryStore } from './workspace-history-store.js';
5
+ import { LocalPortableCommitStore } from './portable-commit-store.js';
6
+ import { parsePortableCommit } from './portable-commit.js';
7
+ import { LocalRemoteTrackingStore } from './workspace-remote-fetch.js';
8
+ import { LocalRemotePushJournalStore } from './workspace-remote-push.js';
9
+ import { LocalRemoteTopicJournalStore } from './workspace-remote-topic-journal.js';
10
+ import { LocalRemotePullRequestJournalStore } from './workspace-remote-pull-request-journal.js';
11
+ import { LocalDecisionStore } from './workspace-decision-store.js';
12
+ import { LocalPickStore } from './workspace-pick-store.js';
13
+ import { LocalBuiltContentStore } from './workspace-built-content.js';
14
+ import { LocalVocabularyAdmissionStore } from './workspace-admission.js';
15
+ import { LocalOrgStore } from './local-org-store.js';
16
+ import { requireMutableLocalBranchRef } from './git-ref-authority.js';
17
+ import { assertTaskScopeSubset, local_workspace_task_scope_schema } from './workspace-scope.js';
18
+ function requireValue(value, label) {
19
+ const normalized_value = value.trim();
20
+ if (normalized_value.length === 0) {
21
+ throw new Error(`${label} must not be empty.`);
22
+ }
23
+ return normalized_value;
24
+ }
25
+ function requireAbsolutePath(path, label) {
26
+ if (!isAbsolute(path)) {
27
+ throw new Error(`${label} must be an absolute path.`);
28
+ }
29
+ return resolve(path);
30
+ }
31
+ function assertPersistedRefAuthority(database) {
32
+ const rows = database
33
+ .prepare(`
34
+ select ref_name from local_workspace_ref
35
+ union
36
+ select attached_ref as ref_name from local_workspace
37
+ where attached_ref is not null
38
+ `)
39
+ .all();
40
+ for (const row of rows) {
41
+ requireMutableLocalBranchRef(row.ref_name, 'Persisted workspace ref');
42
+ }
43
+ const associations = database
44
+ .prepare('select local_ref, git_ref from local_branch_association')
45
+ .all();
46
+ for (const association of associations) {
47
+ requireMutableLocalBranchRef(association.local_ref, 'Persisted local SDLC branch ref');
48
+ requireMutableLocalBranchRef(association.git_ref, 'Persisted associated Git branch ref');
49
+ }
50
+ }
51
+ function backfillLocalBranchAssociations(database) {
52
+ const now = new Date().toISOString();
53
+ database
54
+ .prepare(`
55
+ insert into local_branch_association (
56
+ local_ref, git_ref, upstream_remote_name, upstream_source_ref,
57
+ upstream_tracking_ref, base_portable_commit_id, created_at, updated_at
58
+ )
59
+ select ref_name, ref_name, null, null, null, null, ?, ?
60
+ from local_workspace_ref
61
+ where not exists (
62
+ select 1 from local_branch_association
63
+ where local_branch_association.local_ref = local_workspace_ref.ref_name
64
+ )
65
+ and not exists (
66
+ select 1 from local_branch_association
67
+ where local_branch_association.git_ref = local_workspace_ref.ref_name
68
+ )
69
+ `)
70
+ .run(now, now);
71
+ }
72
+ export class LocalWorkspaceStore {
73
+ state_dir;
74
+ database_path;
75
+ repository;
76
+ history;
77
+ portable_commits;
78
+ remote_tracking;
79
+ remote_push;
80
+ remote_topic;
81
+ remote_pull_request;
82
+ decisions;
83
+ picks;
84
+ built_content;
85
+ admissions;
86
+ org;
87
+ database;
88
+ constructor(input) {
89
+ this.state_dir = input.state_dir;
90
+ this.database_path = join(input.state_dir, 'repository.sqlite');
91
+ this.database = input.database;
92
+ this.repository = input.repository;
93
+ this.history = new LocalWorkspaceHistoryStore(input.database);
94
+ this.portable_commits = new LocalPortableCommitStore(input.database, this.history);
95
+ this.remote_tracking = new LocalRemoteTrackingStore(input.database, this.portable_commits);
96
+ this.remote_push = new LocalRemotePushJournalStore(input.database);
97
+ this.remote_topic = new LocalRemoteTopicJournalStore(input.database);
98
+ this.remote_pull_request = new LocalRemotePullRequestJournalStore(input.database);
99
+ this.picks = new LocalPickStore(input.database);
100
+ this.built_content = new LocalBuiltContentStore(input.database);
101
+ this.admissions = new LocalVocabularyAdmissionStore(input.database);
102
+ this.org = new LocalOrgStore(input.database);
103
+ this.decisions = new LocalDecisionStore(input.database, {
104
+ picks: this.picks,
105
+ isAncestor: (ancestor_id, descendant_id) => this.history.isAncestor(ancestor_id, descendant_id)
106
+ });
107
+ }
108
+ static async open(input) {
109
+ const state_dir = requireAbsolutePath(input.state_dir, 'State directory');
110
+ const git_common_dir = requireAbsolutePath(input.git_common_dir, 'Git common directory');
111
+ const database = await openLocalWorkspaceStoreDatabase(state_dir);
112
+ const proposed_repository = {
113
+ repository_id: randomUUID(),
114
+ git_common_dir,
115
+ schema_version: 1,
116
+ created_at: new Date().toISOString()
117
+ };
118
+ database
119
+ .prepare(`
120
+ insert into local_repository (
121
+ singleton, repository_id, git_common_dir, schema_version,
122
+ created_at
123
+ ) values (1, ?, ?, ?, ?)
124
+ on conflict(singleton) do nothing
125
+ `)
126
+ .run(proposed_repository.repository_id, proposed_repository.git_common_dir, proposed_repository.schema_version, proposed_repository.created_at);
127
+ const repository = database
128
+ .prepare('select * from local_repository where singleton = 1')
129
+ .get();
130
+ if (input.expected_repository_id &&
131
+ repository.repository_id !== input.expected_repository_id) {
132
+ database.close();
133
+ throw new Error('Logical graph repository identity does not match.');
134
+ }
135
+ if (repository.git_common_dir !== git_common_dir &&
136
+ !input.expected_repository_id) {
137
+ database.close();
138
+ throw new Error('Local workspace store belongs to another Git repository; cross-repository access requires its exact graph repository id.');
139
+ }
140
+ backfillLocalBranchAssociations(database);
141
+ try {
142
+ assertPersistedRefAuthority(database);
143
+ }
144
+ catch (error) {
145
+ database.close();
146
+ throw error;
147
+ }
148
+ try {
149
+ return new LocalWorkspaceStore({ state_dir, database, repository });
150
+ }
151
+ catch (error) {
152
+ database.close();
153
+ throw error;
154
+ }
155
+ }
156
+ close() {
157
+ this.database.close();
158
+ }
159
+ checkpoint() {
160
+ this.database.exec('pragma wal_checkpoint(TRUNCATE)');
161
+ }
162
+ runTransaction(operation) {
163
+ this.database.exec('begin immediate');
164
+ try {
165
+ const result = operation();
166
+ this.database.exec('commit');
167
+ return result;
168
+ }
169
+ catch (error) {
170
+ this.database.exec('rollback');
171
+ throw error;
172
+ }
173
+ }
174
+ getSourceRepositoryBinding(git_common_dir) {
175
+ const path = requireAbsolutePath(git_common_dir, 'Git common directory');
176
+ return (this.database
177
+ .prepare('select * from local_source_repository_binding where git_common_dir = ?')
178
+ .get(path) ?? null);
179
+ }
180
+ /** A binding of the source association in this graph, from any repository. */
181
+ getSourceAssociationBinding(source_repository_association_id) {
182
+ return (this.database
183
+ .prepare(`select * from local_source_repository_binding
184
+ where repository_id = ? and source_repository_association_id = ?
185
+ limit 1`)
186
+ .get(this.repository.repository_id, source_repository_association_id) ?? null);
187
+ }
188
+ bindSourceRepository(input) {
189
+ const git_common_dir = requireAbsolutePath(input.git_common_dir, 'Git common directory');
190
+ const association_id = requireValue(input.source_repository_association_id, 'Source repository association id');
191
+ const remote_name = requireValue(input.remote_name, 'Git remote name');
192
+ const remote_url = requireValue(input.remote_url, 'Git remote URL');
193
+ const remote_identity = requireValue(input.remote_identity, 'Git remote identity');
194
+ return this.runTransaction(() => {
195
+ const existing = this.getSourceRepositoryBinding(git_common_dir);
196
+ if (existing) {
197
+ if (existing.source_repository_association_id !== association_id ||
198
+ existing.remote_name !== remote_name ||
199
+ existing.remote_identity !== remote_identity) {
200
+ throw new Error('Current Git repository already has a different source-association binding.');
201
+ }
202
+ return existing;
203
+ }
204
+ const association_binding = this.getSourceAssociationBinding(association_id);
205
+ if (association_binding &&
206
+ association_binding.remote_identity !== remote_identity) {
207
+ throw new Error('Source association is already bound to a different Git repository identity.');
208
+ }
209
+ const now = new Date().toISOString();
210
+ this.database
211
+ .prepare(`insert into local_source_repository_binding (
212
+ git_common_dir, repository_id, source_repository_association_id,
213
+ remote_name, remote_url, remote_identity, created_at, updated_at
214
+ ) values (?, ?, ?, ?, ?, ?, ?, ?)`)
215
+ .run(git_common_dir, this.repository.repository_id, association_id, remote_name, remote_url, remote_identity, now, now);
216
+ return this.getSourceRepositoryBinding(git_common_dir);
217
+ });
218
+ }
219
+ /**
220
+ * Moves a repository's binding from `expected_remote_name` to another
221
+ * remote, keeping its association. Returns null, changing nothing, when the
222
+ * binding is gone or moved, or another repository binds the association
223
+ * under a different identity.
224
+ */
225
+ rebindSourceRepositoryRemote(input) {
226
+ const git_common_dir = requireAbsolutePath(input.git_common_dir, 'Git common directory');
227
+ const remote_name = requireValue(input.remote_name, 'Git remote name');
228
+ const remote_url = requireValue(input.remote_url, 'Git remote URL');
229
+ const remote_identity = requireValue(input.remote_identity, 'Git remote identity');
230
+ return this.runTransaction(() => {
231
+ const existing = this.getSourceRepositoryBinding(git_common_dir);
232
+ if (!existing || existing.remote_name !== input.expected_remote_name) {
233
+ return null;
234
+ }
235
+ const held = this.database
236
+ .prepare(`select 1 from local_source_repository_binding
237
+ where repository_id = ? and source_repository_association_id = ?
238
+ and git_common_dir <> ? and remote_identity <> ?
239
+ limit 1`)
240
+ .get(this.repository.repository_id, existing.source_repository_association_id, git_common_dir, remote_identity);
241
+ if (held)
242
+ return null;
243
+ this.database
244
+ .prepare(`update local_source_repository_binding
245
+ set remote_name = ?, remote_url = ?, remote_identity = ?,
246
+ moved_from_remote_identity = ?, updated_at = ?
247
+ where git_common_dir = ?`)
248
+ .run(remote_name, remote_url, remote_identity, existing.remote_identity, new Date().toISOString(), git_common_dir);
249
+ return this.getSourceRepositoryBinding(git_common_dir);
250
+ });
251
+ }
252
+ unbindSourceRepository(input) {
253
+ const git_common_dir = requireAbsolutePath(input.git_common_dir, 'Git common directory');
254
+ return this.runTransaction(() => {
255
+ const binding = this.getSourceRepositoryBinding(git_common_dir);
256
+ if (!binding)
257
+ throw new Error('Source repository binding was not found.');
258
+ if (binding.source_repository_association_id !==
259
+ input.expected_source_repository_association_id) {
260
+ throw new Error('Source repository binding identity changed.');
261
+ }
262
+ const row = this.database
263
+ .prepare(`select count(*) as count from local_workspace
264
+ where git_common_dir = ? and status = 'active'`)
265
+ .get(git_common_dir);
266
+ if (row.count > 0) {
267
+ return { removed: false, binding, active_workspace_count: row.count };
268
+ }
269
+ this.database
270
+ .prepare(`delete from local_source_repository_binding
271
+ where git_common_dir = ? and source_repository_association_id = ?`)
272
+ .run(git_common_dir, input.expected_source_repository_association_id);
273
+ return { removed: true, binding, active_workspace_count: 0 };
274
+ });
275
+ }
276
+ getWorkspaceCommitSourceContext(commit_id) {
277
+ const row = this.database
278
+ .prepare('select * from local_workspace_commit_source_context where commit_id = ?')
279
+ .get(commit_id);
280
+ if (!row)
281
+ return null;
282
+ const parsed = JSON.parse(row.evidence_scope_json);
283
+ return {
284
+ commit_id: row.commit_id,
285
+ source_repository_association_id: row.source_repository_association_id,
286
+ remote_identity: row.remote_identity,
287
+ git_ref: row.git_ref,
288
+ git_head: row.git_head,
289
+ evidence_scope: parsed,
290
+ created_at: row.created_at
291
+ };
292
+ }
293
+ getWorkspace(workspace_id) {
294
+ return (this.database
295
+ .prepare('select * from local_workspace where id = ?')
296
+ .get(workspace_id) ?? null);
297
+ }
298
+ getWorkspaceByGitWorktreePath(git_worktree_path) {
299
+ const normalized_path = requireAbsolutePath(git_worktree_path, 'Git worktree path');
300
+ return (this.database
301
+ .prepare('select * from local_workspace where git_worktree_path = ?')
302
+ .get(normalized_path) ?? null);
303
+ }
304
+ listWorkspaces() {
305
+ return this.database
306
+ .prepare('select * from local_workspace order by created_at asc, id asc')
307
+ .all();
308
+ }
309
+ listChildWorkspaces(source_workspace_id) {
310
+ return this.database
311
+ .prepare(`
312
+ select * from local_workspace
313
+ where source_workspace_id = ?
314
+ order by created_at asc, id asc
315
+ `)
316
+ .all(source_workspace_id);
317
+ }
318
+ listRetainedGraphRootHashes() {
319
+ const direct_roots = this.database
320
+ .prepare(`
321
+ select root_hash from local_workspace_commit
322
+ union select base_root_hash from local_integration_attempt
323
+ union select coordinator_root_hash from local_integration_attempt
324
+ union select child_root_hash from local_integration_attempt
325
+ union select candidate_root_hash from local_resolution_attempt
326
+ where candidate_root_hash is not null
327
+ union select base_root_hash from local_reconciliation_attempt
328
+ union select child_root_hash from local_reconciliation_attempt
329
+ union select source_root_hash from local_reconciliation_attempt
330
+ union select candidate_root_hash
331
+ from local_reconciliation_resolution_attempt
332
+ where candidate_root_hash is not null
333
+ union select root_hash from local_governance_graph
334
+ `)
335
+ .all();
336
+ const retained_commit_or_root_ids = this.database
337
+ .prepare(`
338
+ select fork_sdlc_commit_id as id from local_workspace
339
+ union select head_sdlc_commit_id from local_workspace
340
+ union select head_commit_id from local_workspace_ref
341
+ `)
342
+ .all();
343
+ const local_commit_roots = new Map(this.database
344
+ .prepare('select id, root_hash from local_workspace_commit')
345
+ .all().map((commit) => [commit.id, commit.root_hash]));
346
+ const portable_commits = this.database
347
+ .prepare('select commit_json from portable_commit order by id')
348
+ .all().map((row) => parsePortableCommit(JSON.parse(row.commit_json)));
349
+ const portable_commit_roots = new Map(portable_commits.map((commit) => [commit.id, commit.graph_root]));
350
+ const retained_workspace_roots = retained_commit_or_root_ids.map(({ id }) => local_commit_roots.get(id) ?? portable_commit_roots.get(id) ?? id);
351
+ return [
352
+ ...direct_roots.map((row) => row.root_hash),
353
+ ...portable_commits.map((commit) => commit.graph_root),
354
+ ...retained_workspace_roots
355
+ ]
356
+ .filter((root_hash) => /^sha256:[0-9a-f]{64}$/.test(root_hash))
357
+ .filter((root_hash, index, values) => values.indexOf(root_hash) === index)
358
+ .sort((left, right) => left.localeCompare(right));
359
+ }
360
+ getWorkspaceTaskScope(workspace_id) {
361
+ const row = this.database
362
+ .prepare('select scope_json from local_workspace_task_scope where workspace_id = ?')
363
+ .get(workspace_id);
364
+ if (!row)
365
+ return null;
366
+ return local_workspace_task_scope_schema.parse(JSON.parse(row.scope_json));
367
+ }
368
+ /** Records that the next projection commit deletes this entity on purpose. */
369
+ recordWorkspaceDeletion(input) {
370
+ this.requireActiveWorkspace(input.workspace_id);
371
+ this.database
372
+ .prepare(`
373
+ insert into local_workspace_deletion_intent (
374
+ workspace_id, entity_kind, entity_id, recorded_at
375
+ ) values (?, ?, ?, ?)
376
+ on conflict (workspace_id, entity_kind, entity_id) do nothing
377
+ `)
378
+ .run(input.workspace_id, input.entity_kind, input.entity_id, new Date().toISOString());
379
+ }
380
+ listWorkspaceDeletions(workspace_id) {
381
+ return this.database
382
+ .prepare(`
383
+ select entity_kind, entity_id from local_workspace_deletion_intent
384
+ where workspace_id = ?
385
+ order by entity_kind asc, entity_id asc
386
+ `)
387
+ .all(workspace_id);
388
+ }
389
+ clearWorkspaceDeletions(workspace_id) {
390
+ this.database
391
+ .prepare('delete from local_workspace_deletion_intent where workspace_id = ?')
392
+ .run(workspace_id);
393
+ }
394
+ getRef(ref_name) {
395
+ const local_ref = requireMutableLocalBranchRef(ref_name, 'Workspace ref lookup');
396
+ return (this.database
397
+ .prepare('select * from local_workspace_ref where ref_name = ?')
398
+ .get(local_ref) ?? null);
399
+ }
400
+ getBranchAssociation(local_ref) {
401
+ const ref = requireMutableLocalBranchRef(local_ref, 'Local SDLC branch ref');
402
+ return (this.database
403
+ .prepare('select * from local_branch_association where local_ref = ?')
404
+ .get(ref) ?? null);
405
+ }
406
+ getBranchAssociationByGitRef(git_ref) {
407
+ const ref = requireMutableLocalBranchRef(git_ref, 'Associated Git branch ref');
408
+ return (this.database
409
+ .prepare('select * from local_branch_association where git_ref = ?')
410
+ .get(ref) ?? null);
411
+ }
412
+ listBranchAssociations() {
413
+ return this.database
414
+ .prepare('select * from local_branch_association order by local_ref')
415
+ .all();
416
+ }
417
+ createBranchFromTrackingRef(input) {
418
+ const local_ref = requireMutableLocalBranchRef(input.local_ref, 'Local SDLC branch ref');
419
+ const git_ref = requireMutableLocalBranchRef(input.git_ref, 'Associated Git branch ref');
420
+ return this.runTransaction(() => {
421
+ const workspace = this.requireActiveWorkspace(input.actor_workspace_id);
422
+ if (workspace.actor_kind !== 'human') {
423
+ throw new Error('Local branch creation is owned by the active human workspace.');
424
+ }
425
+ if (workspace.head_sdlc_commit_id !==
426
+ input.expected_workspace_head_commit_id) {
427
+ throw new Error('Workspace head is stale.');
428
+ }
429
+ const active_child = this.database
430
+ .prepare(`select id from local_workspace where source_workspace_id = ? and status = 'active' limit 1`)
431
+ .get(workspace.id);
432
+ if (active_child)
433
+ throw new Error('Close active child workspaces before changing branches.');
434
+ if (this.getRef(local_ref))
435
+ throw new Error(`Local SDLC branch ${local_ref} already exists.`);
436
+ const existing_git = this.getBranchAssociationByGitRef(git_ref);
437
+ if (existing_git)
438
+ throw new Error(`Git branch ${git_ref} is already associated with ${existing_git.local_ref}.`);
439
+ const tracking = this.database
440
+ .prepare(`select * from remote_tracking_ref where remote_name = ? and source_ref = ? and tracking_ref = ?`)
441
+ .get(input.remote_name, input.source_ref, input.tracking_ref);
442
+ if (!tracking ||
443
+ tracking.commit_id !== input.expected_tracking_commit_id) {
444
+ throw new Error('Remote-tracking ref is missing or stale. Fetch it again.');
445
+ }
446
+ const portable = this.portable_commits.getCommit(input.expected_tracking_commit_id);
447
+ if (!portable)
448
+ throw new Error('Remote-tracking commit is unavailable locally.');
449
+ const now = new Date().toISOString();
450
+ this.database
451
+ .prepare(`insert into local_workspace_ref (ref_name, head_commit_id, created_at, updated_at) values (?, ?, ?, ?)`)
452
+ .run(local_ref, portable.id, now, now);
453
+ this.database
454
+ .prepare(`insert into local_branch_association (
455
+ local_ref, git_ref, upstream_remote_name, upstream_source_ref,
456
+ upstream_tracking_ref, base_portable_commit_id, created_at, updated_at
457
+ ) values (?, ?, ?, ?, ?, ?, ?, ?)`)
458
+ .run(local_ref, git_ref, input.remote_name, input.source_ref, input.tracking_ref, portable.id, now, now);
459
+ this.database
460
+ .prepare(`update local_workspace set fork_git_commit_id = ?, fork_sdlc_commit_id = ?,
461
+ head_sdlc_commit_id = ?, attached_ref = ?, updated_at = ? where id = ?`)
462
+ .run(requireValue(input.git_head_commit_id, 'Git head commit id'), portable.id, portable.id, local_ref, now, workspace.id);
463
+ const association = this.getBranchAssociation(local_ref);
464
+ if (!association)
465
+ throw new Error('Local branch association was not persisted.');
466
+ return {
467
+ workspace: this.requireActiveWorkspace(workspace.id),
468
+ association
469
+ };
470
+ });
471
+ }
472
+ selectBranchForWorkspace(input) {
473
+ const local_ref = requireMutableLocalBranchRef(input.local_ref, 'Local SDLC branch ref');
474
+ const git_ref = requireMutableLocalBranchRef(input.git_ref, 'Associated Git branch ref');
475
+ return this.runTransaction(() => {
476
+ const workspace = this.requireActiveWorkspace(input.actor_workspace_id);
477
+ if (workspace.actor_kind !== 'human') {
478
+ throw new Error('Local branch selection is owned by the active human workspace.');
479
+ }
480
+ if (workspace.head_sdlc_commit_id !==
481
+ input.expected_workspace_head_commit_id) {
482
+ throw new Error('Workspace head is stale.');
483
+ }
484
+ const active_child = this.database
485
+ .prepare(`select id from local_workspace where source_workspace_id = ? and status = 'active' limit 1`)
486
+ .get(workspace.id);
487
+ if (active_child)
488
+ throw new Error('Close active child workspaces before changing branches.');
489
+ const association = this.getBranchAssociation(local_ref);
490
+ if (!association)
491
+ throw new Error(`Local SDLC branch ${local_ref} does not exist.`);
492
+ if (association.git_ref !== git_ref) {
493
+ throw new Error(`Git branch ${git_ref} is not associated with ${local_ref}.`);
494
+ }
495
+ const ref = this.getRef(local_ref);
496
+ if (!ref)
497
+ throw new Error(`Local SDLC branch ${local_ref} is missing.`);
498
+ const attached_elsewhere = this.database
499
+ .prepare(`select id from local_workspace
500
+ where attached_ref = ? and status = 'active' and id <> ? limit 1`)
501
+ .get(local_ref, workspace.id);
502
+ if (attached_elsewhere) {
503
+ throw new Error(`Local SDLC branch ${local_ref} is already attached to another active workspace.`);
504
+ }
505
+ const now = new Date().toISOString();
506
+ this.database
507
+ .prepare(`update local_workspace set fork_git_commit_id = ?, fork_sdlc_commit_id = ?,
508
+ head_sdlc_commit_id = ?, attached_ref = ?, updated_at = ? where id = ?`)
509
+ .run(requireValue(input.git_head_commit_id, 'Git head commit id'), ref.head_commit_id, ref.head_commit_id, local_ref, now, workspace.id);
510
+ return {
511
+ workspace: this.requireActiveWorkspace(workspace.id),
512
+ association
513
+ };
514
+ });
515
+ }
516
+ registerForegroundWorkspace(input) {
517
+ const git_worktree_path = requireAbsolutePath(input.git_worktree_path, 'Git worktree path');
518
+ const git_dir = requireAbsolutePath(input.git_dir, 'Git directory');
519
+ const git_head_commit_id = requireValue(input.git_head_commit_id, 'Git head commit id');
520
+ const sdlc_head_commit_id = requireValue(input.sdlc_head_commit_id, 'SDLC head commit id');
521
+ const attached_ref = input.attached_ref
522
+ ? requireMutableLocalBranchRef(input.attached_ref, 'Attached workspace ref')
523
+ : null;
524
+ return this.runTransaction(() => {
525
+ const now = new Date().toISOString();
526
+ if (attached_ref) {
527
+ const existing_ref = this.getRef(attached_ref);
528
+ if (existing_ref &&
529
+ existing_ref.head_commit_id !== sdlc_head_commit_id) {
530
+ throw new Error('Attached ref head does not match the workspace SDLC head.');
531
+ }
532
+ if (!existing_ref) {
533
+ this.database
534
+ .prepare(`
535
+ insert into local_workspace_ref (
536
+ ref_name, head_commit_id, created_at, updated_at
537
+ ) values (?, ?, ?, ?)
538
+ `)
539
+ .run(attached_ref, sdlc_head_commit_id, now, now);
540
+ }
541
+ const existing_association = this.getBranchAssociation(attached_ref);
542
+ if (!existing_association) {
543
+ this.database
544
+ .prepare(`insert into local_branch_association (
545
+ local_ref, git_ref, upstream_remote_name, upstream_source_ref,
546
+ upstream_tracking_ref, base_portable_commit_id, created_at, updated_at
547
+ ) values (?, ?, null, null, null, null, ?, ?)`)
548
+ .run(attached_ref, attached_ref, now, now);
549
+ }
550
+ }
551
+ const workspace = {
552
+ id: randomUUID(),
553
+ repository_id: this.repository.repository_id,
554
+ source_workspace_id: null,
555
+ actor_kind: input.actor_kind,
556
+ git_worktree_path,
557
+ git_dir,
558
+ git_common_dir: requireAbsolutePath(input.git_common_dir ?? this.repository.git_common_dir, 'Git common directory'),
559
+ fork_git_commit_id: git_head_commit_id,
560
+ fork_sdlc_commit_id: sdlc_head_commit_id,
561
+ head_sdlc_commit_id: sdlc_head_commit_id,
562
+ attached_ref,
563
+ status: 'active',
564
+ created_at: now,
565
+ updated_at: now
566
+ };
567
+ this.insertWorkspace(workspace);
568
+ return workspace;
569
+ });
570
+ }
571
+ forkWorkspace(input) {
572
+ return this.runTransaction(() => {
573
+ const source_workspace = this.requireActiveWorkspace(input.actor_workspace_id);
574
+ if (source_workspace.head_sdlc_commit_id !==
575
+ input.expected_source_sdlc_head_commit_id) {
576
+ throw new Error('Source workspace head is stale.');
577
+ }
578
+ const task_scope = local_workspace_task_scope_schema.parse(input.task_scope);
579
+ assertTaskScopeSubset({
580
+ parent_scope: this.getWorkspaceTaskScope(source_workspace.id),
581
+ child_scope: task_scope
582
+ });
583
+ const now = new Date().toISOString();
584
+ const workspace = {
585
+ id: randomUUID(),
586
+ repository_id: this.repository.repository_id,
587
+ source_workspace_id: source_workspace.id,
588
+ actor_kind: input.actor_kind ?? 'ai',
589
+ git_worktree_path: requireAbsolutePath(input.git_worktree_path, 'Git worktree path'),
590
+ git_dir: requireAbsolutePath(input.git_dir, 'Git directory'),
591
+ git_common_dir: requireAbsolutePath(input.git_common_dir ?? this.repository.git_common_dir, 'Git common directory'),
592
+ fork_git_commit_id: requireValue(input.git_head_commit_id, 'Git head commit id'),
593
+ fork_sdlc_commit_id: source_workspace.head_sdlc_commit_id,
594
+ head_sdlc_commit_id: source_workspace.head_sdlc_commit_id,
595
+ attached_ref: null,
596
+ status: 'active',
597
+ created_at: now,
598
+ updated_at: now
599
+ };
600
+ this.insertWorkspace(workspace);
601
+ this.database
602
+ .prepare(`
603
+ insert into local_workspace_task_scope (
604
+ workspace_id, scope_json, created_at
605
+ ) values (?, ?, ?)
606
+ `)
607
+ .run(workspace.id, JSON.stringify(task_scope), now);
608
+ return workspace;
609
+ });
610
+ }
611
+ /**
612
+ * Reopens a Decision (graph-variants.md, Reopen) and, with `revive`, rebinds
613
+ * a closed candidate to a new active workspace in the same transaction.
614
+ * `closed` stays terminal: the new workspace is a sibling plan of the
615
+ * coordinator that starts at the closed candidate's last head and keeps its
616
+ * fork commit and task scope, so it integrates the same changes. This is the
617
+ * only way to fork from a closed workspace; forkWorkspace still refuses.
618
+ */
619
+ reopenDecision(input) {
620
+ return this.runTransaction(() => {
621
+ let revived = null;
622
+ if (input.revive) {
623
+ const closed = this.getWorkspace(input.revive.workspace_id);
624
+ if (!closed ||
625
+ closed.status !== 'closed' ||
626
+ !closed.source_workspace_id) {
627
+ throw new Error(`Workspace ${input.revive.workspace_id} is not a closed plan workspace.`);
628
+ }
629
+ const coordinator = this.requireActiveWorkspace(closed.source_workspace_id);
630
+ const now = new Date().toISOString();
631
+ revived = {
632
+ id: input.revive.id ?? randomUUID(),
633
+ repository_id: this.repository.repository_id,
634
+ source_workspace_id: coordinator.id,
635
+ actor_kind: input.revive.actor_kind ?? closed.actor_kind,
636
+ git_worktree_path: requireAbsolutePath(input.revive.git_worktree_path, 'Git worktree path'),
637
+ git_dir: requireAbsolutePath(input.revive.git_dir, 'Git directory'),
638
+ git_common_dir: requireAbsolutePath(input.revive.git_common_dir ?? this.repository.git_common_dir, 'Git common directory'),
639
+ fork_git_commit_id: requireValue(input.revive.git_head_commit_id, 'Git head commit id'),
640
+ fork_sdlc_commit_id: closed.fork_sdlc_commit_id,
641
+ head_sdlc_commit_id: closed.head_sdlc_commit_id,
642
+ attached_ref: null,
643
+ status: 'active',
644
+ created_at: now,
645
+ updated_at: now
646
+ };
647
+ this.insertWorkspace(revived);
648
+ const task_scope = this.getWorkspaceTaskScope(closed.id);
649
+ if (task_scope) {
650
+ this.database
651
+ .prepare(`insert into local_workspace_task_scope (
652
+ workspace_id, scope_json, created_at
653
+ ) values (?, ?, ?)`)
654
+ .run(revived.id, JSON.stringify(task_scope), now);
655
+ }
656
+ }
657
+ const decision = this.decisions.applyReopen({
658
+ decision_id: input.decision_id,
659
+ reason: input.reason,
660
+ revived: revived
661
+ ? {
662
+ from_workspace_id: input.revive.workspace_id,
663
+ workspace_id: revived.id
664
+ }
665
+ : null
666
+ });
667
+ return { decision, workspace: revived };
668
+ });
669
+ }
670
+ advanceWorkspaceHead(input) {
671
+ if (input.actor_workspace_id !== input.workspace_id) {
672
+ throw new Error('A workspace may advance only its own head outside explicit Handoff.');
673
+ }
674
+ return this.runTransaction(() => {
675
+ const workspace = this.requireActiveWorkspace(input.workspace_id);
676
+ if (workspace.head_sdlc_commit_id !== input.expected_head_commit_id) {
677
+ return {
678
+ status: 'stale',
679
+ current_head_commit_id: workspace.head_sdlc_commit_id
680
+ };
681
+ }
682
+ const next_head_commit_id = requireValue(input.next_head_commit_id, 'Next head commit id');
683
+ const now = new Date().toISOString();
684
+ if (workspace.attached_ref) {
685
+ const current_ref = this.getRef(workspace.attached_ref);
686
+ if (!current_ref ||
687
+ current_ref.head_commit_id !== workspace.head_sdlc_commit_id) {
688
+ throw new Error('Attached ref and workspace head disagree; refusing to advance.');
689
+ }
690
+ this.database
691
+ .prepare(`
692
+ update local_workspace_ref
693
+ set head_commit_id = ?, updated_at = ?
694
+ where ref_name = ? and head_commit_id = ?
695
+ `)
696
+ .run(next_head_commit_id, now, workspace.attached_ref, workspace.head_sdlc_commit_id);
697
+ }
698
+ this.database
699
+ .prepare(`
700
+ update local_workspace
701
+ set head_sdlc_commit_id = ?, updated_at = ?
702
+ where id = ? and head_sdlc_commit_id = ?
703
+ `)
704
+ .run(next_head_commit_id, now, workspace.id, workspace.head_sdlc_commit_id);
705
+ return {
706
+ status: 'advanced',
707
+ workspace: this.requireActiveWorkspace(workspace.id)
708
+ };
709
+ });
710
+ }
711
+ /**
712
+ * Replaces a child workspace's task scope. The new scope must stay within
713
+ * its source's scope and keep every active child's scope within itself;
714
+ * the caller checks that it still covers the workspace's own changes.
715
+ */
716
+ replaceWorkspaceTaskScope(input) {
717
+ return this.runTransaction(() => {
718
+ const actor = this.requireActiveWorkspace(input.actor_workspace_id);
719
+ const workspace = this.requireActiveWorkspace(input.workspace_id);
720
+ if (actor.id !== workspace.id &&
721
+ workspace.source_workspace_id !== actor.id) {
722
+ throw new Error('Only a workspace or its direct source may change its task scope.');
723
+ }
724
+ if (!workspace.source_workspace_id) {
725
+ throw new Error('A root workspace has no task scope.');
726
+ }
727
+ if (workspace.head_sdlc_commit_id !== input.expected_head_commit_id) {
728
+ throw new Error('Workspace head is stale.');
729
+ }
730
+ const task_scope = local_workspace_task_scope_schema.parse(input.task_scope);
731
+ assertTaskScopeSubset({
732
+ parent_scope: this.getWorkspaceTaskScope(workspace.source_workspace_id),
733
+ child_scope: task_scope
734
+ });
735
+ for (const child of this.listChildWorkspaces(workspace.id)) {
736
+ const child_scope = this.getWorkspaceTaskScope(child.id);
737
+ if (child.status !== 'active' || !child_scope)
738
+ continue;
739
+ assertTaskScopeSubset({ parent_scope: task_scope, child_scope });
740
+ }
741
+ const previous_task_scope = this.getWorkspaceTaskScope(workspace.id);
742
+ this.database
743
+ .prepare(`
744
+ insert into local_workspace_task_scope (
745
+ workspace_id, scope_json, created_at
746
+ ) values (?, ?, ?)
747
+ on conflict (workspace_id) do update set
748
+ scope_json = excluded.scope_json
749
+ `)
750
+ .run(workspace.id, JSON.stringify(task_scope), new Date().toISOString());
751
+ return { previous_task_scope, task_scope };
752
+ });
753
+ }
754
+ closeWorkspace(input) {
755
+ return this.runTransaction(() => {
756
+ const actor = this.requireActiveWorkspace(input.actor_workspace_id);
757
+ const workspace = this.requireActiveWorkspace(input.workspace_id);
758
+ if (actor.id !== workspace.id &&
759
+ workspace.source_workspace_id !== actor.id) {
760
+ throw new Error('Only a workspace or its direct source may close the workspace.');
761
+ }
762
+ if (workspace.head_sdlc_commit_id !== input.expected_head_commit_id) {
763
+ throw new Error('Workspace head is stale.');
764
+ }
765
+ const active_child = this.database
766
+ .prepare(`
767
+ select id from local_workspace
768
+ where source_workspace_id = ? and status = 'active'
769
+ limit 1
770
+ `)
771
+ .get(workspace.id);
772
+ if (active_child) {
773
+ throw new Error('Close active child workspaces first.');
774
+ }
775
+ const now = new Date().toISOString();
776
+ this.database
777
+ .prepare(`
778
+ update local_workspace set status = 'closed', updated_at = ?
779
+ where id = ? and status = 'active' and head_sdlc_commit_id = ?
780
+ `)
781
+ .run(now, workspace.id, input.expected_head_commit_id);
782
+ const closed = this.getWorkspace(workspace.id);
783
+ if (!closed || closed.status !== 'closed') {
784
+ throw new Error('Workspace close did not complete.');
785
+ }
786
+ return closed;
787
+ });
788
+ }
789
+ removeClosedWorkspaceRegistration(input) {
790
+ this.runTransaction(() => {
791
+ const workspace = this.getWorkspace(input.workspace_id);
792
+ if (!workspace ||
793
+ workspace.status !== 'closed' ||
794
+ workspace.source_workspace_id !== input.source_workspace_id ||
795
+ workspace.git_worktree_path !==
796
+ requireAbsolutePath(input.git_worktree_path, 'Git worktree path')) {
797
+ throw new Error('Closed workspace registration does not match attachment rollback.');
798
+ }
799
+ this.database
800
+ .prepare('delete from local_workspace_task_scope where workspace_id = ?')
801
+ .run(workspace.id);
802
+ const removed = this.database
803
+ .prepare(`delete from local_workspace
804
+ where id = ? and status = 'closed' and source_workspace_id = ?`)
805
+ .run(workspace.id, input.source_workspace_id);
806
+ if (removed.changes !== 1) {
807
+ throw new Error('Closed workspace registration was not removed.');
808
+ }
809
+ });
810
+ }
811
+ requireActiveWorkspace(workspace_id) {
812
+ const workspace = this.getWorkspace(workspace_id);
813
+ if (!workspace || workspace.status !== 'active') {
814
+ throw new Error('Active local workspace was not found.');
815
+ }
816
+ return workspace;
817
+ }
818
+ insertWorkspace(workspace) {
819
+ this.database
820
+ .prepare(`
821
+ insert into local_workspace (
822
+ id, repository_id, source_workspace_id, actor_kind,
823
+ git_worktree_path, git_dir, git_common_dir, fork_git_commit_id,
824
+ fork_sdlc_commit_id, head_sdlc_commit_id, attached_ref, status,
825
+ created_at, updated_at
826
+ ) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
827
+ `)
828
+ .run(workspace.id, workspace.repository_id, workspace.source_workspace_id, workspace.actor_kind, workspace.git_worktree_path, workspace.git_dir, workspace.git_common_dir, workspace.fork_git_commit_id, workspace.fork_sdlc_commit_id, workspace.head_sdlc_commit_id, workspace.attached_ref, workspace.status, workspace.created_at, workspace.updated_at);
829
+ }
830
+ }
831
+ //# sourceMappingURL=workspace-store.js.map