gate-evm-tools 1.0.28 → 1.0.31

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 (618) hide show
  1. package/README.md +16 -1
  2. package/bin/cli.js +3 -0
  3. package/bin/delivery.cjs +51 -0
  4. package/bin/manifest-bootstrap.js +4 -15
  5. package/bin/workflow.cjs +1 -1
  6. package/dist/commands/plan/file-store.d.ts.map +1 -0
  7. package/dist/commands/plan/generate-deployment.d.ts +48 -0
  8. package/dist/commands/plan/generate-deployment.d.ts.map +1 -0
  9. package/dist/commands/plan/generate-deployment.js +211 -0
  10. package/dist/commands/plan/generate-deployment.js.map +1 -0
  11. package/dist/commands/plan/helpers.d.ts.map +1 -0
  12. package/dist/commands/plan/index.d.ts +3 -0
  13. package/dist/commands/plan/index.d.ts.map +1 -0
  14. package/dist/commands/plan/index.js +88 -0
  15. package/dist/commands/plan/index.js.map +1 -0
  16. package/dist/commands/sync.js +1 -1
  17. package/dist/commands/sync.js.map +1 -1
  18. package/dist/core/BytecodeChecker.d.ts.map +1 -1
  19. package/dist/core/BytecodeChecker.js +27 -8
  20. package/dist/core/BytecodeChecker.js.map +1 -1
  21. package/dist/core/preparation/artifacts.d.ts +2 -0
  22. package/dist/core/preparation/artifacts.d.ts.map +1 -1
  23. package/dist/core/preparation/artifacts.js +9 -3
  24. package/dist/core/preparation/artifacts.js.map +1 -1
  25. package/dist/core/preparation/evm.d.ts +38 -2
  26. package/dist/core/preparation/evm.d.ts.map +1 -1
  27. package/dist/core/preparation/evm.js +104 -32
  28. package/dist/core/preparation/evm.js.map +1 -1
  29. package/dist/core/preparation/evmManifestSync.d.ts +63 -0
  30. package/dist/core/preparation/evmManifestSync.d.ts.map +1 -0
  31. package/dist/core/preparation/evmManifestSync.js +146 -0
  32. package/dist/core/preparation/evmManifestSync.js.map +1 -0
  33. package/dist/core/preparation/index.d.ts +40 -2
  34. package/dist/core/preparation/index.d.ts.map +1 -1
  35. package/dist/core/preparation/index.js +3 -3
  36. package/dist/core/preparation/index.js.map +1 -1
  37. package/dist/core/preparation/manifest.d.ts +15 -3
  38. package/dist/core/preparation/manifest.d.ts.map +1 -1
  39. package/dist/core/preparation/manifest.js +21 -26
  40. package/dist/core/preparation/manifest.js.map +1 -1
  41. package/dist/core/preparation/normalize.d.ts.map +1 -1
  42. package/dist/core/preparation/normalize.js +14 -9
  43. package/dist/core/preparation/normalize.js.map +1 -1
  44. package/dist/core/preparation/types.d.ts +7 -2
  45. package/dist/core/preparation/types.d.ts.map +1 -1
  46. package/dist/custody/hardhat-runtime.d.ts.map +1 -1
  47. package/dist/custody/hardhat-runtime.js +2 -0
  48. package/dist/custody/hardhat-runtime.js.map +1 -1
  49. package/dist/custody/hardhat.d.ts +1 -0
  50. package/dist/custody/hardhat.d.ts.map +1 -1
  51. package/dist/custody/hardhat.js +1 -0
  52. package/dist/custody/hardhat.js.map +1 -1
  53. package/dist/custody/index.d.ts +1 -0
  54. package/dist/custody/index.d.ts.map +1 -1
  55. package/dist/custody/index.js +1 -0
  56. package/dist/custody/index.js.map +1 -1
  57. package/dist/custody/provider-wait.d.ts +13 -0
  58. package/dist/custody/provider-wait.d.ts.map +1 -0
  59. package/dist/custody/provider-wait.js +78 -0
  60. package/dist/custody/provider-wait.js.map +1 -0
  61. package/dist/delivery/policy.d.ts +6 -0
  62. package/dist/delivery/policy.d.ts.map +1 -0
  63. package/dist/delivery/policy.js +24 -0
  64. package/dist/delivery/policy.js.map +1 -0
  65. package/dist/index.d.ts.map +1 -1
  66. package/dist/index.js +5 -0
  67. package/dist/index.js.map +1 -1
  68. package/dist/sync/index.d.ts +15 -0
  69. package/dist/sync/index.d.ts.map +1 -1
  70. package/dist/sync/index.js +8 -0
  71. package/dist/sync/index.js.map +1 -1
  72. package/dist/workflow/index.d.ts +6 -1
  73. package/dist/workflow/index.d.ts.map +1 -1
  74. package/dist/workflow/index.js +4 -0
  75. package/dist/workflow/index.js.map +1 -1
  76. package/dist-cjs/core/BytecodeChecker.js +526 -0
  77. package/dist-cjs/core/BytecodeChecker.js.map +1 -0
  78. package/dist-cjs/core/legacyProxyArtifact.js +42 -0
  79. package/dist-cjs/core/legacyProxyArtifact.js.map +1 -0
  80. package/dist-cjs/core/preparation/artifacts.js +11 -4
  81. package/dist-cjs/core/preparation/artifacts.js.map +1 -1
  82. package/dist-cjs/core/preparation/evm.js +105 -32
  83. package/dist-cjs/core/preparation/evm.js.map +1 -1
  84. package/dist-cjs/core/preparation/evmManifestSync.js +155 -0
  85. package/dist-cjs/core/preparation/evmManifestSync.js.map +1 -0
  86. package/dist-cjs/core/preparation/index.js +3 -3
  87. package/dist-cjs/core/preparation/index.js.map +1 -1
  88. package/dist-cjs/core/preparation/manifest.js +23 -28
  89. package/dist-cjs/core/preparation/manifest.js.map +1 -1
  90. package/dist-cjs/core/preparation/normalize.js +14 -9
  91. package/dist-cjs/core/preparation/normalize.js.map +1 -1
  92. package/dist-cjs/custody/hardhat-runtime.js +2 -0
  93. package/dist-cjs/custody/hardhat-runtime.js.map +1 -1
  94. package/dist-cjs/custody/hardhat.js +3 -1
  95. package/dist-cjs/custody/hardhat.js.map +1 -1
  96. package/dist-cjs/custody/index.js +3 -1
  97. package/dist-cjs/custody/index.js.map +1 -1
  98. package/dist-cjs/custody/provider-wait.js +81 -0
  99. package/dist-cjs/custody/provider-wait.js.map +1 -0
  100. package/dist-cjs/delivery/policy.js +29 -0
  101. package/dist-cjs/delivery/policy.js.map +1 -0
  102. package/dist-cjs/sync/index.js +8 -0
  103. package/dist-cjs/sync/index.js.map +1 -1
  104. package/dist-cjs/workflow/index.js +12 -1
  105. package/dist-cjs/workflow/index.js.map +1 -1
  106. package/dist-runtime/config/openzeppelin.d.ts +2 -1
  107. package/dist-runtime/config/openzeppelin.js +2 -19
  108. package/dist-runtime/config/openzeppelin.js.map +1 -1
  109. package/dist-runtime/delivery/abi.d.ts +14 -0
  110. package/dist-runtime/delivery/abi.js +161 -0
  111. package/dist-runtime/delivery/abi.js.map +1 -0
  112. package/dist-runtime/delivery/aggregate-bootstrap.d.ts +12 -0
  113. package/dist-runtime/delivery/aggregate-bootstrap.js +40 -0
  114. package/dist-runtime/delivery/aggregate-bootstrap.js.map +1 -0
  115. package/dist-runtime/delivery/aggregate-channel.d.ts +28 -0
  116. package/dist-runtime/delivery/aggregate-channel.js +155 -0
  117. package/dist-runtime/delivery/aggregate-channel.js.map +1 -0
  118. package/dist-runtime/delivery/aggregate-inputs.d.ts +168 -0
  119. package/dist-runtime/delivery/aggregate-inputs.js +57 -0
  120. package/dist-runtime/delivery/aggregate-inputs.js.map +1 -0
  121. package/dist-runtime/delivery/aggregate-source.d.ts +25 -0
  122. package/dist-runtime/delivery/aggregate-source.js +79 -0
  123. package/dist-runtime/delivery/aggregate-source.js.map +1 -0
  124. package/dist-runtime/delivery/aggregate-worker.d.ts +1 -0
  125. package/dist-runtime/delivery/aggregate-worker.js +191 -0
  126. package/dist-runtime/delivery/aggregate-worker.js.map +1 -0
  127. package/dist-runtime/delivery/aggregate.d.ts +51 -0
  128. package/dist-runtime/delivery/aggregate.js +190 -0
  129. package/dist-runtime/delivery/aggregate.js.map +1 -0
  130. package/dist-runtime/delivery/bindings.d.ts +21 -0
  131. package/dist-runtime/delivery/bindings.js +53 -0
  132. package/dist-runtime/delivery/bindings.js.map +1 -0
  133. package/dist-runtime/delivery/check-code.d.ts +19 -0
  134. package/dist-runtime/delivery/check-code.js +63 -0
  135. package/dist-runtime/delivery/check-code.js.map +1 -0
  136. package/dist-runtime/delivery/closure-format.d.ts +77 -0
  137. package/dist-runtime/delivery/closure-format.js +225 -0
  138. package/dist-runtime/delivery/closure-format.js.map +1 -0
  139. package/dist-runtime/delivery/codec-pin.d.ts +2 -0
  140. package/dist-runtime/delivery/codec-pin.js +7 -0
  141. package/dist-runtime/delivery/codec-pin.js.map +1 -0
  142. package/dist-runtime/delivery/codec.d.ts +19 -0
  143. package/dist-runtime/delivery/codec.js +73 -0
  144. package/dist-runtime/delivery/codec.js.map +1 -0
  145. package/dist-runtime/delivery/compiler-dependency-pins.d.ts +7 -0
  146. package/dist-runtime/delivery/compiler-dependency-pins.js +1689 -0
  147. package/dist-runtime/delivery/compiler-dependency-pins.js.map +1 -0
  148. package/dist-runtime/delivery/compiler-files.d.ts +40 -0
  149. package/dist-runtime/delivery/compiler-files.js +220 -0
  150. package/dist-runtime/delivery/compiler-files.js.map +1 -0
  151. package/dist-runtime/delivery/compiler-io.d.ts +2 -0
  152. package/dist-runtime/delivery/compiler-io.js +13 -0
  153. package/dist-runtime/delivery/compiler-io.js.map +1 -0
  154. package/dist-runtime/delivery/compiler-pins.d.ts +10 -0
  155. package/dist-runtime/delivery/compiler-pins.js +147 -0
  156. package/dist-runtime/delivery/compiler-pins.js.map +1 -0
  157. package/dist-runtime/delivery/compiler.d.ts +188 -0
  158. package/dist-runtime/delivery/compiler.js +850 -0
  159. package/dist-runtime/delivery/compiler.js.map +1 -0
  160. package/dist-runtime/delivery/config.d.ts +48 -0
  161. package/dist-runtime/delivery/config.js +99 -0
  162. package/dist-runtime/delivery/config.js.map +1 -0
  163. package/dist-runtime/delivery/configuration-definition.d.ts +22 -0
  164. package/dist-runtime/delivery/configuration-definition.js +316 -0
  165. package/dist-runtime/delivery/configuration-definition.js.map +1 -0
  166. package/dist-runtime/delivery/configuration-hre.d.ts +17 -0
  167. package/dist-runtime/delivery/configuration-hre.js +198 -0
  168. package/dist-runtime/delivery/configuration-hre.js.map +1 -0
  169. package/dist-runtime/delivery/configuration-runtime.d.ts +36 -0
  170. package/dist-runtime/delivery/configuration-runtime.js +248 -0
  171. package/dist-runtime/delivery/configuration-runtime.js.map +1 -0
  172. package/dist-runtime/delivery/configuration.d.ts +35 -0
  173. package/dist-runtime/delivery/configuration.js +83 -0
  174. package/dist-runtime/delivery/configuration.js.map +1 -0
  175. package/dist-runtime/delivery/create2.d.ts +3 -0
  176. package/dist-runtime/delivery/create2.js +48 -0
  177. package/dist-runtime/delivery/create2.js.map +1 -0
  178. package/dist-runtime/delivery/custom-closure.d.ts +27 -0
  179. package/dist-runtime/delivery/custom-closure.js +818 -0
  180. package/dist-runtime/delivery/custom-closure.js.map +1 -0
  181. package/dist-runtime/delivery/custom-format.d.ts +35 -0
  182. package/dist-runtime/delivery/custom-format.js +383 -0
  183. package/dist-runtime/delivery/custom-format.js.map +1 -0
  184. package/dist-runtime/delivery/custom.d.ts +32 -0
  185. package/dist-runtime/delivery/custom.js +158 -0
  186. package/dist-runtime/delivery/custom.js.map +1 -0
  187. package/dist-runtime/delivery/data.d.ts +7 -0
  188. package/dist-runtime/delivery/data.js +86 -0
  189. package/dist-runtime/delivery/data.js.map +1 -0
  190. package/dist-runtime/delivery/development.d.ts +91 -0
  191. package/dist-runtime/delivery/development.js +395 -0
  192. package/dist-runtime/delivery/development.js.map +1 -0
  193. package/dist-runtime/delivery/engine.d.ts +9 -0
  194. package/dist-runtime/delivery/engine.js +23 -0
  195. package/dist-runtime/delivery/engine.js.map +1 -0
  196. package/dist-runtime/delivery/eoa-observation.d.ts +43 -0
  197. package/dist-runtime/delivery/eoa-observation.js +145 -0
  198. package/dist-runtime/delivery/eoa-observation.js.map +1 -0
  199. package/dist-runtime/delivery/eoa-signed.d.ts +2 -0
  200. package/dist-runtime/delivery/eoa-signed.js +74 -0
  201. package/dist-runtime/delivery/eoa-signed.js.map +1 -0
  202. package/dist-runtime/delivery/eoa.d.ts +81 -0
  203. package/dist-runtime/delivery/eoa.js +274 -0
  204. package/dist-runtime/delivery/eoa.js.map +1 -0
  205. package/dist-runtime/delivery/execution-db.d.ts +20 -0
  206. package/dist-runtime/delivery/execution-db.js +153 -0
  207. package/dist-runtime/delivery/execution-db.js.map +1 -0
  208. package/dist-runtime/delivery/execution-files.d.ts +9 -0
  209. package/dist-runtime/delivery/execution-files.js +138 -0
  210. package/dist-runtime/delivery/execution-files.js.map +1 -0
  211. package/dist-runtime/delivery/execution-model.d.ts +56 -0
  212. package/dist-runtime/delivery/execution-model.js +66 -0
  213. package/dist-runtime/delivery/execution-model.js.map +1 -0
  214. package/dist-runtime/delivery/execution-store.d.ts +48 -0
  215. package/dist-runtime/delivery/execution-store.js +361 -0
  216. package/dist-runtime/delivery/execution-store.js.map +1 -0
  217. package/dist-runtime/delivery/existing-code.d.ts +37 -0
  218. package/dist-runtime/delivery/existing-code.js +75 -0
  219. package/dist-runtime/delivery/existing-code.js.map +1 -0
  220. package/dist-runtime/delivery/export.d.ts +51 -0
  221. package/dist-runtime/delivery/export.js +69 -0
  222. package/dist-runtime/delivery/export.js.map +1 -0
  223. package/dist-runtime/delivery/forkAudit.d.ts +119 -0
  224. package/dist-runtime/delivery/forkAudit.js +473 -0
  225. package/dist-runtime/delivery/forkAudit.js.map +1 -0
  226. package/dist-runtime/delivery/hardhat.d.ts +3 -0
  227. package/dist-runtime/delivery/hardhat.js +45 -0
  228. package/dist-runtime/delivery/hardhat.js.map +1 -0
  229. package/dist-runtime/delivery/history-registration.d.ts +2 -0
  230. package/dist-runtime/delivery/history-registration.js +17 -0
  231. package/dist-runtime/delivery/history-registration.js.map +1 -0
  232. package/dist-runtime/delivery/identities.d.ts +22 -0
  233. package/dist-runtime/delivery/identities.js +97 -0
  234. package/dist-runtime/delivery/identities.js.map +1 -0
  235. package/dist-runtime/delivery/input-files.d.ts +5 -0
  236. package/dist-runtime/delivery/input-files.js +70 -0
  237. package/dist-runtime/delivery/input-files.js.map +1 -0
  238. package/dist-runtime/delivery/inputs.d.ts +62 -0
  239. package/dist-runtime/delivery/inputs.js +187 -0
  240. package/dist-runtime/delivery/inputs.js.map +1 -0
  241. package/dist-runtime/delivery/journal.d.ts +35 -0
  242. package/dist-runtime/delivery/journal.js +270 -0
  243. package/dist-runtime/delivery/journal.js.map +1 -0
  244. package/dist-runtime/delivery/manifest.d.ts +14 -0
  245. package/dist-runtime/delivery/manifest.js +68 -0
  246. package/dist-runtime/delivery/manifest.js.map +1 -0
  247. package/dist-runtime/delivery/materialization.d.ts +20 -0
  248. package/dist-runtime/delivery/materialization.js +138 -0
  249. package/dist-runtime/delivery/materialization.js.map +1 -0
  250. package/dist-runtime/delivery/observations.d.ts +31 -0
  251. package/dist-runtime/delivery/observations.js +38 -0
  252. package/dist-runtime/delivery/observations.js.map +1 -0
  253. package/dist-runtime/delivery/parameters.d.ts +53 -0
  254. package/dist-runtime/delivery/parameters.js +257 -0
  255. package/dist-runtime/delivery/parameters.js.map +1 -0
  256. package/dist-runtime/delivery/pending.d.ts +70 -0
  257. package/dist-runtime/delivery/pending.js +99 -0
  258. package/dist-runtime/delivery/pending.js.map +1 -0
  259. package/dist-runtime/delivery/plan.d.ts +50 -0
  260. package/dist-runtime/delivery/plan.js +209 -0
  261. package/dist-runtime/delivery/plan.js.map +1 -0
  262. package/dist-runtime/delivery/planning.d.ts +81 -0
  263. package/dist-runtime/delivery/planning.js +302 -0
  264. package/dist-runtime/delivery/planning.js.map +1 -0
  265. package/dist-runtime/delivery/policy.d.ts +4 -0
  266. package/dist-runtime/delivery/policy.js +9 -0
  267. package/dist-runtime/delivery/policy.js.map +1 -0
  268. package/dist-runtime/delivery/preparation.d.ts +6 -0
  269. package/dist-runtime/delivery/preparation.js +158 -0
  270. package/dist-runtime/delivery/preparation.js.map +1 -0
  271. package/dist-runtime/delivery/production-environment.d.ts +2 -0
  272. package/dist-runtime/delivery/production-environment.js +12 -0
  273. package/dist-runtime/delivery/production-environment.js.map +1 -0
  274. package/dist-runtime/delivery/production-finalization.d.ts +86 -0
  275. package/dist-runtime/delivery/production-finalization.js +278 -0
  276. package/dist-runtime/delivery/production-finalization.js.map +1 -0
  277. package/dist-runtime/delivery/production.d.ts +461 -0
  278. package/dist-runtime/delivery/production.js +396 -0
  279. package/dist-runtime/delivery/production.js.map +1 -0
  280. package/dist-runtime/delivery/project-files.d.ts +8 -0
  281. package/dist-runtime/delivery/project-files.js +82 -0
  282. package/dist-runtime/delivery/project-files.js.map +1 -0
  283. package/dist-runtime/delivery/project.d.ts +15 -0
  284. package/dist-runtime/delivery/project.js +157 -0
  285. package/dist-runtime/delivery/project.js.map +1 -0
  286. package/dist-runtime/delivery/protocol.d.ts +49 -0
  287. package/dist-runtime/delivery/protocol.js +112 -0
  288. package/dist-runtime/delivery/protocol.js.map +1 -0
  289. package/dist-runtime/delivery/references.d.ts +19 -0
  290. package/dist-runtime/delivery/references.js +84 -0
  291. package/dist-runtime/delivery/references.js.map +1 -0
  292. package/dist-runtime/delivery/release-graph.d.ts +93 -0
  293. package/dist-runtime/delivery/release-graph.js +106 -0
  294. package/dist-runtime/delivery/release-graph.js.map +1 -0
  295. package/dist-runtime/delivery/release-history-capture.d.ts +7 -0
  296. package/dist-runtime/delivery/release-history-capture.js +76 -0
  297. package/dist-runtime/delivery/release-history-capture.js.map +1 -0
  298. package/dist-runtime/delivery/release-history.d.ts +43 -0
  299. package/dist-runtime/delivery/release-history.js +246 -0
  300. package/dist-runtime/delivery/release-history.js.map +1 -0
  301. package/dist-runtime/delivery/release.d.ts +172 -0
  302. package/dist-runtime/delivery/release.js +209 -0
  303. package/dist-runtime/delivery/release.js.map +1 -0
  304. package/dist-runtime/delivery/safe-manifest.d.ts +9 -0
  305. package/dist-runtime/delivery/safe-manifest.js +13 -0
  306. package/dist-runtime/delivery/safe-manifest.js.map +1 -0
  307. package/dist-runtime/delivery/safe-observation.d.ts +30 -0
  308. package/dist-runtime/delivery/safe-observation.js +487 -0
  309. package/dist-runtime/delivery/safe-observation.js.map +1 -0
  310. package/dist-runtime/delivery/safe-prepare.d.ts +13 -0
  311. package/dist-runtime/delivery/safe-prepare.js +81 -0
  312. package/dist-runtime/delivery/safe-prepare.js.map +1 -0
  313. package/dist-runtime/delivery/safe.d.ts +91 -0
  314. package/dist-runtime/delivery/safe.js +243 -0
  315. package/dist-runtime/delivery/safe.js.map +1 -0
  316. package/dist-runtime/delivery/same-fork-baseline.d.ts +8 -0
  317. package/dist-runtime/delivery/same-fork-baseline.js +20 -0
  318. package/dist-runtime/delivery/same-fork-baseline.js.map +1 -0
  319. package/dist-runtime/delivery/setup.d.ts +31 -0
  320. package/dist-runtime/delivery/setup.js +215 -0
  321. package/dist-runtime/delivery/setup.js.map +1 -0
  322. package/dist-runtime/delivery/source.d.ts +41 -0
  323. package/dist-runtime/delivery/source.js +137 -0
  324. package/dist-runtime/delivery/source.js.map +1 -0
  325. package/dist-runtime/delivery/target-fields.d.ts +2 -0
  326. package/dist-runtime/delivery/target-fields.js +11 -0
  327. package/dist-runtime/delivery/target-fields.js.map +1 -0
  328. package/dist-runtime/delivery/validation.d.ts +9 -0
  329. package/dist-runtime/delivery/validation.js +150 -0
  330. package/dist-runtime/delivery/validation.js.map +1 -0
  331. package/dist-runtime/delivery/verification.d.ts +16 -0
  332. package/dist-runtime/delivery/verification.js +65 -0
  333. package/dist-runtime/delivery/verification.js.map +1 -0
  334. package/dist-runtime/migrate.js +1 -0
  335. package/dist-runtime/migrate.js.map +1 -1
  336. package/dist-runtime/miner/binary.d.ts +2 -0
  337. package/dist-runtime/miner/binary.js +54 -0
  338. package/dist-runtime/miner/binary.js.map +1 -0
  339. package/dist-runtime/miner/cli.d.ts +1 -0
  340. package/dist-runtime/miner/cli.js +131 -0
  341. package/dist-runtime/miner/cli.js.map +1 -0
  342. package/dist-runtime/miner/index.d.ts +5 -0
  343. package/dist-runtime/miner/index.js +13 -0
  344. package/dist-runtime/miner/index.js.map +1 -0
  345. package/dist-runtime/miner/request.d.ts +7 -0
  346. package/dist-runtime/miner/request.js +73 -0
  347. package/dist-runtime/miner/request.js.map +1 -0
  348. package/dist-runtime/miner/runner.d.ts +2 -0
  349. package/dist-runtime/miner/runner.js +131 -0
  350. package/dist-runtime/miner/runner.js.map +1 -0
  351. package/dist-runtime/miner/types.d.ts +89 -0
  352. package/dist-runtime/miner/types.js +3 -0
  353. package/dist-runtime/miner/types.js.map +1 -0
  354. package/dist-runtime/miner/verify.d.ts +2 -0
  355. package/dist-runtime/miner/verify.js +75 -0
  356. package/dist-runtime/miner/verify.js.map +1 -0
  357. package/dist-runtime/runtime-identity.json +2 -2
  358. package/dist-runtime/vendor/plan-codec/index.cjs +820 -0
  359. package/dist-runtime/vendor/plan-codec/index.d.cts +32 -0
  360. package/dist-runtime/vendor/plan-codec/provenance.json +24 -0
  361. package/dist-runtime/workflow/engine.d.ts +14 -0
  362. package/dist-runtime/workflow/engine.js +160 -0
  363. package/dist-runtime/workflow/engine.js.map +1 -0
  364. package/dist-runtime/workflow/lib/authority.d.ts +6 -3
  365. package/dist-runtime/workflow/lib/authority.js.map +1 -1
  366. package/dist-runtime/workflow/lib/calls.d.ts +1 -1
  367. package/dist-runtime/workflow/lib/calls.js +43 -34
  368. package/dist-runtime/workflow/lib/calls.js.map +1 -1
  369. package/dist-runtime/workflow/lib/canonicalData.d.ts +8 -0
  370. package/dist-runtime/workflow/lib/canonicalData.js +68 -0
  371. package/dist-runtime/workflow/lib/canonicalData.js.map +1 -0
  372. package/dist-runtime/workflow/lib/config.d.ts +3 -1
  373. package/dist-runtime/workflow/lib/config.js.map +1 -1
  374. package/dist-runtime/workflow/lib/context.d.ts +76 -0
  375. package/dist-runtime/workflow/lib/context.js +3 -0
  376. package/dist-runtime/workflow/lib/context.js.map +1 -0
  377. package/dist-runtime/workflow/lib/create2.d.ts +1 -1
  378. package/dist-runtime/workflow/lib/create2.js +9 -12
  379. package/dist-runtime/workflow/lib/create2.js.map +1 -1
  380. package/dist-runtime/workflow/lib/deployments.d.ts +5 -5
  381. package/dist-runtime/workflow/lib/deployments.js +5 -13
  382. package/dist-runtime/workflow/lib/deployments.js.map +1 -1
  383. package/dist-runtime/workflow/lib/evidencePorts.d.ts +55 -0
  384. package/dist-runtime/workflow/lib/evidencePorts.js +3 -0
  385. package/dist-runtime/workflow/lib/evidencePorts.js.map +1 -0
  386. package/dist-runtime/workflow/lib/executionPlan.d.ts +4 -42
  387. package/dist-runtime/workflow/lib/executionPlan.js +15 -210
  388. package/dist-runtime/workflow/lib/executionPlan.js.map +1 -1
  389. package/dist-runtime/workflow/lib/gateTool.d.ts +6 -2
  390. package/dist-runtime/workflow/lib/gateTool.js +20 -10
  391. package/dist-runtime/workflow/lib/gateTool.js.map +1 -1
  392. package/dist-runtime/workflow/lib/gateToolSync.d.ts +1 -1
  393. package/dist-runtime/workflow/lib/gateToolSync.js +3 -2
  394. package/dist-runtime/workflow/lib/gateToolSync.js.map +1 -1
  395. package/dist-runtime/workflow/lib/operationNames.d.ts +3 -0
  396. package/dist-runtime/workflow/lib/operationNames.js +34 -0
  397. package/dist-runtime/workflow/lib/operationNames.js.map +1 -0
  398. package/dist-runtime/workflow/lib/parameters.d.ts +1 -1
  399. package/dist-runtime/workflow/lib/parameters.js +6 -22
  400. package/dist-runtime/workflow/lib/parameters.js.map +1 -1
  401. package/dist-runtime/workflow/lib/pendingDeploymentReuse.js +18 -52
  402. package/dist-runtime/workflow/lib/pendingDeploymentReuse.js.map +1 -1
  403. package/dist-runtime/workflow/lib/pendingUupsBinding.d.ts +42 -0
  404. package/dist-runtime/workflow/lib/pendingUupsBinding.js +39 -0
  405. package/dist-runtime/workflow/lib/pendingUupsBinding.js.map +1 -0
  406. package/dist-runtime/workflow/lib/plan.d.ts +55 -0
  407. package/dist-runtime/workflow/lib/plan.js +324 -0
  408. package/dist-runtime/workflow/lib/plan.js.map +1 -0
  409. package/dist-runtime/workflow/lib/planCli.d.ts +14 -0
  410. package/dist-runtime/workflow/lib/planCli.js +279 -0
  411. package/dist-runtime/workflow/lib/planCli.js.map +1 -0
  412. package/dist-runtime/workflow/lib/preparationEvidence.d.ts +4 -0
  413. package/dist-runtime/workflow/lib/preparationEvidence.js +19 -0
  414. package/dist-runtime/workflow/lib/preparationEvidence.js.map +1 -0
  415. package/dist-runtime/workflow/lib/proxy.d.ts +3 -2
  416. package/dist-runtime/workflow/lib/proxy.js +3 -4
  417. package/dist-runtime/workflow/lib/proxy.js.map +1 -1
  418. package/dist-runtime/workflow/lib/runtime.d.ts +6 -0
  419. package/dist-runtime/workflow/lib/runtime.js +48 -0
  420. package/dist-runtime/workflow/lib/runtime.js.map +1 -0
  421. package/dist-runtime/workflow/lib/signer.d.ts +3 -2
  422. package/dist-runtime/workflow/lib/signer.js +18 -18
  423. package/dist-runtime/workflow/lib/signer.js.map +1 -1
  424. package/dist-runtime/workflow/lib/simulation.d.ts +13 -6
  425. package/dist-runtime/workflow/lib/simulation.js +39 -31
  426. package/dist-runtime/workflow/lib/simulation.js.map +1 -1
  427. package/dist-runtime/workflow/lib/state.js +3 -3
  428. package/dist-runtime/workflow/lib/state.js.map +1 -1
  429. package/dist-runtime/workflow/lib/staticValidation.d.ts +28 -0
  430. package/dist-runtime/workflow/lib/staticValidation.js +54 -10
  431. package/dist-runtime/workflow/lib/staticValidation.js.map +1 -1
  432. package/dist-runtime/workflow/lib/transactionPlanner.d.ts +62 -0
  433. package/dist-runtime/workflow/lib/transactionPlanner.js +258 -0
  434. package/dist-runtime/workflow/lib/transactionPlanner.js.map +1 -0
  435. package/dist-runtime/workflow/lib/typedValue.d.ts +3 -0
  436. package/dist-runtime/workflow/lib/typedValue.js +76 -0
  437. package/dist-runtime/workflow/lib/typedValue.js.map +1 -0
  438. package/dist-runtime/workflow/lib/validation.d.ts +23 -0
  439. package/dist-runtime/workflow/lib/validation.js +15 -0
  440. package/dist-runtime/workflow/lib/validation.js.map +1 -0
  441. package/dist-runtime/workflow/planAdd.d.ts +1 -0
  442. package/dist-runtime/workflow/planAdd.js +11 -0
  443. package/dist-runtime/workflow/planAdd.js.map +1 -0
  444. package/dist-runtime/workflow/planRead.d.ts +1 -0
  445. package/dist-runtime/workflow/planRead.js +11 -0
  446. package/dist-runtime/workflow/planRead.js.map +1 -0
  447. package/dist-runtime/workflow/planStatus.d.ts +1 -0
  448. package/dist-runtime/workflow/planStatus.js +11 -0
  449. package/dist-runtime/workflow/planStatus.js.map +1 -0
  450. package/dist-runtime/workflow/planWrite.d.ts +1 -0
  451. package/dist-runtime/workflow/planWrite.js +11 -0
  452. package/dist-runtime/workflow/planWrite.js.map +1 -0
  453. package/dist-runtime/workflow/run.d.ts +1 -40
  454. package/dist-runtime/workflow/run.js +68 -136
  455. package/dist-runtime/workflow/run.js.map +1 -1
  456. package/dist-runtime/workflow/staticValidate.js +8 -3
  457. package/dist-runtime/workflow/staticValidate.js.map +1 -1
  458. package/dist-runtime/workflow/steps/call.d.ts +1 -1
  459. package/dist-runtime/workflow/steps/check.d.ts +1 -1
  460. package/dist-runtime/workflow/steps/custom.d.ts +1 -1
  461. package/dist-runtime/workflow/steps/deploy.d.ts +1 -1
  462. package/dist-runtime/workflow/steps/deploy.js +57 -55
  463. package/dist-runtime/workflow/steps/deploy.js.map +1 -1
  464. package/dist-runtime/workflow/steps/upgrade.d.ts +1 -1
  465. package/dist-runtime/workflow/steps/upgrade.js +62 -41
  466. package/dist-runtime/workflow/steps/upgrade.js.map +1 -1
  467. package/dist-runtime/workflow/steps/view.d.ts +1 -1
  468. package/docs/compiler-qualification.md +32 -0
  469. package/docs/configuration-runtime-observation.md +29 -0
  470. package/docs/create2-miner.md +100 -0
  471. package/docs/delivery-aggregate.md +27 -0
  472. package/docs/delivery-custom-input-closure.md +51 -0
  473. package/docs/delivery-development.md +32 -0
  474. package/docs/delivery-eoa.md +46 -0
  475. package/docs/delivery-evm-manifest.md +20 -0
  476. package/docs/delivery-execution-store.md +33 -0
  477. package/docs/delivery-inputs.md +46 -0
  478. package/docs/delivery-parameters.md +65 -0
  479. package/docs/delivery-planning.md +140 -0
  480. package/docs/delivery-release.md +65 -0
  481. package/docs/delivery-safe.md +72 -0
  482. package/docs/delivery-setup.md +146 -0
  483. package/docs/delivery-source.md +67 -0
  484. package/docs/superpowers/plans/2026-09-24-scheme-aware-static-validation.md +193 -0
  485. package/docs/superpowers/plans/2026-10-28-create2-miner.md +82 -0
  486. package/package.json +133 -9
  487. package/resources/create2/LICENSE +21 -0
  488. package/resources/create2/README.md +9 -0
  489. package/resources/create2/darwin-arm64/smartflow_miner +0 -0
  490. package/resources/create2/darwin-x64/smartflow_miner +0 -0
  491. package/resources/create2/manifest.json +27 -0
  492. package/runtime/config/openzeppelin.ts +3 -21
  493. package/runtime/delivery/abi.ts +225 -0
  494. package/runtime/delivery/aggregate-bootstrap.ts +29 -0
  495. package/runtime/delivery/aggregate-channel.ts +85 -0
  496. package/runtime/delivery/aggregate-inputs.ts +39 -0
  497. package/runtime/delivery/aggregate-source.ts +53 -0
  498. package/runtime/delivery/aggregate-worker.ts +133 -0
  499. package/runtime/delivery/aggregate.ts +139 -0
  500. package/runtime/delivery/bindings.ts +37 -0
  501. package/runtime/delivery/check-code.ts +38 -0
  502. package/runtime/delivery/closure-format.ts +350 -0
  503. package/runtime/delivery/codec-pin.ts +3 -0
  504. package/runtime/delivery/codec.ts +50 -0
  505. package/runtime/delivery/compiler-dependency-pins.ts +1685 -0
  506. package/runtime/delivery/compiler-files.ts +179 -0
  507. package/runtime/delivery/compiler-io.ts +10 -0
  508. package/runtime/delivery/compiler-pins.ts +143 -0
  509. package/runtime/delivery/compiler.ts +700 -0
  510. package/runtime/delivery/config.ts +93 -0
  511. package/runtime/delivery/configuration-definition.ts +133 -0
  512. package/runtime/delivery/configuration-hre.ts +130 -0
  513. package/runtime/delivery/configuration-runtime.ts +163 -0
  514. package/runtime/delivery/configuration.ts +64 -0
  515. package/runtime/delivery/create2.ts +57 -0
  516. package/runtime/delivery/custom-closure.ts +993 -0
  517. package/runtime/delivery/custom-format.ts +464 -0
  518. package/runtime/delivery/custom.ts +219 -0
  519. package/runtime/delivery/data.ts +94 -0
  520. package/runtime/delivery/development.ts +262 -0
  521. package/runtime/delivery/engine.ts +29 -0
  522. package/runtime/delivery/eoa-observation.ts +106 -0
  523. package/runtime/delivery/eoa-signed.ts +55 -0
  524. package/runtime/delivery/eoa.ts +288 -0
  525. package/runtime/delivery/execution-db.ts +131 -0
  526. package/runtime/delivery/execution-files.ts +135 -0
  527. package/runtime/delivery/execution-model.ts +102 -0
  528. package/runtime/delivery/execution-store.ts +411 -0
  529. package/runtime/delivery/existing-code.ts +44 -0
  530. package/runtime/delivery/export.ts +99 -0
  531. package/runtime/delivery/forkAudit.ts +620 -0
  532. package/runtime/delivery/hardhat.ts +38 -0
  533. package/runtime/delivery/history-registration.ts +10 -0
  534. package/runtime/delivery/identities.ts +132 -0
  535. package/runtime/delivery/input-files.ts +46 -0
  536. package/runtime/delivery/inputs.ts +197 -0
  537. package/runtime/delivery/journal.ts +201 -0
  538. package/runtime/delivery/manifest.ts +54 -0
  539. package/runtime/delivery/materialization.ts +53 -0
  540. package/runtime/delivery/observations.ts +60 -0
  541. package/runtime/delivery/parameters.ts +349 -0
  542. package/runtime/delivery/pending.ts +98 -0
  543. package/runtime/delivery/plan.ts +337 -0
  544. package/runtime/delivery/planning.ts +397 -0
  545. package/runtime/delivery/policy.ts +9 -0
  546. package/runtime/delivery/preparation.ts +224 -0
  547. package/runtime/delivery/production-environment.ts +6 -0
  548. package/runtime/delivery/production-finalization.ts +172 -0
  549. package/runtime/delivery/production.ts +375 -0
  550. package/runtime/delivery/project-files.ts +58 -0
  551. package/runtime/delivery/project.ts +117 -0
  552. package/runtime/delivery/protocol.ts +94 -0
  553. package/runtime/delivery/references.ts +106 -0
  554. package/runtime/delivery/release-graph.ts +49 -0
  555. package/runtime/delivery/release-history-capture.ts +32 -0
  556. package/runtime/delivery/release-history.ts +120 -0
  557. package/runtime/delivery/release.ts +128 -0
  558. package/runtime/delivery/safe-manifest.ts +11 -0
  559. package/runtime/delivery/safe-observation.ts +626 -0
  560. package/runtime/delivery/safe-prepare.ts +101 -0
  561. package/runtime/delivery/safe.ts +344 -0
  562. package/runtime/delivery/same-fork-baseline.ts +16 -0
  563. package/runtime/delivery/setup.ts +172 -0
  564. package/runtime/delivery/source.ts +130 -0
  565. package/runtime/delivery/target-fields.ts +7 -0
  566. package/runtime/delivery/validation.ts +247 -0
  567. package/runtime/delivery/verification.ts +47 -0
  568. package/runtime/migrate.ts +1 -0
  569. package/runtime/miner/binary.ts +41 -0
  570. package/runtime/miner/cli.ts +87 -0
  571. package/runtime/miner/index.ts +5 -0
  572. package/runtime/miner/request.ts +54 -0
  573. package/runtime/miner/runner.ts +90 -0
  574. package/runtime/miner/types.ts +71 -0
  575. package/runtime/miner/verify.ts +61 -0
  576. package/runtime/vendor/plan-codec/index.cjs +820 -0
  577. package/runtime/vendor/plan-codec/index.d.cts +32 -0
  578. package/runtime/vendor/plan-codec/provenance.json +24 -0
  579. package/runtime/workflow/engine.ts +174 -0
  580. package/runtime/workflow/lib/authority.ts +3 -3
  581. package/runtime/workflow/lib/calls.ts +46 -37
  582. package/runtime/workflow/lib/canonicalData.ts +45 -0
  583. package/runtime/workflow/lib/config.ts +1 -1
  584. package/runtime/workflow/lib/context.ts +76 -0
  585. package/runtime/workflow/lib/create2.ts +10 -12
  586. package/runtime/workflow/lib/deployments.ts +6 -14
  587. package/runtime/workflow/lib/evidencePorts.ts +20 -0
  588. package/runtime/workflow/lib/executionPlan.ts +17 -268
  589. package/runtime/workflow/lib/gateTool.ts +20 -8
  590. package/runtime/workflow/lib/gateToolSync.ts +3 -3
  591. package/runtime/workflow/lib/operationNames.ts +32 -0
  592. package/runtime/workflow/lib/parameters.ts +4 -21
  593. package/runtime/workflow/lib/pendingDeploymentReuse.ts +4 -56
  594. package/runtime/workflow/lib/pendingUupsBinding.ts +43 -0
  595. package/runtime/workflow/lib/plan.ts +334 -0
  596. package/runtime/workflow/lib/planCli.ts +279 -0
  597. package/runtime/workflow/lib/preparationEvidence.ts +14 -0
  598. package/runtime/workflow/lib/proxy.ts +5 -3
  599. package/runtime/workflow/lib/runtime.ts +46 -0
  600. package/runtime/workflow/lib/signer.ts +8 -5
  601. package/runtime/workflow/lib/simulation.ts +41 -17
  602. package/runtime/workflow/lib/state.ts +3 -3
  603. package/runtime/workflow/lib/staticValidation.ts +92 -11
  604. package/runtime/workflow/lib/transactionPlanner.ts +314 -0
  605. package/runtime/workflow/lib/typedValue.ts +46 -0
  606. package/runtime/workflow/lib/validation.ts +50 -0
  607. package/runtime/workflow/planAdd.ts +8 -0
  608. package/runtime/workflow/planRead.ts +8 -0
  609. package/runtime/workflow/planStatus.ts +8 -0
  610. package/runtime/workflow/planWrite.ts +8 -0
  611. package/runtime/workflow/run.ts +41 -174
  612. package/runtime/workflow/staticValidate.ts +8 -3
  613. package/runtime/workflow/steps/call.ts +1 -1
  614. package/runtime/workflow/steps/check.ts +1 -1
  615. package/runtime/workflow/steps/custom.ts +1 -1
  616. package/runtime/workflow/steps/deploy.ts +57 -58
  617. package/runtime/workflow/steps/upgrade.ts +69 -46
  618. package/runtime/workflow/steps/view.ts +1 -1
