@paradigma-inc/flywheel 0.1.115 → 0.1.134

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 (623) hide show
  1. package/README.md +67 -10
  2. package/package.json +14 -6
  3. package/skills/flywheel/SKILL.md +9 -6
  4. package/skills/flywheel/example-workflows/organizing-exploring-and-iterating-on-a-research-topic.md +38 -46
  5. package/skills/flywheel/example-workflows/reproducing-papers-on-a-budget.md +34 -36
  6. package/skills/flywheel/getting-started/flywheel-quickstart.md +2 -5
  7. package/skills/flywheel/references/INTERFACES.md +2 -2
  8. package/skills/flywheel/references/experiment-design-protocol.md +32 -25
  9. package/skills/flywheel/references/flywheel-cli-tool-map.md +120 -76
  10. package/skills/flywheel/references/flywheel-mcp-tool-map.md +42 -32
  11. package/skills/flywheel/setting-up-flywheel/claude-code-cli-installation.md +1 -1
  12. package/skills/flywheel/setting-up-flywheel/codex-cli-installation.md +1 -1
  13. package/skills/flywheel/setting-up-flywheel/installation-overview.md +2 -6
  14. package/skills/flywheel/setting-up-flywheel/other-hosts-installation.md +45 -25
  15. package/skills/flywheel/setting-up-flywheel/updating-flywheel-mcp.md +34 -11
  16. package/skills/flywheel-auto/SKILL.md +40 -23
  17. package/skills/flywheel-auto/evals/evals.json +1 -1
  18. package/skills/flywheel-auto/references/INTERFACES.md +2 -2
  19. package/skills/flywheel-auto/references/experiment-design-protocol.md +31 -23
  20. package/skills/flywheel-auto/references/flywheel-cli-tool-map.md +172 -127
  21. package/skills/flywheel-auto/references/flywheel-mcp-tool-map.md +22 -24
  22. package/skills/flywheel-lookahead/SKILL.md +47 -28
  23. package/skills/flywheel-lookahead/agents/openai.yaml +1 -1
  24. package/skills/flywheel-lookahead/evals/evals.json +6 -6
  25. package/skills/flywheel-lookahead/references/INTERFACES.md +2 -2
  26. package/skills/flywheel-lookahead/references/flywheel-cli-tool-map.md +172 -127
  27. package/skills/flywheel-lookahead/references/flywheel-mcp-tool-map.md +22 -24
  28. package/skills/flywheel-prove/SKILL.md +2 -2
  29. package/skills/flywheel-prove/references/workflow.md +21 -2
  30. package/skills/flywheel-reproduce/SKILL.md +39 -19
  31. package/skills/flywheel-reproduce/evals/evals.json +1 -1
  32. package/skills/flywheel-reproduce/references/INTERFACES.md +2 -2
  33. package/skills/flywheel-reproduce/references/experiment-design-protocol.md +31 -23
  34. package/skills/flywheel-reproduce/references/flywheel-cli-tool-map.md +172 -127
  35. package/skills/flywheel-reproduce/references/flywheel-mcp-tool-map.md +22 -24
  36. package/skills/flywheel-to-graph/SKILL.md +37 -17
  37. package/skills/flywheel-to-graph/references/INTERFACES.md +2 -2
  38. package/skills/flywheel-to-graph/references/flywheel-cli-tool-map.md +172 -127
  39. package/skills/flywheel-to-graph/references/flywheel-mcp-tool-map.md +22 -24
  40. package/skills/flywheel-tree/references/workflow.md +6 -37
  41. package/src/cli.mjs +1145 -1141
  42. package/src/mcp-writer.mjs +413 -435
  43. package/src/public-command-metadata.mjs +28 -5
  44. package/src/runtime/delegate.mjs +2 -19
  45. package/src/runtime/required-runtime-commands.json +80 -28
  46. package/src/runtime/runtime-config.mjs +39 -60
  47. package/src/runtime/vendor/flywheel-cli-dist/auth/credentials.js +330 -0
  48. package/src/runtime/vendor/flywheel-cli-dist/auth/credentials.js.map +1 -0
  49. package/src/runtime/vendor/flywheel-cli-dist/auth/login.js +90 -139
  50. package/src/runtime/vendor/flywheel-cli-dist/auth/login.js.map +1 -1
  51. package/src/runtime/vendor/flywheel-cli-dist/auth/profiles.js +1 -1
  52. package/src/runtime/vendor/flywheel-cli-dist/auth/profiles.js.map +1 -1
  53. package/src/runtime/vendor/flywheel-cli-dist/auth/secure-write.js +116 -0
  54. package/src/runtime/vendor/flywheel-cli-dist/auth/secure-write.js.map +1 -0
  55. package/src/runtime/vendor/flywheel-cli-dist/commands/admin-test-users-create.js +248 -1
  56. package/src/runtime/vendor/flywheel-cli-dist/commands/admin-test-users-create.js.map +1 -1
  57. package/src/runtime/vendor/flywheel-cli-dist/commands/admin-test-users-login.js +65 -1
  58. package/src/runtime/vendor/flywheel-cli-dist/commands/admin-test-users-login.js.map +1 -1
  59. package/src/runtime/vendor/flywheel-cli-dist/commands/admin-test-users-revoke-api-key.js +17 -0
  60. package/src/runtime/vendor/flywheel-cli-dist/commands/admin-test-users-revoke-api-key.js.map +1 -0
  61. package/src/runtime/vendor/flywheel-cli-dist/commands/aliases.js +3 -7
  62. package/src/runtime/vendor/flywheel-cli-dist/commands/aliases.js.map +1 -1
  63. package/src/runtime/vendor/flywheel-cli-dist/commands/auth-credentials-clear.js +12 -0
  64. package/src/runtime/vendor/flywheel-cli-dist/commands/auth-credentials-clear.js.map +1 -0
  65. package/src/runtime/vendor/flywheel-cli-dist/commands/auth-credentials-set.js +29 -0
  66. package/src/runtime/vendor/flywheel-cli-dist/commands/auth-credentials-set.js.map +1 -0
  67. package/src/runtime/vendor/flywheel-cli-dist/commands/auth-login.js +12 -0
  68. package/src/runtime/vendor/flywheel-cli-dist/commands/auth-login.js.map +1 -1
  69. package/src/runtime/vendor/flywheel-cli-dist/commands/auth-status.js +46 -10
  70. package/src/runtime/vendor/flywheel-cli-dist/commands/auth-status.js.map +1 -1
  71. package/src/runtime/vendor/flywheel-cli-dist/commands/env.js +17 -40
  72. package/src/runtime/vendor/flywheel-cli-dist/commands/env.js.map +1 -1
  73. package/src/runtime/vendor/flywheel-cli-dist/commands/graph-operation-resources.js +305 -0
  74. package/src/runtime/vendor/flywheel-cli-dist/commands/graph-operation-resources.js.map +1 -0
  75. package/src/runtime/vendor/flywheel-cli-dist/commands/graph-operation-support.js +72 -0
  76. package/src/runtime/vendor/flywheel-cli-dist/commands/graph-operation-support.js.map +1 -0
  77. package/src/runtime/vendor/flywheel-cli-dist/commands/graph-operation.js +286 -0
  78. package/src/runtime/vendor/flywheel-cli-dist/commands/graph-operation.js.map +1 -0
  79. package/src/runtime/vendor/flywheel-cli-dist/commands/help-metadata.js +30 -5
  80. package/src/runtime/vendor/flywheel-cli-dist/commands/help-metadata.js.map +1 -1
  81. package/src/runtime/vendor/flywheel-cli-dist/commands/help.js +27 -12
  82. package/src/runtime/vendor/flywheel-cli-dist/commands/help.js.map +1 -1
  83. package/src/runtime/vendor/flywheel-cli-dist/commands/hosted-commit-replay.js +284 -0
  84. package/src/runtime/vendor/flywheel-cli-dist/commands/hosted-commit-replay.js.map +1 -0
  85. package/src/runtime/vendor/flywheel-cli-dist/commands/hosted-graph.js +169 -0
  86. package/src/runtime/vendor/flywheel-cli-dist/commands/hosted-graph.js.map +1 -0
  87. package/src/runtime/vendor/flywheel-cli-dist/commands/hosted-lineage-list.js +13 -0
  88. package/src/runtime/vendor/flywheel-cli-dist/commands/hosted-lineage-list.js.map +1 -0
  89. package/src/runtime/vendor/flywheel-cli-dist/commands/hosted-repository-snapshot.js +227 -0
  90. package/src/runtime/vendor/flywheel-cli-dist/commands/hosted-repository-snapshot.js.map +1 -0
  91. package/src/runtime/vendor/flywheel-cli-dist/commands/index.js +21 -51
  92. package/src/runtime/vendor/flywheel-cli-dist/commands/index.js.map +1 -1
  93. package/src/runtime/vendor/flywheel-cli-dist/commands/node-create-schema.js +25 -0
  94. package/src/runtime/vendor/flywheel-cli-dist/commands/node-create-schema.js.map +1 -0
  95. package/src/runtime/vendor/flywheel-cli-dist/commands/profile-list.js +11 -9
  96. package/src/runtime/vendor/flywheel-cli-dist/commands/profile-list.js.map +1 -1
  97. package/src/runtime/vendor/flywheel-cli-dist/commands/profile-set.js +38 -45
  98. package/src/runtime/vendor/flywheel-cli-dist/commands/profile-set.js.map +1 -1
  99. package/src/runtime/vendor/flywheel-cli-dist/commands/profile-show.js +14 -17
  100. package/src/runtime/vendor/flywheel-cli-dist/commands/profile-show.js.map +1 -1
  101. package/src/runtime/vendor/flywheel-cli-dist/commands/profile-unset.js +13 -8
  102. package/src/runtime/vendor/flywheel-cli-dist/commands/profile-unset.js.map +1 -1
  103. package/src/runtime/vendor/flywheel-cli-dist/commands/registry/admin.js +34 -3
  104. package/src/runtime/vendor/flywheel-cli-dist/commands/registry/admin.js.map +1 -1
  105. package/src/runtime/vendor/flywheel-cli-dist/commands/registry/auth.js +9 -9
  106. package/src/runtime/vendor/flywheel-cli-dist/commands/registry/auth.js.map +1 -1
  107. package/src/runtime/vendor/flywheel-cli-dist/commands/registry/hosted.js +76 -0
  108. package/src/runtime/vendor/flywheel-cli-dist/commands/registry/hosted.js.map +1 -0
  109. package/src/runtime/vendor/flywheel-cli-dist/commands/registry/lifecycle.js +4 -138
  110. package/src/runtime/vendor/flywheel-cli-dist/commands/registry/lifecycle.js.map +1 -1
  111. package/src/runtime/vendor/flywheel-cli-dist/commands/registry/profile.js +8 -13
  112. package/src/runtime/vendor/flywheel-cli-dist/commands/registry/profile.js.map +1 -1
  113. package/src/runtime/vendor/flywheel-cli-dist/commands/registry/repository.js +362 -0
  114. package/src/runtime/vendor/flywheel-cli-dist/commands/registry/repository.js.map +1 -0
  115. package/src/runtime/vendor/flywheel-cli-dist/commands/registry.js +45 -183
  116. package/src/runtime/vendor/flywheel-cli-dist/commands/registry.js.map +1 -1
  117. package/src/runtime/vendor/flywheel-cli-dist/commands/repository-edit.js +47 -0
  118. package/src/runtime/vendor/flywheel-cli-dist/commands/repository-edit.js.map +1 -0
  119. package/src/runtime/vendor/flywheel-cli-dist/commands/repository-operation.js +181 -0
  120. package/src/runtime/vendor/flywheel-cli-dist/commands/repository-operation.js.map +1 -0
  121. package/src/runtime/vendor/flywheel-cli-dist/commands/repository-output.js +163 -0
  122. package/src/runtime/vendor/flywheel-cli-dist/commands/repository-output.js.map +1 -0
  123. package/src/runtime/vendor/flywheel-cli-dist/commands/repository-projection.js +79 -0
  124. package/src/runtime/vendor/flywheel-cli-dist/commands/repository-projection.js.map +1 -0
  125. package/src/runtime/vendor/flywheel-cli-dist/commands/repository-selection.js +80 -0
  126. package/src/runtime/vendor/flywheel-cli-dist/commands/repository-selection.js.map +1 -0
  127. package/src/runtime/vendor/flywheel-cli-dist/commands/retired-command-names.js +78 -0
  128. package/src/runtime/vendor/flywheel-cli-dist/commands/retired-command-names.js.map +1 -0
  129. package/src/runtime/vendor/flywheel-cli-dist/commands/types.js.map +1 -1
  130. package/src/runtime/vendor/flywheel-cli-dist/commands/usage-spec.js +3 -2
  131. package/src/runtime/vendor/flywheel-cli-dist/commands/usage-spec.js.map +1 -1
  132. package/src/runtime/vendor/flywheel-cli-dist/config/index.js +5 -0
  133. package/src/runtime/vendor/flywheel-cli-dist/config/index.js.map +1 -0
  134. package/src/runtime/vendor/flywheel-cli-dist/config/io.js +139 -0
  135. package/src/runtime/vendor/flywheel-cli-dist/config/io.js.map +1 -0
  136. package/src/runtime/vendor/flywheel-cli-dist/config/migration.js +299 -0
  137. package/src/runtime/vendor/flywheel-cli-dist/config/migration.js.map +1 -0
  138. package/src/runtime/vendor/flywheel-cli-dist/config/model.js +214 -0
  139. package/src/runtime/vendor/flywheel-cli-dist/config/model.js.map +1 -0
  140. package/src/runtime/vendor/flywheel-cli-dist/config/path.js +30 -0
  141. package/src/runtime/vendor/flywheel-cli-dist/config/path.js.map +1 -0
  142. package/src/runtime/vendor/flywheel-cli-dist/credential-output.js +29 -0
  143. package/src/runtime/vendor/flywheel-cli-dist/credential-output.js.map +1 -0
  144. package/src/runtime/vendor/flywheel-cli-dist/errors.js +1 -16
  145. package/src/runtime/vendor/flywheel-cli-dist/errors.js.map +1 -1
  146. package/src/runtime/vendor/flywheel-cli-dist/generatedProductTelemetryContract.js +3 -3
  147. package/src/runtime/vendor/flywheel-cli-dist/generatedProductTelemetryContract.js.map +1 -1
  148. package/src/runtime/vendor/flywheel-cli-dist/grammar/globals.js +19 -9
  149. package/src/runtime/vendor/flywheel-cli-dist/grammar/globals.js.map +1 -1
  150. package/src/runtime/vendor/flywheel-cli-dist/grammar/parse.js +33 -4
  151. package/src/runtime/vendor/flywheel-cli-dist/grammar/parse.js.map +1 -1
  152. package/src/runtime/vendor/flywheel-cli-dist/http/client.js +322 -304
  153. package/src/runtime/vendor/flywheel-cli-dist/http/client.js.map +1 -1
  154. package/src/runtime/vendor/flywheel-cli-dist/http/debug.js +1 -21
  155. package/src/runtime/vendor/flywheel-cli-dist/http/debug.js.map +1 -1
  156. package/src/runtime/vendor/flywheel-cli-dist/http/retry.js +1 -0
  157. package/src/runtime/vendor/flywheel-cli-dist/http/retry.js.map +1 -1
  158. package/src/runtime/vendor/flywheel-cli-dist/local/adapter.js +244 -0
  159. package/src/runtime/vendor/flywheel-cli-dist/local/adapter.js.map +1 -0
  160. package/src/runtime/vendor/flywheel-cli-dist/local/domain/errors.js +7 -0
  161. package/src/runtime/vendor/flywheel-cli-dist/local/domain/errors.js.map +1 -0
  162. package/src/runtime/vendor/flywheel-cli-dist/local/domain/history.js +35 -0
  163. package/src/runtime/vendor/flywheel-cli-dist/local/domain/history.js.map +1 -0
  164. package/src/runtime/vendor/flywheel-cli-dist/local/domain/invariants.js +42 -0
  165. package/src/runtime/vendor/flywheel-cli-dist/local/domain/invariants.js.map +1 -0
  166. package/src/runtime/vendor/flywheel-cli-dist/local/domain/models/artifact-properties.js +179 -0
  167. package/src/runtime/vendor/flywheel-cli-dist/local/domain/models/artifact-properties.js.map +1 -0
  168. package/src/runtime/vendor/flywheel-cli-dist/local/domain/models/commits.js +152 -0
  169. package/src/runtime/vendor/flywheel-cli-dist/local/domain/models/commits.js.map +1 -0
  170. package/src/runtime/vendor/flywheel-cli-dist/local/domain/models/constants.js +71 -0
  171. package/src/runtime/vendor/flywheel-cli-dist/local/domain/models/constants.js.map +1 -0
  172. package/src/runtime/vendor/flywheel-cli-dist/local/domain/models/encoding.js +73 -0
  173. package/src/runtime/vendor/flywheel-cli-dist/local/domain/models/encoding.js.map +1 -0
  174. package/src/runtime/vendor/flywheel-cli-dist/local/domain/models/imported-artifact-properties.js +82 -0
  175. package/src/runtime/vendor/flywheel-cli-dist/local/domain/models/imported-artifact-properties.js.map +1 -0
  176. package/src/runtime/vendor/flywheel-cli-dist/local/domain/models/operations.js +345 -0
  177. package/src/runtime/vendor/flywheel-cli-dist/local/domain/models/operations.js.map +1 -0
  178. package/src/runtime/vendor/flywheel-cli-dist/local/domain/models/tags.js +57 -0
  179. package/src/runtime/vendor/flywheel-cli-dist/local/domain/models/tags.js.map +1 -0
  180. package/src/runtime/vendor/flywheel-cli-dist/local/domain/rebase/conflicts.js +149 -0
  181. package/src/runtime/vendor/flywheel-cli-dist/local/domain/rebase/conflicts.js.map +1 -0
  182. package/src/runtime/vendor/flywheel-cli-dist/local/domain/rebase/context.js +115 -0
  183. package/src/runtime/vendor/flywheel-cli-dist/local/domain/rebase/context.js.map +1 -0
  184. package/src/runtime/vendor/flywheel-cli-dist/local/domain/rebase/keys.js +44 -0
  185. package/src/runtime/vendor/flywheel-cli-dist/local/domain/rebase/keys.js.map +1 -0
  186. package/src/runtime/vendor/flywheel-cli-dist/local/domain/rebase/pull.js +159 -0
  187. package/src/runtime/vendor/flywheel-cli-dist/local/domain/rebase/pull.js.map +1 -0
  188. package/src/runtime/vendor/flywheel-cli-dist/local/domain/rebase/replay.js +346 -0
  189. package/src/runtime/vendor/flywheel-cli-dist/local/domain/rebase/replay.js.map +1 -0
  190. package/src/runtime/vendor/flywheel-cli-dist/local/domain/rebase/resolve.js +37 -0
  191. package/src/runtime/vendor/flywheel-cli-dist/local/domain/rebase/resolve.js.map +1 -0
  192. package/src/runtime/vendor/flywheel-cli-dist/local/domain/revert/inverses.js +203 -0
  193. package/src/runtime/vendor/flywheel-cli-dist/local/domain/revert/inverses.js.map +1 -0
  194. package/src/runtime/vendor/flywheel-cli-dist/local/domain/revert/plan.js +207 -0
  195. package/src/runtime/vendor/flywheel-cli-dist/local/domain/revert/plan.js.map +1 -0
  196. package/src/runtime/vendor/flywheel-cli-dist/local/domain/revert/tag-inverses.js +109 -0
  197. package/src/runtime/vendor/flywheel-cli-dist/local/domain/revert/tag-inverses.js.map +1 -0
  198. package/src/runtime/vendor/flywheel-cli-dist/local/domain/service/commit.js +61 -0
  199. package/src/runtime/vendor/flywheel-cli-dist/local/domain/service/commit.js.map +1 -0
  200. package/src/runtime/vendor/flywheel-cli-dist/local/domain/service/projection.js +46 -0
  201. package/src/runtime/vendor/flywheel-cli-dist/local/domain/service/projection.js.map +1 -0
  202. package/src/runtime/vendor/flywheel-cli-dist/local/domain/service/revert.js +203 -0
  203. package/src/runtime/vendor/flywheel-cli-dist/local/domain/service/revert.js.map +1 -0
  204. package/src/runtime/vendor/flywheel-cli-dist/local/domain/service/staging.js +44 -0
  205. package/src/runtime/vendor/flywheel-cli-dist/local/domain/service/staging.js.map +1 -0
  206. package/src/runtime/vendor/flywheel-cli-dist/local/domain/service/writes.js +188 -0
  207. package/src/runtime/vendor/flywheel-cli-dist/local/domain/service/writes.js.map +1 -0
  208. package/src/runtime/vendor/flywheel-cli-dist/local/domain/sync/cursors.js +54 -0
  209. package/src/runtime/vendor/flywheel-cli-dist/local/domain/sync/cursors.js.map +1 -0
  210. package/src/runtime/vendor/flywheel-cli-dist/local/domain/sync/local-pull.js +25 -0
  211. package/src/runtime/vendor/flywheel-cli-dist/local/domain/sync/local-pull.js.map +1 -0
  212. package/src/runtime/vendor/flywheel-cli-dist/local/domain/sync-models.js +2 -0
  213. package/src/runtime/vendor/flywheel-cli-dist/local/domain/sync-models.js.map +1 -0
  214. package/src/runtime/vendor/flywheel-cli-dist/local/fs/native.js +7 -0
  215. package/src/runtime/vendor/flywheel-cli-dist/local/fs/native.js.map +1 -0
  216. package/src/runtime/vendor/flywheel-cli-dist/local/fs/state.js +129 -0
  217. package/src/runtime/vendor/flywheel-cli-dist/local/fs/state.js.map +1 -0
  218. package/src/runtime/vendor/flywheel-cli-dist/local/fs/writer-lock.js +277 -0
  219. package/src/runtime/vendor/flywheel-cli-dist/local/fs/writer-lock.js.map +1 -0
  220. package/src/runtime/vendor/flywheel-cli-dist/local/runtime/bootstrap.js +183 -0
  221. package/src/runtime/vendor/flywheel-cli-dist/local/runtime/bootstrap.js.map +1 -0
  222. package/src/runtime/vendor/flywheel-cli-dist/local/runtime/context.js +2 -0
  223. package/src/runtime/vendor/flywheel-cli-dist/local/runtime/context.js.map +1 -0
  224. package/src/runtime/vendor/flywheel-cli-dist/local/runtime/dispatch.js +121 -0
  225. package/src/runtime/vendor/flywheel-cli-dist/local/runtime/dispatch.js.map +1 -0
  226. package/src/runtime/vendor/flywheel-cli-dist/local/runtime/doctor.js +16 -0
  227. package/src/runtime/vendor/flywheel-cli-dist/local/runtime/doctor.js.map +1 -0
  228. package/src/runtime/vendor/flywheel-cli-dist/local/runtime/identity.js +72 -0
  229. package/src/runtime/vendor/flywheel-cli-dist/local/runtime/identity.js.map +1 -0
  230. package/src/runtime/vendor/flywheel-cli-dist/local/runtime/operations/conflicts.js +59 -0
  231. package/src/runtime/vendor/flywheel-cli-dist/local/runtime/operations/conflicts.js.map +1 -0
  232. package/src/runtime/vendor/flywheel-cli-dist/local/runtime/operations/core.js +125 -0
  233. package/src/runtime/vendor/flywheel-cli-dist/local/runtime/operations/core.js.map +1 -0
  234. package/src/runtime/vendor/flywheel-cli-dist/local/runtime/operations/history.js +129 -0
  235. package/src/runtime/vendor/flywheel-cli-dist/local/runtime/operations/history.js.map +1 -0
  236. package/src/runtime/vendor/flywheel-cli-dist/local/runtime/operations/index.js +31 -0
  237. package/src/runtime/vendor/flywheel-cli-dist/local/runtime/operations/index.js.map +1 -0
  238. package/src/runtime/vendor/flywheel-cli-dist/local/runtime/operations/maintenance.js +49 -0
  239. package/src/runtime/vendor/flywheel-cli-dist/local/runtime/operations/maintenance.js.map +1 -0
  240. package/src/runtime/vendor/flywheel-cli-dist/local/runtime/operations/projections.js +30 -0
  241. package/src/runtime/vendor/flywheel-cli-dist/local/runtime/operations/projections.js.map +1 -0
  242. package/src/runtime/vendor/flywheel-cli-dist/local/runtime/operations/shared.js +12 -0
  243. package/src/runtime/vendor/flywheel-cli-dist/local/runtime/operations/shared.js.map +1 -0
  244. package/src/runtime/vendor/flywheel-cli-dist/local/runtime/platform.js +18 -0
  245. package/src/runtime/vendor/flywheel-cli-dist/local/runtime/platform.js.map +1 -0
  246. package/src/runtime/vendor/flywheel-cli-dist/local/runtime/projection.js +125 -0
  247. package/src/runtime/vendor/flywheel-cli-dist/local/runtime/projection.js.map +1 -0
  248. package/src/runtime/vendor/flywheel-cli-dist/local/runtime/remote/clone.js +37 -0
  249. package/src/runtime/vendor/flywheel-cli-dist/local/runtime/remote/clone.js.map +1 -0
  250. package/src/runtime/vendor/flywheel-cli-dist/local/runtime/remote/pull.js +44 -0
  251. package/src/runtime/vendor/flywheel-cli-dist/local/runtime/remote/pull.js.map +1 -0
  252. package/src/runtime/vendor/flywheel-cli-dist/local/runtime/remote/purge.js +58 -0
  253. package/src/runtime/vendor/flywheel-cli-dist/local/runtime/remote/purge.js.map +1 -0
  254. package/src/runtime/vendor/flywheel-cli-dist/local/runtime/remote/push.js +118 -0
  255. package/src/runtime/vendor/flywheel-cli-dist/local/runtime/remote/push.js.map +1 -0
  256. package/src/runtime/vendor/flywheel-cli-dist/local/runtime/remote/transport.js +277 -0
  257. package/src/runtime/vendor/flywheel-cli-dist/local/runtime/remote/transport.js.map +1 -0
  258. package/src/runtime/vendor/flywheel-cli-dist/local/store/apply.js +132 -0
  259. package/src/runtime/vendor/flywheel-cli-dist/local/store/apply.js.map +1 -0
  260. package/src/runtime/vendor/flywheel-cli-dist/local/store/backup/archive.js +372 -0
  261. package/src/runtime/vendor/flywheel-cli-dist/local/store/backup/archive.js.map +1 -0
  262. package/src/runtime/vendor/flywheel-cli-dist/local/store/backup/backup.js +210 -0
  263. package/src/runtime/vendor/flywheel-cli-dist/local/store/backup/backup.js.map +1 -0
  264. package/src/runtime/vendor/flywheel-cli-dist/local/store/backup/restore.js +278 -0
  265. package/src/runtime/vendor/flywheel-cli-dist/local/store/backup/restore.js.map +1 -0
  266. package/src/runtime/vendor/flywheel-cli-dist/local/store/backup/retained-directory.js +192 -0
  267. package/src/runtime/vendor/flywheel-cli-dist/local/store/backup/retained-directory.js.map +1 -0
  268. package/src/runtime/vendor/flywheel-cli-dist/local/store/commits.js +114 -0
  269. package/src/runtime/vendor/flywheel-cli-dist/local/store/commits.js.map +1 -0
  270. package/src/runtime/vendor/flywheel-cli-dist/local/store/contract.js +65 -0
  271. package/src/runtime/vendor/flywheel-cli-dist/local/store/contract.js.map +1 -0
  272. package/src/runtime/vendor/flywheel-cli-dist/local/store/diagnostics-worker.js +145 -0
  273. package/src/runtime/vendor/flywheel-cli-dist/local/store/diagnostics-worker.js.map +1 -0
  274. package/src/runtime/vendor/flywheel-cli-dist/local/store/diagnostics.js +218 -0
  275. package/src/runtime/vendor/flywheel-cli-dist/local/store/diagnostics.js.map +1 -0
  276. package/src/runtime/vendor/flywheel-cli-dist/local/store/gc.js +71 -0
  277. package/src/runtime/vendor/flywheel-cli-dist/local/store/gc.js.map +1 -0
  278. package/src/runtime/vendor/flywheel-cli-dist/local/store/history-validation.js +298 -0
  279. package/src/runtime/vendor/flywheel-cli-dist/local/store/history-validation.js.map +1 -0
  280. package/src/runtime/vendor/flywheel-cli-dist/local/store/latest-values.js +121 -0
  281. package/src/runtime/vendor/flywheel-cli-dist/local/store/latest-values.js.map +1 -0
  282. package/src/runtime/vendor/flywheel-cli-dist/local/store/migrate.js +69 -0
  283. package/src/runtime/vendor/flywheel-cli-dist/local/store/migrate.js.map +1 -0
  284. package/src/runtime/vendor/flywheel-cli-dist/local/store/migration/provenance.js +49 -0
  285. package/src/runtime/vendor/flywheel-cli-dist/local/store/migration/provenance.js.map +1 -0
  286. package/src/runtime/vendor/flywheel-cli-dist/local/store/migration/steps.js +424 -0
  287. package/src/runtime/vendor/flywheel-cli-dist/local/store/migration/steps.js.map +1 -0
  288. package/src/runtime/vendor/flywheel-cli-dist/local/store/migration/versions.js +10 -0
  289. package/src/runtime/vendor/flywheel-cli-dist/local/store/migration/versions.js.map +1 -0
  290. package/src/runtime/vendor/flywheel-cli-dist/local/store/migrations/001_initial.sql +319 -0
  291. package/src/runtime/vendor/flywheel-cli-dist/local/store/migrations/002_staged_latest_values.sql +8 -0
  292. package/src/runtime/vendor/flywheel-cli-dist/local/store/migrations/003_remove_cli_editing_lease.sql +21 -0
  293. package/src/runtime/vendor/flywheel-cli-dist/local/store/migrations/004_hosted_association.sql +7 -0
  294. package/src/runtime/vendor/flywheel-cli-dist/local/store/migrations/005_artifact_properties.sql +68 -0
  295. package/src/runtime/vendor/flywheel-cli-dist/local/store/migrations.js +12 -0
  296. package/src/runtime/vendor/flywheel-cli-dist/local/store/migrations.js.map +1 -0
  297. package/src/runtime/vendor/flywheel-cli-dist/local/store/objects.js +410 -0
  298. package/src/runtime/vendor/flywheel-cli-dist/local/store/objects.js.map +1 -0
  299. package/src/runtime/vendor/flywheel-cli-dist/local/store/projection/apply.js +77 -0
  300. package/src/runtime/vendor/flywheel-cli-dist/local/store/projection/apply.js.map +1 -0
  301. package/src/runtime/vendor/flywheel-cli-dist/local/store/projection/artifacts.js +240 -0
  302. package/src/runtime/vendor/flywheel-cli-dist/local/store/projection/artifacts.js.map +1 -0
  303. package/src/runtime/vendor/flywheel-cli-dist/local/store/projection/nodes.js +127 -0
  304. package/src/runtime/vendor/flywheel-cli-dist/local/store/projection/nodes.js.map +1 -0
  305. package/src/runtime/vendor/flywheel-cli-dist/local/store/projection/relations.js +107 -0
  306. package/src/runtime/vendor/flywheel-cli-dist/local/store/projection/relations.js.map +1 -0
  307. package/src/runtime/vendor/flywheel-cli-dist/local/store/projection/rules.js +80 -0
  308. package/src/runtime/vendor/flywheel-cli-dist/local/store/projection/rules.js.map +1 -0
  309. package/src/runtime/vendor/flywheel-cli-dist/local/store/projection/tags.js +219 -0
  310. package/src/runtime/vendor/flywheel-cli-dist/local/store/projection/tags.js.map +1 -0
  311. package/src/runtime/vendor/flywheel-cli-dist/local/store/snapshot/hosted.js +164 -0
  312. package/src/runtime/vendor/flywheel-cli-dist/local/store/snapshot/hosted.js.map +1 -0
  313. package/src/runtime/vendor/flywheel-cli-dist/local/store/snapshot/read.js +20 -0
  314. package/src/runtime/vendor/flywheel-cli-dist/local/store/snapshot/read.js.map +1 -0
  315. package/src/runtime/vendor/flywheel-cli-dist/local/store/snapshot/replace.js +41 -0
  316. package/src/runtime/vendor/flywheel-cli-dist/local/store/snapshot/replace.js.map +1 -0
  317. package/src/runtime/vendor/flywheel-cli-dist/local/store/snapshot/schema.js +22 -0
  318. package/src/runtime/vendor/flywheel-cli-dist/local/store/snapshot/schema.js.map +1 -0
  319. package/src/runtime/vendor/flywheel-cli-dist/local/store/snapshot/validate.js +188 -0
  320. package/src/runtime/vendor/flywheel-cli-dist/local/store/snapshot/validate.js.map +1 -0
  321. package/src/runtime/vendor/flywheel-cli-dist/local/store/snapshot.js +5 -0
  322. package/src/runtime/vendor/flywheel-cli-dist/local/store/snapshot.js.map +1 -0
  323. package/src/runtime/vendor/flywheel-cli-dist/local/store/sqlite/connection.js +214 -0
  324. package/src/runtime/vendor/flywheel-cli-dist/local/store/sqlite/connection.js.map +1 -0
  325. package/src/runtime/vendor/flywheel-cli-dist/local/store/sqlite/errors.js +4 -0
  326. package/src/runtime/vendor/flywheel-cli-dist/local/store/sqlite/errors.js.map +1 -0
  327. package/src/runtime/vendor/flywheel-cli-dist/local/store/sqlite/rows.js +44 -0
  328. package/src/runtime/vendor/flywheel-cli-dist/local/store/sqlite/rows.js.map +1 -0
  329. package/src/runtime/vendor/flywheel-cli-dist/local/store/sqlite/schema.js +38 -0
  330. package/src/runtime/vendor/flywheel-cli-dist/local/store/sqlite/schema.js.map +1 -0
  331. package/src/runtime/vendor/flywheel-cli-dist/local/store/sqlite/store.js +284 -0
  332. package/src/runtime/vendor/flywheel-cli-dist/local/store/sqlite/store.js.map +1 -0
  333. package/src/runtime/vendor/flywheel-cli-dist/local/store/sqlite/verify.js +133 -0
  334. package/src/runtime/vendor/flywheel-cli-dist/local/store/sqlite/verify.js.map +1 -0
  335. package/src/runtime/vendor/flywheel-cli-dist/local/store/sync-commits.js +98 -0
  336. package/src/runtime/vendor/flywheel-cli-dist/local/store/sync-commits.js.map +1 -0
  337. package/src/runtime/vendor/flywheel-cli-dist/local/store/sync.js +161 -0
  338. package/src/runtime/vendor/flywheel-cli-dist/local/store/sync.js.map +1 -0
  339. package/src/runtime/vendor/flywheel-cli-dist/local/store/workspace-state.js +97 -0
  340. package/src/runtime/vendor/flywheel-cli-dist/local/store/workspace-state.js.map +1 -0
  341. package/src/runtime/vendor/flywheel-cli-dist/local/store/workspace.js +69 -0
  342. package/src/runtime/vendor/flywheel-cli-dist/local/store/workspace.js.map +1 -0
  343. package/src/runtime/vendor/flywheel-cli-dist/main.js +651 -376
  344. package/src/runtime/vendor/flywheel-cli-dist/main.js.map +1 -1
  345. package/src/runtime/vendor/flywheel-cli-dist/output/format.js +18 -11
  346. package/src/runtime/vendor/flywheel-cli-dist/output/format.js.map +1 -1
  347. package/src/runtime/vendor/flywheel-cli-dist/prebuilds/darwin-arm64/node.napi.node +0 -0
  348. package/src/runtime/vendor/flywheel-cli-dist/prebuilds/darwin-x64/node.napi.node +0 -0
  349. package/src/runtime/vendor/flywheel-cli-dist/prebuilds/linux-arm64/node.napi.glibc.node +0 -0
  350. package/src/runtime/vendor/flywheel-cli-dist/prebuilds/linux-arm64/node.napi.musl.node +0 -0
  351. package/src/runtime/vendor/flywheel-cli-dist/prebuilds/linux-x64/node.napi.glibc.node +0 -0
  352. package/src/runtime/vendor/flywheel-cli-dist/prebuilds/linux-x64/node.napi.musl.node +0 -0
  353. package/src/runtime/vendor/manifest.json +246 -257
  354. package/src/setup/command.mjs +5 -0
  355. package/src/setup/io/patchers/json.mjs +1 -1
  356. package/src/setup/io/patchers/toml.mjs +3 -1
  357. package/src/setup/io/patchers/yaml.mjs +1 -1
  358. package/src/setup/modes/cli.mjs +76 -7
  359. package/src/setup/modes/mcp-command.mjs +802 -793
  360. package/src/setup/modes/mcp.mjs +7 -3
  361. package/src/setup/shared/prior-mode-detect.mjs +18 -21
  362. package/src/setup/test-seams.mjs +25 -0
  363. package/src/setup-auth.mjs +76 -10
  364. package/src/toml-lines.mjs +52 -0
  365. package/src/unified-cli.mjs +31 -16
  366. package/skills/flywheel-llm-proof-paper/scripts/__pycache__/check_paper.cpython-312.pyc +0 -0
  367. package/src/runtime/vendor/flywheel-cli-dist/auth/active-key-id.d.ts +0 -1
  368. package/src/runtime/vendor/flywheel-cli-dist/auth/baseurl.d.ts +0 -35
  369. package/src/runtime/vendor/flywheel-cli-dist/auth/config.d.ts +0 -34
  370. package/src/runtime/vendor/flywheel-cli-dist/auth/config.js +0 -92
  371. package/src/runtime/vendor/flywheel-cli-dist/auth/config.js.map +0 -1
  372. package/src/runtime/vendor/flywheel-cli-dist/auth/fingerprint.d.ts +0 -5
  373. package/src/runtime/vendor/flywheel-cli-dist/auth/keychain.d.ts +0 -4
  374. package/src/runtime/vendor/flywheel-cli-dist/auth/keychain.js +0 -31
  375. package/src/runtime/vendor/flywheel-cli-dist/auth/keychain.js.map +0 -1
  376. package/src/runtime/vendor/flywheel-cli-dist/auth/login.d.ts +0 -24
  377. package/src/runtime/vendor/flywheel-cli-dist/auth/profile.d.ts +0 -15
  378. package/src/runtime/vendor/flywheel-cli-dist/auth/profile.js +0 -150
  379. package/src/runtime/vendor/flywheel-cli-dist/auth/profile.js.map +0 -1
  380. package/src/runtime/vendor/flywheel-cli-dist/auth/profiles.d.ts +0 -27
  381. package/src/runtime/vendor/flywheel-cli-dist/commands/_admin-auth.d.ts +0 -27
  382. package/src/runtime/vendor/flywheel-cli-dist/commands/_artifacts-upload-helpers.d.ts +0 -32
  383. package/src/runtime/vendor/flywheel-cli-dist/commands/_artifacts-upload-helpers.js +0 -213
  384. package/src/runtime/vendor/flywheel-cli-dist/commands/_artifacts-upload-helpers.js.map +0 -1
  385. package/src/runtime/vendor/flywheel-cli-dist/commands/_browser-handoff.d.ts +0 -35
  386. package/src/runtime/vendor/flywheel-cli-dist/commands/_open-url.d.ts +0 -2
  387. package/src/runtime/vendor/flywheel-cli-dist/commands/_secret-param.d.ts +0 -7
  388. package/src/runtime/vendor/flywheel-cli-dist/commands/_stream-file-out.d.ts +0 -39
  389. package/src/runtime/vendor/flywheel-cli-dist/commands/_stream-writer.d.ts +0 -34
  390. package/src/runtime/vendor/flywheel-cli-dist/commands/_wait-polling.d.ts +0 -50
  391. package/src/runtime/vendor/flywheel-cli-dist/commands/account-detach.d.ts +0 -2
  392. package/src/runtime/vendor/flywheel-cli-dist/commands/account-emails-add.d.ts +0 -2
  393. package/src/runtime/vendor/flywheel-cli-dist/commands/account-emails-remove.d.ts +0 -2
  394. package/src/runtime/vendor/flywheel-cli-dist/commands/account-emails-set-primary.d.ts +0 -2
  395. package/src/runtime/vendor/flywheel-cli-dist/commands/account-get.d.ts +0 -2
  396. package/src/runtime/vendor/flywheel-cli-dist/commands/account-merge-preview.d.ts +0 -2
  397. package/src/runtime/vendor/flywheel-cli-dist/commands/account-merge-proof.d.ts +0 -2
  398. package/src/runtime/vendor/flywheel-cli-dist/commands/account-merge.d.ts +0 -2
  399. package/src/runtime/vendor/flywheel-cli-dist/commands/admin-compute-policy-get.d.ts +0 -2
  400. package/src/runtime/vendor/flywheel-cli-dist/commands/admin-compute-policy-set.d.ts +0 -2
  401. package/src/runtime/vendor/flywheel-cli-dist/commands/admin-graphs-export-stream.d.ts +0 -2
  402. package/src/runtime/vendor/flywheel-cli-dist/commands/admin-graphs-export.d.ts +0 -2
  403. package/src/runtime/vendor/flywheel-cli-dist/commands/admin-graphs-list.d.ts +0 -4
  404. package/src/runtime/vendor/flywheel-cli-dist/commands/admin-nodes-audit-list.d.ts +0 -2
  405. package/src/runtime/vendor/flywheel-cli-dist/commands/admin-test-users-create.d.ts +0 -2
  406. package/src/runtime/vendor/flywheel-cli-dist/commands/admin-test-users-delete.d.ts +0 -2
  407. package/src/runtime/vendor/flywheel-cli-dist/commands/admin-test-users-login.d.ts +0 -2
  408. package/src/runtime/vendor/flywheel-cli-dist/commands/aliases.d.ts +0 -13
  409. package/src/runtime/vendor/flywheel-cli-dist/commands/api-keys-create.d.ts +0 -2
  410. package/src/runtime/vendor/flywheel-cli-dist/commands/api-keys-delete.d.ts +0 -2
  411. package/src/runtime/vendor/flywheel-cli-dist/commands/api-keys-list.d.ts +0 -18
  412. package/src/runtime/vendor/flywheel-cli-dist/commands/api-keys-rotate.d.ts +0 -2
  413. package/src/runtime/vendor/flywheel-cli-dist/commands/approval-sessions-expire.d.ts +0 -2
  414. package/src/runtime/vendor/flywheel-cli-dist/commands/approval-sessions-heartbeat.d.ts +0 -2
  415. package/src/runtime/vendor/flywheel-cli-dist/commands/approval-sessions-list.d.ts +0 -2
  416. package/src/runtime/vendor/flywheel-cli-dist/commands/artifacts-delete-bulk.d.ts +0 -2
  417. package/src/runtime/vendor/flywheel-cli-dist/commands/artifacts-delete-bulk.js +0 -22
  418. package/src/runtime/vendor/flywheel-cli-dist/commands/artifacts-delete-bulk.js.map +0 -1
  419. package/src/runtime/vendor/flywheel-cli-dist/commands/artifacts-delete.d.ts +0 -2
  420. package/src/runtime/vendor/flywheel-cli-dist/commands/artifacts-delete.js +0 -8
  421. package/src/runtime/vendor/flywheel-cli-dist/commands/artifacts-delete.js.map +0 -1
  422. package/src/runtime/vendor/flywheel-cli-dist/commands/artifacts-get.d.ts +0 -2
  423. package/src/runtime/vendor/flywheel-cli-dist/commands/artifacts-list.d.ts +0 -2
  424. package/src/runtime/vendor/flywheel-cli-dist/commands/artifacts-note-set.d.ts +0 -2
  425. package/src/runtime/vendor/flywheel-cli-dist/commands/artifacts-note-set.js +0 -9
  426. package/src/runtime/vendor/flywheel-cli-dist/commands/artifacts-note-set.js.map +0 -1
  427. package/src/runtime/vendor/flywheel-cli-dist/commands/artifacts-upload-finalize.d.ts +0 -2
  428. package/src/runtime/vendor/flywheel-cli-dist/commands/artifacts-upload-finalize.js +0 -7
  429. package/src/runtime/vendor/flywheel-cli-dist/commands/artifacts-upload-finalize.js.map +0 -1
  430. package/src/runtime/vendor/flywheel-cli-dist/commands/artifacts-upload-prepare.d.ts +0 -2
  431. package/src/runtime/vendor/flywheel-cli-dist/commands/artifacts-upload-prepare.js +0 -15
  432. package/src/runtime/vendor/flywheel-cli-dist/commands/artifacts-upload-prepare.js.map +0 -1
  433. package/src/runtime/vendor/flywheel-cli-dist/commands/artifacts-upload.d.ts +0 -2
  434. package/src/runtime/vendor/flywheel-cli-dist/commands/artifacts-upload.js +0 -5
  435. package/src/runtime/vendor/flywheel-cli-dist/commands/artifacts-upload.js.map +0 -1
  436. package/src/runtime/vendor/flywheel-cli-dist/commands/auth-keychain-clear.d.ts +0 -2
  437. package/src/runtime/vendor/flywheel-cli-dist/commands/auth-keychain-clear.js +0 -8
  438. package/src/runtime/vendor/flywheel-cli-dist/commands/auth-keychain-clear.js.map +0 -1
  439. package/src/runtime/vendor/flywheel-cli-dist/commands/auth-keychain-set.d.ts +0 -2
  440. package/src/runtime/vendor/flywheel-cli-dist/commands/auth-keychain-set.js +0 -30
  441. package/src/runtime/vendor/flywheel-cli-dist/commands/auth-keychain-set.js.map +0 -1
  442. package/src/runtime/vendor/flywheel-cli-dist/commands/auth-login.d.ts +0 -2
  443. package/src/runtime/vendor/flywheel-cli-dist/commands/auth-mode.d.ts +0 -4
  444. package/src/runtime/vendor/flywheel-cli-dist/commands/auth-status.d.ts +0 -2
  445. package/src/runtime/vendor/flywheel-cli-dist/commands/blobs-get.d.ts +0 -2
  446. package/src/runtime/vendor/flywheel-cli-dist/commands/campaign-budgets-create.d.ts +0 -2
  447. package/src/runtime/vendor/flywheel-cli-dist/commands/campaign-budgets-list.d.ts +0 -1
  448. package/src/runtime/vendor/flywheel-cli-dist/commands/campaign-budgets-revoke.d.ts +0 -1
  449. package/src/runtime/vendor/flywheel-cli-dist/commands/campaign-budgets-update.d.ts +0 -2
  450. package/src/runtime/vendor/flywheel-cli-dist/commands/campaign-snapshot.d.ts +0 -1
  451. package/src/runtime/vendor/flywheel-cli-dist/commands/compute-acquire.d.ts +0 -2
  452. package/src/runtime/vendor/flywheel-cli-dist/commands/compute-budgets.d.ts +0 -2
  453. package/src/runtime/vendor/flywheel-cli-dist/commands/compute-connection.d.ts +0 -2
  454. package/src/runtime/vendor/flywheel-cli-dist/commands/compute-funding.d.ts +0 -2
  455. package/src/runtime/vendor/flywheel-cli-dist/commands/compute-grants-list.d.ts +0 -2
  456. package/src/runtime/vendor/flywheel-cli-dist/commands/compute-grants-request-approval.d.ts +0 -2
  457. package/src/runtime/vendor/flywheel-cli-dist/commands/compute-options.d.ts +0 -2
  458. package/src/runtime/vendor/flywheel-cli-dist/commands/compute-release-all.d.ts +0 -2
  459. package/src/runtime/vendor/flywheel-cli-dist/commands/compute-release.d.ts +0 -2
  460. package/src/runtime/vendor/flywheel-cli-dist/commands/compute-status.d.ts +0 -2
  461. package/src/runtime/vendor/flywheel-cli-dist/commands/credits-balance.d.ts +0 -1
  462. package/src/runtime/vendor/flywheel-cli-dist/commands/credits-billing-portal.d.ts +0 -2
  463. package/src/runtime/vendor/flywheel-cli-dist/commands/credits-purchase.d.ts +0 -2
  464. package/src/runtime/vendor/flywheel-cli-dist/commands/credits-referral-claim.d.ts +0 -2
  465. package/src/runtime/vendor/flywheel-cli-dist/commands/credits-referral.d.ts +0 -1
  466. package/src/runtime/vendor/flywheel-cli-dist/commands/credits-subscribe.d.ts +0 -2
  467. package/src/runtime/vendor/flywheel-cli-dist/commands/credits-subscription.d.ts +0 -1
  468. package/src/runtime/vendor/flywheel-cli-dist/commands/credits-transactions.d.ts +0 -2
  469. package/src/runtime/vendor/flywheel-cli-dist/commands/credits-usage.d.ts +0 -2
  470. package/src/runtime/vendor/flywheel-cli-dist/commands/destructive-confirmation.d.ts +0 -2
  471. package/src/runtime/vendor/flywheel-cli-dist/commands/enums.d.ts +0 -22
  472. package/src/runtime/vendor/flywheel-cli-dist/commands/env.d.ts +0 -8
  473. package/src/runtime/vendor/flywheel-cli-dist/commands/executions-launch.d.ts +0 -2
  474. package/src/runtime/vendor/flywheel-cli-dist/commands/executions-list.d.ts +0 -1
  475. package/src/runtime/vendor/flywheel-cli-dist/commands/executions-terminate.d.ts +0 -2
  476. package/src/runtime/vendor/flywheel-cli-dist/commands/export-history.d.ts +0 -2
  477. package/src/runtime/vendor/flywheel-cli-dist/commands/export-subgraph.d.ts +0 -2
  478. package/src/runtime/vendor/flywheel-cli-dist/commands/export-summary-pdf.d.ts +0 -2
  479. package/src/runtime/vendor/flywheel-cli-dist/commands/export-summary-render-pdf.d.ts +0 -2
  480. package/src/runtime/vendor/flywheel-cli-dist/commands/export-summary-stream.d.ts +0 -2
  481. package/src/runtime/vendor/flywheel-cli-dist/commands/export-summary.d.ts +0 -2
  482. package/src/runtime/vendor/flywheel-cli-dist/commands/feedback-create.d.ts +0 -2
  483. package/src/runtime/vendor/flywheel-cli-dist/commands/files-list.d.ts +0 -2
  484. package/src/runtime/vendor/flywheel-cli-dist/commands/github-disconnect.d.ts +0 -1
  485. package/src/runtime/vendor/flywheel-cli-dist/commands/github-link.d.ts +0 -2
  486. package/src/runtime/vendor/flywheel-cli-dist/commands/github-refresh-repos.d.ts +0 -1
  487. package/src/runtime/vendor/flywheel-cli-dist/commands/github-status.d.ts +0 -1
  488. package/src/runtime/vendor/flywheel-cli-dist/commands/graph-get.d.ts +0 -2
  489. package/src/runtime/vendor/flywheel-cli-dist/commands/handler-factory.d.ts +0 -22
  490. package/src/runtime/vendor/flywheel-cli-dist/commands/help-format.d.ts +0 -31
  491. package/src/runtime/vendor/flywheel-cli-dist/commands/help-metadata.d.ts +0 -36
  492. package/src/runtime/vendor/flywheel-cli-dist/commands/help.d.ts +0 -17
  493. package/src/runtime/vendor/flywheel-cli-dist/commands/hooks-create.d.ts +0 -2
  494. package/src/runtime/vendor/flywheel-cli-dist/commands/hooks-delete.d.ts +0 -1
  495. package/src/runtime/vendor/flywheel-cli-dist/commands/hooks-list.d.ts +0 -2
  496. package/src/runtime/vendor/flywheel-cli-dist/commands/hooks-runs-list.d.ts +0 -2
  497. package/src/runtime/vendor/flywheel-cli-dist/commands/hooks-secrets-create.d.ts +0 -2
  498. package/src/runtime/vendor/flywheel-cli-dist/commands/hooks-secrets-delete.d.ts +0 -1
  499. package/src/runtime/vendor/flywheel-cli-dist/commands/hooks-secrets-list.d.ts +0 -1
  500. package/src/runtime/vendor/flywheel-cli-dist/commands/hooks-secrets-update.d.ts +0 -2
  501. package/src/runtime/vendor/flywheel-cli-dist/commands/hooks-set-enabled.d.ts +0 -2
  502. package/src/runtime/vendor/flywheel-cli-dist/commands/hooks-update.d.ts +0 -2
  503. package/src/runtime/vendor/flywheel-cli-dist/commands/import-subgraph.d.ts +0 -2
  504. package/src/runtime/vendor/flywheel-cli-dist/commands/index.d.ts +0 -23
  505. package/src/runtime/vendor/flywheel-cli-dist/commands/integrations-huggingface-remove.d.ts +0 -1
  506. package/src/runtime/vendor/flywheel-cli-dist/commands/integrations-huggingface-set.d.ts +0 -2
  507. package/src/runtime/vendor/flywheel-cli-dist/commands/integrations-status.d.ts +0 -1
  508. package/src/runtime/vendor/flywheel-cli-dist/commands/integrations-wandb-remove.d.ts +0 -1
  509. package/src/runtime/vendor/flywheel-cli-dist/commands/integrations-wandb-set.d.ts +0 -2
  510. package/src/runtime/vendor/flywheel-cli-dist/commands/machines-list.d.ts +0 -1
  511. package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-add-parent.d.ts +0 -2
  512. package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-add-parent.js +0 -15
  513. package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-add-parent.js.map +0 -1
  514. package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-branch.d.ts +0 -2
  515. package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-branch.js +0 -10
  516. package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-branch.js.map +0 -1
  517. package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-children.d.ts +0 -2
  518. package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-children.js +0 -8
  519. package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-children.js.map +0 -1
  520. package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-commit-new.d.ts +0 -2
  521. package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-commit-new.js +0 -6
  522. package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-commit-new.js.map +0 -1
  523. package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-commit.d.ts +0 -2
  524. package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-commit.js +0 -7
  525. package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-commit.js.map +0 -1
  526. package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-create.d.ts +0 -2
  527. package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-create.js +0 -6
  528. package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-create.js.map +0 -1
  529. package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-delete-bulk.d.ts +0 -2
  530. package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-delete-bulk.js +0 -16
  531. package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-delete-bulk.js.map +0 -1
  532. package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-delete.d.ts +0 -2
  533. package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-delete.js +0 -11
  534. package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-delete.js.map +0 -1
  535. package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-files.d.ts +0 -1
  536. package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-get.d.ts +0 -2
  537. package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-list.d.ts +0 -2
  538. package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-merge.d.ts +0 -2
  539. package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-merge.js +0 -33
  540. package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-merge.js.map +0 -1
  541. package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-parents.d.ts +0 -2
  542. package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-parents.js +0 -8
  543. package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-parents.js.map +0 -1
  544. package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-remove-parent.d.ts +0 -2
  545. package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-remove-parent.js +0 -15
  546. package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-remove-parent.js.map +0 -1
  547. package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-render-ancestry.d.ts +0 -2
  548. package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-render-summary.d.ts +0 -2
  549. package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-render-tree.d.ts +0 -2
  550. package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-resolve-slug.d.ts +0 -2
  551. package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-sharing-get.d.ts +0 -1
  552. package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-sharing-set-bulk.d.ts +0 -2
  553. package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-sharing-set.d.ts +0 -2
  554. package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-sharing-summaries.d.ts +0 -2
  555. package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-stage-lease-acquire.d.ts +0 -2
  556. package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-stage-lease-heartbeat.d.ts +0 -2
  557. package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-stage-lease-release.d.ts +0 -2
  558. package/src/runtime/vendor/flywheel-cli-dist/commands/profile-list.d.ts +0 -2
  559. package/src/runtime/vendor/flywheel-cli-dist/commands/profile-set.d.ts +0 -2
  560. package/src/runtime/vendor/flywheel-cli-dist/commands/profile-show.d.ts +0 -2
  561. package/src/runtime/vendor/flywheel-cli-dist/commands/profile-unset.d.ts +0 -2
  562. package/src/runtime/vendor/flywheel-cli-dist/commands/registry/account.d.ts +0 -2
  563. package/src/runtime/vendor/flywheel-cli-dist/commands/registry/admin.d.ts +0 -8
  564. package/src/runtime/vendor/flywheel-cli-dist/commands/registry/api-keys.d.ts +0 -2
  565. package/src/runtime/vendor/flywheel-cli-dist/commands/registry/approval.d.ts +0 -2
  566. package/src/runtime/vendor/flywheel-cli-dist/commands/registry/artifacts.d.ts +0 -2
  567. package/src/runtime/vendor/flywheel-cli-dist/commands/registry/artifacts.js +0 -140
  568. package/src/runtime/vendor/flywheel-cli-dist/commands/registry/artifacts.js.map +0 -1
  569. package/src/runtime/vendor/flywheel-cli-dist/commands/registry/auth.d.ts +0 -2
  570. package/src/runtime/vendor/flywheel-cli-dist/commands/registry/budgets.d.ts +0 -2
  571. package/src/runtime/vendor/flywheel-cli-dist/commands/registry/compute.d.ts +0 -2
  572. package/src/runtime/vendor/flywheel-cli-dist/commands/registry/credits.d.ts +0 -2
  573. package/src/runtime/vendor/flywheel-cli-dist/commands/registry/env.d.ts +0 -2
  574. package/src/runtime/vendor/flywheel-cli-dist/commands/registry/executions.d.ts +0 -2
  575. package/src/runtime/vendor/flywheel-cli-dist/commands/registry/export.d.ts +0 -2
  576. package/src/runtime/vendor/flywheel-cli-dist/commands/registry/github.d.ts +0 -2
  577. package/src/runtime/vendor/flywheel-cli-dist/commands/registry/graph.d.ts +0 -2
  578. package/src/runtime/vendor/flywheel-cli-dist/commands/registry/hooks.d.ts +0 -2
  579. package/src/runtime/vendor/flywheel-cli-dist/commands/registry/integrations.d.ts +0 -2
  580. package/src/runtime/vendor/flywheel-cli-dist/commands/registry/lifecycle.d.ts +0 -2
  581. package/src/runtime/vendor/flywheel-cli-dist/commands/registry/profile.d.ts +0 -2
  582. package/src/runtime/vendor/flywheel-cli-dist/commands/registry/resources.d.ts +0 -2
  583. package/src/runtime/vendor/flywheel-cli-dist/commands/registry/sharing.d.ts +0 -2
  584. package/src/runtime/vendor/flywheel-cli-dist/commands/registry/tagging.d.ts +0 -2
  585. package/src/runtime/vendor/flywheel-cli-dist/commands/registry/tagging.js +0 -98
  586. package/src/runtime/vendor/flywheel-cli-dist/commands/registry/tagging.js.map +0 -1
  587. package/src/runtime/vendor/flywheel-cli-dist/commands/registry/updates.d.ts +0 -2
  588. package/src/runtime/vendor/flywheel-cli-dist/commands/registry.d.ts +0 -27
  589. package/src/runtime/vendor/flywheel-cli-dist/commands/remote-artifacts-refresh.d.ts +0 -2
  590. package/src/runtime/vendor/flywheel-cli-dist/commands/remote-artifacts-resolve.d.ts +0 -2
  591. package/src/runtime/vendor/flywheel-cli-dist/commands/tags-assign.d.ts +0 -2
  592. package/src/runtime/vendor/flywheel-cli-dist/commands/tags-assign.js +0 -25
  593. package/src/runtime/vendor/flywheel-cli-dist/commands/tags-assign.js.map +0 -1
  594. package/src/runtime/vendor/flywheel-cli-dist/commands/tags-create.d.ts +0 -2
  595. package/src/runtime/vendor/flywheel-cli-dist/commands/tags-create.js +0 -25
  596. package/src/runtime/vendor/flywheel-cli-dist/commands/tags-create.js.map +0 -1
  597. package/src/runtime/vendor/flywheel-cli-dist/commands/tags-delete.d.ts +0 -2
  598. package/src/runtime/vendor/flywheel-cli-dist/commands/tags-delete.js +0 -11
  599. package/src/runtime/vendor/flywheel-cli-dist/commands/tags-delete.js.map +0 -1
  600. package/src/runtime/vendor/flywheel-cli-dist/commands/tags-update.d.ts +0 -2
  601. package/src/runtime/vendor/flywheel-cli-dist/commands/tags-update.js +0 -28
  602. package/src/runtime/vendor/flywheel-cli-dist/commands/tags-update.js.map +0 -1
  603. package/src/runtime/vendor/flywheel-cli-dist/commands/types.d.ts +0 -30
  604. package/src/runtime/vendor/flywheel-cli-dist/commands/updates-hide-all-active.d.ts +0 -1
  605. package/src/runtime/vendor/flywheel-cli-dist/commands/updates-hide.d.ts +0 -2
  606. package/src/runtime/vendor/flywheel-cli-dist/commands/updates-list.d.ts +0 -2
  607. package/src/runtime/vendor/flywheel-cli-dist/commands/usage-spec.d.ts +0 -6
  608. package/src/runtime/vendor/flywheel-cli-dist/commands/utils.d.ts +0 -11
  609. package/src/runtime/vendor/flywheel-cli-dist/errors.d.ts +0 -86
  610. package/src/runtime/vendor/flywheel-cli-dist/exit-codes.d.ts +0 -8
  611. package/src/runtime/vendor/flywheel-cli-dist/generatedFeedbackContract.d.ts +0 -41
  612. package/src/runtime/vendor/flywheel-cli-dist/generatedProductTelemetryContract.d.ts +0 -13
  613. package/src/runtime/vendor/flywheel-cli-dist/grammar/globals.d.ts +0 -26
  614. package/src/runtime/vendor/flywheel-cli-dist/grammar/parse.d.ts +0 -17
  615. package/src/runtime/vendor/flywheel-cli-dist/http/client.d.ts +0 -91
  616. package/src/runtime/vendor/flywheel-cli-dist/http/debug.d.ts +0 -5
  617. package/src/runtime/vendor/flywheel-cli-dist/http/poll.d.ts +0 -18
  618. package/src/runtime/vendor/flywheel-cli-dist/http/retry.d.ts +0 -30
  619. package/src/runtime/vendor/flywheel-cli-dist/main.d.ts +0 -33
  620. package/src/runtime/vendor/flywheel-cli-dist/output/format.d.ts +0 -9
  621. package/src/runtime/vendor/flywheel-cli-dist/runtime-entry.d.ts +0 -1
  622. package/src/runtime/vendor/flywheel-cli-dist/version.d.ts +0 -3
  623. package/src/secure-write.mjs +0 -43
