@emilia-protocol/gate 0.11.0 → 0.14.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 (425) hide show
  1. package/CHANGELOG.md +80 -0
  2. package/README.md +310 -0
  3. package/action-control-manifest.js +3 -268
  4. package/action-escrow-custodian.js +3 -394
  5. package/action-escrow-evidence.js +3 -858
  6. package/action-escrow-package.js +3 -1668
  7. package/action-escrow-postgres.js +3 -337
  8. package/action-escrow-state.js +3 -396
  9. package/action-escrow-verifiers.js +3 -331
  10. package/action-escrow.js +3 -2447
  11. package/action-packs.js +3 -140
  12. package/adapters/_kit.js +3 -104
  13. package/adapters/aws.js +3 -108
  14. package/adapters/cloudflare.js +3 -54
  15. package/adapters/gcp.js +3 -70
  16. package/adapters/github.js +3 -109
  17. package/adapters/jira.js +3 -55
  18. package/adapters/k8s.js +3 -70
  19. package/adapters/linear.js +3 -55
  20. package/adapters/salesforce.js +3 -55
  21. package/adapters/stripe.js +3 -81
  22. package/adapters/supabase.js +3 -121
  23. package/adapters/terraform.js +3 -59
  24. package/adapters/vercel.js +3 -84
  25. package/aec-execution.js +3 -312
  26. package/breakglass.js +3 -582
  27. package/capability-receipt.js +4 -0
  28. package/cf1-conformance.js +3 -106
  29. package/challenge-store.js +3 -69
  30. package/control-plane.js +3 -340
  31. package/coverage.js +3 -721
  32. package/demo.mjs +1 -1
  33. package/deployment-attestation.js +3 -247
  34. package/dist/action-control-manifest.d.ts +82 -0
  35. package/dist/action-control-manifest.d.ts.map +1 -0
  36. package/dist/action-control-manifest.js +422 -0
  37. package/dist/action-control-manifest.js.map +1 -0
  38. package/dist/action-escrow-custodian.d.ts +74 -0
  39. package/dist/action-escrow-custodian.d.ts.map +1 -0
  40. package/dist/action-escrow-custodian.js +363 -0
  41. package/dist/action-escrow-custodian.js.map +1 -0
  42. package/dist/action-escrow-evidence.d.ts +130 -0
  43. package/dist/action-escrow-evidence.d.ts.map +1 -0
  44. package/dist/action-escrow-evidence.js +1012 -0
  45. package/dist/action-escrow-evidence.js.map +1 -0
  46. package/dist/action-escrow-package.d.ts +10 -0
  47. package/dist/action-escrow-package.d.ts.map +1 -0
  48. package/dist/action-escrow-package.js +1583 -0
  49. package/dist/action-escrow-package.js.map +1 -0
  50. package/dist/action-escrow-postgres.d.ts +62 -0
  51. package/dist/action-escrow-postgres.d.ts.map +1 -0
  52. package/dist/action-escrow-postgres.js +339 -0
  53. package/dist/action-escrow-postgres.js.map +1 -0
  54. package/dist/action-escrow-state.d.ts +141 -0
  55. package/dist/action-escrow-state.d.ts.map +1 -0
  56. package/dist/action-escrow-state.js +413 -0
  57. package/dist/action-escrow-state.js.map +1 -0
  58. package/dist/action-escrow-verifiers.d.ts +65 -0
  59. package/dist/action-escrow-verifiers.d.ts.map +1 -0
  60. package/dist/action-escrow-verifiers.js +421 -0
  61. package/dist/action-escrow-verifiers.js.map +1 -0
  62. package/dist/action-escrow.d.ts +112 -0
  63. package/dist/action-escrow.d.ts.map +1 -0
  64. package/dist/action-escrow.js +2661 -0
  65. package/dist/action-escrow.js.map +1 -0
  66. package/dist/action-packs.d.ts +54 -0
  67. package/dist/action-packs.d.ts.map +1 -0
  68. package/dist/action-packs.js +143 -0
  69. package/dist/action-packs.js.map +1 -0
  70. package/dist/adapters/_kit.d.ts +50 -0
  71. package/dist/adapters/_kit.d.ts.map +1 -0
  72. package/dist/adapters/_kit.js +98 -0
  73. package/dist/adapters/_kit.js.map +1 -0
  74. package/dist/adapters/aws.d.ts +158 -0
  75. package/dist/adapters/aws.d.ts.map +1 -0
  76. package/dist/adapters/aws.js +136 -0
  77. package/dist/adapters/aws.js.map +1 -0
  78. package/dist/adapters/cloudflare.d.ts +116 -0
  79. package/dist/adapters/cloudflare.d.ts.map +1 -0
  80. package/dist/adapters/cloudflare.js +75 -0
  81. package/dist/adapters/cloudflare.js.map +1 -0
  82. package/dist/adapters/gcp.d.ts +139 -0
  83. package/dist/adapters/gcp.d.ts.map +1 -0
  84. package/dist/adapters/gcp.js +69 -0
  85. package/dist/adapters/gcp.js.map +1 -0
  86. package/dist/adapters/github.d.ts +123 -0
  87. package/dist/adapters/github.d.ts.map +1 -0
  88. package/dist/adapters/github.js +105 -0
  89. package/dist/adapters/github.js.map +1 -0
  90. package/dist/adapters/jira.d.ts +109 -0
  91. package/dist/adapters/jira.d.ts.map +1 -0
  92. package/dist/adapters/jira.js +54 -0
  93. package/dist/adapters/jira.js.map +1 -0
  94. package/dist/adapters/k8s.d.ts +139 -0
  95. package/dist/adapters/k8s.d.ts.map +1 -0
  96. package/dist/adapters/k8s.js +69 -0
  97. package/dist/adapters/k8s.js.map +1 -0
  98. package/dist/adapters/linear.d.ts +109 -0
  99. package/dist/adapters/linear.d.ts.map +1 -0
  100. package/dist/adapters/linear.js +54 -0
  101. package/dist/adapters/linear.js.map +1 -0
  102. package/dist/adapters/salesforce.d.ts +109 -0
  103. package/dist/adapters/salesforce.d.ts.map +1 -0
  104. package/dist/adapters/salesforce.js +54 -0
  105. package/dist/adapters/salesforce.js.map +1 -0
  106. package/dist/adapters/stripe.d.ts +116 -0
  107. package/dist/adapters/stripe.d.ts.map +1 -0
  108. package/dist/adapters/stripe.js +77 -0
  109. package/dist/adapters/stripe.js.map +1 -0
  110. package/dist/adapters/supabase.d.ts +127 -0
  111. package/dist/adapters/supabase.d.ts.map +1 -0
  112. package/dist/adapters/supabase.js +112 -0
  113. package/dist/adapters/supabase.js.map +1 -0
  114. package/dist/adapters/terraform.d.ts +109 -0
  115. package/dist/adapters/terraform.d.ts.map +1 -0
  116. package/dist/adapters/terraform.js +58 -0
  117. package/dist/adapters/terraform.js.map +1 -0
  118. package/dist/adapters/vercel.d.ts +114 -0
  119. package/dist/adapters/vercel.d.ts.map +1 -0
  120. package/dist/adapters/vercel.js +81 -0
  121. package/dist/adapters/vercel.js.map +1 -0
  122. package/dist/aec-execution.d.ts +107 -0
  123. package/dist/aec-execution.d.ts.map +1 -0
  124. package/dist/aec-execution.js +334 -0
  125. package/dist/aec-execution.js.map +1 -0
  126. package/dist/breakglass.d.ts +205 -0
  127. package/dist/breakglass.d.ts.map +1 -0
  128. package/dist/breakglass.js +627 -0
  129. package/dist/breakglass.js.map +1 -0
  130. package/dist/capability-receipt.d.ts +601 -0
  131. package/dist/capability-receipt.d.ts.map +1 -0
  132. package/dist/capability-receipt.js +1177 -0
  133. package/dist/capability-receipt.js.map +1 -0
  134. package/dist/cf1-conformance.d.ts +83 -0
  135. package/dist/cf1-conformance.d.ts.map +1 -0
  136. package/dist/cf1-conformance.js +94 -0
  137. package/dist/cf1-conformance.js.map +1 -0
  138. package/dist/challenge-store.d.ts +20 -0
  139. package/dist/challenge-store.d.ts.map +1 -0
  140. package/dist/challenge-store.js +62 -0
  141. package/dist/challenge-store.js.map +1 -0
  142. package/dist/control-plane.d.ts +136 -0
  143. package/dist/control-plane.d.ts.map +1 -0
  144. package/dist/control-plane.js +349 -0
  145. package/dist/control-plane.js.map +1 -0
  146. package/dist/coverage.d.ts +156 -0
  147. package/dist/coverage.d.ts.map +1 -0
  148. package/dist/coverage.js +768 -0
  149. package/dist/coverage.js.map +1 -0
  150. package/dist/deployment-attestation.d.ts +93 -0
  151. package/dist/deployment-attestation.d.ts.map +1 -0
  152. package/dist/deployment-attestation.js +262 -0
  153. package/dist/deployment-attestation.js.map +1 -0
  154. package/dist/eg1-conformance.d.ts +286 -0
  155. package/dist/eg1-conformance.d.ts.map +1 -0
  156. package/dist/eg1-conformance.js +379 -0
  157. package/dist/eg1-conformance.js.map +1 -0
  158. package/dist/enterprise.d.ts +88 -0
  159. package/dist/enterprise.d.ts.map +1 -0
  160. package/dist/enterprise.js +194 -0
  161. package/dist/enterprise.js.map +1 -0
  162. package/dist/evidence-postgres.d.ts +123 -0
  163. package/dist/evidence-postgres.d.ts.map +1 -0
  164. package/dist/evidence-postgres.js +343 -0
  165. package/dist/evidence-postgres.js.map +1 -0
  166. package/dist/evidence.d.ts +113 -0
  167. package/dist/evidence.d.ts.map +1 -0
  168. package/dist/evidence.js +369 -0
  169. package/dist/evidence.js.map +1 -0
  170. package/dist/execution-binding.d.ts +49 -0
  171. package/dist/execution-binding.d.ts.map +1 -0
  172. package/dist/execution-binding.js +243 -0
  173. package/dist/execution-binding.js.map +1 -0
  174. package/dist/formal-runtime-map.d.ts +42 -0
  175. package/dist/formal-runtime-map.d.ts.map +1 -0
  176. package/dist/formal-runtime-map.js +23 -0
  177. package/dist/formal-runtime-map.js.map +1 -0
  178. package/dist/index.d.ts +1003 -0
  179. package/dist/index.d.ts.map +1 -0
  180. package/dist/index.js +1737 -0
  181. package/dist/index.js.map +1 -0
  182. package/dist/key-registry.d.ts +60 -0
  183. package/dist/key-registry.d.ts.map +1 -0
  184. package/dist/key-registry.js +144 -0
  185. package/dist/key-registry.js.map +1 -0
  186. package/dist/mcp.d.ts +53 -0
  187. package/dist/mcp.d.ts.map +1 -0
  188. package/dist/mcp.js +112 -0
  189. package/dist/mcp.js.map +1 -0
  190. package/dist/metering.d.ts +80 -0
  191. package/dist/metering.d.ts.map +1 -0
  192. package/dist/metering.js +227 -0
  193. package/dist/metering.js.map +1 -0
  194. package/dist/metrics.d.ts +68 -0
  195. package/dist/metrics.d.ts.map +1 -0
  196. package/dist/metrics.js +242 -0
  197. package/dist/metrics.js.map +1 -0
  198. package/dist/network-witness.d.ts +167 -0
  199. package/dist/network-witness.d.ts.map +1 -0
  200. package/dist/network-witness.js +520 -0
  201. package/dist/network-witness.js.map +1 -0
  202. package/dist/proposal-to-effect.d.ts +146 -0
  203. package/dist/proposal-to-effect.d.ts.map +1 -0
  204. package/dist/proposal-to-effect.js +427 -0
  205. package/dist/proposal-to-effect.js.map +1 -0
  206. package/dist/protocol-state.d.ts +141 -0
  207. package/dist/protocol-state.d.ts.map +1 -0
  208. package/dist/protocol-state.js +106 -0
  209. package/dist/protocol-state.js.map +1 -0
  210. package/dist/receipt-program.d.ts +59 -0
  211. package/dist/receipt-program.d.ts.map +1 -0
  212. package/dist/receipt-program.js +1053 -0
  213. package/dist/receipt-program.js.map +1 -0
  214. package/dist/reliance-kernel.d.ts +66 -0
  215. package/dist/reliance-kernel.d.ts.map +1 -0
  216. package/dist/reliance-kernel.js +103 -0
  217. package/dist/reliance-kernel.js.map +1 -0
  218. package/dist/reliance-packet.d.ts +67 -0
  219. package/dist/reliance-packet.d.ts.map +1 -0
  220. package/dist/reliance-packet.js +176 -0
  221. package/dist/reliance-packet.js.map +1 -0
  222. package/dist/remedy-program-postgres.d.ts +37 -0
  223. package/dist/remedy-program-postgres.d.ts.map +1 -0
  224. package/dist/remedy-program-postgres.js +291 -0
  225. package/dist/remedy-program-postgres.js.map +1 -0
  226. package/dist/remedy-program-receipt.d.ts +97 -0
  227. package/dist/remedy-program-receipt.d.ts.map +1 -0
  228. package/dist/remedy-program-receipt.js +817 -0
  229. package/dist/remedy-program-receipt.js.map +1 -0
  230. package/dist/remedy-program.d.ts +76 -0
  231. package/dist/remedy-program.d.ts.map +1 -0
  232. package/dist/remedy-program.js +1346 -0
  233. package/dist/remedy-program.js.map +1 -0
  234. package/dist/reports/art14.d.ts +101 -0
  235. package/dist/reports/art14.d.ts.map +1 -0
  236. package/dist/reports/art14.js +340 -0
  237. package/dist/reports/art14.js.map +1 -0
  238. package/dist/reports/assurance-package.d.ts +197 -0
  239. package/dist/reports/assurance-package.d.ts.map +1 -0
  240. package/dist/reports/assurance-package.js +313 -0
  241. package/dist/reports/assurance-package.js.map +1 -0
  242. package/dist/reports/auditor-workpaper.d.ts +194 -0
  243. package/dist/reports/auditor-workpaper.d.ts.map +1 -0
  244. package/dist/reports/auditor-workpaper.js +545 -0
  245. package/dist/reports/auditor-workpaper.js.map +1 -0
  246. package/dist/reports/external-verification.d.ts +76 -0
  247. package/dist/reports/external-verification.d.ts.map +1 -0
  248. package/dist/reports/external-verification.js +209 -0
  249. package/dist/reports/external-verification.js.map +1 -0
  250. package/dist/reports/reperform.d.ts +122 -0
  251. package/dist/reports/reperform.d.ts.map +1 -0
  252. package/dist/reports/reperform.js +432 -0
  253. package/dist/reports/reperform.js.map +1 -0
  254. package/dist/reports/underwriter.d.ts +127 -0
  255. package/dist/reports/underwriter.d.ts.map +1 -0
  256. package/dist/reports/underwriter.js +348 -0
  257. package/dist/reports/underwriter.js.map +1 -0
  258. package/dist/retention.d.ts +88 -0
  259. package/dist/retention.d.ts.map +1 -0
  260. package/dist/retention.js +90 -0
  261. package/dist/retention.js.map +1 -0
  262. package/dist/roster.d.ts +113 -0
  263. package/dist/roster.d.ts.map +1 -0
  264. package/dist/roster.js +261 -0
  265. package/dist/roster.js.map +1 -0
  266. package/dist/runtime-monitor.d.ts +132 -0
  267. package/dist/runtime-monitor.d.ts.map +1 -0
  268. package/dist/runtime-monitor.js +197 -0
  269. package/dist/runtime-monitor.js.map +1 -0
  270. package/dist/settlement.d.ts +68 -0
  271. package/dist/settlement.d.ts.map +1 -0
  272. package/dist/settlement.js +306 -0
  273. package/dist/settlement.js.map +1 -0
  274. package/dist/siem.d.ts +261 -0
  275. package/dist/siem.d.ts.map +1 -0
  276. package/dist/siem.js +247 -0
  277. package/dist/siem.js.map +1 -0
  278. package/dist/store-postgres.d.ts +107 -0
  279. package/dist/store-postgres.d.ts.map +1 -0
  280. package/dist/store-postgres.js +152 -0
  281. package/dist/store-postgres.js.map +1 -0
  282. package/dist/store.d.ts +95 -0
  283. package/dist/store.d.ts.map +1 -0
  284. package/dist/store.js +202 -0
  285. package/dist/store.js.map +1 -0
  286. package/dist/strict-json.d.ts +14 -0
  287. package/dist/strict-json.d.ts.map +1 -0
  288. package/dist/strict-json.js +132 -0
  289. package/dist/strict-json.js.map +1 -0
  290. package/dist/trust-program-adapters.d.ts +122 -0
  291. package/dist/trust-program-adapters.d.ts.map +1 -0
  292. package/dist/trust-program-adapters.js +802 -0
  293. package/dist/trust-program-adapters.js.map +1 -0
  294. package/dist/trust-program-postgres.d.ts +41 -0
  295. package/dist/trust-program-postgres.d.ts.map +1 -0
  296. package/dist/trust-program-postgres.js +346 -0
  297. package/dist/trust-program-postgres.js.map +1 -0
  298. package/dist/trust-program-revocation.d.ts +206 -0
  299. package/dist/trust-program-revocation.d.ts.map +1 -0
  300. package/dist/trust-program-revocation.js +600 -0
  301. package/dist/trust-program-revocation.js.map +1 -0
  302. package/dist/trust-program.d.ts +197 -0
  303. package/dist/trust-program.d.ts.map +1 -0
  304. package/dist/trust-program.js +1351 -0
  305. package/dist/trust-program.js.map +1 -0
  306. package/dist/witness-postgres.d.ts +43 -0
  307. package/dist/witness-postgres.d.ts.map +1 -0
  308. package/dist/witness-postgres.js +92 -0
  309. package/dist/witness-postgres.js.map +1 -0
  310. package/dist/zk-range-proof.d.ts +78 -0
  311. package/dist/zk-range-proof.d.ts.map +1 -0
  312. package/dist/zk-range-proof.js +228 -0
  313. package/dist/zk-range-proof.js.map +1 -0
  314. package/eg1-conformance.js +3 -404
  315. package/enterprise.js +3 -180
  316. package/ep-assure.mjs +1 -0
  317. package/evidence-postgres.js +3 -356
  318. package/evidence.js +4 -360
  319. package/execution-binding.js +3 -212
  320. package/formal-runtime-map.js +4 -0
  321. package/index.js +4 -1249
  322. package/key-registry.js +3 -134
  323. package/mcp.js +3 -109
  324. package/metering.js +3 -226
  325. package/metrics.js +3 -231
  326. package/network-witness.js +3 -499
  327. package/package.json +35 -4
  328. package/proposal-to-effect.js +4 -0
  329. package/receipt-program.js +4 -0
  330. package/reliance-kernel.js +3 -112
  331. package/reliance-packet.js +3 -175
  332. package/remedy-program-postgres.js +4 -0
  333. package/remedy-program-receipt.js +4 -0
  334. package/remedy-program.js +4 -0
  335. package/reports/art14.js +0 -0
  336. package/reports/assurance-package.js +2 -312
  337. package/reports/auditor-workpaper.js +3 -537
  338. package/reports/external-verification.js +3 -222
  339. package/reports/reperform.js +3 -424
  340. package/reports/underwriter.js +3 -339
  341. package/retention.js +3 -84
  342. package/roster.js +3 -264
  343. package/runtime-monitor.js +4 -0
  344. package/settlement.js +3 -299
  345. package/siem.js +3 -235
  346. package/src/action-control-manifest.ts +424 -0
  347. package/src/action-escrow-custodian.ts +427 -0
  348. package/src/action-escrow-evidence.ts +1178 -0
  349. package/src/action-escrow-package.ts +1821 -0
  350. package/src/action-escrow-postgres.ts +366 -0
  351. package/src/action-escrow-state.ts +498 -0
  352. package/src/action-escrow-verifiers.ts +484 -0
  353. package/src/action-escrow.ts +3039 -0
  354. package/src/action-packs.ts +170 -0
  355. package/src/adapters/_kit.ts +117 -0
  356. package/src/adapters/aws.ts +142 -0
  357. package/src/adapters/cloudflare.ts +78 -0
  358. package/src/adapters/gcp.ts +71 -0
  359. package/src/adapters/github.ts +110 -0
  360. package/src/adapters/jira.ts +56 -0
  361. package/src/adapters/k8s.ts +71 -0
  362. package/src/adapters/linear.ts +56 -0
  363. package/src/adapters/salesforce.ts +56 -0
  364. package/src/adapters/stripe.ts +82 -0
  365. package/src/adapters/supabase.ts +122 -0
  366. package/src/adapters/terraform.ts +60 -0
  367. package/src/adapters/vercel.ts +85 -0
  368. package/src/aec-execution.ts +354 -0
  369. package/src/breakglass.ts +647 -0
  370. package/src/capability-receipt.ts +1258 -0
  371. package/src/cf1-conformance.ts +120 -0
  372. package/src/challenge-store.ts +70 -0
  373. package/src/control-plane.ts +374 -0
  374. package/src/coverage.ts +832 -0
  375. package/src/deployment-attestation.ts +259 -0
  376. package/src/eg1-conformance.ts +471 -0
  377. package/src/enterprise.ts +195 -0
  378. package/src/evidence-postgres.ts +374 -0
  379. package/src/evidence.ts +367 -0
  380. package/src/execution-binding.ts +236 -0
  381. package/src/formal-runtime-map.ts +24 -0
  382. package/src/index.ts +2127 -0
  383. package/src/key-registry.ts +150 -0
  384. package/src/mcp.ts +120 -0
  385. package/src/metering.ts +237 -0
  386. package/src/metrics.ts +232 -0
  387. package/src/network-witness.ts +585 -0
  388. package/src/proposal-to-effect.ts +571 -0
  389. package/src/protocol-state.ts +143 -0
  390. package/src/protocol-state.typecheck.ts +94 -0
  391. package/src/receipt-program.ts +1105 -0
  392. package/src/reliance-kernel.ts +119 -0
  393. package/src/reliance-packet.ts +206 -0
  394. package/src/remedy-program-postgres.ts +367 -0
  395. package/src/remedy-program-receipt.ts +891 -0
  396. package/src/remedy-program.ts +1388 -0
  397. package/src/reports/art14.ts +361 -0
  398. package/src/reports/assurance-package.ts +330 -0
  399. package/src/reports/auditor-workpaper.ts +558 -0
  400. package/src/reports/external-verification.ts +232 -0
  401. package/src/reports/reperform.ts +441 -0
  402. package/src/reports/underwriter.ts +356 -0
  403. package/src/retention.ts +100 -0
  404. package/src/roster.ts +273 -0
  405. package/src/runtime-monitor.ts +217 -0
  406. package/src/settlement.ts +313 -0
  407. package/src/siem.ts +247 -0
  408. package/src/store-postgres.ts +167 -0
  409. package/src/store.ts +214 -0
  410. package/src/strict-json.ts +115 -0
  411. package/src/trust-program-adapters.ts +847 -0
  412. package/src/trust-program-postgres.ts +429 -0
  413. package/src/trust-program-revocation.ts +751 -0
  414. package/src/trust-program.ts +1460 -0
  415. package/src/witness-postgres.ts +106 -0
  416. package/src/zk-range-proof.ts +250 -0
  417. package/store-postgres.js +3 -161
  418. package/store.js +4 -198
  419. package/strict-json.js +3 -102
  420. package/trust-program-adapters.js +4 -0
  421. package/trust-program-postgres.js +4 -0
  422. package/trust-program-revocation.js +4 -0
  423. package/trust-program.js +4 -0
  424. package/witness-postgres.js +3 -96
  425. package/zk-range-proof.js +4 -0