@@ -0,0 +1,172 @@
1
+ /** Static production acceptance. No project module, HRE, compiler process or signing port is loaded. */
2
+ import path from 'node:path';
3
+ import {getCreate2Address,Interface} from 'ethers';
4
+ import {withDefaults} from '@openzeppelin/hardhat-upgrades/dist/utils/options';
5
+ import {BytecodeChecker,artifactIdentity,hashStorageLayout,mergeEvmManifestCandidate,parseTargetManifest,resolveTargetManifestPaths} from 'gate-evm-tools/workflow';
6
+ import {canonicalJson,deepFreeze,semanticHash} from '../workflow/lib/canonicalData';
7
+ import {validateContractInfo,resolveDeployment} from '../workflow/lib/deployments';
8
+ import {validateDeploymentInfo} from '../workflow/lib/deploymentInfo';
9
+ import {mergeDevelopmentRegistration} from './development';
10
+ import {parsePreparationJournal} from './journal';
11
+ import {validateDevelopmentCheckReport,type ExpectedDevelopmentCode} from './check-code';
12
+ import {atomicDevelopmentWrite,byteHash,fileBytes,readDevelopmentJournal,withDevelopmentFileLock,commitDevelopmentFilesLocked,type DevelopmentFile} from './materialization';
13
+ import type {CompilerEvidence} from './compiler';
14
+ import type {DeliveryCollection} from './planning';
15
+ import type {EoaExecutionOptions} from './eoa';
16
+ import {parseObservation} from './observations';
17
+ export interface ProductionFinalizationInputs {compiler:CompilerEvidence;registration:{registry:unknown;metadata:unknown};manifests?:Array<{path:string;contents:string|null}>}
18
+ export interface ProductionFinalizationReady {plan:DeliveryCollection['plan'];collection:DeliveryCollection;artifactHash:string;releaseHash:string;finalization?:ProductionFinalizationInputs}
19
+ export interface FinalizedAnchor {hash:string;number:string;timestamp:string}
20
+ const json=(v:unknown)=>canonicalJson(v)+'\n';
21
+ const same=(a:unknown,b:unknown,label:string)=>{if(canonicalJson(a)!==canonicalJson(b))throw Error(`${label} mismatch`);};
22
+ const slot='0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc';
23
+ const recordPath=(r:ProductionFinalizationReady)=>`scripts/tasks/${r.plan.deploymentId}/results/${r.plan.target}/${r.plan.executionId}/deployment.json`;
24
+ function identity(r:ProductionFinalizationReady){return semanticHash({protocol:'static-production-finalizer@1',executionId:r.plan.executionId,planHash:r.plan.planHash,releaseHash:r.releaseHash,artifactHash:r.artifactHash});}
25
+ /** A file retry uses the original canonical state anchor, never a new business execution. */
26
+ export function retainedProductionFinalizationAnchor(root:string,ready:ProductionFinalizationReady):FinalizedAnchor|undefined {
27
+ const journal=readDevelopmentJournal(root,ready.plan.executionId);if(!journal)return;
28
+ if(journal.identity!==identity(ready))throw Error('Production finalization identity conflict');
29
+ const record=journal.files.find((f:any)=>f.path===recordPath(ready));if(!record)throw Error('Production finalization record missing');
30
+ const value=JSON.parse(record.after);if(value.identity!==journal.identity||value.planHash!==ready.plan.planHash||value.releaseHash!==ready.releaseHash)throw Error('Production finalization record conflict');
31
+ return value.anchor;
32
+ }
33
+ export async function finalizeProductionExecution(input:{root:string;ready:ProductionFinalizationReady;provider:EoaExecutionOptions['provider'];anchor:FinalizedAnchor;finalized:unknown[];assertions:unknown[];assertCurrent():void;assertInputs():void}){
34
+ const {root,ready,provider,anchor}=input,{plan}=ready,configuration=ready.finalization;
35
+ if(!configuration)throw Error('Production finalization inputs missing; explicit recovery required');
36
+ if(!/^0x[0-9a-fA-F]{64}$/.test(anchor.hash)||!/^0x[0-9a-fA-F]+$/.test(anchor.number)||!/^0x[0-9a-fA-F]+$/.test(anchor.timestamp)||input.finalized.length!==plan.transactions.length||!input.finalized.length)throw Error('Incomplete production finalized evidence');
37
+ const rpc=async(method:string,params:readonly unknown[])=>{input.assertCurrent();const result=await provider.request(method,params);input.assertCurrent();return result;};
38
+ const block={blockHash:anchor.hash,requireCanonical:true};
39
+ const finalized=input.finalized.map((o,i)=>parseObservation(o,plan,i));
40
+ if(finalized.some(o=>o.state!=='finalized-success'||BigInt(o.blockNumber!)>BigInt(anchor.number)))throw Error('Production anchor precedes finalized execution');
41
+ if(BigInt(await rpc('eth_chainId',[]) as string).toString()!==plan.chainId)throw Error('Production finalization chain mismatch');
42
+ const finalBlock:any=await rpc('eth_getBlockByNumber',['finalized',false]);if(!finalBlock?.number||BigInt(finalBlock.number)<BigInt(anchor.number))throw Error('Production code anchor is not finalized');
43
+ const assertAnchor=async()=>{const current:any=await rpc('eth_getBlockByNumber',[anchor.number,false]);if(current?.hash!==anchor.hash)throw Error('Production finalization anchor changed');};
44
+ await assertAnchor();
45
+ const preparations=parsePreparationJournal(ready.collection.preparations,plan.transactions,plan.derivedBindings,{target:plan.target,chainId:plan.chainId,expectedStepIds:plan.deploymentBindings.map(b=>b.stepId)});
46
+ const compiler=configuration.compiler,base={registry:validateContractInfo(configuration.registration.registry),metadata:validateDeploymentInfo(configuration.registration.metadata)};
47
+ // Only pure comparison/report methods are used. No HRE object or filesystem artifact loader exists.
48
+ const checker=new BytecodeChecker(undefined as never,{},'evm');
49
+ function local(name:string){
50
+ const matches=compiler.artifacts.filter(a=>name.includes(':')?a.fqn===name:a.artifact.contractName===name);
51
+ if(matches.length!==1)throw Error(`Missing unique sealed compiler artifact: ${name}`);
52
+ const entry=matches[0],artifact=entry.artifact,build=compiler.builds.find(b=>b.digest===entry.buildInfo);
53
+ if(semanticHash(artifact)!==entry.digest||canonicalJson(JSON.parse(entry.contents))!==canonicalJson(artifact)||!build||byteHash(build.contents)!==build.digest)throw Error('Sealed compiler artifact/build mismatch');
54
+ const output=JSON.parse(build.contents).output?.contracts?.[artifact.sourceName]?.[artifact.contractName];if(!output)throw Error('Missing sealed compiler output');
55
+ return {entry,artifact,immutableReferences:output.evm?.deployedBytecode?.immutableReferences??{}};
56
+ }
57
+ async function compare(address:string,name:string,key:string){
58
+ const compiled=local(name),code=await rpc('eth_getCode',[address,block]);
59
+ if(typeof code!=='string'||!/^0x(?:[0-9a-fA-F]{2})+$/.test(code))throw Error(`Production code missing: ${key}`);
60
+ const localCode=compiled.artifact.deployedBytecode;if(typeof localCode!=='string'||!/^0x(?:[0-9a-fA-F]{2})+$/.test(localCode))throw Error('Missing sealed runtime bytecode');
61
+ const comparison=checker.compareBytecode(code,localCode,compiled.artifact.abi as any[],compiled.immutableReferences);
62
+ if(!comparison.matches)throw Error(`Production CheckCode mismatch: ${key}: ${comparison.reason}`);
63
+ return {contract:compiled.artifact.contractName,contractName:key,network:plan.target,scheme:'evm',address:address.toLowerCase(),matches:true,error:null,reason:comparison.reason,onChainBytecodeLength:code.length,localBytecodeLength:localCode.length,onChainBytecodeHash:byteHash(code),localBytecodeHash:byteHash(localCode),onChainBytecodeHashNormalized:byteHash(checker.normalizeBytecode(code)),localBytecodeHashNormalized:byteHash(checker.normalizeBytecode(localCode))};
64
+ }
65
+ const changes=new Map<string,any>();
66
+ for(const entry of preparations){
67
+ const p=entry.prepared.plan,r=entry.prepared.request;const compiled=local(p.contract);same(artifactIdentity(compiled.artifact,'evm'),p.artifact,'Prepared sealed artifact');
68
+ for(const deployment of p.deployments){
69
+ if(deployment.initCodeHash&&getCreate2Address(r.factory,deployment.salt,deployment.initCodeHash).toLowerCase()!==deployment.address.toLowerCase())throw Error('Production CREATE2 address mismatch');
70
+ await compare(deployment.address,deployment.role==='proxy'?'@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol:ERC1967Proxy':p.contract,`${entry.change.instanceId}:${deployment.role}`);
71
+ }
72
+ const address=p.deployments.find(d=>d.role==='proxy')?.address??('proxy' in r?r.proxy:p.deployments.find(d=>d.role==='contract')?.address);
73
+ if(!address)throw Error('Production prepared address missing');
74
+ changes.set(entry.change.instanceId,{...entry.change,address,...(p.proxyKind==='uups'?{proxyAddress:address,proxyKind:'uups'}:{})});
75
+ }
76
+ const candidates:any[]=[],expected:ExpectedDevelopmentCode[]=[],effective:Record<string,Record<string,string>>={[plan.target]:{}},checked=new Map<string,{address:string;contract:string;key:string}>();
77
+ function expect(address:string,contract:string,key:string){const row={key,contract,address:address.toLowerCase()},old=checked.get(key);if(old)same(old,row,'Production CheckCode key');else{checked.set(key,row);expected.push(row);}}
78
+ const deployed=[...changes.values()],unchangedAliases=new Set<string>();
79
+ const registrationContext={base,target:plan.target,deploymentId:plan.deploymentId,executionId:plan.executionId,recordPath:recordPath(ready),updatedAt:new Date(Number(BigInt(anchor.timestamp))*1000).toISOString(),changes:deployed,preparations};
80
+ // Apply the same validated upgrade replacement before resolving code coverage.
81
+ const candidate=mergeDevelopmentRegistration({...base,...registrationContext}),registry=candidate.registry[plan.target],metadata=candidate.metadata.networks[plan.target];
82
+ const requiredAddresses=new Set([...deployed.map(c=>c.address.toLowerCase()),...ready.collection.verification.map(a=>a.address.toLowerCase()),...plan.transactionBindings.filter(b=>b.role==='call').map(b=>plan.transactions.find(t=>t.transactionId===b.transactionId)!.to.toLowerCase())]);
83
+ for(const address of requiredAddresses){
84
+ const rows=Object.entries(registry).filter(([,a])=>a.toLowerCase()===address);if(rows.length!==1)throw Error('Production code target requires unique frozen registration');
85
+ const [key]=rows[0],alias=key.split(':')[0],m=metadata[alias],contract=m?.actualContract??key.split(':').at(-1)!;
86
+ effective[plan.target][key]=address;if(!changes.has(alias))unchangedAliases.add(alias);
87
+ if(m?.proxyKind&&m.proxyKind!=='uups')throw Error('Unsupported production proxy kind');
88
+ if(m?.proxyKind==='uups'){
89
+ const storage=await rpc('eth_getStorageAt',[address,slot,block]);if(typeof storage!=='string'||!/^0x0{24}[a-fA-F0-9]{40}$/.test(storage))throw Error('Invalid finalized UUPS implementation slot');
90
+ const implementation='0x'+storage.slice(-40).toLowerCase();if(implementation!==m.implementationAddress?.toLowerCase())throw Error('Final production UUPS implementation mismatch');
91
+ expect(implementation,contract,alias);expect(address,'ERC1967Proxy',`${alias}_Proxy`);
92
+ const artifact=local(contract).entry;
93
+ const paths=resolveTargetManifestPaths(root,plan.target,Number(plan.chainId),{}),manifestPath=path.relative(root,paths.file).split(path.sep).join('/');
94
+ if(paths.file!==paths.fallbackFile&&fileBytes(root,path.relative(root,paths.fallbackFile))!==null)throw Error('Noncanonical manifest fallback requires explicit migration');
95
+ let versionKey:string,layout:any;
96
+ if(changes.has(alias)){
97
+ const preparation=preparations.find(p=>p.stepId===changes.get(alias).stepId&&p.change.instanceId===alias),request=preparation?.prepared.request;
98
+ if(!request||request.kind==='create2-deploy')throw Error('Missing UUPS preparation selection request');
99
+ // Match the compiler's preparationSelection identity. Canonical request data
100
+ // contains no undefined values; omit official optional top-level safety flags.
101
+ const options=Object.fromEntries(Object.entries(withDefaults({kind:'uups',constructorArgs:request.constructorArgs,...(request.unsafeAllow?{unsafeAllow:request.unsafeAllow}: {})} as Parameters<typeof withDefaults>[0])).filter(([,value])=>value!==undefined));
102
+ const encodedArgs=new Interface(artifact.artifact.abi).encodeDeploy(request.constructorArgs),optionsHash=semanticHash(options);
103
+ const selections=compiler.selections.filter(s=>s.fqn===artifact.fqn&&s.artifactDigest===artifact.digest&&s.encodedArgs===encodedArgs&&semanticHash(s.options)===optionsHash);
104
+ if(selections.length!==1)throw Error('Missing unique frozen OZ implementation selection');
105
+ const selected=selections[0];versionKey=selected.version.linkedWithoutMetadata;layout=selected.layout;if(!selected.validation)throw Error('Invalid frozen OZ validation');
106
+ }else{
107
+ // Unchanged UUPS instances retain their own sealed official registration,
108
+ // regardless of selections made for other instances of the same artifact.
109
+ const frozen=configuration.manifests?.filter(f=>f.path===manifestPath);if(frozen?.length!==1||frozen[0].contents===null)throw Error('Missing frozen existing UUPS manifest');
110
+ const manifest=parseTargetManifest(Buffer.from(frozen[0].contents)),proxies=manifest.proxies.filter(p=>p.address.toLowerCase()===address),implementations=Object.entries(manifest.impls).filter(([,v])=>v&&[v.address,...(v.allAddresses??[])].some(a=>a.toLowerCase()===implementation));
111
+ if(proxies.length!==1||proxies[0].kind!=='uups'||implementations.length!==1)throw Error('Invalid frozen existing UUPS manifest registration');
112
+ versionKey=implementations[0][0];layout=implementations[0][1]!.layout;
113
+ }
114
+ if(typeof versionKey!=='string'||!/^[a-f0-9]{64}$/.test(versionKey))throw Error('Invalid frozen OZ version');
115
+ candidates.push({path:manifestPath,proxy:address,implementation,versionKey,layout,layoutHash:hashStorageLayout(layout)});
116
+ }else expect(address,contract,alias);
117
+ }
118
+ if(!expected.length)throw Error('Empty production CheckCode coverage');
119
+ // Validate all business code before promoting any address, then check again after commit for the raw report.
120
+ for(const row of expected)await compare(row.address,row.contract,row.key);
121
+ await assertAnchor();
122
+ function verifyCommitted(journal:any){
123
+ const reg=validateContractInfo(JSON.parse(fileBytes(root,'contractInfo.json')??'{}')),meta=validateDeploymentInfo(JSON.parse(fileBytes(root,'deploymentInfo.json')??'{}'));
124
+ const oldReg=validateContractInfo(JSON.parse(journal.files.find((f:any)=>f.path==='contractInfo.json').after)),oldMeta=validateDeploymentInfo(JSON.parse(journal.files.find((f:any)=>f.path==='deploymentInfo.json').after));
125
+ for(const key of Object.keys(effective[plan.target])){const alias=key.split(':')[0];same(resolveDeployment(reg,plan.target,alias),resolveDeployment(oldReg,plan.target,alias),'Committed production registration');same(meta.networks[plan.target]?.[alias]??null,oldMeta.networks[plan.target]?.[alias]??null,'Committed production metadata');}
126
+ for(const f of journal.files){
127
+ if(['contractInfo.json','deploymentInfo.json'].includes(f.path))continue;
128
+ const owned=candidates.filter(c=>c.path===f.path);
129
+ if(!owned.length){if(fileBytes(root,f.path)!==f.after)throw Error('Committed production file changed');continue;}
130
+ const currentBytes=fileBytes(root,f.path);if(currentBytes===null)throw Error('Committed production manifest missing');
131
+ const current=parseTargetManifest(Buffer.from(currentBytes)),original=parseTargetManifest(Buffer.from(f.after));
132
+ for(const c of owned){
133
+ const proxies=current.proxies.filter(p=>p.address.toLowerCase()===c.proxy),oldProxies=original.proxies.filter(p=>p.address.toLowerCase()===c.proxy);
134
+ if(proxies.length!==1||oldProxies.length!==1)throw Error('Committed production manifest proxy missing or ambiguous');
135
+ same(proxies[0],oldProxies[0],'Committed production manifest proxy');
136
+ const actual=current.impls[c.versionKey],expected=original.impls[c.versionKey];
137
+ if(!actual||!expected)throw Error('Committed production manifest implementation missing');
138
+ const {allAddresses:actualAddresses,...actualEntry}=actual,{allAddresses:expectedAddresses,...expectedEntry}=expected;
139
+ same(actualEntry,expectedEntry,'Committed production manifest implementation');
140
+ const addresses=new Set([actual.address,...(actualAddresses??[])].map(a=>a.toLowerCase()));
141
+ if([expected.address,...(expectedAddresses??[]),c.implementation].some(a=>!addresses.has(a.toLowerCase())))throw Error('Committed production manifest address removed');
142
+ }
143
+ }
144
+ }
145
+ const executionIdentity=identity(ready),record=recordPath(ready),evidence={version:1,identity:executionIdentity,executionId:plan.executionId,planHash:plan.planHash,releaseHash:ready.releaseHash,artifactHash:ready.artifactHash,inputsHash:plan.inputsHash,sourceDefinitionHash:plan.sourceDefinitionHash,planRuntimeIdentity:plan.runtimeIdentity,finalizer:'static-production-finalizer@1',anchor,preparations,finalized,assertions:input.assertions,changes:deployed};
146
+ const journal=await withDevelopmentFileLock(root,async()=>{
147
+ input.assertInputs();const prior=readDevelopmentJournal(root,plan.executionId);
148
+ const currentRegistry=validateContractInfo(JSON.parse(fileBytes(root,'contractInfo.json')??'{}')),currentMetadata=validateDeploymentInfo(JSON.parse(fileBytes(root,'deploymentInfo.json')??'{"version":1,"networks":{}}'));
149
+ for(const alias of unchangedAliases){
150
+ same(resolveDeployment(currentRegistry,plan.target,alias)??null,resolveDeployment(base.registry,plan.target,alias)??null,'Unchanged production registration');
151
+ same(currentMetadata.networks[plan.target]?.[alias]??null,base.metadata.networks[plan.target]?.[alias]??null,'Unchanged production metadata');
152
+ }
153
+ const before=(name:string)=>prior?prior.files.find((f:any)=>f.path===name)?.before:fileBytes(root,name);
154
+ const registryBefore=before('contractInfo.json'),metadataBefore=before('deploymentInfo.json');
155
+ if(registryBefore===undefined||metadataBefore===undefined)throw Error('Production journal registry missing');
156
+ const merged=mergeDevelopmentRegistration({registry:JSON.parse(registryBefore??'{}'),metadata:JSON.parse(metadataBefore??'{"version":1,"networks":{}}'),...registrationContext});
157
+ // Keep exact original containers for pure-call plans; no unrelated metadata is invented.
158
+ const files:DevelopmentFile[]=[{path:record,before:before(record),after:json(evidence)},{path:'contractInfo.json',before:registryBefore,after:deployed.length?json(merged.registry):registryBefore??json(merged.registry)},{path:'deploymentInfo.json',before:metadataBefore,after:deployed.length?json(merged.metadata):metadataBefore??json(merged.metadata)}];
159
+ for(const c of candidates){const old=files.find(f=>f.path===c.path),bytes=old?.after??before(c.path),document=bytes===null?{manifestVersion:'3.2',impls:{},proxies:[]}:parseTargetManifest(Buffer.from(bytes));const after=json(mergeEvmManifestCandidate(document,c));if(old)old.after=after;else files.push({path:c.path,before:bytes,after});}
160
+ if(prior){if(prior.identity!==executionIdentity)throw Error('Production journal identity conflict');same(prior.files.map(({path,before,after}:DevelopmentFile)=>({path,before,after})),files,'Production finalization journal');if(prior.state==='committed'){verifyCommitted(prior);return prior;}}
161
+ else if(files[0].before!==null)throw Error('Production deployment record already exists without journal');
162
+ return commitDevelopmentFilesLocked({root,executionId:plan.executionId,identity:executionIdentity,files});
163
+ });
164
+ const rows=[];for(const row of expected)rows.push(await compare(row.address,row.contract,row.key));
165
+ const report=checker.generateNetworkContractResults(rows as any);validateDevelopmentCheckReport(report,plan.target,expected);await assertAnchor();input.assertInputs();
166
+ verifyCommitted(journal);
167
+ const reportPath=`.gate-delivery/check-code/${plan.executionId}/production.raw.json`,reportBytes=json(report),acceptancePath=`.gate-delivery/production/${plan.executionId}.acceptance.json`;
168
+ const acceptance={...evidence,status:'accepted',materialization:{intentHash:journal.intentHash,recordPath:record,recordHash:byteHash(json(evidence)),manifests:candidates.map(c=>({file:c.path,hash:byteHash(journal.files.find((f:any)=>f.path===c.path).after),layoutHash:c.layoutHash,proxy:c.proxy,implementation:c.implementation}))},checkCode:{version:1,executionId:plan.executionId,planHash:plan.planHash,target:plan.target,anchor,rawFile:reportPath,rawHash:byteHash(reportBytes),registryHash:byteHash(journal.files.find((f:any)=>f.path==='contractInfo.json').after),metadataHash:byteHash(journal.files.find((f:any)=>f.path==='deploymentInfo.json').after),effectiveHash:byteHash(json(effective)),expected,artifacts:compiler.artifacts.map(a=>artifactIdentity(a.artifact,'evm'))},receiptPath:acceptancePath};
169
+ const saved=fileBytes(root,acceptancePath);if(saved!==null){same(JSON.parse(saved),acceptance,'Production acceptance');if(fileBytes(root,reportPath)!==reportBytes)throw Error('Production CheckCode report changed');}
170
+ else{atomicDevelopmentWrite(root,reportPath,reportBytes);atomicDevelopmentWrite(root,acceptancePath,json(acceptance));}
171
+ return deepFreeze(acceptance);
172
+ }
@@ -0,0 +1,375 @@
1
+ /** Public release-only production boundary. Host capabilities never enter JSON options. */
2
+ import fs from 'node:fs';
3
+ import os from 'node:os';
4
+ import path from 'node:path';
5
+ import { randomUUID } from 'node:crypto';
6
+ import { resolveTargetManifestPaths } from 'gate-evm-tools/workflow';
7
+ import { inspectDeliveryRelease } from './release';
8
+ import { readOwnedDeliverySource } from './source';
9
+ import { projectRoot } from './project-files';
10
+ import { safeId, parseDeliveryRequest, type DeliveryRequest } from './protocol';
11
+ import { strictData } from './data';
12
+ import { parseDeliveryPlan } from './plan';
13
+ import { OwnedWorker } from './aggregate-channel';
14
+ import { atomicDevelopmentWrite, fileBytes, byteHash, withDevelopmentFileLock } from './materialization';
15
+ import { canonicalJson, deepFreeze, exactObject, semanticHash } from '../workflow/lib/canonicalData';
16
+ import { createDeliveryEoaExecution, type EoaExecutionOptions, type EoaHashReferences } from './eoa';
17
+ import type { ReleaseGraphOptions } from './release-graph';
18
+ import type { DeliveryCollection } from './planning';
19
+ import { finalizeProductionExecution, retainedProductionFinalizationAnchor, type FinalizedAnchor } from './production-finalization';
20
+ export { productionChildEnvironment } from './production-environment';
21
+ export interface ProductionOptions extends ReleaseGraphOptions {
22
+ planKey: string;
23
+ rev: number;
24
+ target: string;
25
+ operator: string;
26
+ executionId: string;
27
+ }
28
+ export type ProductionCommand = 'prepare' | 'execute' | 'export-calldata' | 'reconcile' | 'verify';
29
+ const keys = ['workspaceRoot', 'projectRoot', 'handoff', 'taskId', 'deploymentId', 'releaseRef', 'planKey', 'rev', 'target', 'operator', 'executionId'];
30
+ const encode = (v: unknown) => canonicalJson(v) + '\n';
31
+ const artifactPath = (id: string) => `.gate-delivery/production/${safeId(id, 'executionId')}.json`;
32
+ function inspect(raw: ProductionOptions, command: ProductionCommand) {
33
+ const input = deepFreeze(strictData(raw));
34
+ exactObject(input, keys, 'production options');
35
+ safeId(input.executionId, 'executionId');
36
+ const mode = command === 'prepare' ? 'simulate' : command;
37
+ const request = parseDeliveryRequest({ version: 1, environment: 'prod', purpose: 'prod-execution', mode, network: input.target, operator: input.operator, releaseRef: input.releaseRef, sourceRef: { path: input.handoff, taskId: input.taskId, planKey: input.planKey, rev: input.rev } });
38
+ const release = inspectDeliveryRelease(input);
39
+ if (release.status === 'pending')
40
+ return { status: 'pending' as const, input };
41
+ const source = readOwnedDeliverySource({ workspaceRoot: input.workspaceRoot, projectRoot: input.projectRoot, request });
42
+ if ((source.invocation.task.scope!.deployment as any).deploymentId !== input.deploymentId)
43
+ throw Error('Production deployment mismatch');
44
+ const target = release.release.targets.find((t: any) => t.id === input.target);
45
+ if (!target)
46
+ throw Error('Unknown production target');
47
+ return { status: 'ready' as const, input, request, source, release: release.release, releaseHash: release.bundleHash, target, root: projectRoot(input.workspaceRoot, input.projectRoot) };
48
+ }
49
+ /** Read the marker before consuming generated output; no missing-file error while pending. */
50
+ export function inspectDeliveryProduction(raw: ProductionOptions, command: ProductionCommand = 'prepare') {
51
+ const current = inspect(raw, command);
52
+ if (current.status === 'pending')
53
+ return current;
54
+ const bytes = fileBytes(current.root, artifactPath(current.input.executionId));
55
+ if (bytes === null)
56
+ return { status: 'pending' as const };
57
+ const record = JSON.parse(bytes), { artifactHash, ...body } = record;
58
+ if (record.schema !== 'gate-delivery-production' || record.version !== 1 || record.status !== 'READY' || record.generation !== 'complete' || semanticHash(body) !== artifactHash)
59
+ throw Error('Invalid production READY artifact');
60
+ const plan = parseDeliveryPlan(record.collection.plan);
61
+ if (record.releaseHash !== current.releaseHash || plan.inputsHash !== current.release.inputsHash || plan.sourceDefinitionHash !== current.release.sourceDefinitionHash || plan.executionId !== current.input.executionId || plan.target !== current.input.target || plan.operator !== current.input.operator.toLowerCase() || plan.environment !== 'prod' || plan.chainId !== String(current.target.chainId))
62
+ throw Error('Production artifact context mismatch');
63
+ return deepFreeze({ status: 'ready' as const, plan, collection: record.collection as DeliveryCollection, finalization: record.finalization, releaseHash: current.releaseHash, artifactHash, sha256: byteHash(bytes), path: artifactPath(current.input.executionId), ...(current.target.safe ? { safeTarget: current.target.safe } : {}) });
64
+ }
65
+ /** Instantiate the delivered business operations, never accept replacement operations or parameters. */
66
+ export async function prepareDeliveryProduction(raw: ProductionOptions) {
67
+ const current = inspect(raw, 'prepare');
68
+ if (current.status === 'pending')
69
+ return { status: 'pending' as const };
70
+ const existing = inspectDeliveryProduction(current.input);
71
+ if (existing.status === 'ready')
72
+ return existing;
73
+ if (path.resolve(process.cwd()) !== current.root)
74
+ throw Error('Production prepare must run from actual project root');
75
+ const { input, request, release, root } = current, session = randomUUID(), dir = fs.mkdtempSync(path.join(os.tmpdir(), 'gate-production-'));
76
+ const workers: OwnedWorker[] = [];
77
+ let failure: Error | undefined;
78
+ const check = () => { if (failure)
79
+ throw failure; const now = inspect(input, 'prepare'); if (now.status !== 'ready' || now.releaseHash !== current.releaseHash)
80
+ throw Error('Production release changed during generation'); };
81
+ try {
82
+ const source = new OwnedWorker(root, session, input.target, 'source', e => { failure ??= e; });
83
+ workers.push(source);
84
+ const common = { root, workspaceRoot: input.workspaceRoot, projectRoot: input.projectRoot, request }, handshakePath = path.join(dir, 'source.json');
85
+ const ready = await source.request('stage', { ...common, role: 'source', handshakePath });
86
+ check();
87
+ if (ready.ready !== true || !fs.existsSync(handshakePath) || canonicalJson(JSON.parse(fs.readFileSync(handshakePath, 'utf8'))) !== canonicalJson(ready.handshake))
88
+ throw Error('Source generation not READY');
89
+ const worker = new OwnedWorker(root, session, input.target, 'target', e => { failure ??= e; });
90
+ workers.push(worker);
91
+ const parameter = release.parameters.find((p: any) => p.target === input.target);
92
+ if (!parameter)
93
+ throw Error('Release parameters missing');
94
+ const staged = await worker.request('stage', { ...common, role: 'target', handshake: ready.handshake, target: current.target, params: parameter.resolved.values, steps: release.operations, deploymentId: input.deploymentId, businessRoot: `scripts/tasks/${input.deploymentId}`, executionId: input.executionId, sourceDefinitionHash: release.sourceDefinitionHash });
95
+ check();
96
+ if (staged.ready !== true)
97
+ throw Error('Production generation not READY');
98
+ const checked = await worker.request('check');
99
+ check();
100
+ const sourceChecked = await source.request('check');
101
+ check();
102
+ const candidate = JSON.parse(fs.readFileSync(path.join(root, release.candidate.path), 'utf8'));
103
+ const expected = candidate.aggregate.inputs.targets.find((t: any) => t.target === input.target);
104
+ for (const [actual, wanted] of [[checked.compiler.stableDigest, expected.compiler.stableDigest], [checked.custom, expected.custom], [checked.configuration.configurationRuntimeHash, expected.configuration.configurationRuntimeHash], [sourceChecked.configuration.configurationRuntimeHash, expected.sourceConfiguration.configurationRuntimeHash]])
105
+ if (canonicalJson(actual) !== canonicalJson(wanted))
106
+ throw Error('Final simulation changed released input closure');
107
+ const collection = await worker.request('bind', { inputsHash: release.inputsHash }) as DeliveryCollection;
108
+ check();
109
+ expectedDevelopmentAssertions(collection, release.operations);
110
+ if (collection.plan.executionId !== input.executionId || collection.plan.operator !== input.operator.toLowerCase())
111
+ throw Error('Final simulation context mismatch');
112
+ await worker.request('close');
113
+ await source.request('close');
114
+ check();
115
+ await withDevelopmentFileLock(root, async () => {
116
+ check();
117
+ const paths = resolveTargetManifestPaths(root, input.target, Number(collection.plan.chainId), {}), manifestPath = path.relative(root, paths.file).split(path.sep).join('/');
118
+ if (paths.file !== paths.fallbackFile && fileBytes(root, path.relative(root, paths.fallbackFile)) !== null)
119
+ throw Error('Noncanonical manifest fallback requires explicit migration');
120
+ const finalization = { compiler: checked.compiler, registration: { registry: JSON.parse(fileBytes(root, 'contractInfo.json') ?? '{}'), metadata: JSON.parse(fileBytes(root, 'deploymentInfo.json') ?? '{"version":1,"networks":{}}') }, manifests: [{ path: manifestPath, contents: fileBytes(root, manifestPath) }] };
121
+ const body = { schema: 'gate-delivery-production', version: 1, status: 'READY', generation: 'complete', releaseHash: current.releaseHash, collection, finalization }, record = { ...body, artifactHash: semanticHash(body) };
122
+ const prior = fileBytes(root, artifactPath(input.executionId));
123
+ if (prior !== null && prior !== encode(record))
124
+ throw Error('Execution ID already has immutable final simulation');
125
+ atomicDevelopmentWrite(root, artifactPath(input.executionId), encode(record));
126
+ });
127
+ return inspectDeliveryProduction(input);
128
+ }
129
+ finally {
130
+ await Promise.all(workers.map(w => w.reap()));
131
+ fs.rmSync(dir, { recursive: true, force: true });
132
+ }
133
+ }
134
+ export interface ProductionHostPorts extends Omit<EoaExecutionOptions, 'plan' | 'context'> {
135
+ finality: EoaExecutionOptions['context']['finality'];
136
+ assertCurrent(): void;
137
+ }
138
+ /** Capture trusted callback identities once. Caller-mutable options cannot replace ports after awaits. */
139
+ function productionPorts(host: ProductionHostPorts) {
140
+ const { store, signer, approval } = host;
141
+ return { store, finality: deepFreeze(strictData(host.finality)), guard: host.assertCurrent.bind(host), request: host.provider.request.bind(host.provider),
142
+ signer: signer ? { address: signer.address, sign: signer.sign.bind(signer), recover: signer.recover?.bind(signer) } : undefined,
143
+ approval: approval ? { withApproval: approval.withApproval.bind(approval) } : undefined };
144
+ }
145
+ /** Explicit commands share validation; only in-process trusted ports can sign or send. */
146
+ export async function runDeliveryProduction(command: Exclude<ProductionCommand, 'prepare'>, raw: ProductionOptions, host?: ProductionHostPorts, detail?: {
147
+ unsigned?: unknown;
148
+ hashes?: EoaHashReferences;
149
+ }) {
150
+ if (!['execute', 'export-calldata', 'reconcile', 'verify'].includes(command))
151
+ throw Error('Explicit production command required');
152
+ const ports = host ? productionPorts(host) : undefined;
153
+ ports?.guard();
154
+ const input = deepFreeze(strictData(raw)), captured = detail ? deepFreeze(strictData(detail)) : undefined, ready = inspectDeliveryProduction(input, command);
155
+ ports?.guard();
156
+ if (ready.status === 'pending')
157
+ return { status: 'pending' as const };
158
+ if (!ports) {
159
+ if (command === 'execute')
160
+ throw Error('PRODUCTION_SIGNER_UNAVAILABLE: trusted host required');
161
+ if (command !== 'export-calldata')
162
+ throw Error('Trusted host observation provider required');
163
+ return renderProductionExport(ready);
164
+ }
165
+ const { guard, request, store, finality, signer, approval } = ports;
166
+ const check = () => { guard(); const current = inspectDeliveryProduction(input, command); if (current.status !== 'ready' || current.artifactHash !== ready.artifactHash)
167
+ throw Error('Production artifact changed'); guard(); };
168
+ const plan = ready.plan, context = { executionId: plan.executionId, planHash: plan.planHash, releaseHash: ready.releaseHash, operator: plan.operator, chainId: plan.chainId, target: plan.target, finality, policyHash: semanticHash(finality) };
169
+ // Read-only observations consume the immutable plan. Full release hashing belongs at effect
170
+ // boundaries, while the live host capability/expiry check still surrounds every RPC await.
171
+ const provider = { async request(method: string, params: readonly unknown[]) { const current = method === 'eth_sendRawTransaction' ? check : guard; current(); const result = await request(method, params); current(); return result; } };
172
+ const controlledSigner = signer ? { address: signer.address, async sign(id: string, unsigned: Parameters<typeof signer.sign>[1]) { check(); const raw = await signer.sign(id, unsigned); check(); return raw; }, ...(signer.recover ? { async recover(id: string) { check(); const raw = await signer.recover!(id); check(); return raw; } } : {}) } : undefined;
173
+ const controlledApproval: ProductionHostPorts['approval'] = approval ? { async withApproval<T>(snapshot: Parameters<typeof approval.withApproval>[0], work: () => Promise<T>) { check(); const result = await approval.withApproval(snapshot, async () => { check(); return work(); }); guard(); return result; } } : undefined;
174
+ const kernel = createDeliveryEoaExecution({ store, plan, context, provider, signer: controlledSigner, approval: controlledApproval });
175
+ const result = command === 'execute' ? await kernel.execute(captured?.unsigned) : command === 'export-calldata' ? await kernel.export() : await kernel.reconcile(captured?.hashes ?? {});
176
+ check();
177
+ if (command === 'export-calldata')
178
+ return renderProductionExport(ready, result as Awaited<ReturnType<typeof kernel.export>>);
179
+ if (command === 'verify' && (result as any).status === 'complete') {
180
+ try {
181
+ const root = projectRoot(input.workspaceRoot, input.projectRoot), priorAnchor = retainedProductionFinalizationAnchor(root, ready);
182
+ const { assertions, anchor } = await verifyProductionAssertions(ready, provider, priorAnchor);
183
+ check();
184
+ const acceptance = await finalizeProductionExecution({ root, ready, provider, anchor, assertions, finalized: (result as any).snapshot.transactions.map((t: any) => t.observation), assertCurrent: guard, assertInputs: check });
185
+ check();
186
+ return deepFreeze({ ...(result as object), status: 'accepted', assertions, acceptance });
187
+ }
188
+ catch (error) {
189
+ guard();
190
+ return deepFreeze({ ...(result as object), status: 'finalization-required', error: error instanceof Error ? error.message : String(error) });
191
+ }
192
+ }
193
+ return result;
194
+ }
195
+ import { renderDeliveryExport } from './export';
196
+ export function renderProductionExport(ready: Extract<ReturnType<typeof inspectDeliveryProduction>, {
197
+ status: 'ready';
198
+ }>, exported = renderDeliveryExport(ready.plan)) {
199
+ const start = exported.model.completed.length, active = ready.plan.transactions[start], frozen = (exported.model as any).safeEnvelopes ?? [];
200
+ const needsPreparation = !!ready.safeTarget && active?.route === 'external' && !frozen.some((x: any) => x.envelope.start === start);
201
+ const model = deepFreeze({ ...exported.model, ...(ready.safeTarget ? { safePreparation: needsPreparation ? 'preparation-required' : active?.route === 'external' ? 'ready' : 'not-applicable', futureSafeEnvelopes: 'pending until their segment becomes executable' } : {}), releaseHash: ready.releaseHash, artifactHash: ready.artifactHash });
202
+ const json = canonicalJson(model);
203
+ const artifact = deepFreeze({ status: 'artifact-delivered' as const, model, json, markdown: `# Production calldata\n\nRelease: ${ready.releaseHash}\nExecution: ${ready.plan.executionId}\n\n\`\`\`json\n${json}\n\`\`\`\n` });
204
+ return needsPreparation ? deepFreeze({ status: 'preparation-required' as const, export: artifact }) : artifact;
205
+ }
206
+ import { parseConfigurationDefinition } from './configuration-definition';
207
+ import { productionChildEnvironment } from './production-environment';
208
+ import { rpcQuantity } from './eoa-observation';
209
+ import { parseUnsigned } from './execution-model';
210
+ import { SAFE_TRACE_MAX_BYTES } from './safe-observation';
211
+ /** Static config parser only. No HRE, project imports, accounts or signing environment are evaluated. */
212
+ export function productionRpc(raw: ProductionOptions, command: ProductionCommand) {
213
+ const current = inspect(raw, command);
214
+ if (current.status !== 'ready')
215
+ throw Error('Production release pending');
216
+ const config = parseConfigurationDefinition(fs.readFileSync(path.join(current.root, 'hardhat.config.ts')), raw.target, productionChildEnvironment(process.env)).userConfig.networks[raw.target];
217
+ const url = new URL(config.url);
218
+ if (!['http:', 'https:'].includes(url.protocol))
219
+ throw Error('Unsupported production RPC');
220
+ return Object.freeze({ async request(method: string, params: readonly unknown[]): Promise<unknown> {
221
+ const controller = new AbortController(), timer = setTimeout(() => controller.abort(), 30000);
222
+ try {
223
+ const response = await fetch(url, { method: 'POST', headers: { 'content-type': 'application/json', ...config.httpHeaders }, body: JSON.stringify({ jsonrpc: '2.0', id: 1, method, params }), signal: controller.signal });
224
+ if (!response.ok || !response.body)
225
+ throw Error('Production RPC transport failed');
226
+ const maxBytes = method === 'debug_traceTransaction' ? SAFE_TRACE_MAX_BYTES : 2 * 1024 * 1024;
227
+ const reader = response.body.getReader(), chunks: Uint8Array[] = [];
228
+ let size = 0;
229
+ try {
230
+ for (;;) {
231
+ const { done, value } = await reader.read();
232
+ if (done) break;
233
+ size += value.byteLength;
234
+ if (size > maxBytes)
235
+ throw Error('Production RPC response exceeds bounded budget');
236
+ chunks.push(value);
237
+ }
238
+ } catch (error) {
239
+ controller.abort();
240
+ await reader.cancel().catch(() => {});
241
+ throw error;
242
+ } finally {
243
+ reader.releaseLock();
244
+ }
245
+ // Parse only after the entire bounded stream completed successfully.
246
+ const result = JSON.parse(new TextDecoder('utf-8', { fatal: true }).decode(Buffer.concat(chunks, size)));
247
+ if (!result || result.error || !Object.hasOwn(result, 'result'))
248
+ throw Error('Production RPC rejected request');
249
+ return result.result;
250
+ } catch (error) {
251
+ controller.abort();
252
+ throw error;
253
+ } finally {
254
+ clearTimeout(timer);
255
+ }
256
+ } });
257
+ }
258
+ /** Separate final preparation: policy comes only from the validated release target. No signing/send. */
259
+ export async function prepareDeliveryProductionSafe(raw: ProductionOptions, host: ProductionHostPorts) {
260
+ return prepareProductionSafe(raw, host, 'prepare');
261
+ }
262
+ /** The owning entry fixes its stage; callers cannot select a weaker task permission. */
263
+ async function prepareProductionSafe(raw: ProductionOptions, host: ProductionHostPorts, command: 'prepare' | 'execute') {
264
+ const ports = productionPorts(host);
265
+ ports.guard();
266
+ const input = deepFreeze(strictData(raw)), ready = inspectDeliveryProduction(input, command), current = inspect(input, command);
267
+ ports.guard();
268
+ if (ready.status !== 'ready' || current.status !== 'ready')
269
+ return { status: 'pending' as const };
270
+ const check = () => { ports.guard(); const now = inspectDeliveryProduction(input, command); if (now.status !== 'ready' || now.artifactHash !== ready.artifactHash)
271
+ throw Error('Production Safe preparation changed'); ports.guard(); };
272
+ const prior = await ports.store.readExecution(input.executionId);
273
+ ports.guard();
274
+ if (prior && prior.planHash !== ready.plan.planHash)
275
+ throw Error('Original execution plan mismatch');
276
+ const first = ready.plan.transactions[prior?.completedCount ?? 0];
277
+ if (!first || first.route !== 'external')
278
+ return { status: 'not-applicable' as const };
279
+ if (!current.target.safe) {
280
+ const code = await ports.request('eth_getCode', [first.executor, 'latest']);
281
+ check();
282
+ if (code !== '0x')
283
+ throw Error('Developer-delivered Safe target policy required');
284
+ return { status: 'not-applicable' as const };
285
+ }
286
+ const plan = ready.plan, context = { executionId: plan.executionId, planHash: plan.planHash, releaseHash: ready.releaseHash, operator: plan.operator, chainId: plan.chainId, target: plan.target, finality: ports.finality, policyHash: semanticHash(ports.finality) };
287
+ const provider = { async request(method: string, params: readonly unknown[]) { ports.guard(); const result = await ports.request(method, params); ports.guard(); return result; } };
288
+ const result = await createDeliveryEoaExecution({ plan, context, store: ports.store, provider }).prepareSafe(current.target.safe);
289
+ check();
290
+ return deepFreeze({ status: 'safe-prepared' as const, envelope: result.envelope });
291
+ }
292
+ export async function freezeDeliveryProduction(raw: ProductionOptions, host: ProductionHostPorts) {
293
+ const { guard, request, store, signer } = productionPorts(host);
294
+ guard();
295
+ const input = deepFreeze(strictData(raw)), ready = inspectDeliveryProduction(input, 'execute');
296
+ guard();
297
+ if (ready.status !== 'ready')
298
+ return { status: 'pending' as const };
299
+ const check = () => { guard(); const now = inspectDeliveryProduction(input, 'execute'); if (now.status !== 'ready' || now.artifactHash !== ready.artifactHash)
300
+ throw Error('Production snapshot context changed'); guard(); };
301
+ const rpc = async (method: string, params: unknown[]) => { guard(); const v = await request(method, params); guard(); return v; };
302
+ const s = await store.readExecution(input.executionId);
303
+ guard();
304
+ if (s && s.planHash !== ready.plan.planHash)
305
+ throw Error('Original execution plan mismatch');
306
+ const tx = ready.plan.transactions[s?.completedCount ?? 0];
307
+ if (!tx) {
308
+ check();
309
+ return { status: 'complete' as const };
310
+ }
311
+ if (rpcQuantity(await rpc('eth_chainId', [])) !== ready.plan.chainId)
312
+ throw Error('Production chain mismatch');
313
+ const code = await rpc('eth_getCode', [tx.executor, 'latest']);
314
+ if (typeof code !== 'string' || !/^0x(?:[a-fA-F0-9]{2})*$/.test(code))
315
+ throw Error('Unknown executor permissions');
316
+ if (tx.route !== 'operator') {
317
+ await prepareProductionSafe(input, host, 'execute');
318
+ return { status: 'external-executor' as const, export: await runDeliveryProduction('export-calldata', input, host) };
319
+ }
320
+ if (code !== '0x' || tx.operation !== 0)
321
+ throw Error('Unsupported contract executor; EOA operation 0 required');
322
+ if (!signer || signer.address !== input.operator.toLowerCase())
323
+ throw Error('PRODUCTION_SIGNER_UNAVAILABLE');
324
+ if (s?.transactions[s.completedCount]?.state && s.transactions[s.completedCount].state !== 'claimed')
325
+ return { status: 'reconcile-required' as const, executionId: input.executionId, planHash: ready.plan.planHash };
326
+ const unsigned = parseUnsigned({ chainId: ready.plan.chainId, signer: tx.executor, nonce: rpcQuantity(await rpc('eth_getTransactionCount', [tx.executor, 'pending'])), to: tx.to, value: tx.value, data: tx.data, operation: tx.operation, type: 0, gasLimit: rpcQuantity(await rpc('eth_estimateGas', [{ from: tx.executor, to: tx.to, data: tx.data, value: '0x' + BigInt(tx.value).toString(16) }])), gasPrice: rpcQuantity(await rpc('eth_gasPrice', [])), maxFeePerGas: null, maxPriorityFeePerGas: null, accessList: [] }, ready.plan, s?.completedCount ?? 0);
327
+ check();
328
+ return deepFreeze({ status: 'frozen' as const, releaseHash: ready.releaseHash, plan: ready.plan, artifactHash: ready.artifactHash, unsigned });
329
+ }
330
+ import { Interface } from 'ethers';
331
+ import { expectedDevelopmentAssertions } from './development';
332
+ import { parseTypedValue } from '../workflow/lib/typedValue';
333
+ import { compareAbiResults, normalizeRuntimeValue } from './abi';
334
+ function assertionValue(raw: any): any { const v = parseTypedValue(raw); switch (v.type) {
335
+ case 'bigint': return v.value;
336
+ case 'number': return Number(v.value);
337
+ case 'array': return v.value.map(assertionValue);
338
+ case 'object': return Object.fromEntries(Object.entries(v.value).map(([k, x]) => [k, assertionValue(x)]));
339
+ default: return v.value;
340
+ } }
341
+ async function verifyProductionAssertions(ready: Extract<ReturnType<typeof inspectDeliveryProduction>, {
342
+ status: 'ready';
343
+ }>, provider: EoaExecutionOptions['provider'], priorAnchor?: FinalizedAnchor) {
344
+ const assertions = ready.collection.verification;
345
+ if (!assertions.length)
346
+ throw Error('Production acceptance requires business assertions');
347
+ for (const binding of ready.plan.verificationBindings) {
348
+ const rows = assertions.filter(o => o.stepId === binding.stepId);
349
+ if (canonicalJson(rows.map(o => o.assertionId)) !== canonicalJson(binding.assertionIds) || semanticHash(rows) !== binding.verificationHash)
350
+ throw Error('Frozen assertion set mismatch');
351
+ }
352
+ if (ready.plan.verificationBindings.reduce((n, b) => n + b.assertionIds.length, 0) !== assertions.length)
353
+ throw Error('Incomplete production assertions');
354
+ const finalized: any = await provider.request('eth_getBlockByNumber', ['finalized', false]);
355
+ if (!finalized?.hash || !finalized?.number)
356
+ throw Error('Finalized business state unavailable');
357
+ const block: any = priorAnchor ?? finalized;
358
+ if (BigInt(block.number) > BigInt(finalized.number))
359
+ throw Error('Production acceptance anchor is not finalized');
360
+ const results = [];
361
+ for (const assertion of assertions) {
362
+ const iface = new Interface(assertion.abi), data = iface.encodeFunctionData(assertion.method, assertionValue(assertion.args));
363
+ const raw = await provider.request('eth_call', [{ to: assertion.address, data }, { blockHash: block.hash, requireCanonical: true }]);
364
+ if (typeof raw !== 'string')
365
+ throw Error('Invalid assertion RPC response');
366
+ const decoded = iface.decodeFunctionResult(assertion.method, raw), actual = decoded.length === 1 ? decoded[0] : decoded, comparison = compareAbiResults(assertion.abi, assertion.method, actual, assertionValue(assertion.expected));
367
+ if (comparison.actual !== comparison.expected)
368
+ throw Error(`Production business assertion failed: ${assertion.assertionId}`);
369
+ results.push({ assertionId: assertion.assertionId, actual: normalizeRuntimeValue(actual), expected: assertion.expected, blockHash: block.hash });
370
+ }
371
+ const end: any = await provider.request('eth_getBlockByNumber', [block.number, false]);
372
+ if (end?.hash !== block.hash)
373
+ throw Error('Production assertion finality changed');
374
+ return { assertions: results, anchor: { hash: block.hash, number: block.number, timestamp: end.timestamp } };
375
+ }
@@ -0,0 +1,58 @@
1
+ // Filesystem-only project boundary helpers; safe to use before loading config tooling.
2
+ import fs from 'node:fs';
3
+ import path from 'node:path';
4
+ import { object, portablePath } from './protocol';
5
+
6
+ export function stat(file: string): fs.Stats | undefined {
7
+ try { return fs.lstatSync(file); } catch (error) {
8
+ if ((error as NodeJS.ErrnoException).code === 'ENOENT') return undefined;
9
+ throw error;
10
+ }
11
+ }
12
+ export function confinedFile(root: string, relative: string, kind: 'file' | 'directory' = 'file'): string {
13
+ portablePath(relative, 'project path');
14
+ let current = root;
15
+ const parts = relative.split('/');
16
+ for (let i = 0; i < parts.length; i++) {
17
+ current = path.join(current, parts[i]);
18
+ const info = stat(current);
19
+ if (!info) continue;
20
+ if (info.isSymbolicLink()) throw new Error(`Unsafe symlink: ${relative}`);
21
+ const file = i === parts.length - 1 && kind === 'file';
22
+ if (file ? !info.isFile() || info.nlink !== 1 : !info.isDirectory()) throw new Error(`Unsafe path type: ${relative}`);
23
+ }
24
+ return current;
25
+ }
26
+ export function projectRoot(workspaceRoot: string, relative: string): string {
27
+ if (typeof workspaceRoot !== 'string' || !path.isAbsolute(workspaceRoot)) throw new Error('workspaceRoot path must be absolute');
28
+ const workspace = fs.realpathSync(workspaceRoot);
29
+ const root = relative === '.' ? workspace : confinedFile(workspace, relative, 'directory');
30
+ if (!stat(root)?.isDirectory()) throw new Error('Project path must be an existing directory');
31
+ return root;
32
+ }
33
+ export function readFile(root: string, relative: string): string | undefined {
34
+ const file = confinedFile(root, relative);
35
+ return stat(file) ? fs.readFileSync(file, 'utf8') : undefined;
36
+ }
37
+ export function coreMarker(root: string): void {
38
+ parseCoreMarker(readFile(root, '.gate-template.json') ?? 'null');
39
+ }
40
+ /** Validate the same captured marker bytes whose digest is being bound. */
41
+ export function parseCoreMarker(bytes: string | Buffer): void {
42
+ const marker = JSON.parse(bytes.toString());
43
+ if (!marker || marker.template !== 'gateflow-evm-core@1' || marker.templateVersion !== 1 || marker.profile !== 'core') throw new Error('Unsupported core template; no legacy migration is performed');
44
+ if (marker.generator?.name !== 'gate-evm-hardhat-foundry' || typeof marker.generator?.version !== 'string'
45
+ || !/^\d+\.\d+\.\d+(?:-[\w.-]+)?$/.test(marker.generator.version)
46
+ || !marker.generation?.inputs || !marker.generation?.files || !Array.isArray(marker.generation?.preserved)) throw new Error('Invalid core generator provenance');
47
+ if (marker.generation.state !== 'complete') throw new Error('Core generation is pending or invalid');
48
+ const inputs = object(marker.generation.inputs, 'core generation provenance inputs');
49
+ const files = object(marker.generation.files, 'core generation provenance files');
50
+ const preserved = marker.generation.preserved as unknown[];
51
+ const optional = ['README.md', 'AGENTS.md', '.gitignore'];
52
+ const assets = ['package.json', 'hardhat.config.ts', 'tsconfig.json', ...optional, 'contracts/.gitkeep', 'test/.gitkeep'];
53
+ if (typeof inputs.projectName !== 'string' || !inputs.projectName || !Array.isArray(inputs.networks)
54
+ || preserved.some(file => typeof file !== 'string' || !optional.includes(file))
55
+ || new Set(preserved).size !== preserved.length
56
+ || Object.keys(files).sort().join('\n') !== assets.filter(file => !preserved.includes(file)).sort().join('\n')
57
+ || Object.values(files).some(hash => typeof hash !== 'string' || !/^[a-f0-9]{64}$/.test(hash))) throw new Error('Invalid core generation provenance');
58
+ }