@@ -0,0 +1,240 @@
1
+ import { createHash } from "node:crypto";
2
+ import { artifactReferenceSetDigest, foldArtifactPropertiesOperation, legacyArtifactMetadata, legacyArtifactProperties, parseArtifactProperties, } from "../../domain/models/artifact-properties.js";
3
+ import { canonicalBytes, valueDigest } from "../../domain/models/encoding.js";
4
+ import { RepositoryStoreError } from "../sqlite/errors.js";
5
+ import { getRow, runSql } from "../sqlite/rows.js";
6
+ import { assertLiveNodes } from "./rules.js";
7
+ const LEGACY_FIELDS = ["name", "media_type", "notes", "tags"];
8
+ function stringValue(value) {
9
+ return typeof value === "string" ? value : undefined;
10
+ }
11
+ function legacyField(value) {
12
+ return typeof value === "string" && LEGACY_FIELDS.includes(value)
13
+ ? value
14
+ : undefined;
15
+ }
16
+ function projectionDigest(value) {
17
+ return `sha256:${createHash("sha256").update(canonicalBytes(value)).digest("hex")}`;
18
+ }
19
+ function latestValue(latestValues, artifactId, field) {
20
+ return latestValues.get(canonicalBytes(["artifact", artifactId, field]).toString("utf8"));
21
+ }
22
+ function requirePropertiesWrite(latestValues, artifactId, digest) {
23
+ const write = latestValue(latestValues, artifactId, "properties");
24
+ if (!write || write.value === null || write.valueDigest !== digest) {
25
+ throw new RepositoryStoreError("artifact properties latest value is invalid");
26
+ }
27
+ try {
28
+ parseArtifactProperties(write.value);
29
+ }
30
+ catch (error) {
31
+ throw new RepositoryStoreError("artifact properties are invalid", { cause: error });
32
+ }
33
+ return write.value;
34
+ }
35
+ function assertOwner(database, repositoryId, kind, ownerId) {
36
+ if (kind === "node") {
37
+ assertLiveNodes(database, repositoryId, [ownerId]);
38
+ return;
39
+ }
40
+ const edge = getRow(database.prepare("SELECT graph_node_id, source_node_id, target_node_id FROM repository_semantic_edges WHERE repository_id = ? AND edge_id = ?"), repositoryId, ownerId);
41
+ if (!edge)
42
+ throw new RepositoryStoreError("artifact owner edge is missing");
43
+ const ids = [edge.graph_node_id, edge.source_node_id, edge.target_node_id];
44
+ if (!ids.every((value) => typeof value === "string")) {
45
+ throw new RepositoryStoreError("artifact owner edge is not live");
46
+ }
47
+ try {
48
+ assertLiveNodes(database, repositoryId, ids);
49
+ }
50
+ catch (error) {
51
+ throw new RepositoryStoreError("artifact owner edge is not live", { cause: error });
52
+ }
53
+ }
54
+ function referenceSet(database, repositoryId, artifactId) {
55
+ const rows = database.prepare(`
56
+ SELECT owner_kind, owner_id, reference_order
57
+ FROM repository_artifact_references
58
+ WHERE repository_id = ? AND artifact_id = ?
59
+ ORDER BY owner_kind, owner_id
60
+ `, { readBigInts: true }).all(repositoryId, artifactId);
61
+ if (rows.length === 0)
62
+ throw new RepositoryStoreError("artifact has no live references");
63
+ const entries = [];
64
+ for (const row of rows) {
65
+ if ((row.owner_kind !== "node" && row.owner_kind !== "edge") || typeof row.owner_id !== "string" ||
66
+ typeof row.reference_order !== "bigint") {
67
+ throw new RepositoryStoreError("artifact reference is invalid");
68
+ }
69
+ assertOwner(database, repositoryId, row.owner_kind, row.owner_id);
70
+ entries.push({ owner_type: row.owner_kind, owner_id: row.owner_id, order: row.reference_order });
71
+ }
72
+ return entries;
73
+ }
74
+ function attachProperties(operation, artifactId, latestValues) {
75
+ if (operation.type === "artifact.attach.v2") {
76
+ const digest = stringValue(operation.payload.properties_digest);
77
+ if (!digest)
78
+ throw new RepositoryStoreError("invalid artifact attachment");
79
+ return { properties: requirePropertiesWrite(latestValues, artifactId, digest), digest };
80
+ }
81
+ const metadata = {};
82
+ for (const field of LEGACY_FIELDS)
83
+ metadata[field] = latestValue(latestValues, artifactId, field)?.value ?? null;
84
+ const metadataDigest = stringValue(operation.payload.metadata_digest);
85
+ if (!metadataDigest || projectionDigest(metadata) !== metadataDigest) {
86
+ throw new RepositoryStoreError("artifact metadata digest is invalid");
87
+ }
88
+ const properties = legacyArtifactProperties(metadata);
89
+ return { properties, digest: valueDigest(properties) };
90
+ }
91
+ function attach(database, commit, operation, artifactId, kind, ownerId, latestValues) {
92
+ const objectDigest = stringValue(operation.payload.object_digest);
93
+ const order = operation.payload.order;
94
+ if (!objectDigest || typeof order !== "bigint")
95
+ throw new RepositoryStoreError("invalid artifact attachment");
96
+ const artifact = getRow(database.prepare("SELECT object_digest, properties, properties_digest FROM repository_artifacts WHERE repository_id = ? AND artifact_id = ?"), commit.repositoryId, artifactId);
97
+ if (!artifact) {
98
+ const { properties, digest } = attachProperties(operation, artifactId, latestValues);
99
+ runSql(database.prepare(`
100
+ INSERT INTO repository_artifacts (
101
+ repository_id, artifact_id, object_digest, properties, properties_digest, created_by_commit_id
102
+ ) VALUES (?, ?, ?, ?, ?, ?)
103
+ `), commit.repositoryId, artifactId, objectDigest, properties, digest, commit.commitId);
104
+ }
105
+ else if (artifact.object_digest !== objectDigest ||
106
+ (operation.type === "artifact.attach.v2"
107
+ ? artifact.properties_digest !== operation.payload.properties_digest
108
+ : projectionDigest(legacyArtifactMetadata(String(artifact.properties))) !== operation.payload.metadata_digest)) {
109
+ throw new RepositoryStoreError("artifact object or properties digest precondition failed");
110
+ }
111
+ if (getRow(database.prepare("SELECT 1 AS present FROM repository_artifact_references WHERE repository_id = ? AND artifact_id = ? AND owner_kind = ? AND owner_id = ?"), commit.repositoryId, artifactId, kind, ownerId)) {
112
+ throw new RepositoryStoreError("artifact reference already exists");
113
+ }
114
+ runSql(database.prepare(`
115
+ INSERT INTO repository_artifact_references (
116
+ repository_id, artifact_id, owner_kind, owner_id, node_owner_id, edge_owner_id, reference_order, attached_by_commit_id
117
+ ) VALUES (?, ?, ?, ?, ?, ?, ?, ?)
118
+ `), commit.repositoryId, artifactId, kind, ownerId, kind === "node" ? ownerId : null, kind === "edge" ? ownerId : null, order, commit.commitId);
119
+ }
120
+ function referenceDigest(artifactId, objectDigest, kind, ownerId, order) {
121
+ return projectionDigest({ artifact_id: artifactId, object_digest: objectDigest, owner_kind: kind, owner_id: ownerId, reference_order: order });
122
+ }
123
+ function detach(database, commit, operation, artifactId, kind, ownerId) {
124
+ const objectDigest = stringValue(operation.payload.object_digest);
125
+ const expected = stringValue(operation.payload.reference_digest);
126
+ if (!objectDigest || !expected)
127
+ throw new RepositoryStoreError("invalid artifact detachment");
128
+ const row = getRow(database.prepare(`
129
+ SELECT artifact.object_digest, reference.reference_order
130
+ FROM repository_artifacts AS artifact
131
+ JOIN repository_artifact_references AS reference
132
+ ON reference.repository_id = artifact.repository_id AND reference.artifact_id = artifact.artifact_id
133
+ WHERE artifact.repository_id = ? AND artifact.artifact_id = ? AND reference.owner_kind = ? AND reference.owner_id = ?
134
+ `, { readBigInts: true }), commit.repositoryId, artifactId, kind, ownerId);
135
+ if (!row || row.object_digest !== objectDigest || typeof row.reference_order !== "bigint" ||
136
+ expected !== referenceDigest(artifactId, objectDigest, kind, ownerId, row.reference_order)) {
137
+ throw new RepositoryStoreError("artifact reference digest precondition failed");
138
+ }
139
+ rootArtifactHistory(database, commit.repositoryId, commit.commitId, [objectDigest]);
140
+ runSql(database.prepare("DELETE FROM repository_artifact_references WHERE repository_id = ? AND artifact_id = ? AND owner_kind = ? AND owner_id = ?"), commit.repositoryId, artifactId, kind, ownerId);
141
+ }
142
+ function rootArtifactHistory(database, repositoryId, commitId, digests) {
143
+ const statement = database.prepare(`
144
+ INSERT OR IGNORE INTO repository_gc_roots (repository_id, root_kind, root_id, digest)
145
+ VALUES (?, 'artifact_history', ?, ?)
146
+ `);
147
+ for (const digest of new Set(digests))
148
+ runSql(statement, repositoryId, commitId, digest);
149
+ }
150
+ function setSharedValue(database, commit, operation, artifactId, latestValues) {
151
+ const artifact = getRow(database.prepare("SELECT object_digest, properties_digest FROM repository_artifacts WHERE repository_id = ? AND artifact_id = ?"), commit.repositoryId, artifactId);
152
+ if (!artifact || typeof artifact.object_digest !== "string" || typeof artifact.properties_digest !== "string") {
153
+ throw new RepositoryStoreError("artifact is missing");
154
+ }
155
+ const expectedReferences = stringValue(operation.payload.expected_reference_digest);
156
+ if (!expectedReferences || expectedReferences !== artifactReferenceSetDigest(referenceSet(database, commit.repositoryId, artifactId))) {
157
+ throw new RepositoryStoreError("artifact reference digest precondition failed");
158
+ }
159
+ if (operation.type === "artifact.content.set.v1") {
160
+ const expected = stringValue(operation.payload.expected_object_digest);
161
+ const replacement = stringValue(operation.payload.object_digest);
162
+ if (!expected || !replacement || artifact.object_digest !== expected) {
163
+ throw new RepositoryStoreError("artifact object digest precondition failed");
164
+ }
165
+ runSql(database.prepare("UPDATE repository_artifacts SET object_digest = ? WHERE repository_id = ? AND artifact_id = ?"), replacement, commit.repositoryId, artifactId);
166
+ rootArtifactHistory(database, commit.repositoryId, commit.commitId, [artifact.object_digest, replacement]);
167
+ return;
168
+ }
169
+ const expected = stringValue(operation.payload.expected_digest);
170
+ const replacement = stringValue(operation.payload.new_digest);
171
+ if (!expected || !replacement || artifact.properties_digest !== expected) {
172
+ throw new RepositoryStoreError("artifact properties digest precondition failed");
173
+ }
174
+ const properties = requirePropertiesWrite(latestValues, artifactId, replacement);
175
+ runSql(database.prepare("UPDATE repository_artifacts SET properties = ?, properties_digest = ? WHERE repository_id = ? AND artifact_id = ?"), properties, replacement, commit.repositoryId, artifactId);
176
+ }
177
+ function setLegacyMetadata(database, commit, operation, artifactId, kind, ownerId, latestValues) {
178
+ const field = legacyField(operation.payload.field);
179
+ const expected = stringValue(operation.payload.expected_digest);
180
+ const replacement = stringValue(operation.payload.new_digest);
181
+ if (!field || !expected || !replacement)
182
+ throw new RepositoryStoreError("invalid artifact metadata operation");
183
+ if (!getRow(database.prepare("SELECT 1 AS present FROM repository_artifact_references WHERE repository_id = ? AND artifact_id = ? AND owner_kind = ? AND owner_id = ?"), commit.repositoryId, artifactId, kind, ownerId)) {
184
+ throw new RepositoryStoreError("artifact metadata owner reference is missing");
185
+ }
186
+ const row = getRow(database.prepare("SELECT properties FROM repository_artifacts WHERE repository_id = ? AND artifact_id = ?"), commit.repositoryId, artifactId);
187
+ if (!row || typeof row.properties !== "string")
188
+ throw new RepositoryStoreError("artifact metadata is missing");
189
+ let metadata;
190
+ try {
191
+ metadata = legacyArtifactMetadata(row.properties);
192
+ }
193
+ catch (error) {
194
+ throw new RepositoryStoreError("artifact properties are invalid", { cause: error });
195
+ }
196
+ if (valueDigest(metadata[field]) !== expected)
197
+ throw new RepositoryStoreError("artifact metadata digest precondition failed");
198
+ const write = latestValue(latestValues, artifactId, field);
199
+ if (!write || write.valueDigest !== replacement)
200
+ throw new RepositoryStoreError("artifact metadata latest value is invalid");
201
+ let properties;
202
+ try {
203
+ properties = foldArtifactPropertiesOperation(row.properties, operation, latestValues);
204
+ }
205
+ catch (error) {
206
+ throw new RepositoryStoreError("artifact properties are invalid", { cause: error });
207
+ }
208
+ if (properties === undefined)
209
+ throw new RepositoryStoreError("artifact properties are invalid");
210
+ runSql(database.prepare("UPDATE repository_artifacts SET properties = ?, properties_digest = ? WHERE repository_id = ? AND artifact_id = ?"), properties, valueDigest(properties), commit.repositoryId, artifactId);
211
+ }
212
+ export function applyArtifact(database, commit, operation, latestValues) {
213
+ const artifactId = stringValue(operation.payload.artifact_id);
214
+ if (!artifactId)
215
+ throw new RepositoryStoreError("invalid artifact projection payload");
216
+ if (operation.type === "artifact.content.set.v1" || operation.type === "artifact.properties.set.v1") {
217
+ setSharedValue(database, commit, operation, artifactId, latestValues);
218
+ return;
219
+ }
220
+ const owner = operation.payload.owner;
221
+ if (!owner || typeof owner !== "object" || Array.isArray(owner)) {
222
+ throw new RepositoryStoreError("invalid artifact projection payload");
223
+ }
224
+ const kind = owner.owner_type;
225
+ const ownerId = stringValue(owner.owner_id);
226
+ if ((kind !== "node" && kind !== "edge") || !ownerId)
227
+ throw new RepositoryStoreError("invalid artifact owner");
228
+ if (operation.type === "artifact.attach.v1" || operation.type === "artifact.attach.v2") {
229
+ assertOwner(database, commit.repositoryId, kind, ownerId);
230
+ attach(database, commit, operation, artifactId, kind, ownerId, latestValues);
231
+ return;
232
+ }
233
+ if (operation.type === "artifact.detach.v1") {
234
+ detach(database, commit, operation, artifactId, kind, ownerId);
235
+ return;
236
+ }
237
+ assertOwner(database, commit.repositoryId, kind, ownerId);
238
+ setLegacyMetadata(database, commit, operation, artifactId, kind, ownerId, latestValues);
239
+ }
240
+ //# sourceMappingURL=artifacts.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"artifacts.js","sourceRoot":"","sources":["../../../../src/local/store/projection/artifacts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC,OAAO,EACL,0BAA0B,EAC1B,+BAA+B,EAC/B,sBAAsB,EACtB,wBAAwB,EACxB,uBAAuB,GACxB,MAAM,4CAA4C,CAAC;AACpD,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAI9E,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,eAAe,EAAE,MAA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,oBAAoB,CAAC,wBAAwB,CAAC,CAAC;IAC/G,IAAI,SAAS,CAAC,IAAI,KAAK,oBAAoB,IAAI,SAAS,CAAC,IAAI,KAAK,oBAAoB,EAAE,CAAC;QACvF,WAAW,CAAC,QAAQ,EAAE,MAAM,CAAC,YAAY,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;QAC1D,MAAM,CAAC,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,UAAU,EAAE,IAAI,EAAE,OAAO,EAAE,YAAY,CAAC,CAAC;QAC7E,OAAO;IACT,CAAC;IACD,IAAI,SAAS,CAAC,IAAI,KAAK,oBAAoB,EAAE,CAAC;QAC5C,MAAM,CAAC,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,UAAU,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;QAC/D,OAAO;IACT,CAAC;IACD,WAAW,CAAC,QAAQ,EAAE,MAAM,CAAC,YAAY,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;IAC1D,iBAAiB,CAAC,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,UAAU,EAAE,IAAI,EAAE,OAAO,EAAE,YAAY,CAAC,CAAC;AAC1F,CAAC"}
@@ -0,0 +1,127 @@
1
+ import { RepositoryCommit } from "../../domain/models/commits.js";
2
+ import { RepositoryStoreError } from "../sqlite/errors.js";
3
+ import { getRow, runSql } from "../sqlite/rows.js";
4
+ const NODE_FIELDS = ["title", "slug_name", "summary", "content", "origin_host", "external_transcript_ref"];
5
+ function stringValue(value) {
6
+ return typeof value === "string" ? value : undefined;
7
+ }
8
+ function nodeField(value) {
9
+ return typeof value === "string" && NODE_FIELDS.includes(value) ? value : undefined;
10
+ }
11
+ export function applyNodeCreate(database, commit, operation) {
12
+ const nodeId = stringValue(operation.payload.node_id);
13
+ const values = operation.payload.initial_values;
14
+ const digests = operation.payload.initial_field_digests;
15
+ if (!nodeId || !values || typeof values !== "object" || Array.isArray(values) || !digests || typeof digests !== "object" || Array.isArray(digests)) {
16
+ throw new RepositoryStoreError("invalid node create projection payload");
17
+ }
18
+ const initial = values;
19
+ const fieldDigests = digests;
20
+ if (NODE_FIELDS.some((field) => (initial[field] !== null && typeof initial[field] !== "string") || typeof fieldDigests[field] !== "string")) {
21
+ throw new RepositoryStoreError("invalid node create projection payload");
22
+ }
23
+ runSql(database.prepare("INSERT INTO repository_nodes VALUES (?, ?, 'live', ?, ?)"), commit.repositoryId, nodeId, commit.commitId, commit.commitId);
24
+ runSql(database.prepare(`INSERT INTO repository_node_latest_values (
25
+ repository_id, node_id, title, slug_name, summary, content, origin_host, external_transcript_ref,
26
+ title_digest, slug_name_digest, summary_digest, content_digest, origin_host_digest, external_transcript_ref_digest,
27
+ updated_by_commit_id
28
+ ) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`), commit.repositoryId, nodeId, initial.title, initial.slug_name, initial.summary, initial.content, initial.origin_host, initial.external_transcript_ref, fieldDigests.title, fieldDigests.slug_name, fieldDigests.summary, fieldDigests.content, fieldDigests.origin_host, fieldDigests.external_transcript_ref, commit.commitId);
29
+ }
30
+ export function applyNodeFieldSet(database, commit, operation, latestValue) {
31
+ const nodeId = stringValue(operation.payload.node_id);
32
+ const field = nodeField(operation.payload.field);
33
+ const expected = stringValue(operation.payload.expected_digest);
34
+ const replacement = stringValue(operation.payload.new_digest);
35
+ if (!nodeId || !field || !expected || !replacement)
36
+ throw new RepositoryStoreError("invalid node field operation");
37
+ const row = getRow(database.prepare(`SELECT ${field}_digest AS digest FROM repository_node_latest_values WHERE repository_id = ? AND node_id = ?`), commit.repositoryId, nodeId);
38
+ if (!row || row.digest !== expected)
39
+ throw new RepositoryStoreError("node field projection precondition failed");
40
+ runSql(database.prepare(`UPDATE repository_node_latest_values
41
+ SET ${field} = ?, ${field}_digest = ?, updated_by_commit_id = ?
42
+ WHERE repository_id = ? AND node_id = ?`), latestValue.value, replacement, commit.commitId, commit.repositoryId, nodeId);
43
+ }
44
+ function structuralDependencyCount(database, repositoryId, nodeId) {
45
+ const row = getRow(database.prepare(`SELECT COUNT(*) AS count FROM (
46
+ SELECT parent_node_id FROM repository_lineage WHERE repository_id = ? AND (parent_node_id = ? OR child_node_id = ?)
47
+ UNION ALL SELECT containment_id FROM repository_containments WHERE repository_id = ? AND (container_node_id = ? OR child_node_id = ?)
48
+ UNION ALL SELECT edge_id FROM repository_semantic_edges WHERE repository_id = ? AND (graph_node_id = ? OR source_node_id = ? OR target_node_id = ?)
49
+ UNION ALL SELECT tag_id FROM repository_tag_definitions WHERE repository_id = ? AND scope_node_id = ? AND state = 'active'
50
+ UNION ALL SELECT tag_id FROM repository_tag_assignments WHERE repository_id = ? AND (scope_node_id = ? OR node_id = ?)
51
+ UNION ALL SELECT artifact_id FROM repository_artifact_references WHERE repository_id = ? AND node_owner_id = ?
52
+ )`, { readBigInts: true }), repositoryId, nodeId, nodeId, repositoryId, nodeId, nodeId, repositoryId, nodeId, nodeId, nodeId, repositoryId, nodeId, repositoryId, nodeId, nodeId, repositoryId, nodeId);
53
+ if (!row || typeof row.count !== "bigint")
54
+ throw new RepositoryStoreError("structural dependency count is invalid");
55
+ return row.count;
56
+ }
57
+ function assertRestoreStructure(database, repositoryId, nodeId) {
58
+ const row = getRow(database.prepare(`SELECT 1 AS present FROM repository_containments AS relation
59
+ JOIN repository_nodes AS counterpart ON counterpart.repository_id = relation.repository_id
60
+ AND counterpart.node_id = CASE WHEN relation.container_node_id = ? THEN relation.child_node_id ELSE relation.container_node_id END
61
+ WHERE relation.repository_id = ? AND (? IN (relation.container_node_id, relation.child_node_id)) AND counterpart.lifecycle_state != 'live'
62
+ UNION ALL
63
+ SELECT 1 AS present FROM repository_lineage AS relation
64
+ JOIN repository_nodes AS counterpart ON counterpart.repository_id = relation.repository_id
65
+ AND counterpart.node_id = CASE WHEN relation.parent_node_id = ? THEN relation.child_node_id ELSE relation.parent_node_id END
66
+ WHERE relation.repository_id = ? AND (? IN (relation.parent_node_id, relation.child_node_id)) AND counterpart.lifecycle_state != 'live'
67
+ UNION ALL
68
+ SELECT 1 AS present FROM repository_semantic_edges AS relation
69
+ JOIN repository_nodes AS counterpart ON counterpart.repository_id = relation.repository_id
70
+ AND counterpart.node_id IN (relation.graph_node_id, relation.source_node_id, relation.target_node_id) AND counterpart.node_id != ?
71
+ WHERE relation.repository_id = ? AND ? IN (relation.graph_node_id, relation.source_node_id, relation.target_node_id) AND counterpart.lifecycle_state != 'live'
72
+ LIMIT 1`), nodeId, repositoryId, nodeId, nodeId, repositoryId, nodeId, nodeId, repositoryId, nodeId);
73
+ if (row)
74
+ throw new RepositoryStoreError("node restore violates structural invariants");
75
+ }
76
+ function revertsNodeCreate(database, commit, nodeId) {
77
+ if (!commit.intent || !/^revert:sha256:[0-9a-f]{64}$/.test(commit.intent))
78
+ return false;
79
+ const targetId = commit.intent.slice("revert:".length);
80
+ const row = getRow(database.prepare("SELECT canonical_bytes FROM repository_commits WHERE repository_id = ? AND commit_id = ?"), commit.repositoryId, targetId);
81
+ if (!row)
82
+ throw new RepositoryStoreError("revert target commit is missing");
83
+ if (!(row.canonical_bytes instanceof Uint8Array))
84
+ throw new RepositoryStoreError("revert target commit is corrupt");
85
+ let target;
86
+ try {
87
+ target = RepositoryCommit.fromCanonicalBytes(targetId, row.canonical_bytes);
88
+ }
89
+ catch (error) {
90
+ throw new RepositoryStoreError("revert target commit is corrupt", { cause: error });
91
+ }
92
+ return target.operations.some((candidate) => candidate.type === "node.create.v1" && candidate.payload.node_id === nodeId);
93
+ }
94
+ export function applyNodeLifecycle(database, commit, operation) {
95
+ const nodeId = stringValue(operation.payload.node_id);
96
+ const expected = stringValue(operation.payload.expected_lifecycle);
97
+ if (!nodeId || (expected !== "live" && expected !== "tombstoned"))
98
+ throw new RepositoryStoreError("invalid node lifecycle operation");
99
+ if (operation.type === "node.restore.v1")
100
+ assertRestoreStructure(database, commit.repositoryId, nodeId);
101
+ else if (revertsNodeCreate(database, commit, nodeId) && structuralDependencyCount(database, commit.repositoryId, nodeId) !== 0n) {
102
+ throw new RepositoryStoreError("node create revert has new live structural dependencies");
103
+ }
104
+ const next = operation.type === "node.tombstone.v1" ? "tombstoned" : "live";
105
+ if (runSql(database.prepare("UPDATE repository_nodes SET lifecycle_state = ?, lifecycle_commit_id = ? WHERE repository_id = ? AND node_id = ? AND lifecycle_state = ?"), next, commit.commitId, commit.repositoryId, nodeId, expected).changes !== 1)
106
+ throw new RepositoryStoreError("node lifecycle projection precondition failed");
107
+ }
108
+ export function applyNodePurge(database, commit, operation) {
109
+ const nodeId = stringValue(operation.payload.node_id);
110
+ const expectedHead = stringValue(operation.payload.expected_head);
111
+ const confirmation = stringValue(operation.payload.confirmation_node_id);
112
+ const declared = operation.payload.live_dependency_count;
113
+ const acceptedZero = declared === 0 || declared === 0n || declared === false ||
114
+ (JSON.isRawJSON(declared) && Number(declared.rawJSON) === 0);
115
+ if (!nodeId || !expectedHead || !confirmation || !acceptedZero)
116
+ throw new RepositoryStoreError("invalid node purge operation");
117
+ if (nodeId !== confirmation || expectedHead !== commit.expectedHead) {
118
+ throw new RepositoryStoreError("node purge confirmation or head is invalid");
119
+ }
120
+ const dependencies = structuralDependencyCount(database, commit.repositoryId, nodeId);
121
+ if (dependencies !== 0n)
122
+ throw new RepositoryStoreError("node purge has live structural dependencies");
123
+ if (runSql(database.prepare("UPDATE repository_nodes SET lifecycle_state = 'purged', lifecycle_commit_id = ? WHERE repository_id = ? AND node_id = ? AND lifecycle_state = 'tombstoned'"), commit.commitId, commit.repositoryId, nodeId).changes !== 1)
124
+ throw new RepositoryStoreError("node purge projection precondition failed");
125
+ runSql(database.prepare("DELETE FROM repository_node_latest_values WHERE repository_id = ? AND node_id = ?"), commit.repositoryId, nodeId);
126
+ }
127
+ //# sourceMappingURL=nodes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"nodes.js","sourceRoot":"","sources":["../../../../src/local/store/projection/nodes.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,M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,CAAC,YAAY,EAAE,MAAM,CAAC,CAAC;AAC5I,CAAC"}
@@ -0,0 +1,107 @@
1
+ import { canonicalBytes } from "../../domain/models/encoding.js";
2
+ import { RepositoryStoreError } from "../sqlite/errors.js";
3
+ import { getRow, runSql } from "../sqlite/rows.js";
4
+ import { assertAcyclicRelation, assertAllSemanticEdgesValid, assertLiveNodes, assertSemanticEdgeValid } from "./rules.js";
5
+ function stringValue(value) {
6
+ return typeof value === "string" ? value : undefined;
7
+ }
8
+ export function applyLineage(database, commit, operation) {
9
+ const parentId = stringValue(operation.payload.parent_node_id);
10
+ const childId = stringValue(operation.payload.child_node_id);
11
+ if (!parentId || !childId)
12
+ throw new RepositoryStoreError("invalid lineage operation");
13
+ if (operation.type === "lineage.add.v1") {
14
+ assertLiveNodes(database, commit.repositoryId, [parentId, childId]);
15
+ assertAcyclicRelation(database, commit.repositoryId, parentId, childId, "repository_lineage");
16
+ try {
17
+ runSql(database.prepare("INSERT INTO repository_lineage VALUES (?, ?, ?, ?)"), commit.repositoryId, parentId, childId, commit.commitId);
18
+ }
19
+ catch (error) {
20
+ throw new RepositoryStoreError("lineage relation already exists", { cause: error });
21
+ }
22
+ return;
23
+ }
24
+ if (runSql(database.prepare("DELETE FROM repository_lineage WHERE repository_id = ? AND parent_node_id = ? AND child_node_id = ?"), commit.repositoryId, parentId, childId).changes !== 1)
25
+ throw new RepositoryStoreError("lineage relation projection precondition failed");
26
+ }
27
+ export function applyContainment(database, commit, operation) {
28
+ const containmentId = stringValue(operation.payload.containment_id);
29
+ const childId = stringValue(operation.payload.child_node_id);
30
+ const relationDigest = stringValue(operation.payload.relation_digest);
31
+ if (!containmentId || !childId || !relationDigest)
32
+ throw new RepositoryStoreError("invalid containment operation");
33
+ if (operation.type === "containment.assign.v1") {
34
+ const containerId = stringValue(operation.payload.container_node_id);
35
+ const ordinal = operation.payload.ordinal;
36
+ const sourceArtifactId = operation.payload.source_artifact_id;
37
+ if (!containerId || (ordinal !== null && typeof ordinal !== "bigint") ||
38
+ (sourceArtifactId !== null && typeof sourceArtifactId !== "string")) {
39
+ throw new RepositoryStoreError("invalid containment assignment");
40
+ }
41
+ assertLiveNodes(database, commit.repositoryId, [containerId, childId]);
42
+ const existing = getRow(database.prepare("SELECT containment_id FROM repository_containments WHERE repository_id = ? AND child_node_id = ?"), commit.repositoryId, childId);
43
+ if (existing)
44
+ throw new RepositoryStoreError("containment relation already has active containment");
45
+ assertAcyclicRelation(database, commit.repositoryId, containerId, childId, "repository_containments");
46
+ try {
47
+ runSql(database.prepare("INSERT INTO repository_containments VALUES (?, ?, ?, ?, ?, ?, ?, ?)"), commit.repositoryId, containmentId, containerId, childId, relationDigest, ordinal, sourceArtifactId, commit.commitId);
48
+ }
49
+ catch (error) {
50
+ throw new RepositoryStoreError("containment relation already exists", { cause: error });
51
+ }
52
+ assertAllSemanticEdgesValid(database, commit.repositoryId);
53
+ return;
54
+ }
55
+ if (runSql(database.prepare("DELETE FROM repository_containments WHERE repository_id = ? AND containment_id = ? AND child_node_id = ? AND relation_digest = ?"), commit.repositoryId, containmentId, childId, relationDigest).changes !== 1)
56
+ throw new RepositoryStoreError("containment relation projection precondition failed");
57
+ assertAllSemanticEdgesValid(database, commit.repositoryId);
58
+ }
59
+ function latestValue(latestValues, edgeId) {
60
+ const value = latestValues.get(canonicalBytes(["edge", edgeId, "content"]).toString("utf8"));
61
+ if (!value)
62
+ throw new RepositoryStoreError("edge latest value is missing");
63
+ return value;
64
+ }
65
+ export function applyEdge(database, commit, operation, latestValues) {
66
+ const edgeId = stringValue(operation.payload.edge_id);
67
+ if (!edgeId)
68
+ throw new RepositoryStoreError("invalid edge operation");
69
+ if (operation.type === "edge.add.v1") {
70
+ const graphId = stringValue(operation.payload.graph_node_id);
71
+ const sourceId = stringValue(operation.payload.source_node_id);
72
+ const targetId = stringValue(operation.payload.target_node_id);
73
+ const relationDigest = stringValue(operation.payload.relation_digest);
74
+ const contentDigest = stringValue(operation.payload.content_digest);
75
+ if (!graphId || !sourceId || !targetId || !relationDigest || !contentDigest) {
76
+ throw new RepositoryStoreError("invalid edge addition");
77
+ }
78
+ assertLiveNodes(database, commit.repositoryId, [graphId, sourceId, targetId]);
79
+ assertSemanticEdgeValid(database, commit.repositoryId, graphId, sourceId, targetId);
80
+ try {
81
+ runSql(database.prepare(`INSERT INTO repository_semantic_edges (
82
+ repository_id, edge_id, graph_node_id, source_node_id, target_node_id,
83
+ relation_digest, content, content_digest, created_by_commit_id, updated_by_commit_id
84
+ ) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`), commit.repositoryId, edgeId, graphId, sourceId, targetId, relationDigest, latestValue(latestValues, edgeId).value, contentDigest, commit.commitId, commit.commitId);
85
+ }
86
+ catch (error) {
87
+ throw new RepositoryStoreError("semantic edge already exists", { cause: error });
88
+ }
89
+ return;
90
+ }
91
+ if (operation.type === "edge.field.set.v1") {
92
+ const expected = stringValue(operation.payload.expected_digest);
93
+ const replacement = stringValue(operation.payload.new_digest);
94
+ if (!expected || !replacement)
95
+ throw new RepositoryStoreError("invalid edge field operation");
96
+ if (runSql(database.prepare(`UPDATE repository_semantic_edges SET content = ?, content_digest = ?, updated_by_commit_id = ?
97
+ WHERE repository_id = ? AND edge_id = ? AND content_digest = ?`), latestValue(latestValues, edgeId).value, replacement, commit.commitId, commit.repositoryId, edgeId, expected).changes !== 1)
98
+ throw new RepositoryStoreError("edge field projection precondition failed");
99
+ return;
100
+ }
101
+ const relationDigest = stringValue(operation.payload.relation_digest);
102
+ if (!relationDigest)
103
+ throw new RepositoryStoreError("invalid edge removal");
104
+ if (runSql(database.prepare("DELETE FROM repository_semantic_edges WHERE repository_id = ? AND edge_id = ? AND relation_digest = ?"), commit.repositoryId, edgeId, relationDigest).changes !== 1)
105
+ throw new RepositoryStoreError("edge relation projection precondition failed");
106
+ }
107
+ //# sourceMappingURL=relations.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"relations.js","sourceRoot":"","sources":["../../../../src/local/store/projection/relations.ts"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;IAC5E,IAAI,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,uGAAuG,CAAC,EAAE,MAAM,CAAC,YAAY,EACxJ,MAAM,EACN,cAAc,CAAE,CAAC,OAAO,KAAK,CAAC;QAAE,MAAM,IAAI,oBAAoB,CAAC,8CAA8C,CAAC,CAAC;AACjH,CAAC"}
@@ -0,0 +1,80 @@
1
+ import { validateAcyclicRelation, validateSemanticEdgeScale } from "../../domain/invariants.js";
2
+ import { RepositoryStoreError } from "../sqlite/errors.js";
3
+ import { allRows, getRow } from "../sqlite/rows.js";
4
+ function asString(value) {
5
+ return typeof value === "string" ? value : undefined;
6
+ }
7
+ export function assertLiveNodes(database, repositoryId, nodeIds) {
8
+ const unique = [...new Set(nodeIds)];
9
+ const rows = allRows(database.prepare(`SELECT node_id FROM repository_nodes
10
+ WHERE repository_id = ? AND lifecycle_state = 'live'
11
+ AND node_id IN (${unique.map(() => "?").join(", ")})`), repositoryId, ...unique);
12
+ if (rows.length !== unique.length) {
13
+ throw new RepositoryStoreError("structural relation requires live repository nodes");
14
+ }
15
+ }
16
+ export function assertAcyclicRelation(database, repositoryId, parentId, childId, table) {
17
+ if (parentId === childId) {
18
+ throw new RepositoryStoreError(`${table === "repository_lineage" ? "lineage" : "containment"} cycle is invalid`);
19
+ }
20
+ const parentColumn = table === "repository_lineage" ? "parent_node_id" : "container_node_id";
21
+ const cycle = getRow(database.prepare(`WITH RECURSIVE descendants(node_id) AS (
22
+ SELECT child_node_id FROM ${table}
23
+ WHERE repository_id = ? AND ${parentColumn} = ?
24
+ UNION
25
+ SELECT relation.child_node_id FROM ${table} AS relation
26
+ JOIN descendants ON relation.${parentColumn} = descendants.node_id
27
+ WHERE relation.repository_id = ?
28
+ )
29
+ SELECT 1 AS present FROM descendants WHERE node_id = ? LIMIT 1`), repositoryId, childId, repositoryId, parentId);
30
+ try {
31
+ validateAcyclicRelation(parentId, childId, cycle !== undefined, table === "repository_lineage" ? "lineage" : "containment");
32
+ }
33
+ catch (error) {
34
+ if (error instanceof Error)
35
+ throw new RepositoryStoreError(error.message, { cause: error });
36
+ throw error;
37
+ }
38
+ }
39
+ export function assertSemanticEdgeValid(database, repositoryId, graphId, sourceId, targetId) {
40
+ if (graphId === sourceId || graphId === targetId) {
41
+ throw new RepositoryStoreError("semantic edge endpoints must be descendants");
42
+ }
43
+ if (sourceId === targetId)
44
+ throw new RepositoryStoreError("semantic edge endpoints must be distinct");
45
+ const rows = allRows(database.prepare(`WITH RECURSIVE descendants(node_id, scale) AS (
46
+ SELECT child_node_id, 1 FROM repository_containments
47
+ WHERE repository_id = ? AND container_node_id = ?
48
+ UNION ALL
49
+ SELECT relation.child_node_id, descendants.scale + 1
50
+ FROM repository_containments AS relation
51
+ JOIN descendants ON relation.container_node_id = descendants.node_id
52
+ WHERE relation.repository_id = ?
53
+ )
54
+ SELECT node_id, scale FROM descendants WHERE node_id IN (?, ?)`, { readBigInts: true }), repositoryId, graphId, repositoryId, sourceId, targetId);
55
+ const scales = {};
56
+ for (const row of rows) {
57
+ const nodeId = asString(row.node_id);
58
+ if (nodeId && typeof row.scale === "bigint")
59
+ scales[nodeId] = row.scale;
60
+ }
61
+ try {
62
+ validateSemanticEdgeScale(graphId, sourceId, targetId, scales);
63
+ }
64
+ catch (error) {
65
+ if (error instanceof Error)
66
+ throw new RepositoryStoreError(error.message, { cause: error });
67
+ throw error;
68
+ }
69
+ }
70
+ export function assertAllSemanticEdgesValid(database, repositoryId) {
71
+ for (const row of allRows(database.prepare("SELECT graph_node_id, source_node_id, target_node_id FROM repository_semantic_edges WHERE repository_id = ?"), repositoryId)) {
72
+ const graphId = asString(row.graph_node_id);
73
+ const sourceId = asString(row.source_node_id);
74
+ const targetId = asString(row.target_node_id);
75
+ if (!graphId || !sourceId || !targetId)
76
+ throw new RepositoryStoreError("semantic edge projection is corrupt");
77
+ assertSemanticEdgeValid(database, repositoryId, graphId, sourceId, targetId);
78
+ }
79
+ }
80
+ //# sourceMappingURL=rules.js.map
@@ -0,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