@agent-teams/engineering-foundation 0.7.0 → 0.9.0

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 (275) hide show
  1. package/README.md +6 -2
  2. package/dist/capabilities/contract-protobuf-evolution/adapters/outbound/crypto/node-sha256-digest.d.ts +6 -0
  3. package/dist/capabilities/contract-protobuf-evolution/adapters/outbound/crypto/node-sha256-digest.d.ts.map +1 -0
  4. package/dist/capabilities/contract-protobuf-evolution/adapters/outbound/crypto/node-sha256-digest.js +7 -0
  5. package/dist/capabilities/contract-protobuf-evolution/adapters/outbound/crypto/node-sha256-digest.js.map +1 -0
  6. package/dist/capabilities/contract-protobuf-evolution/adapters/outbound/qualification/filesystem-buf-breaking-qualification-evidence.d.ts +8 -0
  7. package/dist/capabilities/contract-protobuf-evolution/adapters/outbound/qualification/filesystem-buf-breaking-qualification-evidence.d.ts.map +1 -0
  8. package/dist/capabilities/contract-protobuf-evolution/adapters/outbound/qualification/filesystem-buf-breaking-qualification-evidence.js +131 -0
  9. package/dist/capabilities/contract-protobuf-evolution/adapters/outbound/qualification/filesystem-buf-breaking-qualification-evidence.js.map +1 -0
  10. package/dist/capabilities/contract-protobuf-evolution/application/model/buf-breaking-qualification.d.ts +37 -0
  11. package/dist/capabilities/contract-protobuf-evolution/application/model/buf-breaking-qualification.d.ts.map +1 -0
  12. package/dist/capabilities/contract-protobuf-evolution/application/model/buf-breaking-qualification.js +258 -0
  13. package/dist/capabilities/contract-protobuf-evolution/application/model/buf-breaking-qualification.js.map +1 -0
  14. package/dist/capabilities/contract-protobuf-evolution/application/model/protobuf-release-evidence.d.ts +52 -2
  15. package/dist/capabilities/contract-protobuf-evolution/application/model/protobuf-release-evidence.d.ts.map +1 -1
  16. package/dist/capabilities/contract-protobuf-evolution/application/policies/evaluate-protobuf-evolution.d.ts.map +1 -1
  17. package/dist/capabilities/contract-protobuf-evolution/application/policies/evaluate-protobuf-evolution.js +0 -3
  18. package/dist/capabilities/contract-protobuf-evolution/application/policies/evaluate-protobuf-evolution.js.map +1 -1
  19. package/dist/capabilities/contract-protobuf-evolution/application/ports/buf-breaking-qualification-evidence.d.ts +14 -0
  20. package/dist/capabilities/contract-protobuf-evolution/application/ports/buf-breaking-qualification-evidence.d.ts.map +1 -0
  21. package/dist/capabilities/contract-protobuf-evolution/application/ports/buf-breaking-qualification-evidence.js +2 -0
  22. package/dist/capabilities/contract-protobuf-evolution/application/ports/buf-breaking-qualification-evidence.js.map +1 -0
  23. package/dist/capabilities/contract-protobuf-evolution/application/ports/sha256-digest.d.ts +5 -0
  24. package/dist/capabilities/contract-protobuf-evolution/application/ports/sha256-digest.d.ts.map +1 -0
  25. package/dist/capabilities/contract-protobuf-evolution/application/ports/sha256-digest.js +2 -0
  26. package/dist/capabilities/contract-protobuf-evolution/application/ports/sha256-digest.js.map +1 -0
  27. package/dist/capabilities/contract-protobuf-evolution/application/use-cases/resolve-protobuf-evolution-policy.d.ts +2 -0
  28. package/dist/capabilities/contract-protobuf-evolution/application/use-cases/resolve-protobuf-evolution-policy.d.ts.map +1 -1
  29. package/dist/capabilities/contract-protobuf-evolution/application/use-cases/resolve-protobuf-evolution-policy.js +10 -1
  30. package/dist/capabilities/contract-protobuf-evolution/application/use-cases/resolve-protobuf-evolution-policy.js.map +1 -1
  31. package/dist/capabilities/contract-protobuf-evolution/contract/config.d.ts.map +1 -1
  32. package/dist/capabilities/contract-protobuf-evolution/contract/config.js +30 -15
  33. package/dist/capabilities/contract-protobuf-evolution/contract/config.js.map +1 -1
  34. package/dist/capabilities/contract-protobuf-evolution/module.d.ts +3 -1
  35. package/dist/capabilities/contract-protobuf-evolution/module.d.ts.map +1 -1
  36. package/dist/capabilities/contract-protobuf-evolution/module.js +4 -1
  37. package/dist/capabilities/contract-protobuf-evolution/module.js.map +1 -1
  38. package/dist/capabilities/contract-protobuf-evolution/qualification/adapters/outbound/filesystem/filesystem-buf-qualification-artifacts.d.ts +21 -0
  39. package/dist/capabilities/contract-protobuf-evolution/qualification/adapters/outbound/filesystem/filesystem-buf-qualification-artifacts.d.ts.map +1 -0
  40. package/dist/capabilities/contract-protobuf-evolution/qualification/adapters/outbound/filesystem/filesystem-buf-qualification-artifacts.js +301 -0
  41. package/dist/capabilities/contract-protobuf-evolution/qualification/adapters/outbound/filesystem/filesystem-buf-qualification-artifacts.js.map +1 -0
  42. package/dist/capabilities/contract-protobuf-evolution/qualification/adapters/outbound/process/process-buf-executable.d.ts +2 -0
  43. package/dist/capabilities/contract-protobuf-evolution/qualification/adapters/outbound/process/process-buf-executable.d.ts.map +1 -1
  44. package/dist/capabilities/contract-protobuf-evolution/qualification/adapters/outbound/process/process-buf-executable.js +28 -41
  45. package/dist/capabilities/contract-protobuf-evolution/qualification/adapters/outbound/process/process-buf-executable.js.map +1 -1
  46. package/dist/capabilities/contract-protobuf-evolution/qualification/adapters/outbound/process/process-buf-qualification-runner.d.ts +8 -0
  47. package/dist/capabilities/contract-protobuf-evolution/qualification/adapters/outbound/process/process-buf-qualification-runner.d.ts.map +1 -0
  48. package/dist/capabilities/contract-protobuf-evolution/qualification/adapters/outbound/process/process-buf-qualification-runner.js +102 -0
  49. package/dist/capabilities/contract-protobuf-evolution/qualification/adapters/outbound/process/process-buf-qualification-runner.js.map +1 -0
  50. package/dist/capabilities/contract-protobuf-evolution/qualification/module.d.ts +14 -0
  51. package/dist/capabilities/contract-protobuf-evolution/qualification/module.d.ts.map +1 -1
  52. package/dist/capabilities/contract-protobuf-evolution/qualification/module.js +22 -0
  53. package/dist/capabilities/contract-protobuf-evolution/qualification/module.js.map +1 -1
  54. package/dist/capabilities/contract-protobuf-evolution/qualification/ports/buf-qualification-artifacts.d.ts +21 -0
  55. package/dist/capabilities/contract-protobuf-evolution/qualification/ports/buf-qualification-artifacts.d.ts.map +1 -0
  56. package/dist/capabilities/contract-protobuf-evolution/qualification/ports/buf-qualification-artifacts.js +2 -0
  57. package/dist/capabilities/contract-protobuf-evolution/qualification/ports/buf-qualification-artifacts.js.map +1 -0
  58. package/dist/capabilities/contract-protobuf-evolution/qualification/ports/buf-qualification-runner.d.ts +18 -0
  59. package/dist/capabilities/contract-protobuf-evolution/qualification/ports/buf-qualification-runner.d.ts.map +1 -0
  60. package/dist/capabilities/contract-protobuf-evolution/qualification/ports/buf-qualification-runner.js +2 -0
  61. package/dist/capabilities/contract-protobuf-evolution/qualification/ports/buf-qualification-runner.js.map +1 -0
  62. package/dist/capabilities/contract-protobuf-evolution/qualification/use-cases/qualify-buf-breaking-evidence.d.ts +22 -0
  63. package/dist/capabilities/contract-protobuf-evolution/qualification/use-cases/qualify-buf-breaking-evidence.d.ts.map +1 -0
  64. package/dist/capabilities/contract-protobuf-evolution/qualification/use-cases/qualify-buf-breaking-evidence.js +221 -0
  65. package/dist/capabilities/contract-protobuf-evolution/qualification/use-cases/qualify-buf-breaking-evidence.js.map +1 -0
  66. package/dist/capabilities/public-api-compatibility/adapters/outbound/api-extractor/microsoft-public-api-extractor.d.ts.map +1 -1
  67. package/dist/capabilities/public-api-compatibility/adapters/outbound/api-extractor/microsoft-public-api-extractor.js +1 -14
  68. package/dist/capabilities/public-api-compatibility/adapters/outbound/api-extractor/microsoft-public-api-extractor.js.map +1 -1
  69. package/dist/capabilities/public-api-compatibility/adapters/outbound/filesystem/public-api-baseline-mapper.d.ts +4 -4
  70. package/dist/capabilities/public-api-compatibility/adapters/outbound/filesystem/public-api-baseline-mapper.d.ts.map +1 -1
  71. package/dist/capabilities/public-api-compatibility/adapters/outbound/filesystem/public-api-baseline-mapper.js +34 -46
  72. package/dist/capabilities/public-api-compatibility/adapters/outbound/filesystem/public-api-baseline-mapper.js.map +1 -1
  73. package/dist/capabilities/public-api-compatibility/application/model/public-api.d.ts +18 -75
  74. package/dist/capabilities/public-api-compatibility/application/model/public-api.d.ts.map +1 -1
  75. package/dist/capabilities/public-api-compatibility/application/model/public-api.js +7 -29
  76. package/dist/capabilities/public-api-compatibility/application/model/public-api.js.map +1 -1
  77. package/dist/capabilities/public-api-compatibility/application/policies/accepted-breaking-change.d.ts +1 -5
  78. package/dist/capabilities/public-api-compatibility/application/policies/accepted-breaking-change.d.ts.map +1 -1
  79. package/dist/capabilities/public-api-compatibility/application/policies/accepted-breaking-change.js +1 -8
  80. package/dist/capabilities/public-api-compatibility/application/policies/accepted-breaking-change.js.map +1 -1
  81. package/dist/capabilities/public-api-compatibility/application/policies/evaluate-public-api-compatibility.d.ts.map +1 -1
  82. package/dist/capabilities/public-api-compatibility/application/policies/evaluate-public-api-compatibility.js +5 -38
  83. package/dist/capabilities/public-api-compatibility/application/policies/evaluate-public-api-compatibility.js.map +1 -1
  84. package/dist/capabilities/public-api-compatibility/application/policies/validate-package-export-coverage.d.ts +1 -1
  85. package/dist/capabilities/public-api-compatibility/application/policies/validate-package-export-coverage.js +2 -2
  86. package/dist/capabilities/public-api-compatibility/application/policies/validate-package-export-coverage.js.map +1 -1
  87. package/dist/capabilities/public-api-compatibility/application/use-cases/analyze-public-api-compatibility.d.ts.map +1 -1
  88. package/dist/capabilities/public-api-compatibility/application/use-cases/analyze-public-api-compatibility.js +0 -1
  89. package/dist/capabilities/public-api-compatibility/application/use-cases/analyze-public-api-compatibility.js.map +1 -1
  90. package/dist/capabilities/public-api-compatibility/application/use-cases/promote-public-api-baselines.d.ts.map +1 -1
  91. package/dist/capabilities/public-api-compatibility/application/use-cases/promote-public-api-baselines.js +0 -38
  92. package/dist/capabilities/public-api-compatibility/application/use-cases/promote-public-api-baselines.js.map +1 -1
  93. package/dist/capabilities/public-api-compatibility/contract/config.d.ts +1 -1
  94. package/dist/capabilities/public-api-compatibility/contract/config.d.ts.map +1 -1
  95. package/dist/capabilities/public-api-compatibility/contract/config.js +32 -106
  96. package/dist/capabilities/public-api-compatibility/contract/config.js.map +1 -1
  97. package/dist/cli-arguments.d.ts +2 -0
  98. package/dist/cli-arguments.d.ts.map +1 -1
  99. package/dist/cli-arguments.js +34 -2
  100. package/dist/cli-arguments.js.map +1 -1
  101. package/dist/cli.js +40 -1
  102. package/dist/cli.js.map +1 -1
  103. package/dist/scaffolding/adapters/node/filesystem-authority-workspace.d.ts +13 -0
  104. package/dist/scaffolding/adapters/node/filesystem-authority-workspace.d.ts.map +1 -0
  105. package/dist/scaffolding/adapters/node/filesystem-authority-workspace.js +257 -0
  106. package/dist/scaffolding/adapters/node/filesystem-authority-workspace.js.map +1 -0
  107. package/dist/scaffolding/adapters/node/filesystem-authority.d.ts +20 -0
  108. package/dist/scaffolding/adapters/node/filesystem-authority.d.ts.map +1 -0
  109. package/dist/scaffolding/adapters/node/filesystem-authority.js +55 -0
  110. package/dist/scaffolding/adapters/node/filesystem-authority.js.map +1 -0
  111. package/dist/scaffolding/adapters/node/filesystem-file-identity.d.ts +20 -0
  112. package/dist/scaffolding/adapters/node/filesystem-file-identity.d.ts.map +1 -0
  113. package/dist/scaffolding/adapters/node/filesystem-file-identity.js +122 -0
  114. package/dist/scaffolding/adapters/node/filesystem-file-identity.js.map +1 -0
  115. package/dist/scaffolding/adapters/node/filesystem-finalization.d.ts +22 -0
  116. package/dist/scaffolding/adapters/node/filesystem-finalization.d.ts.map +1 -0
  117. package/dist/scaffolding/adapters/node/filesystem-finalization.js +169 -0
  118. package/dist/scaffolding/adapters/node/filesystem-finalization.js.map +1 -0
  119. package/dist/scaffolding/adapters/node/filesystem-journal-state.d.ts +25 -0
  120. package/dist/scaffolding/adapters/node/filesystem-journal-state.d.ts.map +1 -0
  121. package/dist/scaffolding/adapters/node/filesystem-journal-state.js +119 -0
  122. package/dist/scaffolding/adapters/node/filesystem-journal-state.js.map +1 -0
  123. package/dist/scaffolding/adapters/node/filesystem-journal.d.ts +7 -4
  124. package/dist/scaffolding/adapters/node/filesystem-journal.d.ts.map +1 -1
  125. package/dist/scaffolding/adapters/node/filesystem-journal.js +104 -29
  126. package/dist/scaffolding/adapters/node/filesystem-journal.js.map +1 -1
  127. package/dist/scaffolding/adapters/node/filesystem-operation-state.d.ts +16 -0
  128. package/dist/scaffolding/adapters/node/filesystem-operation-state.d.ts.map +1 -0
  129. package/dist/scaffolding/adapters/node/filesystem-operation-state.js +158 -0
  130. package/dist/scaffolding/adapters/node/filesystem-operation-state.js.map +1 -0
  131. package/dist/scaffolding/adapters/node/filesystem-path-guard.d.ts +2 -2
  132. package/dist/scaffolding/adapters/node/filesystem-path-guard.d.ts.map +1 -1
  133. package/dist/scaffolding/adapters/node/filesystem-path-guard.js.map +1 -1
  134. package/dist/scaffolding/adapters/node/node-authority-error.d.ts +4 -0
  135. package/dist/scaffolding/adapters/node/node-authority-error.d.ts.map +1 -0
  136. package/dist/scaffolding/adapters/node/node-authority-error.js +7 -0
  137. package/dist/scaffolding/adapters/node/node-authority-error.js.map +1 -0
  138. package/dist/scaffolding/adapters/node/node-authority-input-loader.d.ts +20 -0
  139. package/dist/scaffolding/adapters/node/node-authority-input-loader.d.ts.map +1 -0
  140. package/dist/scaffolding/adapters/node/node-authority-input-loader.js +180 -0
  141. package/dist/scaffolding/adapters/node/node-authority-input-loader.js.map +1 -0
  142. package/dist/scaffolding/adapters/node/node-authority-receipt-validator.d.ts +4 -0
  143. package/dist/scaffolding/adapters/node/node-authority-receipt-validator.d.ts.map +1 -0
  144. package/dist/scaffolding/adapters/node/node-authority-receipt-validator.js +10 -0
  145. package/dist/scaffolding/adapters/node/node-authority-receipt-validator.js.map +1 -0
  146. package/dist/scaffolding/adapters/node/node-owner-document-resolver.d.ts +17 -0
  147. package/dist/scaffolding/adapters/node/node-owner-document-resolver.d.ts.map +1 -0
  148. package/dist/scaffolding/adapters/node/node-owner-document-resolver.js +161 -0
  149. package/dist/scaffolding/adapters/node/node-owner-document-resolver.js.map +1 -0
  150. package/dist/scaffolding/adapters/node/node-plan-authority.d.ts +14 -2
  151. package/dist/scaffolding/adapters/node/node-plan-authority.d.ts.map +1 -1
  152. package/dist/scaffolding/adapters/node/node-plan-authority.js +28 -9
  153. package/dist/scaffolding/adapters/node/node-plan-authority.js.map +1 -1
  154. package/dist/scaffolding/adapters/node/node-repository-file.d.ts +9 -0
  155. package/dist/scaffolding/adapters/node/node-repository-file.d.ts.map +1 -0
  156. package/dist/scaffolding/adapters/node/node-repository-file.js +65 -0
  157. package/dist/scaffolding/adapters/node/node-repository-file.js.map +1 -0
  158. package/dist/scaffolding/adapters/node/node-scaffold-limits.d.ts +2 -0
  159. package/dist/scaffolding/adapters/node/node-scaffold-limits.d.ts.map +1 -0
  160. package/dist/scaffolding/adapters/node/node-scaffold-limits.js +2 -0
  161. package/dist/scaffolding/adapters/node/node-scaffold-limits.js.map +1 -0
  162. package/dist/scaffolding/authority-service.d.ts +7 -0
  163. package/dist/scaffolding/authority-service.d.ts.map +1 -0
  164. package/dist/scaffolding/authority-service.js +15 -0
  165. package/dist/scaffolding/authority-service.js.map +1 -0
  166. package/dist/scaffolding/canonical-api.d.ts +14 -0
  167. package/dist/scaffolding/canonical-api.d.ts.map +1 -0
  168. package/dist/scaffolding/canonical-api.js +32 -0
  169. package/dist/scaffolding/canonical-api.js.map +1 -0
  170. package/dist/scaffolding/cli-command.d.ts.map +1 -1
  171. package/dist/scaffolding/cli-command.js +1 -2
  172. package/dist/scaffolding/cli-command.js.map +1 -1
  173. package/dist/scaffolding/contract/receipt-authority-types.d.ts +125 -0
  174. package/dist/scaffolding/contract/receipt-authority-types.d.ts.map +1 -0
  175. package/dist/scaffolding/contract/receipt-authority-types.js +2 -0
  176. package/dist/scaffolding/contract/receipt-authority-types.js.map +1 -0
  177. package/dist/scaffolding/contract/scaffold-contract.d.ts +329 -0
  178. package/dist/scaffolding/contract/scaffold-contract.d.ts.map +1 -0
  179. package/dist/scaffolding/contract/scaffold-contract.js +2 -0
  180. package/dist/scaffolding/contract/scaffold-contract.js.map +1 -0
  181. package/dist/scaffolding/contract/types.d.ts +130 -193
  182. package/dist/scaffolding/contract/types.d.ts.map +1 -1
  183. package/dist/scaffolding/definitions/node-typescript-library.d.ts +3 -0
  184. package/dist/scaffolding/definitions/node-typescript-library.d.ts.map +1 -0
  185. package/dist/scaffolding/definitions/node-typescript-library.js +134 -0
  186. package/dist/scaffolding/definitions/node-typescript-library.js.map +1 -0
  187. package/dist/scaffolding/definitions/registry.d.ts +1 -1
  188. package/dist/scaffolding/definitions/registry.d.ts.map +1 -1
  189. package/dist/scaffolding/definitions/registry.js +6 -2
  190. package/dist/scaffolding/definitions/registry.js.map +1 -1
  191. package/dist/scaffolding/index.d.ts +4 -8
  192. package/dist/scaffolding/index.d.ts.map +1 -1
  193. package/dist/scaffolding/index.js +2 -7
  194. package/dist/scaffolding/index.js.map +1 -1
  195. package/dist/scaffolding/kernel/authority-compiler.d.ts +4 -0
  196. package/dist/scaffolding/kernel/authority-compiler.d.ts.map +1 -0
  197. package/dist/scaffolding/kernel/authority-compiler.js +78 -0
  198. package/dist/scaffolding/kernel/authority-compiler.js.map +1 -0
  199. package/dist/scaffolding/kernel/authority-evidence.d.ts +13 -0
  200. package/dist/scaffolding/kernel/authority-evidence.d.ts.map +1 -0
  201. package/dist/scaffolding/kernel/authority-evidence.js +79 -0
  202. package/dist/scaffolding/kernel/authority-evidence.js.map +1 -0
  203. package/dist/scaffolding/kernel/authority-receipt.d.ts +11 -0
  204. package/dist/scaffolding/kernel/authority-receipt.d.ts.map +1 -0
  205. package/dist/scaffolding/kernel/authority-receipt.js +189 -0
  206. package/dist/scaffolding/kernel/authority-receipt.js.map +1 -0
  207. package/dist/scaffolding/kernel/compiler.d.ts +28 -2
  208. package/dist/scaffolding/kernel/compiler.d.ts.map +1 -1
  209. package/dist/scaffolding/kernel/compiler.js +22 -36
  210. package/dist/scaffolding/kernel/compiler.js.map +1 -1
  211. package/dist/scaffolding/kernel/definition-registry.d.ts +6 -3
  212. package/dist/scaffolding/kernel/definition-registry.d.ts.map +1 -1
  213. package/dist/scaffolding/kernel/definition-registry.js +17 -1
  214. package/dist/scaffolding/kernel/definition-registry.js.map +1 -1
  215. package/dist/scaffolding/kernel/plan-content-validation.d.ts +3 -0
  216. package/dist/scaffolding/kernel/plan-content-validation.d.ts.map +1 -0
  217. package/dist/scaffolding/kernel/plan-content-validation.js +44 -0
  218. package/dist/scaffolding/kernel/plan-content-validation.js.map +1 -0
  219. package/dist/scaffolding/kernel/plan-validation.d.ts +2 -2
  220. package/dist/scaffolding/kernel/plan-validation.d.ts.map +1 -1
  221. package/dist/scaffolding/kernel/plan-validation.js +16 -40
  222. package/dist/scaffolding/kernel/plan-validation.js.map +1 -1
  223. package/dist/scaffolding/scaffold-defaults.d.ts +2 -0
  224. package/dist/scaffolding/scaffold-defaults.d.ts.map +1 -0
  225. package/dist/scaffolding/scaffold-defaults.js +2 -0
  226. package/dist/scaffolding/scaffold-defaults.js.map +1 -0
  227. package/dist/scaffolding/scaffold-error.d.ts +3 -3
  228. package/dist/scaffolding/scaffold-error.d.ts.map +1 -1
  229. package/dist/scaffolding/scaffold-error.js.map +1 -1
  230. package/dist/schema-catalog.d.ts +2 -2
  231. package/dist/schema-catalog.d.ts.map +1 -1
  232. package/dist/schema-catalog.js +41 -8
  233. package/dist/schema-catalog.js.map +1 -1
  234. package/dist/schema-ids.d.ts +2 -1
  235. package/dist/schema-ids.d.ts.map +1 -1
  236. package/dist/schema-ids.js +3 -2
  237. package/dist/schema-ids.js.map +1 -1
  238. package/package.json +25 -2
  239. package/schemas/contract-protobuf-breaking-qualification/v1.schema.json +93 -0
  240. package/schemas/contract-protobuf-evolution/v1.schema.json +47 -15
  241. package/schemas/package-public-api-baseline/v1.schema.json +49 -12
  242. package/schemas/package-public-api-compatibility/v1.schema.json +46 -5
  243. package/schemas/scaffold-authority-evidence/v1.schema.json +103 -0
  244. package/schemas/scaffold-intent/v1.schema.json +1 -1
  245. package/schemas/scaffold-plan/v1.schema.json +86 -8
  246. package/schemas/scaffold-receipt/v1.schema.json +102 -221
  247. package/schemas/scaffold-recovery-journal/v1.schema.json +31 -0
  248. package/schemas/scaffold-target-catalog/v1.schema.json +9 -8
  249. package/schemas/scaffolding-config/v1.schema.json +38 -2
  250. package/dist/scaffolding/adapters/memory/memory-workspace.d.ts +0 -9
  251. package/dist/scaffolding/adapters/memory/memory-workspace.d.ts.map +0 -1
  252. package/dist/scaffolding/adapters/memory/memory-workspace.js +0 -93
  253. package/dist/scaffolding/adapters/memory/memory-workspace.js.map +0 -1
  254. package/dist/scaffolding/adapters/node/filesystem-workspace.d.ts +0 -13
  255. package/dist/scaffolding/adapters/node/filesystem-workspace.d.ts.map +0 -1
  256. package/dist/scaffolding/adapters/node/filesystem-workspace.js +0 -336
  257. package/dist/scaffolding/adapters/node/filesystem-workspace.js.map +0 -1
  258. package/dist/scaffolding/adapters/node/node-input-loader.d.ts +0 -17
  259. package/dist/scaffolding/adapters/node/node-input-loader.d.ts.map +0 -1
  260. package/dist/scaffolding/adapters/node/node-input-loader.js +0 -157
  261. package/dist/scaffolding/adapters/node/node-input-loader.js.map +0 -1
  262. package/dist/scaffolding/adapters/node/node-receipt-validator.d.ts +0 -4
  263. package/dist/scaffolding/adapters/node/node-receipt-validator.d.ts.map +0 -1
  264. package/dist/scaffolding/adapters/node/node-receipt-validator.js +0 -10
  265. package/dist/scaffolding/adapters/node/node-receipt-validator.js.map +0 -1
  266. package/dist/scaffolding/kernel/receipt.d.ts +0 -35
  267. package/dist/scaffolding/kernel/receipt.d.ts.map +0 -1
  268. package/dist/scaffolding/kernel/receipt.js +0 -206
  269. package/dist/scaffolding/kernel/receipt.js.map +0 -1
  270. package/dist/scaffolding/service.d.ts +0 -8
  271. package/dist/scaffolding/service.d.ts.map +0 -1
  272. package/dist/scaffolding/service.js +0 -15
  273. package/dist/scaffolding/service.js.map +0 -1
  274. package/schemas/package-public-api-baseline/v2.schema.json +0 -62
  275. package/schemas/package-public-api-compatibility/v2.schema.json +0 -113