@@ -0,0 +1,110 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ /**
3
+ * EMILIA Gate — GitHub System-of-Record adapter.
4
+ *
5
+ * "Install this before your agent can touch production GitHub." Wraps destructive
6
+ * Octokit operations so the mutation NEVER reaches GitHub without a valid,
7
+ * sufficiently-assured, non-replayed human/quorum receipt bound to THIS repo —
8
+ * and on success returns a reliance packet proving exactly what was authorized
9
+ * and what executed.
10
+ *
11
+ * import { Octokit } from '@octokit/rest';
12
+ * import { createGate } from '@emilia-protocol/gate';
13
+ * import { createGithubManifest, guardGithubMutation } from '@emilia-protocol/gate/adapters/github';
14
+ *
15
+ * const gate = createGate({ manifest: createGithubManifest(), trustedKeys: [ISSUER], store: sharedConsumptionStore });
16
+ * const octokit = new Octokit({ auth });
17
+ * await guardGithubMutation(gate, octokit, {
18
+ * op: 'repo.delete', params: { owner, repo }, receipt, // throws if no valid receipt
19
+ * });
20
+ *
21
+ * The receipt's claim must carry the same owner/repo (and username/permission or
22
+ * branch) as the call — a receipt for repo A cannot authorize deleting repo B.
23
+ */
24
+ import { createAdapter, manifestFromPack } from './_kit.js';
25
+
26
+ export const GITHUB_ACTION_PACK = Object.freeze([
27
+ Object.freeze({
28
+ id: 'github.repo.delete',
29
+ label: 'GitHub repo delete',
30
+ action_type: 'github.repo.delete',
31
+ risk: 'critical',
32
+ receipt_required: true,
33
+ assurance_class: 'class_a',
34
+ match: { protocol: 'github', tool: 'delete_repo' },
35
+ why: 'Destroys a repository and its history. Bind owner/repo to a named human approval.',
36
+ execution_binding: { required_fields: ['action_type', 'owner', 'repo'] },
37
+ }),
38
+ Object.freeze({
39
+ id: 'github.permission.change',
40
+ label: 'GitHub permission change',
41
+ action_type: 'github.permission.change',
42
+ risk: 'critical',
43
+ receipt_required: true,
44
+ assurance_class: 'quorum',
45
+ match: { protocol: 'github', tool: 'update_collaborator_permission' },
46
+ why: 'Changes who can act on the repo. Privilege change deserves the two-person rule.',
47
+ execution_binding: { required_fields: ['action_type', 'owner', 'repo', 'username', 'permission'] },
48
+ }),
49
+ Object.freeze({
50
+ id: 'github.branch_protection.remove',
51
+ label: 'GitHub branch-protection removal',
52
+ action_type: 'github.branch_protection.remove',
53
+ risk: 'critical',
54
+ receipt_required: true,
55
+ assurance_class: 'class_a',
56
+ match: { protocol: 'github', tool: 'delete_branch_protection' },
57
+ why: 'Removes the guard rails on a protected branch.',
58
+ execution_binding: { required_fields: ['action_type', 'owner', 'repo', 'branch'] },
59
+ }),
60
+ ]);
61
+
62
+ const OPS = {
63
+ 'repo.delete': {
64
+ selector: { protocol: 'github', tool: 'delete_repo' },
65
+ observed: (p) => ({ action_type: 'github.repo.delete', owner: p.owner, repo: p.repo }),
66
+ perform: (octokit, p) => octokit.repos.delete({ owner: p.owner, repo: p.repo }),
67
+ },
68
+ 'permission.change': {
69
+ selector: { protocol: 'github', tool: 'update_collaborator_permission' },
70
+ observed: (p) => ({
71
+ action_type: 'github.permission.change',
72
+ owner: p.owner, repo: p.repo, username: p.username, permission: p.permission,
73
+ }),
74
+ perform: (octokit, p) => octokit.repos.addCollaborator({
75
+ owner: p.owner, repo: p.repo, username: p.username, permission: p.permission,
76
+ }),
77
+ },
78
+ 'branch_protection.remove': {
79
+ selector: { protocol: 'github', tool: 'delete_branch_protection' },
80
+ observed: (p) => ({ action_type: 'github.branch_protection.remove', owner: p.owner, repo: p.repo, branch: p.branch }),
81
+ perform: (octokit, p) => octokit.repos.deleteBranchProtection({ owner: p.owner, repo: p.repo, branch: p.branch }),
82
+ },
83
+ };
84
+
85
+ const adapter = createAdapter({ system: 'github', ops: OPS });
86
+ export const GITHUB_OPS = adapter.OPS;
87
+
88
+ /** Build an action-risk manifest for the GitHub destructive ops (plus any extras). */
89
+ export function createGithubManifest(extraActions = []) {
90
+ return manifestFromPack(GITHUB_ACTION_PACK, extraActions);
91
+ }
92
+
93
+ /**
94
+ * Guard a destructive GitHub mutation behind the gate. The call never reaches
95
+ * GitHub unless a valid, sufficiently-assured, non-replayed receipt bound to
96
+ * THIS repo is present.
97
+ * @param {object} gate a gate built with createGithubManifest()
98
+ * @param {object} octokit an Octokit-like client (@octokit/rest or compatible)
99
+ * @param {object} o
100
+ * @param {string} o.op 'repo.delete' | 'permission.change' | 'branch_protection.remove'
101
+ * @param {object} o.params { owner, repo, [username], [permission], [branch] }
102
+ * @param {object} o.receipt the EMILIA receipt authorizing THIS exact op
103
+ * @returns {Promise<{ result:any, reliance:object, execution:object }>}
104
+ * @throws Error{code:'EMILIA_RECEIPT_REQUIRED'} if refused — the call never reaches GitHub
105
+ */
106
+ export function guardGithubMutation(gate, octokit, args) {
107
+ return adapter.guard(gate, octokit, args);
108
+ }
109
+
110
+ export default { GITHUB_ACTION_PACK, GITHUB_OPS, createGithubManifest, guardGithubMutation };
@@ -0,0 +1,56 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ /**
3
+ * EMILIA Gate — Jira System-of-Record adapter.
4
+ * Guards bulk issue delete, project delete, and permission grants so they never
5
+ * reach Jira without a receipt bound to THIS resource. Client injected.
6
+ */
7
+ import { createAdapter, manifestFromPack, hashCanonical } from './_kit.js';
8
+
9
+ export const JIRA_ACTION_PACK = Object.freeze([
10
+ Object.freeze({
11
+ id: 'jira.issue.bulk_delete', label: 'Bulk delete issues', action_type: 'jira.issue.bulk_delete',
12
+ risk: 'critical', receipt_required: true, assurance_class: 'class_a',
13
+ match: { protocol: 'jira', tool: 'bulk_delete_issues' },
14
+ why: 'Mass-destroys issues. Bind the exact JQL.',
15
+ execution_binding: { required_fields: ['action_type', 'project', 'jql_hash'] },
16
+ }),
17
+ Object.freeze({
18
+ id: 'jira.project.delete', label: 'Delete project', action_type: 'jira.project.delete',
19
+ risk: 'critical', receipt_required: true, assurance_class: 'quorum',
20
+ match: { protocol: 'jira', tool: 'delete_project' },
21
+ why: 'Deletes a project and its issues. Quorum.',
22
+ execution_binding: { required_fields: ['action_type', 'project_key'] },
23
+ }),
24
+ Object.freeze({
25
+ id: 'jira.permission.grant', label: 'Grant permission', action_type: 'jira.permission.grant',
26
+ risk: 'critical', receipt_required: true, assurance_class: 'quorum',
27
+ match: { protocol: 'jira', tool: 'grant_permission' },
28
+ why: 'Changes who can act. Quorum + bind project/principal/role.',
29
+ execution_binding: { required_fields: ['action_type', 'project', 'principal', 'role'] },
30
+ }),
31
+ ]);
32
+
33
+ const OPS = {
34
+ 'issue.bulk_delete': {
35
+ selector: { protocol: 'jira', tool: 'bulk_delete_issues' },
36
+ observed: (p) => ({ action_type: 'jira.issue.bulk_delete', project: p.project, jql_hash: hashCanonical(String(p.jql || '').trim()) }),
37
+ actuator: (p, observed) => ({ ...observed, jql: p.jql }),
38
+ perform: (c, p) => c.bulkDeleteIssues({ project: p.project, jql: p.jql }),
39
+ },
40
+ 'project.delete': {
41
+ selector: { protocol: 'jira', tool: 'delete_project' },
42
+ observed: (p) => ({ action_type: 'jira.project.delete', project_key: p.project_key }),
43
+ perform: (c, p) => c.deleteProject({ projectKey: p.project_key }),
44
+ },
45
+ 'permission.grant': {
46
+ selector: { protocol: 'jira', tool: 'grant_permission' },
47
+ observed: (p) => ({ action_type: 'jira.permission.grant', project: p.project, principal: p.principal, role: p.role }),
48
+ perform: (c, p) => c.grantPermission({ project: p.project, principal: p.principal, role: p.role }),
49
+ },
50
+ };
51
+
52
+ const adapter = createAdapter({ system: 'jira', ops: OPS });
53
+ export const JIRA_OPS = adapter.OPS;
54
+ export function createJiraManifest(extra = []) { return manifestFromPack(JIRA_ACTION_PACK, extra); }
55
+ export function guardJiraMutation(gate, client, args) { return adapter.guard(gate, client, args); }
56
+ export default { JIRA_ACTION_PACK, JIRA_OPS, createJiraManifest, guardJiraMutation };
@@ -0,0 +1,71 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ /**
3
+ * EMILIA Gate — Kubernetes System-of-Record adapter.
4
+ *
5
+ * "Install this before your agent can touch the cluster." Guards the operations
6
+ * that take a cluster down or hand it away — namespace delete, workload delete,
7
+ * RBAC binding, secret delete — so they never reach the API server without a
8
+ * receipt bound to THIS namespace/resource. Client is injected (a @kubernetes/
9
+ * client-node wrapper or compatible).
10
+ */
11
+ import { createAdapter, manifestFromPack } from './_kit.js';
12
+
13
+ export const K8S_ACTION_PACK = Object.freeze([
14
+ Object.freeze({
15
+ id: 'k8s.namespace.delete', label: 'Delete namespace', action_type: 'k8s.namespace.delete',
16
+ risk: 'critical', receipt_required: true, assurance_class: 'quorum',
17
+ match: { protocol: 'k8s', tool: 'delete_namespace' },
18
+ why: 'Deletes an entire namespace and everything in it. Quorum.',
19
+ execution_binding: { required_fields: ['action_type', 'namespace'] },
20
+ }),
21
+ Object.freeze({
22
+ id: 'k8s.workload.delete', label: 'Delete workload', action_type: 'k8s.workload.delete',
23
+ risk: 'high', receipt_required: true, assurance_class: 'class_a',
24
+ match: { protocol: 'k8s', tool: 'delete_workload' },
25
+ why: 'Deletes a deployment/statefulset/job. Bind namespace+kind+name.',
26
+ execution_binding: { required_fields: ['action_type', 'namespace', 'kind', 'name'] },
27
+ }),
28
+ Object.freeze({
29
+ id: 'k8s.rbac.bind', label: 'RBAC binding', action_type: 'k8s.rbac.bind',
30
+ risk: 'critical', receipt_required: true, assurance_class: 'quorum',
31
+ match: { protocol: 'k8s', tool: 'create_role_binding' },
32
+ why: 'Grants cluster permissions. Privilege change → two-person rule.',
33
+ execution_binding: { required_fields: ['action_type', 'subject', 'role', 'namespace'] },
34
+ }),
35
+ Object.freeze({
36
+ id: 'k8s.secret.delete', label: 'Delete secret', action_type: 'k8s.secret.delete',
37
+ risk: 'high', receipt_required: true, assurance_class: 'class_a',
38
+ match: { protocol: 'k8s', tool: 'delete_secret' },
39
+ why: 'Destroys a secret. Bind namespace+name.',
40
+ execution_binding: { required_fields: ['action_type', 'namespace', 'name'] },
41
+ }),
42
+ ]);
43
+
44
+ const OPS = {
45
+ 'namespace.delete': {
46
+ selector: { protocol: 'k8s', tool: 'delete_namespace' },
47
+ observed: (p) => ({ action_type: 'k8s.namespace.delete', namespace: p.namespace }),
48
+ perform: (c, p) => c.deleteNamespace({ namespace: p.namespace }),
49
+ },
50
+ 'workload.delete': {
51
+ selector: { protocol: 'k8s', tool: 'delete_workload' },
52
+ observed: (p) => ({ action_type: 'k8s.workload.delete', namespace: p.namespace, kind: p.kind, name: p.name }),
53
+ perform: (c, p) => c.deleteWorkload({ namespace: p.namespace, kind: p.kind, name: p.name }),
54
+ },
55
+ 'rbac.bind': {
56
+ selector: { protocol: 'k8s', tool: 'create_role_binding' },
57
+ observed: (p) => ({ action_type: 'k8s.rbac.bind', subject: p.subject, role: p.role, namespace: p.namespace }),
58
+ perform: (c, p) => c.createRoleBinding({ subject: p.subject, role: p.role, namespace: p.namespace }),
59
+ },
60
+ 'secret.delete': {
61
+ selector: { protocol: 'k8s', tool: 'delete_secret' },
62
+ observed: (p) => ({ action_type: 'k8s.secret.delete', namespace: p.namespace, name: p.name }),
63
+ perform: (c, p) => c.deleteSecret({ namespace: p.namespace, name: p.name }),
64
+ },
65
+ };
66
+
67
+ const adapter = createAdapter({ system: 'k8s', ops: OPS });
68
+ export const K8S_OPS = adapter.OPS;
69
+ export function createK8sManifest(extraActions = []) { return manifestFromPack(K8S_ACTION_PACK, extraActions); }
70
+ export function guardK8sMutation(gate, client, args) { return adapter.guard(gate, client, args); }
71
+ export default { K8S_ACTION_PACK, K8S_OPS, createK8sManifest, guardK8sMutation };
@@ -0,0 +1,56 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ /**
3
+ * EMILIA Gate — Linear System-of-Record adapter.
4
+ * Guards issue deletion, bulk delete, and team deletion so they never reach
5
+ * Linear without a receipt bound to THIS resource. Client injected.
6
+ */
7
+ import { createAdapter, manifestFromPack, hashCanonical } from './_kit.js';
8
+
9
+ export const LINEAR_ACTION_PACK = Object.freeze([
10
+ Object.freeze({
11
+ id: 'linear.issue.delete', label: 'Delete issue', action_type: 'linear.issue.delete',
12
+ risk: 'high', receipt_required: true, assurance_class: 'class_a',
13
+ match: { protocol: 'linear', tool: 'delete_issue' },
14
+ why: 'Destroys an issue. Bind the issue id.',
15
+ execution_binding: { required_fields: ['action_type', 'issue_id'] },
16
+ }),
17
+ Object.freeze({
18
+ id: 'linear.issue.bulk_delete', label: 'Bulk delete issues', action_type: 'linear.issue.bulk_delete',
19
+ risk: 'critical', receipt_required: true, assurance_class: 'class_a',
20
+ match: { protocol: 'linear', tool: 'bulk_delete_issues' },
21
+ why: 'Mass-destroys issues. Bind the exact query.',
22
+ execution_binding: { required_fields: ['action_type', 'team', 'query_hash'] },
23
+ }),
24
+ Object.freeze({
25
+ id: 'linear.team.delete', label: 'Delete team', action_type: 'linear.team.delete',
26
+ risk: 'critical', receipt_required: true, assurance_class: 'quorum',
27
+ match: { protocol: 'linear', tool: 'delete_team' },
28
+ why: 'Deletes a team and its issues. Quorum.',
29
+ execution_binding: { required_fields: ['action_type', 'team_id'] },
30
+ }),
31
+ ]);
32
+
33
+ const OPS = {
34
+ 'issue.delete': {
35
+ selector: { protocol: 'linear', tool: 'delete_issue' },
36
+ observed: (p) => ({ action_type: 'linear.issue.delete', issue_id: p.issue_id }),
37
+ perform: (c, p) => c.deleteIssue({ issueId: p.issue_id }),
38
+ },
39
+ 'issue.bulk_delete': {
40
+ selector: { protocol: 'linear', tool: 'bulk_delete_issues' },
41
+ observed: (p) => ({ action_type: 'linear.issue.bulk_delete', team: p.team, query_hash: hashCanonical(String(p.query || '').trim()) }),
42
+ actuator: (p, observed) => ({ ...observed, query: p.query }),
43
+ perform: (c, p) => c.bulkDeleteIssues({ team: p.team, query: p.query }),
44
+ },
45
+ 'team.delete': {
46
+ selector: { protocol: 'linear', tool: 'delete_team' },
47
+ observed: (p) => ({ action_type: 'linear.team.delete', team_id: p.team_id }),
48
+ perform: (c, p) => c.deleteTeam({ teamId: p.team_id }),
49
+ },
50
+ };
51
+
52
+ const adapter = createAdapter({ system: 'linear', ops: OPS });
53
+ export const LINEAR_OPS = adapter.OPS;
54
+ export function createLinearManifest(extra = []) { return manifestFromPack(LINEAR_ACTION_PACK, extra); }
55
+ export function guardLinearMutation(gate, client, args) { return adapter.guard(gate, client, args); }
56
+ export default { LINEAR_ACTION_PACK, LINEAR_OPS, createLinearManifest, guardLinearMutation };
@@ -0,0 +1,56 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ /**
3
+ * EMILIA Gate — Salesforce System-of-Record adapter.
4
+ * Guards bulk record delete, data export, and permission-set assignment so they
5
+ * never reach Salesforce without a receipt bound to THIS object. Client injected.
6
+ */
7
+ import { createAdapter, manifestFromPack, hashCanonical } from './_kit.js';
8
+
9
+ export const SALESFORCE_ACTION_PACK = Object.freeze([
10
+ Object.freeze({
11
+ id: 'salesforce.records.bulk_delete', label: 'Bulk delete records', action_type: 'salesforce.records.bulk_delete',
12
+ risk: 'critical', receipt_required: true, assurance_class: 'class_a',
13
+ match: { protocol: 'salesforce', tool: 'bulk_delete' },
14
+ why: 'Mass-destroys CRM records. Bind object + the exact SOQL.',
15
+ execution_binding: { required_fields: ['action_type', 'object', 'soql_hash'] },
16
+ }),
17
+ Object.freeze({
18
+ id: 'salesforce.data.export', label: 'Bulk data export', action_type: 'salesforce.data.export',
19
+ risk: 'high', receipt_required: true, assurance_class: 'class_a',
20
+ match: { protocol: 'salesforce', tool: 'export' },
21
+ why: 'Exfiltrates CRM data. Bind object + recipient.',
22
+ execution_binding: { required_fields: ['action_type', 'object', 'recipient'] },
23
+ }),
24
+ Object.freeze({
25
+ id: 'salesforce.permission_set.assign', label: 'Assign permission set', action_type: 'salesforce.permission_set.assign',
26
+ risk: 'critical', receipt_required: true, assurance_class: 'quorum',
27
+ match: { protocol: 'salesforce', tool: 'assign_permission_set' },
28
+ why: 'Grants privileges. Quorum + bind user + permission set.',
29
+ execution_binding: { required_fields: ['action_type', 'user', 'permission_set'] },
30
+ }),
31
+ ]);
32
+
33
+ const OPS = {
34
+ 'records.bulk_delete': {
35
+ selector: { protocol: 'salesforce', tool: 'bulk_delete' },
36
+ observed: (p) => ({ action_type: 'salesforce.records.bulk_delete', object: p.object, soql_hash: hashCanonical(String(p.soql || '').trim()) }),
37
+ actuator: (p, observed) => ({ ...observed, soql: p.soql }),
38
+ perform: (c, p) => c.bulkDelete({ object: p.object, soql: p.soql }),
39
+ },
40
+ 'data.export': {
41
+ selector: { protocol: 'salesforce', tool: 'export' },
42
+ observed: (p) => ({ action_type: 'salesforce.data.export', object: p.object, recipient: p.recipient }),
43
+ perform: (c, p) => c.export({ object: p.object, recipient: p.recipient }),
44
+ },
45
+ 'permission_set.assign': {
46
+ selector: { protocol: 'salesforce', tool: 'assign_permission_set' },
47
+ observed: (p) => ({ action_type: 'salesforce.permission_set.assign', user: p.user, permission_set: p.permission_set }),
48
+ perform: (c, p) => c.assignPermissionSet({ user: p.user, permissionSet: p.permission_set }),
49
+ },
50
+ };
51
+
52
+ const adapter = createAdapter({ system: 'salesforce', ops: OPS });
53
+ export const SALESFORCE_OPS = adapter.OPS;
54
+ export function createSalesforceManifest(extra = []) { return manifestFromPack(SALESFORCE_ACTION_PACK, extra); }
55
+ export function guardSalesforceMutation(gate, client, args) { return adapter.guard(gate, client, args); }
56
+ export default { SALESFORCE_ACTION_PACK, SALESFORCE_OPS, createSalesforceManifest, guardSalesforceMutation };
@@ -0,0 +1,82 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ /**
3
+ * EMILIA Gate — Stripe / payments System-of-Record adapter.
4
+ *
5
+ * "Install this before your agent can move money." Wraps the destructive Stripe
6
+ * operations so a payout, refund, or payout-destination change never reaches
7
+ * Stripe without a valid, sufficiently-assured, non-replayed receipt bound to
8
+ * THIS amount/destination. A receipt for $100 to acct_A cannot authorize
9
+ * $10,000 to acct_B.
10
+ *
11
+ * import Stripe from 'stripe';
12
+ * import { createGate } from '@emilia-protocol/gate';
13
+ * import { createStripeManifest, guardStripeMutation } from '@emilia-protocol/gate/adapters/stripe';
14
+ *
15
+ * const gate = createGate({ manifest: createStripeManifest(), trustedKeys: [ISSUER], store: sharedConsumptionStore });
16
+ * await guardStripeMutation(gate, new Stripe(key), {
17
+ * op: 'payout.create', params: { amount: 40000, currency: 'usd', destination: 'acct_x' }, receipt,
18
+ * });
19
+ */
20
+ import { createAdapter, manifestFromPack } from './_kit.js';
21
+
22
+ export const STRIPE_ACTION_PACK = Object.freeze([
23
+ Object.freeze({
24
+ id: 'stripe.payout.create', label: 'Stripe payout', action_type: 'stripe.payout.create',
25
+ risk: 'critical', receipt_required: true, assurance_class: 'class_a',
26
+ match: { protocol: 'stripe', tool: 'create_payout' },
27
+ why: 'Moves money out. Bind amount/currency/destination to a named human approval.',
28
+ execution_binding: { required_fields: ['action_type', 'amount', 'currency', 'destination'] },
29
+ }),
30
+ Object.freeze({
31
+ id: 'stripe.refund.create', label: 'Stripe refund', action_type: 'stripe.refund.create',
32
+ risk: 'high', receipt_required: true, assurance_class: 'class_a',
33
+ match: { protocol: 'stripe', tool: 'create_refund' },
34
+ why: 'Returns funds. Bind the payment and amount so a refund cannot be silently inflated.',
35
+ execution_binding: { required_fields: ['action_type', 'payment_intent', 'amount'] },
36
+ }),
37
+ Object.freeze({
38
+ id: 'stripe.bank_account.change', label: 'Stripe payout-destination change', action_type: 'stripe.bank_account.change',
39
+ risk: 'critical', receipt_required: true, assurance_class: 'quorum',
40
+ match: { protocol: 'stripe', tool: 'update_external_account' },
41
+ why: 'Changes WHERE future money flows. Quorum: the classic redirect-the-payouts attack.',
42
+ execution_binding: { required_fields: ['action_type', 'account', 'external_account'] },
43
+ }),
44
+ ]);
45
+
46
+ const OPS = {
47
+ 'payout.create': {
48
+ selector: { protocol: 'stripe', tool: 'create_payout' },
49
+ observed: (p) => ({ action_type: 'stripe.payout.create', amount: p.amount, currency: p.currency, destination: p.destination }),
50
+ perform: (stripe, p) => stripe.payouts.create({ amount: p.amount, currency: p.currency, destination: p.destination }),
51
+ },
52
+ 'refund.create': {
53
+ selector: { protocol: 'stripe', tool: 'create_refund' },
54
+ observed: (p) => ({ action_type: 'stripe.refund.create', payment_intent: p.payment_intent, amount: p.amount }),
55
+ perform: (stripe, p) => stripe.refunds.create({ payment_intent: p.payment_intent, amount: p.amount }),
56
+ },
57
+ 'bank_account.change': {
58
+ selector: { protocol: 'stripe', tool: 'update_external_account' },
59
+ observed: (p) => ({ action_type: 'stripe.bank_account.change', account: p.account, external_account: p.external_account }),
60
+ perform: (stripe, p) => stripe.accounts.updateExternalAccount(p.account, p.external_account, p.update || {}),
61
+ },
62
+ };
63
+
64
+ const adapter = createAdapter({ system: 'stripe', ops: OPS });
65
+ export const STRIPE_OPS = adapter.OPS;
66
+
67
+ export function createStripeManifest(extraActions = []) {
68
+ return manifestFromPack(STRIPE_ACTION_PACK, extraActions);
69
+ }
70
+
71
+ /**
72
+ * Guard a destructive Stripe mutation behind the gate.
73
+ * @param {object} gate a gate built with createStripeManifest()
74
+ * @param {object} stripe a Stripe-like client (the official `stripe` SDK or compatible)
75
+ * @param {object} args { op:'payout.create'|'refund.create'|'bank_account.change', params, receipt }
76
+ * @throws Error{code:'EMILIA_RECEIPT_REQUIRED'} if refused — the call never reaches Stripe
77
+ */
78
+ export function guardStripeMutation(gate, stripe, args) {
79
+ return adapter.guard(gate, stripe, args);
80
+ }
81
+
82
+ export default { STRIPE_ACTION_PACK, STRIPE_OPS, createStripeManifest, guardStripeMutation };
@@ -0,0 +1,122 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ /**
3
+ * EMILIA Gate — Supabase / Postgres System-of-Record adapter.
4
+ *
5
+ * "Install this before your agent can run destructive SQL." Wraps the dangerous
6
+ * database operations — destructive SQL (DELETE/DROP/TRUNCATE/UPDATE), bulk
7
+ * export, and RLS-policy change — so they never execute without a valid,
8
+ * sufficiently-assured, non-replayed receipt bound to THIS statement/table. The
9
+ * exact statement is bound by hash, so an approval for one DELETE cannot be
10
+ * swapped for a DROP.
11
+ *
12
+ * import { createGate } from '@emilia-protocol/gate';
13
+ * import { createSupabaseManifest, guardSupabaseMutation, isDestructiveSql } from '@emilia-protocol/gate/adapters/supabase';
14
+ *
15
+ * const gate = createGate({ manifest: createSupabaseManifest(), trustedKeys: [ISSUER], store: sharedConsumptionStore });
16
+ * // client: anything with .query(sql) (node-postgres / a Supabase RPC wrapper).
17
+ * await guardSupabaseMutation(gate, client, {
18
+ * op: 'sql.destructive', params: { sql: 'DELETE FROM payments WHERE id=1', table: 'payments' }, receipt,
19
+ * });
20
+ */
21
+ import { createAdapter, manifestFromPack, hashCanonical } from './_kit.js';
22
+
23
+ export const RLS_DEFINITION_BINDING_VERSION = 'EP-SUPABASE-RLS-DEFINITION-v1';
24
+
25
+ const DESTRUCTIVE = /\b(delete|drop|truncate|alter\s+table)\b/i;
26
+ const UPDATE_NO_WHERE = /\bupdate\b(?:(?!\bwhere\b).)*$/is;
27
+
28
+ /** Heuristic: is this SQL destructive (DELETE/DROP/TRUNCATE/ALTER, or UPDATE without WHERE)? */
29
+ export function isDestructiveSql(sql) {
30
+ const s = String(sql || '');
31
+ return DESTRUCTIVE.test(s) || UPDATE_NO_WHERE.test(s.trim());
32
+ }
33
+
34
+ /** Canonical hash of a SQL statement, whitespace-collapsed and lowercased. */
35
+ export function statementHash(sql) {
36
+ return hashCanonical(String(sql || '').replace(/\s+/g, ' ').trim().toLowerCase());
37
+ }
38
+
39
+ /** Digest the exact canonical RLS definition without placing it in evidence. */
40
+ export function rlsDefinitionDigest(definition) {
41
+ return hashCanonical({
42
+ version: RLS_DEFINITION_BINDING_VERSION,
43
+ definition,
44
+ });
45
+ }
46
+
47
+ export const SUPABASE_ACTION_PACK = Object.freeze([
48
+ Object.freeze({
49
+ id: 'supabase.sql.destructive', label: 'Destructive SQL', action_type: 'supabase.sql.destructive',
50
+ risk: 'critical', receipt_required: true, assurance_class: 'class_a',
51
+ match: { protocol: 'supabase', tool: 'execute_sql' },
52
+ why: 'DELETE/DROP/TRUNCATE/ALTER destroys or rewrites system-of-record state. Bind the exact statement.',
53
+ execution_binding: { required_fields: ['action_type', 'statement_hash'] },
54
+ }),
55
+ Object.freeze({
56
+ id: 'supabase.data.export', label: 'Bulk data export', action_type: 'supabase.data.export',
57
+ risk: 'high', receipt_required: true, assurance_class: 'class_a',
58
+ match: { protocol: 'supabase', tool: 'export_table' },
59
+ why: 'Moves data out of its system of record. Bind table + recipient to the approval.',
60
+ execution_binding: { required_fields: ['action_type', 'table', 'recipient'] },
61
+ }),
62
+ Object.freeze({
63
+ id: 'supabase.rls.change', label: 'RLS policy change', action_type: 'supabase.rls.change',
64
+ risk: 'critical', receipt_required: true, assurance_class: 'quorum',
65
+ match: { protocol: 'supabase', tool: 'alter_policy' },
66
+ why: 'Changes who can read/write rows. Row-Level-Security changes deserve the two-person rule.',
67
+ execution_binding: {
68
+ required_fields: [
69
+ 'action_type', 'table', 'policy', 'rls_definition_digest', 'rls_definition_version',
70
+ ],
71
+ },
72
+ }),
73
+ ]);
74
+
75
+ const OPS = {
76
+ 'sql.destructive': {
77
+ selector: { protocol: 'supabase', tool: 'execute_sql' },
78
+ observed: (p) => ({ action_type: 'supabase.sql.destructive', statement_hash: statementHash(p.sql) }),
79
+ actuator: (p, observed) => ({ ...observed, sql: p.sql }),
80
+ perform: (client, p) => client.query(p.sql),
81
+ },
82
+ 'data.export': {
83
+ selector: { protocol: 'supabase', tool: 'export_table' },
84
+ observed: (p) => ({ action_type: 'supabase.data.export', table: p.table, recipient: p.recipient }),
85
+ perform: (client, p) => client.export(p.table, p.recipient),
86
+ },
87
+ 'rls.change': {
88
+ selector: { protocol: 'supabase', tool: 'alter_policy' },
89
+ observed: (p) => ({
90
+ action_type: 'supabase.rls.change',
91
+ table: p.table,
92
+ policy: p.policy,
93
+ rls_definition_digest: rlsDefinitionDigest(p.definition),
94
+ rls_definition_version: RLS_DEFINITION_BINDING_VERSION,
95
+ }),
96
+ actuator: (p, observed) => ({ ...observed, definition: p.definition }),
97
+ perform: (client, p) => client.alterPolicy(p.table, p.policy, p.definition),
98
+ },
99
+ };
100
+
101
+ const adapter = createAdapter({ system: 'supabase', ops: OPS });
102
+ export const SUPABASE_OPS = adapter.OPS;
103
+
104
+ export function createSupabaseManifest(extraActions = []) {
105
+ return manifestFromPack(SUPABASE_ACTION_PACK, extraActions);
106
+ }
107
+
108
+ /**
109
+ * Guard a destructive Supabase/Postgres mutation behind the gate.
110
+ * @param {object} gate a gate built with createSupabaseManifest()
111
+ * @param {object} client a client exposing { query(sql), export(table,recipient), alterPolicy(table,policy,def) }
112
+ * @param {object} args { op:'sql.destructive'|'data.export'|'rls.change', params, receipt }
113
+ * @throws Error{code:'EMILIA_RECEIPT_REQUIRED'} if refused — the statement never executes
114
+ */
115
+ export function guardSupabaseMutation(gate, client, args) {
116
+ return adapter.guard(gate, client, args);
117
+ }
118
+
119
+ export default {
120
+ SUPABASE_ACTION_PACK, SUPABASE_OPS, createSupabaseManifest, guardSupabaseMutation,
121
+ isDestructiveSql, statementHash, rlsDefinitionDigest, RLS_DEFINITION_BINDING_VERSION,
122
+ };
@@ -0,0 +1,60 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ /**
3
+ * EMILIA Gate — Terraform System-of-Record adapter.
4
+ *
5
+ * "Install this before your agent can destroy infrastructure." Guards the
6
+ * irreversible Terraform operations — destroy, state rm, workspace delete — so
7
+ * they never run without a receipt bound to THIS workspace/plan. The destroy
8
+ * plan is bound by hash, so an approved small destroy cannot be swapped for a
9
+ * full teardown. Runner is injected (a `terraform`/`tofu` CLI wrapper or Cloud
10
+ * API client).
11
+ */
12
+ import { createAdapter, manifestFromPack } from './_kit.js';
13
+
14
+ export const TERRAFORM_ACTION_PACK = Object.freeze([
15
+ Object.freeze({
16
+ id: 'terraform.apply.destroy', label: 'Terraform destroy', action_type: 'terraform.apply.destroy',
17
+ risk: 'critical', receipt_required: true, assurance_class: 'quorum',
18
+ match: { protocol: 'terraform', tool: 'destroy' },
19
+ why: 'Tears down real infrastructure. Bind the workspace + plan hash; quorum.',
20
+ execution_binding: { required_fields: ['action_type', 'workspace', 'plan_hash'] },
21
+ }),
22
+ Object.freeze({
23
+ id: 'terraform.state.rm', label: 'Terraform state rm', action_type: 'terraform.state.rm',
24
+ risk: 'high', receipt_required: true, assurance_class: 'class_a',
25
+ match: { protocol: 'terraform', tool: 'state_rm' },
26
+ why: 'Detaches a resource from state (orphans real infra). Bind workspace+address.',
27
+ execution_binding: { required_fields: ['action_type', 'workspace', 'address'] },
28
+ }),
29
+ Object.freeze({
30
+ id: 'terraform.workspace.delete', label: 'Terraform workspace delete', action_type: 'terraform.workspace.delete',
31
+ risk: 'high', receipt_required: true, assurance_class: 'class_a',
32
+ match: { protocol: 'terraform', tool: 'workspace_delete' },
33
+ why: 'Deletes a workspace and its state. Bind the workspace.',
34
+ execution_binding: { required_fields: ['action_type', 'workspace'] },
35
+ }),
36
+ ]);
37
+
38
+ const OPS = {
39
+ 'apply.destroy': {
40
+ selector: { protocol: 'terraform', tool: 'destroy' },
41
+ observed: (p) => ({ action_type: 'terraform.apply.destroy', workspace: p.workspace, plan_hash: p.plan_hash }),
42
+ perform: (r, p) => r.destroy({ workspace: p.workspace, plan_hash: p.plan_hash }),
43
+ },
44
+ 'state.rm': {
45
+ selector: { protocol: 'terraform', tool: 'state_rm' },
46
+ observed: (p) => ({ action_type: 'terraform.state.rm', workspace: p.workspace, address: p.address }),
47
+ perform: (r, p) => r.stateRm({ workspace: p.workspace, address: p.address }),
48
+ },
49
+ 'workspace.delete': {
50
+ selector: { protocol: 'terraform', tool: 'workspace_delete' },
51
+ observed: (p) => ({ action_type: 'terraform.workspace.delete', workspace: p.workspace }),
52
+ perform: (r, p) => r.workspaceDelete({ workspace: p.workspace }),
53
+ },
54
+ };
55
+
56
+ const adapter = createAdapter({ system: 'terraform', ops: OPS });
57
+ export const TERRAFORM_OPS = adapter.OPS;
58
+ export function createTerraformManifest(extraActions = []) { return manifestFromPack(TERRAFORM_ACTION_PACK, extraActions); }
59
+ export function guardTerraformMutation(gate, runner, args) { return adapter.guard(gate, runner, args); }
60
+ export default { TERRAFORM_ACTION_PACK, TERRAFORM_OPS, createTerraformManifest, guardTerraformMutation };