@@ -0,0 +1,257 @@
1
+ import { realpath } from "node:fs/promises";
2
+ import { join, resolve } from "node:path";
3
+ import { assertAuthorityScaffoldPlanDigest } from "../../kernel/plan-validation.js";
4
+ import { ScaffoldError } from "../../scaffold-error.js";
5
+ import { assertSchema } from "../../../schema-catalog.js";
6
+ import { acquireFoundationOperationLock } from "../../../local-mode/service.js";
7
+ import { LOCAL_STATE_DIRECTORY } from "../../../local-mode/types.js";
8
+ import { assessScaffoldPlanAuthority } from "./node-plan-authority.js";
9
+ import { assertSafeExistingAncestors, assertSafeOperationPaths } from "./filesystem-path-guard.js";
10
+ import { assertTransactionTemporariesAbsent, publishFilesystemOperation } from "./filesystem-operation-state.js";
11
+ import { freshAuthorityScaffoldJournal, receiptFromJournalStates, reconcileAuthorityScaffoldJournal, replaceScaffoldJournalOperation } from "./filesystem-journal-state.js";
12
+ import { finalizeAuthorityScaffoldJournal, staleBeforeJournal, verifyAlreadyAppliedScaffold } from "./filesystem-finalization.js";
13
+ import { recoveryRequiredForAuthority, resolveAuthority, safeClassifyPlan } from "./filesystem-authority.js";
14
+ import { assertAuthorityScaffoldJournalTemporaryAbsent, readScaffoldJournalEnvelope, SCAFFOLD_JOURNAL_FILE, writeAuthorityScaffoldJournal } from "./filesystem-journal.js";
15
+ function journalFault(faultInjector, operationIndex, operationPath) {
16
+ return faultInjector === undefined
17
+ ? undefined
18
+ : () => faultInjector({
19
+ phase: "after-journal-temporary-synced",
20
+ ...(operationIndex === undefined ? {} : { operationIndex }),
21
+ ...(operationPath === undefined ? {} : { operationPath })
22
+ });
23
+ }
24
+ function recoveryRequired(plan, phase, ruleId, message, remediation) {
25
+ return recoveryRequiredForAuthority({ plan, phase, ruleId, message, remediation });
26
+ }
27
+ function isReceipt(value) {
28
+ return typeof value === "object" && value !== null && "receiptDigest" in value;
29
+ }
30
+ function deepFreezePlanValue(value, visited) {
31
+ if (typeof value !== "object" || value === null || visited.has(value)) {
32
+ return;
33
+ }
34
+ visited.add(value);
35
+ for (const child of Object.values(value)) {
36
+ deepFreezePlanValue(child, visited);
37
+ }
38
+ Object.freeze(value);
39
+ }
40
+ function snapshotAuthorityScaffoldPlan(plan) {
41
+ let snapshot;
42
+ try {
43
+ snapshot = structuredClone(plan);
44
+ deepFreezePlanValue(snapshot, new Set());
45
+ }
46
+ catch (error) {
47
+ throw new ScaffoldError("SCAFFOLD_PLAN_INVALID", "Scaffolding Plan cannot be snapshotted as canonical data.", [], { cause: error });
48
+ }
49
+ return snapshot;
50
+ }
51
+ async function prepareJournal(options) {
52
+ let journal = options.journal;
53
+ const initialAuthority = await resolveAuthority({ ...options, journal });
54
+ if (initialAuthority !== undefined) {
55
+ return initialAuthority;
56
+ }
57
+ try {
58
+ await assertTransactionTemporariesAbsent(options.root, journal.plan);
59
+ const reconciled = await reconcileAuthorityScaffoldJournal(options.root, journal);
60
+ journal = reconciled.journal;
61
+ if (reconciled.conflictIds.size !== 0) {
62
+ await writeAuthorityScaffoldJournal(options.journalPath, journal, journalFault(options.faultInjector));
63
+ return receiptFromJournalStates({
64
+ plan: journal.plan,
65
+ journal,
66
+ outcome: "recovery-required",
67
+ phase: "recovery",
68
+ conflictOperationIds: reconciled.conflictIds
69
+ });
70
+ }
71
+ }
72
+ catch {
73
+ return recoveryRequired(journal.plan, options.recovered ? "recovery" : "apply", "scaffolding.recovery.unverifiable-workspace", "The workspace cannot be safely reconciled; no transaction output was removed.", "Resolve the filesystem state manually, then retry recovery.");
74
+ }
75
+ await writeAuthorityScaffoldJournal(options.journalPath, journal, journalFault(options.faultInjector));
76
+ return journal;
77
+ }
78
+ async function publishPendingOperations(options) {
79
+ const { continuation } = options;
80
+ let journal = options.journal;
81
+ const receipts = new Map();
82
+ for (const [operationIndex, operation] of journal.plan.operations.entries()) {
83
+ const current = journal.operations.find((candidate) => candidate.operationId === operation.id);
84
+ if (current === undefined) {
85
+ throw new ScaffoldError("SCAFFOLD_RECOVERY_REQUIRED", "Scaffolding source-bound journal operation is missing.");
86
+ }
87
+ if (current.state === "preexisting" || current.state === "published") {
88
+ receipts.set(operation.id, {
89
+ operationId: operation.id,
90
+ path: operation.path,
91
+ outcome: "already-satisfied",
92
+ resultDigest: operation.after.digest
93
+ });
94
+ continue;
95
+ }
96
+ await continuation.faultInjector?.({
97
+ phase: "before-operation-authority-recheck",
98
+ operationIndex,
99
+ operationPath: operation.path
100
+ });
101
+ const authority = await resolveAuthority({ ...continuation, journal });
102
+ if (authority !== undefined) {
103
+ return authority;
104
+ }
105
+ try {
106
+ await assertSafeExistingAncestors(continuation.root, operation.path);
107
+ }
108
+ catch {
109
+ return recoveryRequired(journal.plan, continuation.recovered ? "recovery" : "apply", "scaffolding.recovery.unsafe-ancestor", "Filesystem ancestry cannot be proven safe for publication.", "Resolve the filesystem state manually, then retry recovery.");
110
+ }
111
+ journal = replaceScaffoldJournalOperation(journal, operation.id, "publishing");
112
+ await writeAuthorityScaffoldJournal(continuation.journalPath, journal, journalFault(continuation.faultInjector, operationIndex, operation.path));
113
+ await continuation.faultInjector?.({
114
+ phase: "after-journal-operation-publishing",
115
+ operationIndex,
116
+ operationPath: operation.path
117
+ });
118
+ const outcome = await publishFilesystemOperation(continuation.root, operation, journal.plan.planDigest, operationIndex, continuation.faultInjector);
119
+ journal = replaceScaffoldJournalOperation(journal, operation.id, outcome === "applied" ? "published" : "preexisting");
120
+ await writeAuthorityScaffoldJournal(continuation.journalPath, journal, journalFault(continuation.faultInjector, operationIndex, operation.path));
121
+ await continuation.faultInjector?.({
122
+ phase: "after-journal-operation-published",
123
+ operationIndex,
124
+ operationPath: operation.path
125
+ });
126
+ receipts.set(operation.id, {
127
+ operationId: operation.id,
128
+ path: operation.path,
129
+ outcome: continuation.recovered && outcome === "applied" ? "recovered" : outcome,
130
+ resultDigest: operation.after.digest
131
+ });
132
+ }
133
+ return { journal, receipts };
134
+ }
135
+ async function continueJournal(options) {
136
+ const prepared = await prepareJournal(options);
137
+ if (isReceipt(prepared)) {
138
+ return prepared;
139
+ }
140
+ const published = await publishPendingOperations({
141
+ continuation: options,
142
+ journal: prepared
143
+ });
144
+ if (isReceipt(published)) {
145
+ return published;
146
+ }
147
+ return finalizeAuthorityScaffoldJournal({ ...options, ...published });
148
+ }
149
+ export async function applyAuthorityFilesystemScaffold(consumerRoot, plan) {
150
+ return applyAuthorityFilesystemScaffoldWithFaultInjection(consumerRoot, plan);
151
+ }
152
+ /** Internal conformance seam. It is intentionally absent from package exports. */
153
+ export async function applyAuthorityFilesystemScaffoldWithFaultInjection(consumerRoot, callerPlan, faultInjector) {
154
+ const plan = snapshotAuthorityScaffoldPlan(callerPlan);
155
+ await assertSchema("scaffold-plan/v1", plan, "scaffold-apply-plan");
156
+ assertAuthorityScaffoldPlanDigest(plan);
157
+ assertSafeOperationPaths(plan);
158
+ const canonicalRoot = await realpath(resolve(consumerRoot));
159
+ const release = await acquireFoundationOperationLock(canonicalRoot);
160
+ try {
161
+ const journalPath = join(canonicalRoot, LOCAL_STATE_DIRECTORY, SCAFFOLD_JOURNAL_FILE);
162
+ await assertAuthorityScaffoldJournalTemporaryAbsent(journalPath);
163
+ const existing = await readScaffoldJournalEnvelope(journalPath);
164
+ if (existing !== undefined) {
165
+ if (existing.plan.planDigest !== plan.planDigest) {
166
+ throw new ScaffoldError("SCAFFOLD_RECOVERY_REQUIRED", "A different scaffolding transaction requires recovery before this Plan can apply.");
167
+ }
168
+ return continueJournal({
169
+ root: canonicalRoot,
170
+ journalPath,
171
+ journal: existing,
172
+ recovered: true,
173
+ ...(faultInjector === undefined ? {} : { faultInjector })
174
+ });
175
+ }
176
+ const authority = await assessScaffoldPlanAuthority(canonicalRoot, plan);
177
+ if (authority.state === "stale") {
178
+ return staleBeforeJournal(plan);
179
+ }
180
+ if (authority.state === "unverifiable") {
181
+ return recoveryRequired(plan, "apply", "scaffolding.authority.unverifiable", "Authority cannot be re-verified safely; no transaction output was created.", "Restore readable authority sources, then compile a new Plan.");
182
+ }
183
+ let classifications;
184
+ try {
185
+ classifications = await safeClassifyPlan(canonicalRoot, plan);
186
+ await assertTransactionTemporariesAbsent(canonicalRoot, plan);
187
+ }
188
+ catch {
189
+ return recoveryRequired(plan, "apply", "scaffolding.apply.unverifiable-workspace", "The workspace cannot be safely prepared for this transaction.", "Resolve the filesystem state manually, then compile a new Plan.");
190
+ }
191
+ if (classifications.some(({ state }) => state === "conflict")) {
192
+ let rejectedJournal = freshAuthorityScaffoldJournal(plan);
193
+ for (const { operation, state } of classifications) {
194
+ if (state === "after") {
195
+ rejectedJournal = replaceScaffoldJournalOperation(rejectedJournal, operation.id, "preexisting");
196
+ }
197
+ }
198
+ return receiptFromJournalStates({
199
+ plan,
200
+ journal: rejectedJournal,
201
+ outcome: "rejected",
202
+ phase: "apply",
203
+ conflictOperationIds: new Set(classifications
204
+ .filter(({ state }) => state === "conflict")
205
+ .map(({ operation }) => operation.id))
206
+ });
207
+ }
208
+ if (classifications.every(({ state }) => state === "after")) {
209
+ return verifyAlreadyAppliedScaffold({
210
+ root: canonicalRoot,
211
+ plan,
212
+ ...(faultInjector === undefined ? {} : { faultInjector })
213
+ });
214
+ }
215
+ let journal = freshAuthorityScaffoldJournal(plan);
216
+ for (const { operation, state } of classifications) {
217
+ if (state === "after") {
218
+ journal = replaceScaffoldJournalOperation(journal, operation.id, "preexisting");
219
+ }
220
+ }
221
+ await writeAuthorityScaffoldJournal(journalPath, journal, journalFault(faultInjector));
222
+ await faultInjector?.({ phase: "after-journal-prepared" });
223
+ return continueJournal({
224
+ root: canonicalRoot,
225
+ journalPath,
226
+ journal,
227
+ recovered: false,
228
+ ...(faultInjector === undefined ? {} : { faultInjector })
229
+ });
230
+ }
231
+ finally {
232
+ await release();
233
+ }
234
+ }
235
+ export async function recoverAuthorityFilesystemScaffold(consumerRoot) {
236
+ const canonicalRoot = await realpath(resolve(consumerRoot));
237
+ const release = await acquireFoundationOperationLock(canonicalRoot);
238
+ try {
239
+ const journalPath = join(canonicalRoot, LOCAL_STATE_DIRECTORY, SCAFFOLD_JOURNAL_FILE);
240
+ await assertAuthorityScaffoldJournalTemporaryAbsent(journalPath);
241
+ const journal = await readScaffoldJournalEnvelope(journalPath);
242
+ if (journal === undefined) {
243
+ return undefined;
244
+ }
245
+ assertSafeOperationPaths(journal.plan);
246
+ return continueJournal({
247
+ root: canonicalRoot,
248
+ journalPath,
249
+ journal,
250
+ recovered: true
251
+ });
252
+ }
253
+ finally {
254
+ await release();
255
+ }
256
+ }
257
+ //# sourceMappingURL=filesystem-authority-workspace.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"filesystem-authority-workspace.js","sourceRoot":"","sources":["../../../../src/scaffolding/adapters/node/filesystem-authority-workspace.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAQ1C,OAAO,EAAE,iCAAiC,EAAE,MAAM,iCAAiC,CAAC;AACpF,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,EAAE,8BAA8B,EAAE,MAAM,gCAAgC,CAAC;AAChF,OAAO,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AACrE,OAAO,EAAE,2BAA2B,EAAE,MAAM,0BAA0B,CAAC;AACvE,OAAO,EACL,2BAA2B,EAC3B,wBAAwB,EACzB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EACL,kCAAkC,EAClC,0BAA0B,EAC3B,MAAM,iCAAiC,CAAC;AACzC,OAAO,EACL,6BAA6B,EAC7B,wBAAwB,EACxB,iCAAiC,EACjC,+BAA+B,EAChC,MAAM,+BAA+B,CAAC;AACvC,OAAO,EACL,gCAAgC,EAChC,kBAAkB,EAClB,4BAA4B,EAC7B,MAAM,8BAA8B,CAAC;AACtC,OAAO,EACL,4BAA4B,EAC5B,gBAAgB,EAChB,gBAAgB,EACjB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EACL,6CAA6C,EAC7C,2BAA2B,EAC3B,qBAAqB,EACrB,6BAA6B,EAC9B,MAAM,yBAAyB,CAAC;AAuBjC,SAAS,YAAY,CACnB,aAAyD,EACzD,cAAuB,EACvB,aAAsB;IAEtB,OAAO,aAAa,KAAK,SA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,CAAC;IAC5D,MAAM,OAAO,GAAG,MAAM,8BAA8B,CAAC,aAAa,CAAC,CAAC;IACpE,IAAI,CAAC;QACH,MAAM,WAAW,GAAG,IAAI,CAAC,aAAa,EAAE,qBAAqB,EAAE,qBAAqB,CAAC,CAAC;QACtF,MAAM,6CAA6C,CAAC,WAAW,CAAC,CAAC;QACjE,MAAM,OAAO,GAAG,MAAM,2BAA2B,CAAC,WAAW,CAAC,CAAC;QAC/D,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;YAC1B,OAAO,SAAS,CAAC;QACnB,CAAC;QACD,wBAAwB,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QACvC,OAAO,eAAe,CAAC;YACrB,IAAI,EAAE,aAAa;YACnB,WAAW;YACX,OAAO;YACP,SAAS,EAAE,IAAI;SAChB,CAAC,CAAC;IACL,CAAC;YAAS,CAAC;QACT,MAAM,OAAO,EAAE,CAAC;IAClB,CAAC;AACH,CAAC"}
@@ -0,0 +1,20 @@
1
+ import type { AuthorityScaffoldJournal, AuthorityScaffoldOperationReceipt, AuthorityScaffoldPlan, AuthorityScaffoldReceipt } from "../../contract/types.js";
2
+ export declare function recoveryRequiredForAuthority(options: {
3
+ readonly plan: AuthorityScaffoldPlan;
4
+ readonly phase: "apply" | "recovery";
5
+ readonly ruleId: string;
6
+ readonly message: string;
7
+ readonly remediation: string;
8
+ readonly operations?: readonly AuthorityScaffoldOperationReceipt[];
9
+ }): AuthorityScaffoldReceipt;
10
+ export declare function safeClassifyPlan(root: string, plan: AuthorityScaffoldPlan): Promise<readonly {
11
+ readonly operation: AuthorityScaffoldPlan["operations"][number];
12
+ readonly state: "absent" | "after" | "conflict";
13
+ }[]>;
14
+ export declare function resolveAuthority(options: {
15
+ readonly root: string;
16
+ readonly journal: AuthorityScaffoldJournal;
17
+ readonly recovered: boolean;
18
+ readonly observedOperations?: readonly AuthorityScaffoldOperationReceipt[];
19
+ }): Promise<AuthorityScaffoldReceipt | undefined>;
20
+ //# sourceMappingURL=filesystem-authority.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"filesystem-authority.d.ts","sourceRoot":"","sources":["../../../../src/scaffolding/adapters/node/filesystem-authority.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,wBAAwB,EACxB,iCAAiC,EACjC,qBAAqB,EACrB,wBAAwB,EACzB,MAAM,yBAAyB,CAAC;AAMjC,wBAAgB,4BAA4B,CAAC,OAAO,EAAE;IACpD,QAAQ,CAAC,IAAI,EAAE,qBAAqB,CAAC;IACrC,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,UAAU,CAAC;IACrC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,UAAU,CAAC,EAAE,SAAS,iCAAiC,EAAE,CAAC;CACpE,GAAG,wBAAwB,CAU3B;AAED,wBAAsB,gBAAgB,CACpC,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,qBAAqB,GAC1B,OAAO,CACR,SAAS;IACP,QAAQ,CAAC,SAAS,EAAE,qBAAqB,CAAC,YAAY,CAAC,CAAC,MAAM,CAAC,CAAC;IAChE,QAAQ,CAAC,KAAK,EAAE,QAAQ,GAAG,OAAO,GAAG,UAAU,CAAC;CACjD,EAAE,CACJ,CAaA;AAED,wBAAsB,gBAAgB,CAAC,OAAO,EAAE;IAC9C,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,OAAO,EAAE,wBAAwB,CAAC;IAC3C,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC;IAC5B,QAAQ,CAAC,kBAAkB,CAAC,EAAE,SAAS,iCAAiC,EAAE,CAAC;CAC5E,GAAG,OAAO,CAAC,wBAAwB,GAAG,SAAS,CAAC,CAgChD"}
@@ -0,0 +1,55 @@
1
+ import { assessScaffoldPlanAuthority } from "./node-plan-authority.js";
2
+ import { assertSafeExistingAncestors } from "./filesystem-path-guard.js";
3
+ import { classifyFilesystemOperation } from "./filesystem-operation-state.js";
4
+ import { createRecoveryRequiredReceipt } from "./filesystem-journal-state.js";
5
+ export function recoveryRequiredForAuthority(options) {
6
+ return createRecoveryRequiredReceipt({
7
+ plan: options.plan,
8
+ phase: options.phase,
9
+ ruleId: options.ruleId,
10
+ subject: options.plan.projectId,
11
+ message: options.message,
12
+ remediation: options.remediation,
13
+ ...(options.operations === undefined ? {} : { operations: options.operations })
14
+ });
15
+ }
16
+ export async function safeClassifyPlan(root, plan) {
17
+ const classifications = [];
18
+ for (const operation of plan.operations) {
19
+ await assertSafeExistingAncestors(root, operation.path);
20
+ classifications.push({
21
+ operation,
22
+ state: await classifyFilesystemOperation(root, operation)
23
+ });
24
+ }
25
+ return classifications;
26
+ }
27
+ export async function resolveAuthority(options) {
28
+ const assessment = await assessScaffoldPlanAuthority(options.root, options.journal.plan);
29
+ if (assessment.state === "current") {
30
+ return undefined;
31
+ }
32
+ if (assessment.state === "unverifiable") {
33
+ return recoveryRequiredForAuthority({
34
+ plan: options.journal.plan,
35
+ phase: options.recovered ? "recovery" : "apply",
36
+ ruleId: "scaffolding.authority.unverifiable",
37
+ message: "Authority cannot be re-verified safely after publication began; outputs and journal were preserved.",
38
+ remediation: "Restore readable authority sources, then retry recovery.",
39
+ ...(options.observedOperations === undefined
40
+ ? {}
41
+ : { operations: options.observedOperations })
42
+ });
43
+ }
44
+ return recoveryRequiredForAuthority({
45
+ plan: options.journal.plan,
46
+ phase: options.recovered ? "recovery" : "apply",
47
+ ruleId: "scaffolding.authority.stale-after-publication",
48
+ message: "Authority changed after publication began; outputs and journal were preserved because portable file ownership cannot be proven.",
49
+ remediation: "Resolve the transaction state explicitly, then compile a new Plan.",
50
+ ...(options.observedOperations === undefined
51
+ ? {}
52
+ : { operations: options.observedOperations })
53
+ });
54
+ }
55
+ //# sourceMappingURL=filesystem-authority.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"filesystem-authority.js","sourceRoot":"","sources":["../../../../src/scaffolding/adapters/node/filesystem-authority.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,2BAA2B,EAAE,MAAM,0BAA0B,CAAC;AACvE,OAAO,EAAE,2BAA2B,EAAE,MAAM,4BAA4B,CAAC;AACzE,OAAO,EAAE,2BAA2B,EAAE,MAAM,iCAAiC,CAAC;AAC9E,OAAO,EAAE,6BAA6B,EAAE,MAAM,+BAA+B,CAAC;AAE9E,MAAM,UAAU,4BAA4B,CAAC,OAO5C;IACC,OAAO,6BAA6B,CAAC;QACnC,IAAI,EAAE,OAAO,CAAC,IAAI;QAClB,KAAK,EAAE,OAAO,CAAC,KAAK;QACpB,MAAM,EAAE,OAAO,CAAC,MAAM;QACtB,OAAO,EAAE,OAAO,CAAC,IAAI,CAAC,SAAS;QAC/B,OAAO,EAAE,OAAO,CAAC,OAAO;QACxB,WAAW,EAAE,OAAO,CAAC,WAAW;QAChC,GAAG,CAAC,OAAO,CAAC,UAAU,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,UAAU,EAAE,OAAO,CAAC,UAAU,EAAE,CAAC;KAChF,CAAC,CAAC;AACL,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,gBAAgB,CACpC,IAAY,EACZ,IAA2B;IAO3B,MAAM,eAAe,GAAG,EAGrB,CAAC;IACJ,KAAK,MAAM,SAAS,IAAI,IAAI,CAAC,UAAU,EAAE,CAAC;QACxC,MAAM,2BAA2B,CAAC,IAAI,EAAE,SAAS,CAAC,IAAI,CAAC,CAAC;QACxD,eAAe,CAAC,IAAI,CAAC;YACnB,SAAS;YACT,KAAK,EAAE,MAAM,2BAA2B,CAAC,IAAI,EAAE,SAAS,CAAC;SAC1D,CAAC,CAAC;IACL,CAAC;IACD,OAAO,eAAe,CAAC;AACzB,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,gBAAgB,CAAC,OAKtC;IACC,MAAM,UAAU,GAAG,MAAM,2BAA2B,CAClD,OAAO,CAAC,IAAI,EACZ,OAAO,CAAC,OAAO,CAAC,IAAI,CACrB,CAAC;IACF,IAAI,UAAU,CAAC,KAAK,KAAK,SAAS,EAAE,CAAC;QACnC,OAAO,SAAS,CAAC;IACnB,CAAC;IACD,IAAI,UAAU,CAAC,KAAK,KAAK,cAAc,EAAE,CAAC;QACxC,OAAO,4BAA4B,CAAC;YAClC,IAAI,EAAE,OAAO,CAAC,OAAO,CAAC,IAAI;YAC1B,KAAK,EAAE,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,OAAO;YAC/C,MAAM,EAAE,oCAAoC;YAC5C,OAAO,EACL,qGAAqG;YACvG,WAAW,EAAE,0DAA0D;YACvE,GAAG,CAAC,OAAO,CAAC,kBAAkB,KAAK,SAAS;gBAC1C,CAAC,CAAC,EAAE;gBACJ,CAAC,CAAC,EAAE,UAAU,EAAE,OAAO,CAAC,kBAAkB,EAAE,CAAC;SAChD,CAAC,CAAC;IACL,CAAC;IACD,OAAO,4BAA4B,CAAC;QAClC,IAAI,EAAE,OAAO,CAAC,OAAO,CAAC,IAAI;QAC1B,KAAK,EAAE,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,OAAO;QAC/C,MAAM,EAAE,+CAA+C;QACvD,OAAO,EACL,iIAAiI;QACnI,WAAW,EAAE,oEAAoE;QACjF,GAAG,CAAC,OAAO,CAAC,kBAAkB,KAAK,SAAS;YAC1C,CAAC,CAAC,EAAE;YACJ,CAAC,CAAC,EAAE,UAAU,EAAE,OAAO,CAAC,kBAAkB,EAAE,CAAC;KAChD,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,20 @@
1
+ import { type FileHandle } from "node:fs/promises";
2
+ export interface PortableFileIdentity {
3
+ readonly birthtimeNs: bigint;
4
+ readonly dev: bigint;
5
+ readonly ino: bigint;
6
+ }
7
+ export type BoundedRegularFileRead = {
8
+ readonly outcome: "read";
9
+ readonly bytes: Buffer;
10
+ readonly identity: PortableFileIdentity;
11
+ readonly mode: number;
12
+ } | {
13
+ readonly outcome: "changed";
14
+ } | {
15
+ readonly outcome: "invalid";
16
+ };
17
+ export declare function readBoundedRegularFile(path: string, maximumBytes: number): Promise<BoundedRegularFileRead>;
18
+ export declare function captureFileHandleIdentity(handle: FileHandle): Promise<PortableFileIdentity>;
19
+ export declare function pathMatchesFileIdentity(path: string, expected: PortableFileIdentity): Promise<"different" | "match" | "missing">;
20
+ //# sourceMappingURL=filesystem-file-identity.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"filesystem-file-identity.d.ts","sourceRoot":"","sources":["../../../../src/scaffolding/adapters/node/filesystem-file-identity.ts"],"names":[],"mappings":"AAAA,OAAO,EAA0B,KAAK,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE3E,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,MAAM,sBAAsB,GAC9B;IACE,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,QAAQ,EAAE,oBAAoB,CAAC;IACxC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB,GACD;IAAE,QAAQ,CAAC,OAAO,EAAE,SAAS,CAAA;CAAE,GAC/B;IAAE,QAAQ,CAAC,OAAO,EAAE,SAAS,CAAA;CAAE,CAAC;AAiFpC,wBAAsB,sBAAsB,CAC1C,IAAI,EAAE,MAAM,EACZ,YAAY,EAAE,MAAM,GACnB,OAAO,CAAC,sBAAsB,CAAC,CAiDjC;AAED,wBAAsB,yBAAyB,CAC7C,MAAM,EAAE,UAAU,GACjB,OAAO,CAAC,oBAAoB,CAAC,CAE/B;AAED,wBAAsB,uBAAuB,CAC3C,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,oBAAoB,GAC7B,OAAO,CAAC,WAAW,GAAG,OAAO,GAAG,SAAS,CAAC,CAkB5C"}
@@ -0,0 +1,122 @@
1
+ import { constants, lstat, open } from "node:fs/promises";
2
+ function identityFromStat(metadata) {
3
+ return {
4
+ birthtimeNs: metadata.birthtimeNs,
5
+ dev: metadata.dev,
6
+ ino: metadata.ino
7
+ };
8
+ }
9
+ function isMissing(error) {
10
+ return (error instanceof Error &&
11
+ "code" in error &&
12
+ error.code === "ENOENT");
13
+ }
14
+ function hasErrorCode(error, code) {
15
+ return (error instanceof Error &&
16
+ "code" in error &&
17
+ error.code === code);
18
+ }
19
+ async function isExistingNonRegularPath(path) {
20
+ try {
21
+ const metadata = await lstat(path);
22
+ return metadata.isSymbolicLink() || !metadata.isFile();
23
+ }
24
+ catch {
25
+ return false;
26
+ }
27
+ }
28
+ function sameFileObservation(left, right) {
29
+ return (left.dev === right.dev &&
30
+ left.ino === right.ino &&
31
+ left.birthtimeNs === right.birthtimeNs &&
32
+ left.ctimeNs === right.ctimeNs &&
33
+ left.mtimeNs === right.mtimeNs &&
34
+ left.size === right.size);
35
+ }
36
+ async function readAtMost(handle, maximumBytes) {
37
+ const chunks = [];
38
+ let total = 0;
39
+ while (total <= maximumBytes) {
40
+ const remaining = maximumBytes + 1 - total;
41
+ const buffer = Buffer.allocUnsafe(Math.min(64 * 1024, remaining));
42
+ const { bytesRead } = await handle.read(buffer, 0, buffer.byteLength, null);
43
+ if (bytesRead === 0) {
44
+ return Buffer.concat(chunks, total);
45
+ }
46
+ chunks.push(buffer.subarray(0, bytesRead));
47
+ total += bytesRead;
48
+ }
49
+ return undefined;
50
+ }
51
+ export async function readBoundedRegularFile(path, maximumBytes) {
52
+ if (!Number.isSafeInteger(maximumBytes) || maximumBytes < 0) {
53
+ throw new TypeError("maximumBytes must be a non-negative safe integer.");
54
+ }
55
+ if (await isExistingNonRegularPath(path)) {
56
+ return { outcome: "invalid" };
57
+ }
58
+ const noFollow = process.platform === "win32" ? 0 : constants.O_NOFOLLOW;
59
+ const nonBlocking = process.platform === "win32" ? 0 : constants.O_NONBLOCK;
60
+ let handle;
61
+ try {
62
+ handle = await open(path, constants.O_RDONLY | noFollow | nonBlocking);
63
+ }
64
+ catch (error) {
65
+ if (hasErrorCode(error, "ELOOP") ||
66
+ (await isExistingNonRegularPath(path))) {
67
+ return { outcome: "invalid" };
68
+ }
69
+ throw error;
70
+ }
71
+ try {
72
+ const before = await handle.stat({ bigint: true });
73
+ if (!before.isFile() || before.size > BigInt(maximumBytes)) {
74
+ return { outcome: "invalid" };
75
+ }
76
+ const identity = identityFromStat(before);
77
+ const bytes = await readAtMost(handle, maximumBytes);
78
+ if (bytes === undefined) {
79
+ return { outcome: "invalid" };
80
+ }
81
+ const after = await handle.stat({ bigint: true });
82
+ if (!after.isFile() ||
83
+ !sameFileObservation(before, after) ||
84
+ after.size !== BigInt(bytes.byteLength) ||
85
+ (await pathMatchesFileIdentity(path, identity)) !== "match") {
86
+ return { outcome: "changed" };
87
+ }
88
+ return {
89
+ outcome: "read",
90
+ bytes,
91
+ identity,
92
+ mode: Number(after.mode)
93
+ };
94
+ }
95
+ finally {
96
+ await handle.close();
97
+ }
98
+ }
99
+ export async function captureFileHandleIdentity(handle) {
100
+ return identityFromStat(await handle.stat({ bigint: true }));
101
+ }
102
+ export async function pathMatchesFileIdentity(path, expected) {
103
+ try {
104
+ const metadata = await lstat(path, { bigint: true });
105
+ if (metadata.isSymbolicLink() || !metadata.isFile()) {
106
+ return "different";
107
+ }
108
+ const observed = identityFromStat(metadata);
109
+ return observed.dev === expected.dev &&
110
+ observed.ino === expected.ino &&
111
+ observed.birthtimeNs === expected.birthtimeNs
112
+ ? "match"
113
+ : "different";
114
+ }
115
+ catch (error) {
116
+ if (isMissing(error)) {
117
+ return "missing";
118
+ }
119
+ throw error;
120
+ }
121
+ }
122
+ //# sourceMappingURL=filesystem-file-identity.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"filesystem-file-identity.js","sourceRoot":"","sources":["../../../../src/scaffolding/adapters/node/filesystem-file-identity.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,IAAI,EAAmB,MAAM,kBAAkB,CAAC;AAkB3E,SAAS,gBAAgB,CAAC,QAIzB;IACC,OAAO;QACL,WAAW,EAAE,QAAQ,CAAC,WAAW;QACjC,GAAG,EAAE,QAAQ,CAAC,GAAG;QACjB,GAAG,EAAE,QAAQ,CAAC,GAAG;KAClB,CAAC;AACJ,CAAC;AAED,SAAS,SAAS,CAAC,KAAc;IAC/B,OAAO,CACL,KAAK,YAAY,KAAK;QACtB,MAAM,IAAI,KAAK;QACd,KAA+B,CAAC,IAAI,KAAK,QAAQ,CACnD,CAAC;AACJ,CAAC;AAED,SAAS,YAAY,CAAC,KAAc,EAAE,IAAY;IAChD,OAAO,CACL,KAAK,YAAY,KAAK;QACtB,MAAM,IAAI,KAAK;QACd,KAA+B,CAAC,IAAI,KAAK,IAAI,CAC/C,CAAC;AACJ,CAAC;AAED,KAAK,UAAU,wBAAwB,CAAC,IAAY;IAClD,IAAI,CAAC;QACH,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,IAAI,CAAC,CAAC;QACnC,OAAO,QAAQ,CAAC,cAAc,EAAE,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC;IACzD,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC;AAWD,SAAS,mBAAmB,CAC1B,IAA2B,EAC3B,KAA4B;IAE5B,OAAO,CACL,IAAI,CAAC,GAAG,KAAK,KAAK,CAAC,GAAG;QACtB,IAAI,CAAC,GAAG,KAAK,KAAK,CAAC,GAAG;QACtB,IAAI,CAAC,WAAW,KAAK,KAAK,CAAC,WAAW;QACtC,IAAI,CAAC,OAAO,KAAK,KAAK,CAAC,OAAO;QAC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;YACT,CAAC,CAAC,WAAW,CAAC;IAClB,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAI,SAAS,CAAC,KAAK,CAAC,EAAE,CAAC;YACrB,OAAO,SAAS,CAAC;QACnB,CAAC;QACD,MAAM,KAAK,CAAC;IACd,CAAC;AACH,CAAC"}
@@ -0,0 +1,22 @@
1
+ import type { AuthorityScaffoldJournal, AuthorityScaffoldOperationReceipt, AuthorityScaffoldPlan, AuthorityScaffoldReceipt } from "../../contract/types.js";
2
+ interface FinalizationFaultPoint {
3
+ readonly phase: "after-final-verification" | "after-journal-unlinked" | "before-final-authority-recheck";
4
+ }
5
+ type FinalizationFaultInjector = (point: FinalizationFaultPoint) => Promise<void> | void;
6
+ export declare function staleBeforeJournal(plan: AuthorityScaffoldPlan): AuthorityScaffoldReceipt;
7
+ export declare function verifyAlreadyAppliedScaffold(options: {
8
+ readonly root: string;
9
+ readonly plan: AuthorityScaffoldPlan;
10
+ readonly faultInjector?: FinalizationFaultInjector;
11
+ }): Promise<AuthorityScaffoldReceipt>;
12
+ interface FinalizationOptions {
13
+ readonly root: string;
14
+ readonly journalPath: string;
15
+ readonly journal: AuthorityScaffoldJournal;
16
+ readonly recovered: boolean;
17
+ readonly receipts: ReadonlyMap<string, AuthorityScaffoldOperationReceipt>;
18
+ readonly faultInjector?: FinalizationFaultInjector;
19
+ }
20
+ export declare function finalizeAuthorityScaffoldJournal(options: FinalizationOptions): Promise<AuthorityScaffoldReceipt>;
21
+ export {};
22
+ //# sourceMappingURL=filesystem-finalization.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"filesystem-finalization.d.ts","sourceRoot":"","sources":["../../../../src/scaffolding/adapters/node/filesystem-finalization.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,wBAAwB,EACxB,iCAAiC,EACjC,qBAAqB,EACrB,wBAAwB,EACzB,MAAM,yBAAyB,CAAC;AAoBjC,UAAU,sBAAsB;IAC9B,QAAQ,CAAC,KAAK,EACV,0BAA0B,GAC1B,wBAAwB,GACxB,gCAAgC,CAAC;CACtC;AAED,KAAK,yBAAyB,GAAG,CAC/B,KAAK,EAAE,sBAAsB,KAC1B,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;AAE1B,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,qBAAqB,GAAG,wBAAwB,CAoBxF;AAwDD,wBAAsB,4BAA4B,CAAC,OAAO,EAAE;IAC1D,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,qBAAqB,CAAC;IACrC,QAAQ,CAAC,aAAa,CAAC,EAAE,yBAAyB,CAAC;CACpD,GAAG,OAAO,CAAC,wBAAwB,CAAC,CA8BpC;AAED,UAAU,mBAAmB;IAC3B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,OAAO,EAAE,wBAAwB,CAAC;IAC3C,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC;IAC5B,QAAQ,CAAC,QAAQ,EAAE,WAAW,CAAC,MAAM,EAAE,iCAAiC,CAAC,CAAC;IAC1E,QAAQ,CAAC,aAAa,CAAC,EAAE,yBAAyB,CAAC;CACpD;AA2DD,wBAAsB,gCAAgC,CACpD,OAAO,EAAE,mBAAmB,GAC3B,OAAO,CAAC,wBAAwB,CAAC,CA8CnC"}