@usesigil/kit 0.15.0 → 0.17.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 (627) hide show
  1. package/README.md +56 -0
  2. package/dist/advanced-analytics.d.ts +3 -2
  3. package/dist/advanced-analytics.d.ts.map +1 -1
  4. package/dist/advanced-analytics.js +9 -42
  5. package/dist/advanced-analytics.js.map +1 -1
  6. package/dist/agent-bootstrap.d.ts +117 -0
  7. package/dist/agent-bootstrap.d.ts.map +1 -0
  8. package/dist/agent-bootstrap.js +211 -0
  9. package/dist/agent-bootstrap.js.map +1 -0
  10. package/dist/agent-errors.d.ts +20 -4
  11. package/dist/agent-errors.d.ts.map +1 -1
  12. package/dist/agent-errors.js +947 -377
  13. package/dist/agent-errors.js.map +1 -1
  14. package/dist/audit-log.d.ts +101 -0
  15. package/dist/audit-log.d.ts.map +1 -0
  16. package/dist/audit-log.js +145 -0
  17. package/dist/audit-log.js.map +1 -0
  18. package/dist/build-unsigned.d.ts +152 -0
  19. package/dist/build-unsigned.d.ts.map +1 -0
  20. package/dist/build-unsigned.js +152 -0
  21. package/dist/build-unsigned.js.map +1 -0
  22. package/dist/caip2-network.d.ts +171 -0
  23. package/dist/caip2-network.d.ts.map +1 -0
  24. package/dist/caip2-network.js +202 -0
  25. package/dist/caip2-network.js.map +1 -0
  26. package/dist/canonical-encode.d.ts +59 -0
  27. package/dist/canonical-encode.d.ts.map +1 -0
  28. package/dist/canonical-encode.js +141 -0
  29. package/dist/canonical-encode.js.map +1 -0
  30. package/dist/cosign-helper.d.ts +264 -0
  31. package/dist/cosign-helper.d.ts.map +1 -0
  32. package/dist/cosign-helper.js +147 -0
  33. package/dist/cosign-helper.js.map +1 -0
  34. package/dist/create-vault.d.ts +102 -1
  35. package/dist/create-vault.d.ts.map +1 -1
  36. package/dist/create-vault.js +108 -9
  37. package/dist/create-vault.js.map +1 -1
  38. package/dist/dashboard/close-vault.d.ts +110 -0
  39. package/dist/dashboard/close-vault.d.ts.map +1 -0
  40. package/dist/dashboard/close-vault.js +165 -0
  41. package/dist/dashboard/close-vault.js.map +1 -0
  42. package/dist/dashboard/errors.d.ts +37 -0
  43. package/dist/dashboard/errors.d.ts.map +1 -1
  44. package/dist/dashboard/errors.js +81 -1
  45. package/dist/dashboard/errors.js.map +1 -1
  46. package/dist/dashboard/from-json.d.ts.map +1 -1
  47. package/dist/dashboard/from-json.js +1 -2
  48. package/dist/dashboard/from-json.js.map +1 -1
  49. package/dist/dashboard/index.d.ts +204 -31
  50. package/dist/dashboard/index.d.ts.map +1 -1
  51. package/dist/dashboard/index.js +290 -49
  52. package/dist/dashboard/index.js.map +1 -1
  53. package/dist/dashboard/mutations.d.ts +160 -10
  54. package/dist/dashboard/mutations.d.ts.map +1 -1
  55. package/dist/dashboard/mutations.js +584 -66
  56. package/dist/dashboard/mutations.js.map +1 -1
  57. package/dist/dashboard/post-assertion-validation.d.ts +88 -0
  58. package/dist/dashboard/post-assertion-validation.d.ts.map +1 -0
  59. package/dist/dashboard/post-assertion-validation.js +312 -0
  60. package/dist/dashboard/post-assertion-validation.js.map +1 -0
  61. package/dist/dashboard/reads.d.ts +92 -1
  62. package/dist/dashboard/reads.d.ts.map +1 -1
  63. package/dist/dashboard/reads.js +244 -26
  64. package/dist/dashboard/reads.js.map +1 -1
  65. package/dist/dashboard/types.d.ts +172 -21
  66. package/dist/dashboard/types.d.ts.map +1 -1
  67. package/dist/errors/agent-errors.generated.d.ts +21 -0
  68. package/dist/errors/agent-errors.generated.d.ts.map +1 -0
  69. package/dist/errors/agent-errors.generated.js +133 -0
  70. package/dist/errors/agent-errors.generated.js.map +1 -0
  71. package/dist/errors/codes.d.ts +21 -2
  72. package/dist/errors/codes.d.ts.map +1 -1
  73. package/dist/errors/codes.js +20 -1
  74. package/dist/errors/codes.js.map +1 -1
  75. package/dist/errors/context.d.ts +9 -1
  76. package/dist/errors/context.d.ts.map +1 -1
  77. package/dist/event-analytics.d.ts +1 -3
  78. package/dist/event-analytics.d.ts.map +1 -1
  79. package/dist/event-analytics.js +28 -81
  80. package/dist/event-analytics.js.map +1 -1
  81. package/dist/events.d.ts.map +1 -1
  82. package/dist/events.js +23 -13
  83. package/dist/events.js.map +1 -1
  84. package/dist/generated/accounts/agentSpendOverlay.d.ts +60 -0
  85. package/dist/generated/accounts/agentSpendOverlay.d.ts.map +1 -1
  86. package/dist/generated/accounts/agentSpendOverlay.js +6 -2
  87. package/dist/generated/accounts/agentSpendOverlay.js.map +1 -1
  88. package/dist/generated/accounts/agentVault.d.ts +168 -4
  89. package/dist/generated/accounts/agentVault.d.ts.map +1 -1
  90. package/dist/generated/accounts/agentVault.js +11 -3
  91. package/dist/generated/accounts/agentVault.js.map +1 -1
  92. package/dist/generated/accounts/auditLogRejected.d.ts +66 -0
  93. package/dist/generated/accounts/auditLogRejected.d.ts.map +1 -0
  94. package/dist/generated/accounts/auditLogRejected.js +68 -0
  95. package/dist/generated/accounts/auditLogRejected.js.map +1 -0
  96. package/dist/generated/accounts/auditLogSuccess.d.ts +78 -0
  97. package/dist/generated/accounts/auditLogSuccess.d.ts.map +1 -0
  98. package/dist/generated/accounts/auditLogSuccess.js +68 -0
  99. package/dist/generated/accounts/auditLogSuccess.js.map +1 -0
  100. package/dist/generated/accounts/index.d.ts +4 -4
  101. package/dist/generated/accounts/index.d.ts.map +1 -1
  102. package/dist/generated/accounts/index.js +4 -4
  103. package/dist/generated/accounts/index.js.map +1 -1
  104. package/dist/generated/accounts/pendingAgentGrant.d.ts +199 -0
  105. package/dist/generated/accounts/pendingAgentGrant.d.ts.map +1 -0
  106. package/dist/generated/accounts/pendingAgentGrant.js +75 -0
  107. package/dist/generated/accounts/pendingAgentGrant.js.map +1 -0
  108. package/dist/generated/accounts/pendingAgentPermissionsUpdate.d.ts +76 -0
  109. package/dist/generated/accounts/pendingAgentPermissionsUpdate.d.ts.map +1 -1
  110. package/dist/generated/accounts/pendingAgentPermissionsUpdate.js +9 -1
  111. package/dist/generated/accounts/pendingAgentPermissionsUpdate.js.map +1 -1
  112. package/dist/generated/accounts/pendingOwnershipTransfer.d.ts +131 -0
  113. package/dist/generated/accounts/pendingOwnershipTransfer.d.ts.map +1 -0
  114. package/dist/generated/accounts/pendingOwnershipTransfer.js +76 -0
  115. package/dist/generated/accounts/pendingOwnershipTransfer.js.map +1 -0
  116. package/dist/generated/accounts/pendingPolicyUpdate.d.ts +220 -4
  117. package/dist/generated/accounts/pendingPolicyUpdate.d.ts.map +1 -1
  118. package/dist/generated/accounts/pendingPolicyUpdate.js +25 -5
  119. package/dist/generated/accounts/pendingPolicyUpdate.js.map +1 -1
  120. package/dist/generated/accounts/policyConfig.d.ts +495 -34
  121. package/dist/generated/accounts/policyConfig.d.ts.map +1 -1
  122. package/dist/generated/accounts/policyConfig.js +34 -7
  123. package/dist/generated/accounts/policyConfig.js.map +1 -1
  124. package/dist/generated/accounts/postExecutionAssertions.d.ts +2 -2
  125. package/dist/generated/accounts/postExecutionAssertions.d.ts.map +1 -1
  126. package/dist/generated/accounts/postExecutionAssertions.js +3 -3
  127. package/dist/generated/accounts/sessionAuthority.d.ts +154 -12
  128. package/dist/generated/accounts/sessionAuthority.d.ts.map +1 -1
  129. package/dist/generated/accounts/sessionAuthority.js +12 -10
  130. package/dist/generated/accounts/sessionAuthority.js.map +1 -1
  131. package/dist/generated/accounts/spendTracker.d.ts +83 -3
  132. package/dist/generated/accounts/spendTracker.d.ts.map +1 -1
  133. package/dist/generated/accounts/spendTracker.js +14 -2
  134. package/dist/generated/accounts/spendTracker.js.map +1 -1
  135. package/dist/generated/errors/sigil.d.ts +160 -100
  136. package/dist/generated/errors/sigil.d.ts.map +1 -1
  137. package/dist/generated/errors/sigil.js +214 -124
  138. package/dist/generated/errors/sigil.js.map +1 -1
  139. package/dist/generated/event-discriminators.d.ts.map +1 -1
  140. package/dist/generated/event-discriminators.js +11 -13
  141. package/dist/generated/event-discriminators.js.map +1 -1
  142. package/dist/generated/instructions/acceptOwnershipTransfer.d.ts +142 -0
  143. package/dist/generated/instructions/acceptOwnershipTransfer.d.ts.map +1 -0
  144. package/dist/generated/instructions/acceptOwnershipTransfer.js +171 -0
  145. package/dist/generated/instructions/acceptOwnershipTransfer.js.map +1 -0
  146. package/dist/generated/instructions/acceptOwnershipTransferMultisig.d.ts +142 -0
  147. package/dist/generated/instructions/acceptOwnershipTransferMultisig.d.ts.map +1 -0
  148. package/dist/generated/instructions/acceptOwnershipTransferMultisig.js +171 -0
  149. package/dist/generated/instructions/acceptOwnershipTransferMultisig.js.map +1 -0
  150. package/dist/generated/instructions/applyAgentGrant.d.ts +100 -0
  151. package/dist/generated/instructions/applyAgentGrant.d.ts.map +1 -0
  152. package/dist/generated/instructions/{applyConstraintsUpdate.js → applyAgentGrant.js} +66 -42
  153. package/dist/generated/instructions/applyAgentGrant.js.map +1 -0
  154. package/dist/generated/instructions/applyAgentPermissionsUpdate.d.ts +31 -8
  155. package/dist/generated/instructions/applyAgentPermissionsUpdate.d.ts.map +1 -1
  156. package/dist/generated/instructions/applyAgentPermissionsUpdate.js +38 -2
  157. package/dist/generated/instructions/applyAgentPermissionsUpdate.js.map +1 -1
  158. package/dist/generated/instructions/applyPendingPolicy.d.ts +18 -7
  159. package/dist/generated/instructions/applyPendingPolicy.d.ts.map +1 -1
  160. package/dist/generated/instructions/applyPendingPolicy.js +38 -2
  161. package/dist/generated/instructions/applyPendingPolicy.js.map +1 -1
  162. package/dist/generated/instructions/cancelAgentGrant.d.ts +106 -0
  163. package/dist/generated/instructions/cancelAgentGrant.d.ts.map +1 -0
  164. package/dist/generated/instructions/{allocatePendingConstraintsPda.js → cancelAgentGrant.js} +54 -42
  165. package/dist/generated/instructions/cancelAgentGrant.js.map +1 -0
  166. package/dist/generated/instructions/cancelOwnershipTransfer.d.ts +121 -0
  167. package/dist/generated/instructions/cancelOwnershipTransfer.d.ts.map +1 -0
  168. package/dist/generated/instructions/{queueCloseConstraints.js → cancelOwnershipTransfer.js} +58 -44
  169. package/dist/generated/instructions/cancelOwnershipTransfer.js.map +1 -0
  170. package/dist/generated/instructions/closePostAssertions.d.ts +6 -1
  171. package/dist/generated/instructions/closePostAssertions.d.ts.map +1 -1
  172. package/dist/generated/instructions/closePostAssertions.js +11 -3
  173. package/dist/generated/instructions/closePostAssertions.js.map +1 -1
  174. package/dist/generated/instructions/closeVault.d.ts +40 -8
  175. package/dist/generated/instructions/closeVault.d.ts.map +1 -1
  176. package/dist/generated/instructions/closeVault.js +40 -2
  177. package/dist/generated/instructions/closeVault.js.map +1 -1
  178. package/dist/generated/instructions/createPostAssertions.d.ts +4 -0
  179. package/dist/generated/instructions/createPostAssertions.d.ts.map +1 -1
  180. package/dist/generated/instructions/createPostAssertions.js +2 -0
  181. package/dist/generated/instructions/createPostAssertions.js.map +1 -1
  182. package/dist/generated/instructions/depositFunds.d.ts +21 -10
  183. package/dist/generated/instructions/depositFunds.d.ts.map +1 -1
  184. package/dist/generated/instructions/depositFunds.js +37 -2
  185. package/dist/generated/instructions/depositFunds.js.map +1 -1
  186. package/dist/generated/instructions/finalizeSession.d.ts +49 -7
  187. package/dist/generated/instructions/finalizeSession.d.ts.map +1 -1
  188. package/dist/generated/instructions/finalizeSession.js +59 -2
  189. package/dist/generated/instructions/finalizeSession.js.map +1 -1
  190. package/dist/generated/instructions/freezeVault.d.ts +39 -5
  191. package/dist/generated/instructions/freezeVault.d.ts.map +1 -1
  192. package/dist/generated/instructions/freezeVault.js +77 -5
  193. package/dist/generated/instructions/freezeVault.js.map +1 -1
  194. package/dist/generated/instructions/index.d.ts +10 -14
  195. package/dist/generated/instructions/index.d.ts.map +1 -1
  196. package/dist/generated/instructions/index.js +10 -14
  197. package/dist/generated/instructions/index.js.map +1 -1
  198. package/dist/generated/instructions/initializeVault.d.ts +79 -13
  199. package/dist/generated/instructions/initializeVault.d.ts.map +1 -1
  200. package/dist/generated/instructions/initializeVault.js +57 -5
  201. package/dist/generated/instructions/initializeVault.js.map +1 -1
  202. package/dist/generated/instructions/initiateOwnershipTransfer.d.ts +106 -0
  203. package/dist/generated/instructions/initiateOwnershipTransfer.d.ts.map +1 -0
  204. package/dist/generated/instructions/initiateOwnershipTransfer.js +181 -0
  205. package/dist/generated/instructions/initiateOwnershipTransfer.js.map +1 -0
  206. package/dist/generated/instructions/pauseAgent.d.ts +49 -5
  207. package/dist/generated/instructions/pauseAgent.d.ts.map +1 -1
  208. package/dist/generated/instructions/pauseAgent.js +80 -5
  209. package/dist/generated/instructions/pauseAgent.js.map +1 -1
  210. package/dist/generated/instructions/promoteGraylistDestination.d.ts +56 -0
  211. package/dist/generated/instructions/promoteGraylistDestination.d.ts.map +1 -0
  212. package/dist/generated/instructions/{createInstructionConstraints.js → promoteGraylistDestination.js} +23 -40
  213. package/dist/generated/instructions/promoteGraylistDestination.js.map +1 -0
  214. package/dist/generated/instructions/queueAgentGrant.d.ts +113 -0
  215. package/dist/generated/instructions/queueAgentGrant.d.ts.map +1 -0
  216. package/dist/generated/instructions/queueAgentGrant.js +181 -0
  217. package/dist/generated/instructions/queueAgentGrant.js.map +1 -0
  218. package/dist/generated/instructions/queueAgentPermissionsUpdate.d.ts +8 -0
  219. package/dist/generated/instructions/queueAgentPermissionsUpdate.d.ts.map +1 -1
  220. package/dist/generated/instructions/queueAgentPermissionsUpdate.js +4 -0
  221. package/dist/generated/instructions/queueAgentPermissionsUpdate.js.map +1 -1
  222. package/dist/generated/instructions/queuePolicyUpdate.d.ts +40 -8
  223. package/dist/generated/instructions/queuePolicyUpdate.d.ts.map +1 -1
  224. package/dist/generated/instructions/queuePolicyUpdate.js +21 -5
  225. package/dist/generated/instructions/queuePolicyUpdate.js.map +1 -1
  226. package/dist/generated/instructions/reactivateVault.d.ts +71 -5
  227. package/dist/generated/instructions/reactivateVault.d.ts.map +1 -1
  228. package/dist/generated/instructions/reactivateVault.js +80 -5
  229. package/dist/generated/instructions/reactivateVault.js.map +1 -1
  230. package/dist/generated/instructions/recordAgentViolation.d.ts +89 -0
  231. package/dist/generated/instructions/recordAgentViolation.d.ts.map +1 -0
  232. package/dist/generated/instructions/recordAgentViolation.js +152 -0
  233. package/dist/generated/instructions/recordAgentViolation.js.map +1 -0
  234. package/dist/generated/instructions/registerAgent.d.ts +84 -6
  235. package/dist/generated/instructions/registerAgent.d.ts.map +1 -1
  236. package/dist/generated/instructions/registerAgent.js +81 -4
  237. package/dist/generated/instructions/registerAgent.js.map +1 -1
  238. package/dist/generated/instructions/revokeAgent.d.ts +49 -6
  239. package/dist/generated/instructions/revokeAgent.d.ts.map +1 -1
  240. package/dist/generated/instructions/revokeAgent.js +81 -4
  241. package/dist/generated/instructions/revokeAgent.js.map +1 -1
  242. package/dist/generated/instructions/setObserveOnly.d.ts +56 -0
  243. package/dist/generated/instructions/setObserveOnly.d.ts.map +1 -0
  244. package/dist/generated/instructions/setObserveOnly.js +111 -0
  245. package/dist/generated/instructions/setObserveOnly.js.map +1 -0
  246. package/dist/generated/instructions/unpauseAgent.d.ts +46 -5
  247. package/dist/generated/instructions/unpauseAgent.d.ts.map +1 -1
  248. package/dist/generated/instructions/unpauseAgent.js +80 -5
  249. package/dist/generated/instructions/unpauseAgent.js.map +1 -1
  250. package/dist/generated/instructions/validateAndAuthorize.d.ts +29 -0
  251. package/dist/generated/instructions/validateAndAuthorize.d.ts.map +1 -1
  252. package/dist/generated/instructions/validateAndAuthorize.js +4 -0
  253. package/dist/generated/instructions/validateAndAuthorize.js.map +1 -1
  254. package/dist/generated/instructions/withdrawFunds.d.ts +53 -11
  255. package/dist/generated/instructions/withdrawFunds.d.ts.map +1 -1
  256. package/dist/generated/instructions/withdrawFunds.js +51 -2
  257. package/dist/generated/instructions/withdrawFunds.js.map +1 -1
  258. package/dist/generated/programs/sigil.d.ts +79 -95
  259. package/dist/generated/programs/sigil.d.ts.map +1 -1
  260. package/dist/generated/programs/sigil.js +139 -187
  261. package/dist/generated/programs/sigil.js.map +1 -1
  262. package/dist/generated/types/actionAuthorized.d.ts +0 -2
  263. package/dist/generated/types/actionAuthorized.d.ts.map +1 -1
  264. package/dist/generated/types/actionAuthorized.js +0 -2
  265. package/dist/generated/types/actionAuthorized.js.map +1 -1
  266. package/dist/generated/types/agentAutoRevoked.d.ts +31 -0
  267. package/dist/generated/types/agentAutoRevoked.d.ts.map +1 -0
  268. package/dist/generated/types/{pdaAllocated.js → agentAutoRevoked.js} +12 -10
  269. package/dist/generated/types/agentAutoRevoked.js.map +1 -0
  270. package/dist/generated/types/agentEntry.d.ts +48 -0
  271. package/dist/generated/types/agentEntry.d.ts.map +1 -1
  272. package/dist/generated/types/agentEntry.js +4 -2
  273. package/dist/generated/types/agentEntry.js.map +1 -1
  274. package/dist/generated/types/agentGrantApplied.d.ts +38 -0
  275. package/dist/generated/types/agentGrantApplied.d.ts.map +1 -0
  276. package/dist/generated/types/agentGrantApplied.js +34 -0
  277. package/dist/generated/types/agentGrantApplied.js.map +1 -0
  278. package/dist/generated/types/agentGrantCancelled.d.ts +33 -0
  279. package/dist/generated/types/agentGrantCancelled.d.ts.map +1 -0
  280. package/dist/generated/types/agentGrantCancelled.js +28 -0
  281. package/dist/generated/types/agentGrantCancelled.js.map +1 -0
  282. package/dist/generated/types/agentGrantQueued.d.ts +38 -0
  283. package/dist/generated/types/agentGrantQueued.d.ts.map +1 -0
  284. package/dist/generated/types/agentGrantQueued.js +32 -0
  285. package/dist/generated/types/agentGrantQueued.js.map +1 -0
  286. package/dist/generated/types/auditEntry.d.ts +120 -0
  287. package/dist/generated/types/auditEntry.d.ts.map +1 -0
  288. package/dist/generated/types/auditEntry.js +34 -0
  289. package/dist/generated/types/auditEntry.js.map +1 -0
  290. package/dist/generated/types/destinationGraylistEntry.d.ts +32 -0
  291. package/dist/generated/types/destinationGraylistEntry.d.ts.map +1 -0
  292. package/dist/generated/types/destinationGraylistEntry.js +24 -0
  293. package/dist/generated/types/destinationGraylistEntry.js.map +1 -0
  294. package/dist/generated/types/graylistEntered.d.ts +31 -0
  295. package/dist/generated/types/graylistEntered.d.ts.map +1 -0
  296. package/dist/generated/types/graylistEntered.js +30 -0
  297. package/dist/generated/types/graylistEntered.js.map +1 -0
  298. package/dist/generated/types/graylistPromoted.d.ts +29 -0
  299. package/dist/generated/types/graylistPromoted.d.ts.map +1 -0
  300. package/dist/generated/types/graylistPromoted.js +28 -0
  301. package/dist/generated/types/graylistPromoted.js.map +1 -0
  302. package/dist/generated/types/index.d.ts +13 -21
  303. package/dist/generated/types/index.d.ts.map +1 -1
  304. package/dist/generated/types/index.js +13 -21
  305. package/dist/generated/types/index.js.map +1 -1
  306. package/dist/generated/types/observeOnlyChanged.d.ts +33 -0
  307. package/dist/generated/types/observeOnlyChanged.d.ts.map +1 -0
  308. package/dist/generated/types/observeOnlyChanged.js +32 -0
  309. package/dist/generated/types/observeOnlyChanged.js.map +1 -0
  310. package/dist/generated/types/ownershipTransferAccepted.d.ts +32 -0
  311. package/dist/generated/types/ownershipTransferAccepted.d.ts.map +1 -0
  312. package/dist/generated/types/ownershipTransferAccepted.js +30 -0
  313. package/dist/generated/types/ownershipTransferAccepted.js.map +1 -0
  314. package/dist/generated/types/ownershipTransferCancelled.d.ts +29 -0
  315. package/dist/generated/types/ownershipTransferCancelled.d.ts.map +1 -0
  316. package/dist/generated/types/ownershipTransferCancelled.js +28 -0
  317. package/dist/generated/types/ownershipTransferCancelled.js.map +1 -0
  318. package/dist/generated/types/ownershipTransferInitiated.d.ts +33 -0
  319. package/dist/generated/types/ownershipTransferInitiated.d.ts.map +1 -0
  320. package/dist/generated/types/ownershipTransferInitiated.js +30 -0
  321. package/dist/generated/types/ownershipTransferInitiated.js.map +1 -0
  322. package/dist/generated/types/perRecipientCounter.d.ts +61 -0
  323. package/dist/generated/types/perRecipientCounter.d.ts.map +1 -0
  324. package/dist/generated/types/perRecipientCounter.js +26 -0
  325. package/dist/generated/types/perRecipientCounter.js.map +1 -0
  326. package/dist/generated/types/postAssertionEntry.d.ts +14 -7
  327. package/dist/generated/types/postAssertionEntry.d.ts.map +1 -1
  328. package/dist/generated/types/postAssertionEntry.js +5 -7
  329. package/dist/generated/types/postAssertionEntry.js.map +1 -1
  330. package/dist/generated/types/postAssertionEntryZC.d.ts +53 -22
  331. package/dist/generated/types/postAssertionEntryZC.d.ts.map +1 -1
  332. package/dist/generated/types/postAssertionEntryZC.js +4 -6
  333. package/dist/generated/types/postAssertionEntryZC.js.map +1 -1
  334. package/dist/generated/types/sessionFinalized.d.ts +0 -4
  335. package/dist/generated/types/sessionFinalized.d.ts.map +1 -1
  336. package/dist/generated/types/sessionFinalized.js +0 -2
  337. package/dist/generated/types/sessionFinalized.js.map +1 -1
  338. package/dist/generated/types/vaultFrozen.d.ts +26 -0
  339. package/dist/generated/types/vaultFrozen.d.ts.map +1 -1
  340. package/dist/generated/types/vaultFrozen.js +5 -1
  341. package/dist/generated/types/vaultFrozen.js.map +1 -1
  342. package/dist/index.d.ts +35 -6
  343. package/dist/index.d.ts.map +1 -1
  344. package/dist/index.js +81 -7
  345. package/dist/index.js.map +1 -1
  346. package/dist/inscribe.d.ts +0 -4
  347. package/dist/inscribe.d.ts.map +1 -1
  348. package/dist/inscribe.js +0 -1
  349. package/dist/inscribe.js.map +1 -1
  350. package/dist/inspector.d.ts +0 -23
  351. package/dist/inspector.d.ts.map +1 -1
  352. package/dist/inspector.js +0 -52
  353. package/dist/inspector.js.map +1 -1
  354. package/dist/kit-adapter.d.ts +1 -1
  355. package/dist/kit-adapter.d.ts.map +1 -1
  356. package/dist/kit-adapter.js +1 -1
  357. package/dist/kit-adapter.js.map +1 -1
  358. package/dist/logger.d.ts +48 -0
  359. package/dist/logger.d.ts.map +1 -1
  360. package/dist/logger.js +36 -0
  361. package/dist/logger.js.map +1 -1
  362. package/dist/multisig-detection.d.ts +83 -0
  363. package/dist/multisig-detection.d.ts.map +1 -0
  364. package/dist/multisig-detection.js +128 -0
  365. package/dist/multisig-detection.js.map +1 -0
  366. package/dist/owner-transaction.d.ts +8 -0
  367. package/dist/owner-transaction.d.ts.map +1 -1
  368. package/dist/owner-transaction.js +1 -0
  369. package/dist/owner-transaction.js.map +1 -1
  370. package/dist/ownership-transfer.d.ts +79 -0
  371. package/dist/ownership-transfer.d.ts.map +1 -0
  372. package/dist/ownership-transfer.js +66 -0
  373. package/dist/ownership-transfer.js.map +1 -0
  374. package/dist/policy/compute-cosign-digest.d.ts +193 -0
  375. package/dist/policy/compute-cosign-digest.d.ts.map +1 -0
  376. package/dist/policy/compute-cosign-digest.js +318 -0
  377. package/dist/policy/compute-cosign-digest.js.map +1 -0
  378. package/dist/policy/compute-policy-preview-digest.d.ts +258 -0
  379. package/dist/policy/compute-policy-preview-digest.d.ts.map +1 -0
  380. package/dist/policy/compute-policy-preview-digest.js +351 -0
  381. package/dist/policy/compute-policy-preview-digest.js.map +1 -0
  382. package/dist/policy-attestation.d.ts +51 -0
  383. package/dist/policy-attestation.d.ts.map +1 -0
  384. package/dist/policy-attestation.js +43 -0
  385. package/dist/policy-attestation.js.map +1 -0
  386. package/dist/presets.d.ts +1 -7
  387. package/dist/presets.d.ts.map +1 -1
  388. package/dist/presets.js +0 -5
  389. package/dist/presets.js.map +1 -1
  390. package/dist/preview-create-vault.d.ts +280 -0
  391. package/dist/preview-create-vault.d.ts.map +1 -0
  392. package/dist/preview-create-vault.js +498 -0
  393. package/dist/preview-create-vault.js.map +1 -0
  394. package/dist/resolve-accounts.d.ts +75 -10
  395. package/dist/resolve-accounts.d.ts.map +1 -1
  396. package/dist/resolve-accounts.js +68 -32
  397. package/dist/resolve-accounts.js.map +1 -1
  398. package/dist/rpc-helpers.d.ts +29 -3
  399. package/dist/rpc-helpers.d.ts.map +1 -1
  400. package/dist/rpc-helpers.js +51 -12
  401. package/dist/rpc-helpers.js.map +1 -1
  402. package/dist/seal/intent-digest.d.ts +195 -0
  403. package/dist/seal/intent-digest.d.ts.map +1 -0
  404. package/dist/seal/intent-digest.js +372 -0
  405. package/dist/seal/intent-digest.js.map +1 -0
  406. package/dist/seal.d.ts +166 -3
  407. package/dist/seal.d.ts.map +1 -1
  408. package/dist/seal.js +428 -8
  409. package/dist/seal.js.map +1 -1
  410. package/dist/security-analytics.d.ts +3 -3
  411. package/dist/security-analytics.d.ts.map +1 -1
  412. package/dist/security-analytics.js +13 -128
  413. package/dist/security-analytics.js.map +1 -1
  414. package/dist/session-mint.d.ts +72 -0
  415. package/dist/session-mint.d.ts.map +1 -0
  416. package/dist/session-mint.js +59 -0
  417. package/dist/session-mint.js.map +1 -0
  418. package/dist/sigil.d.ts +0 -4
  419. package/dist/sigil.d.ts.map +1 -1
  420. package/dist/simulation.d.ts +19 -0
  421. package/dist/simulation.d.ts.map +1 -1
  422. package/dist/simulation.js +211 -138
  423. package/dist/simulation.js.map +1 -1
  424. package/dist/squads-detection.d.ts +135 -0
  425. package/dist/squads-detection.d.ts.map +1 -0
  426. package/dist/squads-detection.js +124 -0
  427. package/dist/squads-detection.js.map +1 -0
  428. package/dist/state-resolver.d.ts +0 -16
  429. package/dist/state-resolver.d.ts.map +1 -1
  430. package/dist/state-resolver.js +162 -97
  431. package/dist/state-resolver.js.map +1 -1
  432. package/dist/testing/devnet.d.ts +40 -1
  433. package/dist/testing/devnet.d.ts.map +1 -1
  434. package/dist/testing/devnet.js +333 -45
  435. package/dist/testing/devnet.js.map +1 -1
  436. package/dist/testing/errors/expect.d.ts +137 -0
  437. package/dist/testing/errors/expect.d.ts.map +1 -0
  438. package/dist/testing/errors/expect.js +372 -0
  439. package/dist/testing/errors/expect.js.map +1 -0
  440. package/dist/testing/errors/index.d.ts +3 -0
  441. package/dist/testing/errors/index.d.ts.map +1 -0
  442. package/dist/testing/errors/index.js +8 -0
  443. package/dist/testing/errors/index.js.map +1 -0
  444. package/dist/testing/errors/names.generated.d.ts +211 -0
  445. package/dist/testing/errors/names.generated.d.ts.map +1 -0
  446. package/dist/testing/errors/names.generated.js +206 -0
  447. package/dist/testing/errors/names.generated.js.map +1 -0
  448. package/dist/testing/index.d.ts +1 -0
  449. package/dist/testing/index.d.ts.map +1 -1
  450. package/dist/testing/index.js +8 -0
  451. package/dist/testing/index.js.map +1 -1
  452. package/dist/testing/mock-rpc.d.ts +16 -0
  453. package/dist/testing/mock-rpc.d.ts.map +1 -1
  454. package/dist/testing/mock-rpc.js +27 -0
  455. package/dist/testing/mock-rpc.js.map +1 -1
  456. package/dist/testing/mock-state.d.ts +2 -0
  457. package/dist/testing/mock-state.d.ts.map +1 -1
  458. package/dist/testing/mock-state.js +45 -6
  459. package/dist/testing/mock-state.js.map +1 -1
  460. package/dist/types.d.ts +5 -15
  461. package/dist/types.d.ts.map +1 -1
  462. package/dist/types.js +11 -69
  463. package/dist/types.js.map +1 -1
  464. package/dist/vault-analytics.d.ts +0 -2
  465. package/dist/vault-analytics.d.ts.map +1 -1
  466. package/dist/vault-analytics.js +1 -9
  467. package/dist/vault-analytics.js.map +1 -1
  468. package/package.json +12 -5
  469. package/dist/dashboard/constraint-reads.d.ts +0 -50
  470. package/dist/dashboard/constraint-reads.d.ts.map +0 -1
  471. package/dist/dashboard/constraint-reads.js +0 -119
  472. package/dist/dashboard/constraint-reads.js.map +0 -1
  473. package/dist/generated/accounts/escrowDeposit.d.ts +0 -50
  474. package/dist/generated/accounts/escrowDeposit.d.ts.map +0 -1
  475. package/dist/generated/accounts/escrowDeposit.js +0 -76
  476. package/dist/generated/accounts/escrowDeposit.js.map +0 -1
  477. package/dist/generated/accounts/instructionConstraints.d.ts +0 -46
  478. package/dist/generated/accounts/instructionConstraints.d.ts.map +0 -1
  479. package/dist/generated/accounts/instructionConstraints.js +0 -73
  480. package/dist/generated/accounts/instructionConstraints.js.map +0 -1
  481. package/dist/generated/accounts/pendingCloseConstraints.d.ts +0 -37
  482. package/dist/generated/accounts/pendingCloseConstraints.d.ts.map +0 -1
  483. package/dist/generated/accounts/pendingCloseConstraints.js +0 -66
  484. package/dist/generated/accounts/pendingCloseConstraints.js.map +0 -1
  485. package/dist/generated/accounts/pendingConstraintsUpdate.d.ts +0 -62
  486. package/dist/generated/accounts/pendingConstraintsUpdate.d.ts.map +0 -1
  487. package/dist/generated/accounts/pendingConstraintsUpdate.js +0 -75
  488. package/dist/generated/accounts/pendingConstraintsUpdate.js.map +0 -1
  489. package/dist/generated/instructions/allocateConstraintsPda.d.ts +0 -62
  490. package/dist/generated/instructions/allocateConstraintsPda.d.ts.map +0 -1
  491. package/dist/generated/instructions/allocateConstraintsPda.js +0 -134
  492. package/dist/generated/instructions/allocateConstraintsPda.js.map +0 -1
  493. package/dist/generated/instructions/allocatePendingConstraintsPda.d.ts +0 -66
  494. package/dist/generated/instructions/allocatePendingConstraintsPda.d.ts.map +0 -1
  495. package/dist/generated/instructions/allocatePendingConstraintsPda.js.map +0 -1
  496. package/dist/generated/instructions/applyCloseConstraints.d.ts +0 -59
  497. package/dist/generated/instructions/applyCloseConstraints.d.ts.map +0 -1
  498. package/dist/generated/instructions/applyCloseConstraints.js +0 -143
  499. package/dist/generated/instructions/applyCloseConstraints.js.map +0 -1
  500. package/dist/generated/instructions/applyConstraintsUpdate.d.ts +0 -62
  501. package/dist/generated/instructions/applyConstraintsUpdate.d.ts.map +0 -1
  502. package/dist/generated/instructions/applyConstraintsUpdate.js.map +0 -1
  503. package/dist/generated/instructions/cancelCloseConstraints.d.ts +0 -51
  504. package/dist/generated/instructions/cancelCloseConstraints.d.ts.map +0 -1
  505. package/dist/generated/instructions/cancelCloseConstraints.js +0 -115
  506. package/dist/generated/instructions/cancelCloseConstraints.js.map +0 -1
  507. package/dist/generated/instructions/cancelConstraintsUpdate.d.ts +0 -51
  508. package/dist/generated/instructions/cancelConstraintsUpdate.d.ts.map +0 -1
  509. package/dist/generated/instructions/cancelConstraintsUpdate.js +0 -115
  510. package/dist/generated/instructions/cancelConstraintsUpdate.js.map +0 -1
  511. package/dist/generated/instructions/closeSettledEscrow.d.ts +0 -72
  512. package/dist/generated/instructions/closeSettledEscrow.d.ts.map +0 -1
  513. package/dist/generated/instructions/closeSettledEscrow.js +0 -127
  514. package/dist/generated/instructions/closeSettledEscrow.js.map +0 -1
  515. package/dist/generated/instructions/createEscrow.d.ts +0 -131
  516. package/dist/generated/instructions/createEscrow.d.ts.map +0 -1
  517. package/dist/generated/instructions/createEscrow.js +0 -272
  518. package/dist/generated/instructions/createEscrow.js.map +0 -1
  519. package/dist/generated/instructions/createInstructionConstraints.d.ts +0 -68
  520. package/dist/generated/instructions/createInstructionConstraints.d.ts.map +0 -1
  521. package/dist/generated/instructions/createInstructionConstraints.js.map +0 -1
  522. package/dist/generated/instructions/extendPda.d.ts +0 -52
  523. package/dist/generated/instructions/extendPda.d.ts.map +0 -1
  524. package/dist/generated/instructions/extendPda.js +0 -86
  525. package/dist/generated/instructions/extendPda.js.map +0 -1
  526. package/dist/generated/instructions/queueCloseConstraints.d.ts +0 -66
  527. package/dist/generated/instructions/queueCloseConstraints.d.ts.map +0 -1
  528. package/dist/generated/instructions/queueCloseConstraints.js.map +0 -1
  529. package/dist/generated/instructions/queueConstraintsUpdate.d.ts +0 -75
  530. package/dist/generated/instructions/queueConstraintsUpdate.d.ts.map +0 -1
  531. package/dist/generated/instructions/queueConstraintsUpdate.js +0 -154
  532. package/dist/generated/instructions/queueConstraintsUpdate.js.map +0 -1
  533. package/dist/generated/instructions/refundEscrow.d.ts +0 -74
  534. package/dist/generated/instructions/refundEscrow.d.ts.map +0 -1
  535. package/dist/generated/instructions/refundEscrow.js +0 -142
  536. package/dist/generated/instructions/refundEscrow.js.map +0 -1
  537. package/dist/generated/instructions/settleEscrow.d.ts +0 -80
  538. package/dist/generated/instructions/settleEscrow.d.ts.map +0 -1
  539. package/dist/generated/instructions/settleEscrow.js +0 -173
  540. package/dist/generated/instructions/settleEscrow.js.map +0 -1
  541. package/dist/generated/types/accountConstraint.d.ts +0 -18
  542. package/dist/generated/types/accountConstraint.d.ts.map +0 -1
  543. package/dist/generated/types/accountConstraint.js +0 -24
  544. package/dist/generated/types/accountConstraint.js.map +0 -1
  545. package/dist/generated/types/accountConstraintZC.d.ts +0 -18
  546. package/dist/generated/types/accountConstraintZC.d.ts.map +0 -1
  547. package/dist/generated/types/accountConstraintZC.js +0 -26
  548. package/dist/generated/types/accountConstraintZC.js.map +0 -1
  549. package/dist/generated/types/closeConstraintsApplied.d.ts +0 -20
  550. package/dist/generated/types/closeConstraintsApplied.d.ts.map +0 -1
  551. package/dist/generated/types/closeConstraintsApplied.js +0 -24
  552. package/dist/generated/types/closeConstraintsApplied.js.map +0 -1
  553. package/dist/generated/types/closeConstraintsCancelled.d.ts +0 -16
  554. package/dist/generated/types/closeConstraintsCancelled.d.ts.map +0 -1
  555. package/dist/generated/types/closeConstraintsCancelled.js +0 -18
  556. package/dist/generated/types/closeConstraintsCancelled.js.map +0 -1
  557. package/dist/generated/types/closeConstraintsQueued.d.ts +0 -20
  558. package/dist/generated/types/closeConstraintsQueued.d.ts.map +0 -1
  559. package/dist/generated/types/closeConstraintsQueued.js +0 -24
  560. package/dist/generated/types/closeConstraintsQueued.js.map +0 -1
  561. package/dist/generated/types/constraintEntry.d.ts +0 -39
  562. package/dist/generated/types/constraintEntry.d.ts.map +0 -1
  563. package/dist/generated/types/constraintEntry.js +0 -31
  564. package/dist/generated/types/constraintEntry.js.map +0 -1
  565. package/dist/generated/types/constraintEntryZC.d.ts +0 -68
  566. package/dist/generated/types/constraintEntryZC.d.ts.map +0 -1
  567. package/dist/generated/types/constraintEntryZC.js +0 -49
  568. package/dist/generated/types/constraintEntryZC.js.map +0 -1
  569. package/dist/generated/types/constraintOperator.d.ts +0 -22
  570. package/dist/generated/types/constraintOperator.d.ts.map +0 -1
  571. package/dist/generated/types/constraintOperator.js +0 -28
  572. package/dist/generated/types/constraintOperator.js.map +0 -1
  573. package/dist/generated/types/constraintsChangeApplied.d.ts +0 -30
  574. package/dist/generated/types/constraintsChangeApplied.d.ts.map +0 -1
  575. package/dist/generated/types/constraintsChangeApplied.js +0 -32
  576. package/dist/generated/types/constraintsChangeApplied.js.map +0 -1
  577. package/dist/generated/types/constraintsChangeCancelled.d.ts +0 -16
  578. package/dist/generated/types/constraintsChangeCancelled.d.ts.map +0 -1
  579. package/dist/generated/types/constraintsChangeCancelled.js +0 -18
  580. package/dist/generated/types/constraintsChangeCancelled.js.map +0 -1
  581. package/dist/generated/types/constraintsChangeQueued.d.ts +0 -30
  582. package/dist/generated/types/constraintsChangeQueued.d.ts.map +0 -1
  583. package/dist/generated/types/constraintsChangeQueued.js +0 -32
  584. package/dist/generated/types/constraintsChangeQueued.js.map +0 -1
  585. package/dist/generated/types/dataConstraint.d.ts +0 -23
  586. package/dist/generated/types/dataConstraint.d.ts.map +0 -1
  587. package/dist/generated/types/dataConstraint.js +0 -27
  588. package/dist/generated/types/dataConstraint.js.map +0 -1
  589. package/dist/generated/types/dataConstraintZC.d.ts +0 -20
  590. package/dist/generated/types/dataConstraintZC.d.ts.map +0 -1
  591. package/dist/generated/types/dataConstraintZC.js +0 -30
  592. package/dist/generated/types/dataConstraintZC.js.map +0 -1
  593. package/dist/generated/types/discriminatorFormat.d.ts +0 -25
  594. package/dist/generated/types/discriminatorFormat.d.ts.map +0 -1
  595. package/dist/generated/types/discriminatorFormat.js +0 -31
  596. package/dist/generated/types/discriminatorFormat.js.map +0 -1
  597. package/dist/generated/types/escrowCreated.d.ts +0 -30
  598. package/dist/generated/types/escrowCreated.d.ts.map +0 -1
  599. package/dist/generated/types/escrowCreated.js +0 -34
  600. package/dist/generated/types/escrowCreated.js.map +0 -1
  601. package/dist/generated/types/escrowRefunded.d.ts +0 -26
  602. package/dist/generated/types/escrowRefunded.d.ts.map +0 -1
  603. package/dist/generated/types/escrowRefunded.js +0 -30
  604. package/dist/generated/types/escrowRefunded.js.map +0 -1
  605. package/dist/generated/types/escrowSettled.d.ts +0 -26
  606. package/dist/generated/types/escrowSettled.d.ts.map +0 -1
  607. package/dist/generated/types/escrowSettled.js +0 -30
  608. package/dist/generated/types/escrowSettled.js.map +0 -1
  609. package/dist/generated/types/escrowStatus.d.ts +0 -18
  610. package/dist/generated/types/escrowStatus.d.ts.map +0 -1
  611. package/dist/generated/types/escrowStatus.js +0 -24
  612. package/dist/generated/types/escrowStatus.js.map +0 -1
  613. package/dist/generated/types/instructionConstraintsCreated.d.ts +0 -34
  614. package/dist/generated/types/instructionConstraintsCreated.d.ts.map +0 -1
  615. package/dist/generated/types/instructionConstraintsCreated.js +0 -36
  616. package/dist/generated/types/instructionConstraintsCreated.js.map +0 -1
  617. package/dist/generated/types/pdaAllocated.d.ts +0 -24
  618. package/dist/generated/types/pdaAllocated.d.ts.map +0 -1
  619. package/dist/generated/types/pdaAllocated.js.map +0 -1
  620. package/dist/generated/types/pdaExtended.d.ts +0 -24
  621. package/dist/generated/types/pdaExtended.d.ts.map +0 -1
  622. package/dist/generated/types/pdaExtended.js +0 -28
  623. package/dist/generated/types/pdaExtended.js.map +0 -1
  624. package/dist/integrations/protocol-handler.d.ts +0 -59
  625. package/dist/integrations/protocol-handler.d.ts.map +0 -1
  626. package/dist/integrations/protocol-handler.js +0 -9
  627. package/dist/integrations/protocol-handler.js.map +0 -1
@@ -5,12 +5,43 @@
5
5
  * Every error includes a category, retryability flag, and
6
6
  * recovery actions that tell the agent exactly what to do next.
7
7
  *
8
- * Maps all 81 on-chain error codes (6000-6080) plus 34 SDK
9
- * error codes (7000-7033) to AgentError with machine-readable metadata.
8
+ * Maps all 105 on-chain error codes (6000-6104) post M1-04 constraints-engine
9
+ * teardown, which removed 10 dead constraint-only variants and renumbered the
10
+ * enum (positional). The IDL (`target/idl/sigil.json`) is the authoritative
11
+ * code↔name source; `error-map-drift.test.ts` enforces this map agrees with it.
12
+ * Plus 34 SDK error codes (7000-7033), all to AgentError with machine-readable
13
+ * metadata.
10
14
  *
11
15
  * Zero dependency on @solana/web3.js or @coral-xyz/anchor.
12
16
  * Uses bigint instead of BN for context values.
13
17
  */
18
+ // ---------------------------------------------------------------------------
19
+ // On-chain error code range constants — single source of truth.
20
+ //
21
+ // `dashboard/errors.ts` re-imports these for the FE→BE category mapping.
22
+ // `tests/dashboard/errors-categorize.test.ts` iterates every generated
23
+ // `SIGIL_ERROR__*` constant and asserts it falls within this range, so
24
+ // drift between MAX and the highest variant breaks CI immediately.
25
+ //
26
+ // MAINTENANCE — when `programs/sigil/src/errors.rs` adds a new variant:
27
+ // 1. Bump SIGIL_ON_CHAIN_ERROR_MAX below to the new highest code.
28
+ // 2. Add an entry to ON_CHAIN_ERRORS for that code (or a TODO with
29
+ // explicit deferral rationale).
30
+ // 3. Regenerate the IDL + SDK with `pnpm codama` so generated/errors
31
+ // stays in lockstep.
32
+ // ---------------------------------------------------------------------------
33
+ /** Lowest Anchor-error code Sigil emits. */
34
+ export const SIGIL_ON_CHAIN_ERROR_MIN = 6000;
35
+ /**
36
+ * Highest Anchor-error code currently in use. Bump when errors.rs grows.
37
+ *
38
+ * The enum tops out at 6106 (107 codes). The drift gate at
39
+ * `tests/error-map-drift.test.ts` derives the expected count from
40
+ * `target/idl/sigil.json` (the authoritative code↔name source) and asserts
41
+ * this map agrees with it by code AND name — so adding or renumbering an
42
+ * on-chain error without updating this map fails at test time.
43
+ */
44
+ export const SIGIL_ON_CHAIN_ERROR_MAX = 6110;
14
45
  export const ON_CHAIN_ERROR_MAP = {
15
46
  // --- Vault state errors ---
16
47
  6000: {
@@ -130,23 +161,6 @@ export const ON_CHAIN_ERROR_MAP = {
130
161
  ],
131
162
  },
132
163
  6007: {
133
- name: "LeverageTooHigh",
134
- message: "Leverage exceeds maximum allowed by policy",
135
- category: "POLICY_VIOLATION",
136
- retryable: false,
137
- recovery_actions: [
138
- {
139
- action: "reduce_leverage",
140
- description: "Reduce leverage to within maxLeverageBps",
141
- },
142
- {
143
- action: "check_limits",
144
- description: "Check the vault's maxLeverageBps policy",
145
- tool: "sigil_check_vault",
146
- },
147
- ],
148
- },
149
- 6008: {
150
164
  name: "SessionNotAuthorized",
151
165
  message: "Session authority not authorized for this action",
152
166
  category: "PERMISSION",
@@ -158,7 +172,7 @@ export const ON_CHAIN_ERROR_MAP = {
158
172
  },
159
173
  ],
160
174
  },
161
- 6009: {
175
+ 6008: {
162
176
  name: "InvalidSession",
163
177
  message: "Session does not belong to this vault or is invalid",
164
178
  category: "PERMISSION",
@@ -170,7 +184,7 @@ export const ON_CHAIN_ERROR_MAP = {
170
184
  },
171
185
  ],
172
186
  },
173
- 6010: {
187
+ 6009: {
174
188
  name: "TooManyAllowedProtocols",
175
189
  message: "Policy configuration has too many allowed protocols (max 10)",
176
190
  category: "INPUT_VALIDATION",
@@ -182,7 +196,7 @@ export const ON_CHAIN_ERROR_MAP = {
182
196
  },
183
197
  ],
184
198
  },
185
- 6011: {
199
+ 6010: {
186
200
  name: "AgentAlreadyRegistered",
187
201
  message: "Agent is already registered on this vault",
188
202
  category: "INPUT_VALIDATION",
@@ -195,7 +209,7 @@ export const ON_CHAIN_ERROR_MAP = {
195
209
  },
196
210
  ],
197
211
  },
198
- 6012: {
212
+ 6011: {
199
213
  name: "NoAgentRegistered",
200
214
  message: "No agent registered on this vault",
201
215
  category: "RESOURCE_NOT_FOUND",
@@ -208,7 +222,7 @@ export const ON_CHAIN_ERROR_MAP = {
208
222
  },
209
223
  ],
210
224
  },
211
- 6013: {
225
+ 6012: {
212
226
  name: "VaultNotFrozen",
213
227
  message: "Vault is not frozen (expected frozen for reactivation)",
214
228
  category: "INPUT_VALIDATION",
@@ -221,7 +235,7 @@ export const ON_CHAIN_ERROR_MAP = {
221
235
  },
222
236
  ],
223
237
  },
224
- 6014: {
238
+ 6013: {
225
239
  name: "VaultAlreadyClosed",
226
240
  message: "Vault is permanently closed",
227
241
  category: "INPUT_VALIDATION",
@@ -234,7 +248,7 @@ export const ON_CHAIN_ERROR_MAP = {
234
248
  },
235
249
  ],
236
250
  },
237
- 6015: {
251
+ 6014: {
238
252
  name: "InsufficientBalance",
239
253
  message: "Insufficient vault balance for this operation",
240
254
  category: "SPENDING_CAP",
@@ -255,7 +269,7 @@ export const ON_CHAIN_ERROR_MAP = {
255
269
  },
256
270
  ],
257
271
  },
258
- 6016: {
272
+ 6015: {
259
273
  name: "DeveloperFeeTooHigh",
260
274
  message: "Developer fee rate exceeds maximum (500 / 1,000,000 = 5 BPS)",
261
275
  category: "INPUT_VALIDATION",
@@ -267,7 +281,7 @@ export const ON_CHAIN_ERROR_MAP = {
267
281
  },
268
282
  ],
269
283
  },
270
- 6017: {
284
+ 6016: {
271
285
  name: "InvalidFeeDestination",
272
286
  message: "Fee destination account is invalid",
273
287
  category: "INPUT_VALIDATION",
@@ -279,7 +293,7 @@ export const ON_CHAIN_ERROR_MAP = {
279
293
  },
280
294
  ],
281
295
  },
282
- 6018: {
296
+ 6017: {
283
297
  name: "InvalidProtocolTreasury",
284
298
  message: "Protocol treasury account does not match expected address",
285
299
  category: "INPUT_VALIDATION",
@@ -291,7 +305,7 @@ export const ON_CHAIN_ERROR_MAP = {
291
305
  },
292
306
  ],
293
307
  },
294
- 6019: {
308
+ 6018: {
295
309
  name: "InvalidAgentKey",
296
310
  message: "Agent cannot be the zero address",
297
311
  category: "INPUT_VALIDATION",
@@ -303,7 +317,7 @@ export const ON_CHAIN_ERROR_MAP = {
303
317
  },
304
318
  ],
305
319
  },
306
- 6020: {
320
+ 6019: {
307
321
  name: "AgentIsOwner",
308
322
  message: "Agent cannot be the vault owner",
309
323
  category: "INPUT_VALIDATION",
@@ -315,7 +329,7 @@ export const ON_CHAIN_ERROR_MAP = {
315
329
  },
316
330
  ],
317
331
  },
318
- 6021: {
332
+ 6020: {
319
333
  name: "Overflow",
320
334
  message: "Arithmetic overflow in on-chain computation",
321
335
  category: "FATAL",
@@ -327,7 +341,7 @@ export const ON_CHAIN_ERROR_MAP = {
327
341
  },
328
342
  ],
329
343
  },
330
- 6022: {
344
+ 6021: {
331
345
  name: "InvalidTokenAccount",
332
346
  message: "Token account does not belong to vault or has wrong mint",
333
347
  category: "INPUT_VALIDATION",
@@ -340,7 +354,7 @@ export const ON_CHAIN_ERROR_MAP = {
340
354
  ],
341
355
  },
342
356
  // --- Timelock + Destination errors ---
343
- 6023: {
357
+ 6022: {
344
358
  name: "TimelockNotExpired",
345
359
  message: "Timelock period has not expired yet",
346
360
  category: "POLICY_VIOLATION",
@@ -353,7 +367,7 @@ export const ON_CHAIN_ERROR_MAP = {
353
367
  },
354
368
  ],
355
369
  },
356
- 6024: {
370
+ 6023: {
357
371
  name: "NoTimelockConfigured",
358
372
  message: "No timelock configured on this vault",
359
373
  category: "INPUT_VALIDATION",
@@ -365,7 +379,7 @@ export const ON_CHAIN_ERROR_MAP = {
365
379
  },
366
380
  ],
367
381
  },
368
- 6025: {
382
+ 6024: {
369
383
  name: "DestinationNotAllowed",
370
384
  message: "Destination address not in vault's allowed destinations list",
371
385
  category: "POLICY_VIOLATION",
@@ -382,7 +396,7 @@ export const ON_CHAIN_ERROR_MAP = {
382
396
  },
383
397
  ],
384
398
  },
385
- 6026: {
399
+ 6025: {
386
400
  name: "TooManyDestinations",
387
401
  message: "Too many destinations in allowlist (max 10)",
388
402
  category: "INPUT_VALIDATION",
@@ -394,7 +408,7 @@ export const ON_CHAIN_ERROR_MAP = {
394
408
  },
395
409
  ],
396
410
  },
397
- 6027: {
411
+ 6026: {
398
412
  name: "InvalidProtocolMode",
399
413
  message: "Invalid protocol mode (must be 0=all, 1=allowlist, or 2=denylist)",
400
414
  category: "INPUT_VALIDATION",
@@ -407,19 +421,7 @@ export const ON_CHAIN_ERROR_MAP = {
407
421
  ],
408
422
  },
409
423
  // --- Flash Trade expansion errors ---
410
- 6028: {
411
- name: "InvalidNonSpendingAmount",
412
- message: "Non-spending action must have amount = 0",
413
- category: "INPUT_VALIDATION",
414
- retryable: false,
415
- recovery_actions: [
416
- {
417
- action: "set_zero_amount",
418
- description: "Set amount to 0 for non-spending actions (close, cancel, etc.)",
419
- },
420
- ],
421
- },
422
- 6029: {
424
+ 6027: {
423
425
  name: "CpiCallNotAllowed",
424
426
  message: "Instruction must be top-level (CPI calls not allowed for validate/finalize)",
425
427
  category: "FATAL",
@@ -431,7 +433,7 @@ export const ON_CHAIN_ERROR_MAP = {
431
433
  },
432
434
  ],
433
435
  },
434
- 6030: {
436
+ 6028: {
435
437
  name: "MissingFinalizeInstruction",
436
438
  message: "Transaction must include finalize_session after validate_and_authorize",
437
439
  category: "INPUT_VALIDATION",
@@ -444,7 +446,7 @@ export const ON_CHAIN_ERROR_MAP = {
444
446
  ],
445
447
  },
446
448
  // --- Stablecoin-only enforcement errors ---
447
- 6031: {
449
+ 6029: {
448
450
  name: "NonTrackedSwapMustReturnStablecoin",
449
451
  message: "Non-stablecoin swap must return stablecoin (vault stablecoin balance did not increase)",
450
452
  category: "INPUT_VALIDATION",
@@ -456,36 +458,7 @@ export const ON_CHAIN_ERROR_MAP = {
456
458
  },
457
459
  ],
458
460
  },
459
- 6032: {
460
- name: "SwapSlippageExceeded",
461
- message: "Swap slippage exceeds policy max_slippage_bps or quoted output is zero",
462
- category: "POLICY_VIOLATION",
463
- retryable: false,
464
- recovery_actions: [
465
- {
466
- action: "reduce_slippage",
467
- description: "Use a lower slippageBps value within the vault's maxSlippageBps",
468
- },
469
- {
470
- action: "check_policy",
471
- description: "Check the vault's maxSlippageBps setting",
472
- tool: "sigil_check_vault",
473
- },
474
- ],
475
- },
476
- 6033: {
477
- name: "InvalidJupiterInstruction",
478
- message: "Cannot parse Jupiter swap instruction data",
479
- category: "INPUT_VALIDATION",
480
- retryable: false,
481
- recovery_actions: [
482
- {
483
- action: "use_sdk",
484
- description: "Use the SDK's composeJupiterSwap — manual instruction building is error-prone",
485
- },
486
- ],
487
- },
488
- 6034: {
461
+ 6030: {
489
462
  name: "UnauthorizedTokenTransfer",
490
463
  message: "Top-level SPL Token transfer not allowed between validate and finalize",
491
464
  category: "POLICY_VIOLATION",
@@ -497,7 +470,7 @@ export const ON_CHAIN_ERROR_MAP = {
497
470
  },
498
471
  ],
499
472
  },
500
- 6035: {
473
+ 6031: {
501
474
  name: "SlippageBpsTooHigh",
502
475
  message: "Slippage BPS exceeds maximum allowed (5000 = 50%)",
503
476
  category: "INPUT_VALIDATION",
@@ -509,7 +482,7 @@ export const ON_CHAIN_ERROR_MAP = {
509
482
  },
510
483
  ],
511
484
  },
512
- 6036: {
485
+ 6032: {
513
486
  name: "ProtocolMismatch",
514
487
  message: "DeFi instruction program does not match the declared target_protocol",
515
488
  category: "INPUT_VALIDATION",
@@ -521,7 +494,7 @@ export const ON_CHAIN_ERROR_MAP = {
521
494
  },
522
495
  ],
523
496
  },
524
- 6037: {
497
+ 6033: {
525
498
  name: "TooManyDeFiInstructions",
526
499
  message: "Non-stablecoin swap allows exactly one DeFi instruction",
527
500
  category: "INPUT_VALIDATION",
@@ -534,7 +507,7 @@ export const ON_CHAIN_ERROR_MAP = {
534
507
  ],
535
508
  },
536
509
  // --- Multi-Agent errors ---
537
- 6038: {
510
+ 6034: {
538
511
  name: "MaxAgentsReached",
539
512
  message: "Maximum agents per vault reached (limit: 10)",
540
513
  category: "INPUT_VALIDATION",
@@ -547,7 +520,7 @@ export const ON_CHAIN_ERROR_MAP = {
547
520
  },
548
521
  ],
549
522
  },
550
- 6039: {
523
+ 6035: {
551
524
  name: "InsufficientPermissions",
552
525
  message: "Agent lacks permission for this action type",
553
526
  category: "PERMISSION",
@@ -564,7 +537,7 @@ export const ON_CHAIN_ERROR_MAP = {
564
537
  },
565
538
  ],
566
539
  },
567
- 6040: {
540
+ 6036: {
568
541
  name: "InvalidPermissions",
569
542
  message: "Capability exceeds the on-chain maximum (valid values: 0 = Disabled, 1 = Observer, 2 = Operator)",
570
543
  category: "INPUT_VALIDATION",
@@ -576,536 +549,1115 @@ export const ON_CHAIN_ERROR_MAP = {
576
549
  },
577
550
  ],
578
551
  },
579
- // --- Escrow errors ---
580
- 6041: {
581
- name: "EscrowNotActive",
582
- message: "Escrow is not in Active status",
583
- category: "RESOURCE_NOT_FOUND",
552
+ // --- Post-execution assertion config error ---
553
+ 6037: {
554
+ name: "InvalidConstraintConfig",
555
+ message: "Invalid constraint configuration: bounds exceeded",
556
+ category: "INPUT_VALIDATION",
584
557
  retryable: false,
585
558
  recovery_actions: [
586
559
  {
587
- action: "check_escrow",
588
- description: "Verify the escrow exists and is in Active status",
560
+ action: "fix_constraints",
561
+ description: "Ensure constraint entries are within bounds (max 64 entries, 8 data constraints each)",
589
562
  },
590
563
  ],
591
564
  },
592
- 6042: {
593
- name: "EscrowExpired",
594
- message: "Escrow has expired — can only be refunded now",
565
+ // --- Per-agent spend limit errors ---
566
+ 6038: {
567
+ name: "AgentSpendLimitExceeded",
568
+ message: "Agent's rolling 24h spend exceeds their individual spending limit",
569
+ category: "SPENDING_CAP",
570
+ retryable: true,
571
+ retry_after_ms: 3_600_000,
572
+ recovery_actions: [
573
+ {
574
+ action: "reduce_amount",
575
+ description: "Reduce the amount to fit within the agent's remaining limit",
576
+ },
577
+ {
578
+ action: "check_spending",
579
+ description: "Check the agent's current spend against their limit",
580
+ tool: "sigil_check_spending",
581
+ },
582
+ {
583
+ action: "wait",
584
+ description: "Wait for the 24h rolling window to release spent capacity",
585
+ },
586
+ ],
587
+ },
588
+ 6039: {
589
+ name: "OverlaySlotExhausted",
590
+ message: "Per-agent overlay is full — cannot register agent with spending limit",
591
+ category: "INPUT_VALIDATION",
592
+ retryable: false,
593
+ recovery_actions: [
594
+ {
595
+ action: "revoke_agent",
596
+ description: "Revoke an unused agent to free an overlay slot",
597
+ tool: "sigil_revoke_agent",
598
+ },
599
+ ],
600
+ },
601
+ 6040: {
602
+ name: "AgentSlotNotFound",
603
+ message: "Agent has per-agent spending limit but no overlay tracking slot",
595
604
  category: "RESOURCE_NOT_FOUND",
596
605
  retryable: false,
597
606
  recovery_actions: [
598
607
  {
599
- action: "refund_escrow",
600
- description: "Refund the expired escrow back to the source vault",
601
- tool: "sigil_refund_escrow",
608
+ action: "contact_support",
609
+ description: "This is an internal consistency error the overlay may need reinitialization",
610
+ },
611
+ ],
612
+ },
613
+ 6041: {
614
+ name: "UnauthorizedTokenApproval",
615
+ message: "Unauthorized SPL Token Approve detected between validate and finalize",
616
+ category: "POLICY_VIOLATION",
617
+ retryable: false,
618
+ recovery_actions: [
619
+ {
620
+ action: "use_sdk",
621
+ description: "Use the SDK's compose functions — do not insert raw SPL Approve in the sandwich",
602
622
  },
603
623
  ],
604
624
  },
605
- 6043: {
606
- name: "EscrowNotExpired",
607
- message: "Escrow has not expired yet cannot refund before expiry",
625
+ 6042: {
626
+ name: "InvalidSessionExpiry",
627
+ message: "Session expiry slots out of range (10-450)",
608
628
  category: "INPUT_VALIDATION",
609
629
  retryable: false,
630
+ recovery_actions: [
631
+ {
632
+ action: "fix_expiry",
633
+ description: "Set session expiry between 10 and 450 slots",
634
+ },
635
+ ],
636
+ },
637
+ // --- Per-protocol spend cap errors ---
638
+ // Phase 5 §RP-1 V5: 6047 semantics flipped. The "rolling 24h per-protocol
639
+ // cap exceeded" semantic moved to 6095 (ErrDailyCapExceeded). 6047 now
640
+ // only emits from `state/tracker.rs:313` when the fixed-size per-protocol
641
+ // counter slot allocation (max 10 protocols tracked) is exhausted —
642
+ // i.e. an 11th distinct protocol attempted within the rolling window.
643
+ 6043: {
644
+ name: "ProtocolCapExceeded",
645
+ message: "Per-protocol counter slot allocation exhausted (max 10 protocols tracked)",
646
+ category: "SPENDING_CAP",
647
+ retryable: true,
648
+ retry_after_ms: 3_600_000,
610
649
  recovery_actions: [
611
650
  {
612
651
  action: "wait",
613
- description: "Wait for the escrow to expire before requesting a refund",
652
+ description: "Wait for an existing protocol slot's 24h rolling window to elapse before invoking a new protocol",
614
653
  },
615
654
  {
616
- action: "settle",
617
- description: "Settle the escrow if you are the destination agent",
618
- tool: "sigil_settle_escrow",
655
+ action: "use_existing_protocol",
656
+ description: "Reuse one of the protocols already tracked in the rolling window rather than invoking an 11th distinct protocol",
619
657
  },
620
658
  ],
621
659
  },
622
660
  6044: {
623
- name: "InvalidEscrowVault",
624
- message: "Invalid escrow vault source or destination vault mismatch",
661
+ name: "ProtocolCapsMismatch",
662
+ message: "protocol_caps length must match protocols length when has_protocol_caps is true",
625
663
  category: "INPUT_VALIDATION",
626
664
  retryable: false,
627
665
  recovery_actions: [
628
666
  {
629
- action: "verify_vaults",
630
- description: "Ensure source and destination vault addresses match the escrow",
667
+ action: "fix_config",
668
+ description: "Ensure protocol_caps array length matches the protocols array length",
631
669
  },
632
670
  ],
633
671
  },
672
+ // --- Vault closure guard errors ---
634
673
  6045: {
635
- name: "EscrowConditionsNotMet",
636
- message: "Escrow settlement conditions not met (SHA-256 proof invalid)",
637
- category: "INPUT_VALIDATION",
674
+ name: "PendingPolicyExists",
675
+ message: "A pending policy update exists apply or cancel it before closing vault",
676
+ category: "RESOURCE_NOT_FOUND",
638
677
  retryable: false,
639
678
  recovery_actions: [
640
679
  {
641
- action: "provide_proof",
642
- description: "Provide the correct pre-image for the escrow's condition_hash",
680
+ action: "resolve_pending_policy",
681
+ description: "Apply or cancel the pending policy update before closing the vault",
643
682
  },
644
683
  ],
645
684
  },
685
+ // --- Agent pause errors ---
646
686
  6046: {
647
- name: "EscrowDurationExceeded",
648
- message: "Escrow duration exceeds maximum (30 days)",
687
+ name: "AgentPaused",
688
+ message: "Agent is paused unpause before executing actions",
689
+ category: "PERMISSION",
690
+ retryable: false,
691
+ recovery_actions: [
692
+ {
693
+ action: "unpause_agent",
694
+ description: "Ask the vault owner to unpause this agent",
695
+ },
696
+ ],
697
+ },
698
+ 6047: {
699
+ name: "AgentAlreadyPaused",
700
+ message: "Agent is already paused",
701
+ category: "INPUT_VALIDATION",
702
+ retryable: false,
703
+ recovery_actions: [
704
+ {
705
+ action: "check_agent_status",
706
+ description: "Agent is already paused — no action needed",
707
+ },
708
+ ],
709
+ },
710
+ 6048: {
711
+ name: "AgentNotPaused",
712
+ message: "Agent is not paused — cannot unpause",
713
+ category: "INPUT_VALIDATION",
714
+ retryable: false,
715
+ recovery_actions: [
716
+ {
717
+ action: "check_agent_status",
718
+ description: "Agent is not paused — no action needed",
719
+ },
720
+ ],
721
+ },
722
+ 6049: {
723
+ name: "UnauthorizedPostFinalizeInstruction",
724
+ message: "Instructions after finalize_session must be ComputeBudget or SystemProgram only",
725
+ category: "POLICY_VIOLATION",
726
+ retryable: false,
727
+ recovery_actions: [
728
+ {
729
+ action: "remove_post_finalize_instructions",
730
+ description: "Remove any instructions placed after finalize_session in the transaction. Only ComputeBudget and SystemProgram instructions are allowed after finalize.",
731
+ },
732
+ ],
733
+ },
734
+ 6050: {
735
+ name: "UnexpectedBalanceDecrease",
736
+ message: "Vault stablecoin balance decreased more than the session authorized amount. " +
737
+ "This indicates a compromised DeFi program attempted to drain vault tokens via CPI.",
738
+ category: "FATAL",
739
+ retryable: false,
740
+ recovery_actions: [
741
+ {
742
+ action: "investigate_defi_program",
743
+ description: "The whitelisted DeFi program may be compromised. The actual vault balance decrease " +
744
+ "exceeded the authorized delegation amount (fees + DeFi spend). Freeze the vault, " +
745
+ "investigate the DeFi program, and consider removing it from the protocol allowlist.",
746
+ },
747
+ {
748
+ action: "freeze_vault",
749
+ description: "Immediately freeze the vault to prevent further transactions until the cause is identified.",
750
+ },
751
+ ],
752
+ },
753
+ // --- TOCTOU + timelock hardening errors ---
754
+ 6051: {
755
+ name: "TimelockTooShort",
756
+ message: "Timelock duration is below the minimum (1800 seconds / 30 minutes).",
757
+ category: "INPUT_VALIDATION",
758
+ retryable: false,
759
+ recovery_actions: [
760
+ {
761
+ action: "increase_timelock",
762
+ description: "Set timelock_duration to at least 1800 seconds (30 minutes).",
763
+ },
764
+ ],
765
+ },
766
+ 6052: {
767
+ name: "PolicyVersionMismatch",
768
+ message: "Policy version changed since agent's last RPC read. Re-resolve vault state and retry.",
769
+ category: "TRANSIENT",
770
+ retryable: true,
771
+ retry_after_ms: 1000,
772
+ recovery_actions: [
773
+ {
774
+ action: "re_resolve_state",
775
+ description: "Re-fetch vault state via resolveVaultState() to get current policy version, then retry.",
776
+ },
777
+ ],
778
+ },
779
+ 6053: {
780
+ name: "ActiveSessionsExist",
781
+ message: "Cannot close vault with active sessions. Finalize all pending sessions first.",
782
+ category: "POLICY_VIOLATION",
783
+ retryable: true,
784
+ retry_after_ms: 10000,
785
+ recovery_actions: [
786
+ {
787
+ action: "finalize_sessions",
788
+ description: "Wait for active sessions to finalize or expire, then retry close_vault.",
789
+ },
790
+ ],
791
+ },
792
+ // --- Post-execution assertions (Phase B scaffolding) ---
793
+ 6054: {
794
+ name: "PostAssertionFailed",
795
+ message: "Post-execution assertion failed: account state did not satisfy constraint.",
796
+ category: "POLICY_VIOLATION",
797
+ retryable: false,
798
+ recovery_actions: [
799
+ {
800
+ action: "review_assertions",
801
+ description: "Review the vault's post-execution assertions. The trade's resulting account state violated a configured assertion.",
802
+ },
803
+ ],
804
+ },
805
+ 6055: {
806
+ name: "InvalidPostAssertionIndex",
807
+ message: "Post-assertion references an invalid instruction index.",
808
+ category: "INPUT_VALIDATION",
809
+ retryable: false,
810
+ recovery_actions: [
811
+ {
812
+ action: "fix_assertions",
813
+ description: "Review and update the vault's post-assertion configuration.",
814
+ },
815
+ ],
816
+ },
817
+ 6056: {
818
+ name: "UnauthorizedPreValidateInstruction",
819
+ message: "Non-infrastructure instruction detected before validate_and_authorize.",
820
+ category: "PERMISSION",
821
+ retryable: false,
822
+ recovery_actions: [
823
+ {
824
+ action: "fix_instruction_order",
825
+ description: "Place validate_and_authorize before any DeFi or program instruction.",
826
+ },
827
+ ],
828
+ },
829
+ 6057: {
830
+ name: "SnapshotNotCaptured",
831
+ message: "Delta assertion snapshot was not captured in validate_and_authorize.",
832
+ category: "INPUT_VALIDATION",
833
+ retryable: false,
834
+ recovery_actions: [
835
+ {
836
+ action: "fix_assertions",
837
+ description: "Ensure validate_and_authorize captures a snapshot before finalize delta check.",
838
+ },
839
+ ],
840
+ },
841
+ 6058: {
842
+ name: "InvalidConstraintOperator",
843
+ message: "Constraint operator value is not a valid ConstraintOperator discriminant.",
649
844
  category: "INPUT_VALIDATION",
650
845
  retryable: false,
651
846
  recovery_actions: [
652
847
  {
653
- action: "reduce_duration",
654
- description: "Set escrow duration to 2,592,000 seconds (30 days) or less",
848
+ action: "fix_constraints",
849
+ description: "Ensure constraint operators are valid (0-6).",
850
+ },
851
+ ],
852
+ },
853
+ 6059: {
854
+ name: "ZeroCopyVaultMismatch",
855
+ message: "Zero-copy constraints account has wrong vault.",
856
+ category: "INPUT_VALIDATION",
857
+ retryable: false,
858
+ recovery_actions: [
859
+ {
860
+ action: "verify_pda",
861
+ description: "The constraints PDA does not belong to this vault.",
862
+ },
863
+ ],
864
+ },
865
+ // F-10 audit fix: durable-nonce pre-signing defense (extended Bucket-3
866
+ // 2026-05-23 to cover the 2 timelocked-admin PDAs via the wider
867
+ // MAX_APPLY_AGE_SLOTS_TIMELOCKED_ADMIN ceiling)
868
+ 6060: {
869
+ name: "QueuedUpdateExpired",
870
+ message: "Queued update is too old (>MAX_APPLY_AGE_SLOTS / >MAX_APPLY_AGE_SLOTS_TIMELOCKED_ADMIN) — re-queue to apply. Defends against durable-nonce pre-signing.",
871
+ category: "POLICY_VIOLATION",
872
+ retryable: false,
873
+ recovery_actions: [
874
+ {
875
+ action: "requeue",
876
+ description: "Re-queue the update via the matching ix for your flow: queue_policy_update / queue_constraints_update / queue_close_constraints / queue_agent_permissions_update / queue_agent_grant / initiate_ownership_transfer — the original queued update is past the freshness window.",
877
+ },
878
+ ],
879
+ },
880
+ 6061: {
881
+ name: "AccountWritabilityMismatch",
882
+ message: "Account writability flag does not match the constraint requirement (read-only vs writable).",
883
+ category: "INPUT_VALIDATION",
884
+ retryable: false,
885
+ recovery_actions: [
886
+ {
887
+ action: "fix_constraints",
888
+ description: "Match the writability flag (read-only or writable) of the account passed to the instruction with the constraint's is_writable_required value.",
889
+ },
890
+ ],
891
+ },
892
+ // M11 SIMD-0296 pad-attack DoS guard
893
+ 6062: {
894
+ name: "SysvarScanBoundExceeded",
895
+ message: "Sysvar instruction scan exceeded the per-tx safety bound (MAX_SYSVAR_SCAN_ITERATIONS=64).",
896
+ category: "INPUT_VALIDATION",
897
+ retryable: false,
898
+ recovery_actions: [
899
+ {
900
+ action: "fix_transaction_shape",
901
+ description: "Reduce the number of instructions in the transaction. The on-chain sysvar walk is bounded at 64 ix to defend against pad-attack DoS (M11 / SIMD-0296). Legitimate flows fit well under this cap.",
902
+ },
903
+ ],
904
+ },
905
+ // C4 audit fix: async-fulfillment program deny
906
+ 6063: {
907
+ name: "AsyncFulfillmentNotPermitted",
908
+ message: "Async-fulfillment programs (Jupiter Perps, Drift v2, Drift JIT) are not permitted in V1 — keeper-driven settlement happens after finalize_session returns and cannot be measured against the spending cap.",
909
+ category: "POLICY_VIOLATION",
910
+ retryable: false,
911
+ recovery_actions: [
912
+ {
913
+ action: "use_supported_protocol",
914
+ description: "Use a synchronous protocol (Jupiter swap, Jupiter Lend, etc.). V1.1 will add a sanctioned async-friendly path with settlement-tracked counters or post-execution attestation.",
915
+ },
916
+ ],
917
+ },
918
+ // PR 7: Token-2022 opcode blocks (M3 + Pentester HIGH/MED + third-pass audit)
919
+ 6064: {
920
+ name: "ConfidentialTransferBlocked",
921
+ message: "Token-2022 ConfidentialTransfer is not permitted between validate_and_authorize and finalize_session.",
922
+ category: "POLICY_VIOLATION",
923
+ retryable: false,
924
+ recovery_actions: [
925
+ {
926
+ action: "use_supported_protocol",
927
+ description: "Token-2022 ConfidentialTransfer (opcode 27/42) hides spending amounts from sysvar accounting and cannot be tracked. Use the standard SPL Token transfer or Jupiter swap path instead.",
928
+ },
929
+ ],
930
+ },
931
+ 6065: {
932
+ name: "PermanentDelegateBlocked",
933
+ message: "Token-2022 PermanentDelegate is not permitted between validate_and_authorize and finalize_session.",
934
+ category: "POLICY_VIOLATION",
935
+ retryable: false,
936
+ recovery_actions: [
937
+ {
938
+ action: "use_supported_protocol",
939
+ description: "Token-2022 PermanentDelegate (opcode 35) installs a session-bound delegate that survives finalize. Reject up-front; use a per-tx Approve instead.",
940
+ },
941
+ ],
942
+ },
943
+ 6066: {
944
+ name: "TransferHookBlocked",
945
+ message: "Token-2022 TransferHook is not permitted between validate_and_authorize and finalize_session.",
946
+ category: "POLICY_VIOLATION",
947
+ retryable: false,
948
+ recovery_actions: [
949
+ {
950
+ action: "use_supported_protocol",
951
+ description: "Token-2022 TransferHook (opcode 36) routes mid-tx control to attacker-chosen code. Use a non-hook mint or whitelist the hook program in V1.1.",
952
+ },
953
+ ],
954
+ },
955
+ 6067: {
956
+ name: "LamportDrainBlocked",
957
+ message: "Token-2022 destructive-balance instruction (opcode 38/45/46) is not permitted between validate_and_authorize and finalize_session.",
958
+ category: "POLICY_VIOLATION",
959
+ retryable: false,
960
+ recovery_actions: [
961
+ {
962
+ action: "use_supported_protocol",
963
+ description: "WithdrawExcessLamports/UnwrapLamports/PermissionedBurnExtension drain SOL or balances outside the spending-cap path. Block at the gate; V1.1 may add an owner-allowlist for legitimate uses.",
964
+ },
965
+ ],
966
+ },
967
+ 6068: {
968
+ name: "BatchInstructionBlocked",
969
+ message: "Token-2022 Batch instruction (opcode 255) is blocked outright — wraps inner instructions and bypasses the byte-0 blocklist.",
970
+ category: "POLICY_VIOLATION",
971
+ retryable: false,
972
+ recovery_actions: [
973
+ {
974
+ action: "use_supported_protocol",
975
+ description: "Token-2022 Batch (opcode 255) wraps inner TokenInstructions; the byte-0 blocklist cannot see them. Submit each inner ix as its own top-level instruction so guards can inspect each.",
976
+ },
977
+ ],
978
+ },
979
+ // F-4 audit fix: explicit destination_mode. Phase 2 Option A tightens to
980
+ // 0 = RESTRICTED only — OPEN_WITH_CAP path deleted.
981
+ 6069: {
982
+ name: "InvalidDestinationMode",
983
+ message: "Invalid destination mode (must be 0 = RESTRICTED).",
984
+ category: "INPUT_VALIDATION",
985
+ retryable: false,
986
+ recovery_actions: [
987
+ {
988
+ action: "fix_policy",
989
+ description: "Pass destination_mode = 0 (RESTRICTED). Phase 2 deleted the permissive OPEN_WITH_CAP path.",
990
+ },
991
+ ],
992
+ },
993
+ // Phase 2 TA-04: reserved AgentEntry.capability values 3..=255 reject.
994
+ 6070: {
995
+ name: "InvalidCapability",
996
+ message: "Invalid agent capability value (must be 0 = Disabled, 1 = Observer, or 2 = Operator).",
997
+ category: "INPUT_VALIDATION",
998
+ retryable: false,
999
+ recovery_actions: [
1000
+ {
1001
+ action: "fix_policy",
1002
+ description: "Pass capability = 0, 1, or 2. Reserved values 3..=255 are explicitly rejected by register_agent / queue_agent_permissions_update / apply_agent_permissions_update.",
1003
+ },
1004
+ ],
1005
+ },
1006
+ // Phase 2 TA-19: policy_preview_digest mismatch — owner blind-sign defense.
1007
+ 6071: {
1008
+ name: "PolicyPreviewMismatch",
1009
+ message: "Policy preview digest mismatch — caller's signed digest differs from recomputed canonical digest.",
1010
+ category: "INPUT_VALIDATION",
1011
+ retryable: false,
1012
+ recovery_actions: [
1013
+ {
1014
+ action: "recompute_digest",
1015
+ description: "Recompute the policy preview digest via computePolicyPreviewDigest() against the actual policy fields and resubmit. Likely cause: owner signed a digest produced from stale fields, or a pending PDA was tampered with between queue and apply.",
1016
+ },
1017
+ ],
1018
+ },
1019
+ // Phase 2 TA-19: observe_only mode rejects all validate_and_authorize calls.
1020
+ 6072: {
1021
+ name: "ObserveOnlyModeBlocksExecute",
1022
+ message: "Vault is in observe_only mode — validate_and_authorize is blocked.",
1023
+ category: "POLICY_VIOLATION",
1024
+ retryable: false,
1025
+ recovery_actions: [
1026
+ {
1027
+ action: "switch_vault_mode",
1028
+ description: "Owner must queue + apply a policy update to flip observe_only off (or create a separate vault without observe_only set).",
1029
+ },
1030
+ ],
1031
+ },
1032
+ // Phase 2 F-11: active vault (observe_only=false) requires at least one
1033
+ // entry on the protocol allowlist OR destination allowlist. An empty
1034
+ // allowlist would leave the vault silently inert.
1035
+ 6073: {
1036
+ name: "ActiveVaultRequiresAllowlist",
1037
+ message: "Active vault (observe_only=false) requires at least one protocol or destination on its allowlist.",
1038
+ category: "INPUT_VALIDATION",
1039
+ retryable: false,
1040
+ recovery_actions: [
1041
+ {
1042
+ action: "add_allowlist_entry",
1043
+ description: "Either add at least one program to `protocols`, at least one wallet to `allowed_destinations`, or pass `observe_only=true` (intentional inert vault).",
1044
+ },
1045
+ ],
1046
+ },
1047
+ // ─── Phase 3 pre-execution guards (TA-03/05/06/07/08/09/17) ───────────────
1048
+ // 6083-6090 codes added by Phase 3 — each is an on-chain policy-violation
1049
+ // surface that the SDK surfaces to dashboard / agent consumers.
1050
+ 6074: {
1051
+ name: "ErrMintNotPinned",
1052
+ message: "Deposit mint is not on the build-time stablecoin allowlist (USDC + USDT). Reject prevents exotic / typosquatted mints from being parked in the vault.",
1053
+ category: "INPUT_VALIDATION",
1054
+ retryable: false,
1055
+ recovery_actions: [
1056
+ {
1057
+ action: "use_pinned_stablecoin",
1058
+ description: "Re-issue the deposit using the USDC or USDT mint. Other tokens are not accepted by the vault.",
1059
+ },
1060
+ ],
1061
+ },
1062
+ 6075: {
1063
+ name: "ErrOutsideOperatingHours",
1064
+ message: "Current UTC hour is outside the policy's operating_hours bitmask. The vault is configured to spend only during specific UTC hours.",
1065
+ category: "POLICY_VIOLATION",
1066
+ retryable: true,
1067
+ recovery_actions: [
1068
+ {
1069
+ action: "retry_in_window",
1070
+ description: "Wait until a UTC hour permitted by the policy's operating_hours bitmask, or have the owner widen the mask via queue_policy_update.",
655
1071
  },
656
1072
  ],
657
1073
  },
658
- // --- Instruction constraints errors ---
659
- 6047: {
660
- name: "InvalidConstraintConfig",
661
- message: "Invalid constraint configuration: bounds exceeded",
662
- category: "INPUT_VALIDATION",
663
- retryable: false,
1074
+ 6076: {
1075
+ name: "ErrCooldownActive",
1076
+ message: "Agent cooldown has not elapsed since the last successful action. Per-agent cooldown is configured by the owner.",
1077
+ category: "POLICY_VIOLATION",
1078
+ retryable: true,
664
1079
  recovery_actions: [
665
1080
  {
666
- action: "fix_constraints",
667
- description: "Ensure constraint entries are within bounds (max 64 entries, 8 data constraints each)",
1081
+ action: "wait_cooldown",
1082
+ description: "Wait until the per-agent cooldown (in seconds) has elapsed since the agent's last successful action.",
668
1083
  },
669
1084
  ],
670
1085
  },
671
- 6048: {
672
- name: "ConstraintViolated",
673
- message: "Instruction violated a configured constraint",
1086
+ 6077: {
1087
+ name: "ErrGraylistFriction",
1088
+ message: "Destination is on the graylist — a 24h friction window applied to newly-added allowlist destinations. Promote via promote_graylist_destination or wait for unlock.",
674
1089
  category: "POLICY_VIOLATION",
675
- retryable: false,
1090
+ retryable: true,
676
1091
  recovery_actions: [
677
1092
  {
678
- action: "check_constraints",
679
- description: "Review the vault's instruction constraints to understand what is allowed",
680
- tool: "sigil_check_vault",
681
- },
682
- {
683
- action: "modify_instruction",
684
- description: "Modify the instruction parameters to satisfy the constraints",
1093
+ action: "wait_or_promote",
1094
+ description: "Owner can promote the destination to active via promote_graylist_destination, or wait the remaining time until automatic unlock.",
685
1095
  },
686
1096
  ],
687
1097
  },
688
- 6049: {
689
- name: "InvalidConstraintsPda",
690
- message: "Invalid constraints PDA: wrong owner or vault",
1098
+ 6078: {
1099
+ name: "ErrGraylistFull",
1100
+ message: "Graylist bound exceeded (max 10 entries). Wait for an existing entry to unlock or promote.",
691
1101
  category: "INPUT_VALIDATION",
692
1102
  retryable: false,
693
1103
  recovery_actions: [
694
1104
  {
695
- action: "verify_pda",
696
- description: "Use the correct constraints PDA derived from the vault",
1105
+ action: "promote_or_wait",
1106
+ description: "Promote at least one graylist entry to active or wait for unlock. Then re-issue the destination-allowlist add.",
697
1107
  },
698
1108
  ],
699
1109
  },
700
- 6050: {
701
- name: "InvalidPendingConstraintsPda",
702
- message: "Invalid pending constraints PDA: wrong owner or vault",
1110
+ 6079: {
1111
+ name: "ErrToken2022ExtensionForbidden",
1112
+ message: "Token-2022 mint has a forbidden extension. Only MemoTransfer and MetadataPointer extensions are permitted at deposit.",
703
1113
  category: "INPUT_VALIDATION",
704
1114
  retryable: false,
705
1115
  recovery_actions: [
706
1116
  {
707
- action: "verify_pda",
708
- description: "Use the correct pending constraints PDA derived from the vault",
1117
+ action: "use_supported_mint",
1118
+ description: "Use a Token-2022 mint with no extensions, or one limited to MemoTransfer/MetadataPointer.",
709
1119
  },
710
1120
  ],
711
1121
  },
712
- // --- Per-agent spend limit errors ---
713
- 6051: {
714
- name: "AgentSpendLimitExceeded",
715
- message: "Agent's rolling 24h spend exceeds their individual spending limit",
716
- category: "SPENDING_CAP",
717
- retryable: true,
718
- retry_after_ms: 3_600_000,
1122
+ 6080: {
1123
+ name: "ErrCosignRequired",
1124
+ // §RP-2 M-NEW-3 (audit 2026-05-19): after P0.1 + H-NEW-1, 6089
1125
+ // fires from four sites queue_policy_update (original elevated
1126
+ // mutation path), register_agent, set_observe_only(false→true),
1127
+ // and unpause_agent. The message + recovery now reflect that the
1128
+ // common axis is "cosign-opted-in vault + owner action lacking a
1129
+ // non-owner co-signer", not just queue_policy_update specifically.
1130
+ message: "Cosign-opted-in vault requires a non-owner signer for this owner-action. Original sites: queue_policy_update (elevated), register_agent, set_observe_only(false→true), unpause_agent.",
1131
+ category: "PERMISSION",
1132
+ retryable: false,
719
1133
  recovery_actions: [
720
1134
  {
721
- action: "reduce_amount",
722
- description: "Reduce the amount to fit within the agent's remaining limit",
723
- },
724
- {
725
- action: "check_spending",
726
- description: "Check the agent's current spend against their limit",
727
- tool: "sigil_check_spending",
728
- },
729
- {
730
- action: "wait",
731
- description: "Wait for the 24h rolling window to release spent capacity",
1135
+ action: "supply_cosigner",
1136
+ description: "Supply the cosign session pubkey as a signer in remaining_accounts. For queue_policy_update, also pass cosign_session as an arg. The cosign session must not be the owner's own key.",
732
1137
  },
733
1138
  ],
734
1139
  },
735
- 6052: {
736
- name: "OverlaySlotExhausted",
737
- message: "Per-agent overlay is full cannot register agent with spending limit",
738
- category: "INPUT_VALIDATION",
1140
+ 6081: {
1141
+ name: "ErrAutoRevoked",
1142
+ message: "Agent capability was auto-revoked after consecutive policy-violation failures. Owner must re-enable via queue_agent_permissions_update.",
1143
+ category: "PERMISSION",
739
1144
  retryable: false,
740
1145
  recovery_actions: [
741
1146
  {
742
- action: "revoke_agent",
743
- description: "Revoke an unused agent to free an overlay slot",
744
- tool: "sigil_revoke_agent",
1147
+ action: "owner_reenable",
1148
+ description: "Owner queues a fresh queue_agent_permissions_update setting the agent's capability back to Observer or Operator.",
745
1149
  },
746
1150
  ],
747
1151
  },
748
- 6053: {
749
- name: "AgentSlotNotFound",
750
- message: "Agent has per-agent spending limit but no overlay tracking slot",
751
- category: "RESOURCE_NOT_FOUND",
1152
+ // Phase 4 — Bundle integrity (TA-10 + TA-11 + AC-10)
1153
+ 6082: {
1154
+ name: "ErrSandwichIntegrity",
1155
+ message: "Bundle integrity violation: multiple validate_and_authorize instructions for the same (vault, agent, mint) tuple in one transaction. At most one is permitted (TA-10 hardening).",
1156
+ category: "POLICY_VIOLATION",
752
1157
  retryable: false,
753
1158
  recovery_actions: [
754
1159
  {
755
- action: "contact_support",
756
- description: "This is an internal consistency error the overlay may need reinitialization",
1160
+ action: "rebuild_bundle",
1161
+ description: "Rebuild the transaction with exactly one validate_and_authorize per (vault, agent, mint) tuple. ComputeBudget and SystemProgram instructions may be interleaved.",
757
1162
  },
758
1163
  ],
759
1164
  },
760
- 6054: {
761
- name: "UnauthorizedTokenApproval",
762
- message: "Unauthorized SPL Token Approve detected between validate and finalize",
1165
+ 6083: {
1166
+ name: "ErrProtectedWritable",
1167
+ message: "A Sigil-owned PDA was passed as writable to a foreign instruction between validate and finalize (TA-11). Protected PDAs include vault, policy, tracker, session, post_assertions, audit, constraints, and overlay accounts.",
763
1168
  category: "POLICY_VIOLATION",
764
1169
  retryable: false,
765
1170
  recovery_actions: [
766
1171
  {
767
- action: "use_sdk",
768
- description: "Use the SDK's compose functions do not insert raw SPL Approve in the sandwich",
1172
+ action: "remove_protected_pda_writable",
1173
+ description: "Remove the writable flag on any Sigil PDA passed to the DeFi instruction, or remove the PDA from that instruction's account metas entirely. Sigil PDAs may still be read by foreign instructions (writable=false is allowed).",
769
1174
  },
770
1175
  ],
771
1176
  },
772
- 6055: {
773
- name: "InvalidSessionExpiry",
774
- message: "Session expiry slots out of range (10-450)",
1177
+ 6084: {
1178
+ name: "ErrSessionNonceMismatch",
1179
+ message: "Session nonce mismatch (AC-10 durable-nonce replay defense). The caller's expected_nonce does not match the session's stored nonce. For a fresh session, pass expected_nonce = 0.",
775
1180
  category: "INPUT_VALIDATION",
776
1181
  retryable: false,
777
1182
  recovery_actions: [
778
1183
  {
779
- action: "fix_expiry",
780
- description: "Set session expiry between 10 and 450 slots",
1184
+ action: "fresh_session_nonce",
1185
+ description: "Pass expected_nonce = 0 for a fresh validate_and_authorize. A non-zero value is only valid in Phase 8 ownership-transfer flow (M-5).",
781
1186
  },
782
1187
  ],
783
1188
  },
784
- 6056: {
785
- name: "UnconstrainedProgramBlocked",
786
- message: "Program has no constraint entry and strict mode is enabled",
1189
+ // ─── Phase 5: post-execution invariants (TA-12 + TA-13 + TA-14) ───
1190
+ // §RP-1 V5: added Phase 5 mappings missing from the SDK error table.
1191
+ // Source of truth: programs/sigil/src/errors.rs:407-451 + IDL.
1192
+ /** 6085 — TA-12: combined USDC+USDT vault balance dropped below the
1193
+ * owner-configured `policy.stable_balance_floor`. The HARD reserve —
1194
+ * no combination of attacks (CPI drain, per-protocol cap bypass, fee
1195
+ * inflation) may drain the vault below this line. Asserted in both
1196
+ * `finalize_session` and `agent_transfer` after the CPI completes.
1197
+ */
1198
+ 6085: {
1199
+ name: "ErrStableFloorViolation",
1200
+ message: "Stable balance floor violated — combined USDC+USDT balance dropped below policy.stable_balance_floor",
787
1201
  category: "POLICY_VIOLATION",
788
1202
  retryable: false,
789
1203
  recovery_actions: [
790
1204
  {
791
- action: "add_constraint",
792
- description: "Add a constraint entry for this program, or disable strict mode",
1205
+ action: "reduce_amount",
1206
+ description: "Reduce the transfer amount so the post-execution combined USDC+USDT vault balance stays at or above policy.stable_balance_floor",
793
1207
  },
794
1208
  {
795
- action: "check_constraints",
796
- description: "Review the vault's instruction constraints",
797
- tool: "sigil_check_vault",
1209
+ action: "deposit_more",
1210
+ description: "Owner can deposit additional USDC or USDT to raise the combined balance above the floor before the agent retries",
1211
+ },
1212
+ {
1213
+ action: "lower_floor",
1214
+ description: "Owner can queue a policy update to lower stable_balance_floor (timelock-gated, owner-only)",
798
1215
  },
799
1216
  ],
800
1217
  },
801
- // --- Per-protocol spend cap errors ---
802
- 6057: {
803
- name: "ProtocolCapExceeded",
804
- message: "Per-protocol rolling 24h spending cap would be exceeded",
1218
+ /** 6095 — TA-13: per-protocol daily cap exceeded. The owner-configured
1219
+ * `policy.protocol_caps[i]` rolling-24h cap for the protocol the agent
1220
+ * is invoking would be exceeded by this transaction. Distinct from
1221
+ * 6047 (ProtocolCapExceeded), which now signals slot-allocation
1222
+ * exhaustion only — see §RP-1 V5 disposition.
1223
+ */
1224
+ 6086: {
1225
+ name: "ErrDailyCapExceeded",
1226
+ message: "Per-protocol daily spending cap would be exceeded (rolling 24h)",
805
1227
  category: "SPENDING_CAP",
806
1228
  retryable: true,
807
1229
  retry_after_ms: 3_600_000,
808
1230
  recovery_actions: [
809
1231
  {
810
1232
  action: "reduce_amount",
811
- description: "Reduce the amount to fit within the protocol's remaining cap",
1233
+ description: "Reduce the amount to fit within this protocol's remaining 24h rolling-window cap",
812
1234
  },
813
1235
  {
814
1236
  action: "use_different_protocol",
815
- description: "Use a different protocol that has remaining capacity",
1237
+ description: "Route through a different allowlisted protocol that has remaining 24h capacity",
816
1238
  },
817
1239
  {
818
1240
  action: "wait",
819
- description: "Wait for the 24h rolling window to release spent capacity",
820
- },
821
- ],
822
- },
823
- 6058: {
824
- name: "ProtocolCapsMismatch",
825
- message: "protocol_caps length must match protocols length when has_protocol_caps is true",
826
- category: "INPUT_VALIDATION",
827
- retryable: false,
1241
+ description: "Wait for the 24h rolling window to release spent capacity for this protocol",
1242
+ },
1243
+ ],
1244
+ },
1245
+ /** 6096 — TA-14: per-recipient daily cap exceeded. The recipient's
1246
+ * rolling-24h outflow would breach `policy.per_recipient_daily_cap_usd`.
1247
+ * Resolved via SPL TokenAccount.owner (the WALLET that holds the
1248
+ * destination ATA), NOT the meta pubkey. Eviction is age-based, never
1249
+ * LRU — array-full with no expired slot returns this code too,
1250
+ * preventing churn-eviction bypass.
1251
+ *
1252
+ * **H-10 (pre-redeploy audit 2026-05-21) — TRIPLE-CAUSE DISAMBIGUATION:**
1253
+ * The same code (6096) fires from THREE distinct branches inside
1254
+ * `programs/sigil/src/instructions/finalize_session.rs`:
1255
+ *
1256
+ * 1. **Cap exceeded** (`finalize_session.rs:654`): cumulative 24h
1257
+ * recipient outflow + this transfer > policy cap. Recovery: shrink
1258
+ * the amount, route via a different allowed recipient with cap
1259
+ * headroom, or wait for the rolling window to release capacity.
1260
+ * 2. **Multiple distinct recipients in one tx** (`finalize_session.rs:638`):
1261
+ * V1 enforces single-recipient-per-tx for per-recipient cap
1262
+ * attribution sanity. Recovery: SPLIT the bundle so each finalize
1263
+ * touches at most one allowlisted recipient
1264
+ * (`split_into_separate_transactions`).
1265
+ * 3. **`per_recipient` array full with no expired slot**
1266
+ * (`finalize_session.rs:658` via `tracker.record_recipient_spend`):
1267
+ * the fixed-size 10-slot tracker has no entry eligible for
1268
+ * age-based eviction. Recovery: wait for an entry to age out
1269
+ * (same `wait` action as cause 1).
1270
+ *
1271
+ * UX-side: callers cannot distinguish the three branches from the
1272
+ * error code alone — the recovery list below covers all three.
1273
+ */
1274
+ 6087: {
1275
+ name: "ErrRecipientCapExceeded",
1276
+ message: "Per-recipient cap blocked — three possible causes: (a) recipient outflow would breach policy.per_recipient_daily_cap_usd within rolling 24h window; (b) bundle touches multiple distinct allowlisted recipients in one finalize (V1 single-recipient-per-tx rule); (c) per_recipient tracker array full with no expired slot to evict",
1277
+ category: "SPENDING_CAP",
1278
+ retryable: true,
1279
+ retry_after_ms: 3_600_000,
828
1280
  recovery_actions: [
829
1281
  {
830
- action: "fix_config",
831
- description: "Ensure protocol_caps array length matches the protocols array length",
1282
+ action: "reduce_amount",
1283
+ description: "Reduce the transfer amount so the recipient's 24h rolling outflow stays under policy.per_recipient_daily_cap_usd",
832
1284
  },
833
- ],
834
- },
835
- // --- Vault closure guard errors ---
836
- 6059: {
837
- name: "ActiveEscrowsExist",
838
- message: "Active escrow deposits exist — close them before closing vault",
839
- category: "RESOURCE_NOT_FOUND",
1285
+ {
1286
+ action: "split_into_separate_transactions",
1287
+ description: "If the bundle touches multiple distinct allowlisted recipients in one finalize, split it so each transaction touches at most one recipient. V1 enforces single-recipient-per-tx for per-recipient cap attribution.",
1288
+ },
1289
+ {
1290
+ action: "use_different_recipient",
1291
+ description: "Route the transfer to a different allowed destination that has remaining 24h cap headroom",
1292
+ },
1293
+ {
1294
+ action: "wait",
1295
+ description: "Wait for the recipient's rolling 24h window to release spent capacity (also remediates the array-full / no-evictable-slot case)",
1296
+ },
1297
+ ],
1298
+ },
1299
+ // ─── Phase 6: Maestro borrows R-1/R-2/R-3/R-4 (TA-13 absorption) ───
1300
+ // §RP-2 H-NEW-2: added Phase 6 mappings (R-1..R-4) — the predicate already
1301
+ // routes them as "Sigil error" via the >= 6000 && <= SIGIL_ON_CHAIN_ERROR_MAX
1302
+ // bound, but ON_CHAIN_ERROR_MAP had no entries, so users got "Unknown
1303
+ // on-chain error code N" with category FATAL + empty recovery.
1304
+ // Source of truth: programs/sigil/src/errors.rs + IDL.
1305
+ /** 6097 — R-1 MintDeltaCap (attack signal): combined balance of
1306
+ * vault-owned ATAs for the configured mint dropped by more than
1307
+ * `max_net_decrease` between `validate_and_authorize` (pre-snap sum)
1308
+ * and `finalize_session` (post sum). Two enforcement shapes:
1309
+ * scope=0 (vault-wide multi-ATA sum) and scope=1 (single target_account).
1310
+ * Pairs with R-2 (6099) per F-18 to close close-and-recreate evasion.
1311
+ */
1312
+ 6088: {
1313
+ name: "ErrMintDeltaCapExceeded",
1314
+ message: "Mint delta cap exceeded — net outflow of [mint] from vault exceeded policy.mint_delta_cap[mint] within the post-execution check window.",
1315
+ category: "POLICY_VIOLATION",
840
1316
  retryable: false,
841
1317
  recovery_actions: [
842
1318
  {
843
- action: "close_escrows",
844
- description: "Settle or refund all active escrows before closing the vault",
1319
+ action: "verify_post_assertions",
1320
+ description: "Verify the policy.post_assertions configuration for the affected mint. Reduce transaction outflow or raise the per-mint cap via queue_policy_update (timelock-gated).",
845
1321
  },
846
1322
  ],
847
1323
  },
848
- 6060: {
849
- name: "ConstraintsNotClosed",
850
- message: "Instruction constraints PDA still exists close it before closing vault",
851
- category: "RESOURCE_NOT_FOUND",
1324
+ /** 6098 — R-1 MintDeltaCap (caller-bug signal): entry's accounts
1325
+ * couldn't be resolved at validate time. Common shapes:
1326
+ * - scope=1 and target_account not present in remaining_accounts
1327
+ * - target_account's mint field doesn't match the configured mint
1328
+ * - target_account isn't owned by the vault
1329
+ * - scope=0 with no derived ATAs supplied in remaining_accounts
1330
+ * Distinct from ErrMintDeltaCapExceeded because this is a
1331
+ * configuration or caller-side bug (recoverable by fixing the caller),
1332
+ * not an attack signal (which fires 6097 at finalize).
1333
+ */
1334
+ 6089: {
1335
+ name: "MintDeltaCapMisconfigured",
1336
+ message: "Mint delta cap entry misconfigured — invalid scope value, zero max_net_decrease, or required derived ATA missing from remaining_accounts.",
1337
+ category: "FATAL",
852
1338
  retryable: false,
853
1339
  recovery_actions: [
854
1340
  {
855
- action: "close_constraints",
856
- description: "Close the instruction constraints account before closing the vault",
1341
+ action: "inspect_entry_config",
1342
+ description: "Inspect the failed entry's scope value (0 or 1 only), max_net_decrease (must be non-zero for scope=0), and remaining_accounts (must include every derived ATA for scope=0).",
857
1343
  },
858
1344
  ],
859
1345
  },
860
- 6061: {
861
- name: "PendingPolicyExists",
862
- message: "A pending policy update exists apply or cancel it before closing vault",
863
- category: "RESOURCE_NOT_FOUND",
1346
+ /** 6099 — R-2 AtaAuthorityPin (attack signal): a vault-owned token
1347
+ * account had its authority changed during the sandwich, or was
1348
+ * closed and not reinstated as a vault-owned account before finalize.
1349
+ * Detected by reading bytes 32..64 of the post-CPI token account data
1350
+ * and comparing to `vault.key().to_bytes()`. Also fires when the
1351
+ * account is closed (data length < 64) or its owner program is no
1352
+ * longer SPL Token or Token-2022. Pairs with 6097 to close F-18
1353
+ * close+drain+recreate.
1354
+ */
1355
+ 6090: {
1356
+ name: "ErrAtaAuthorityChanged",
1357
+ message: "Vault ATA authority changed mid-transaction — a CPI altered the SPL TokenAccount owner field, defeating the vault's custody.",
1358
+ category: "POLICY_VIOLATION",
864
1359
  retryable: false,
865
1360
  recovery_actions: [
866
1361
  {
867
- action: "resolve_pending_policy",
868
- description: "Apply or cancel the pending policy update before closing the vault",
1362
+ action: "audit_ix_for_set_authority",
1363
+ description: "Verify the DeFi instruction in the bundle does not call setAuthority on any vault-owned ATA. Refuse the bundle and audit the agent's request.",
869
1364
  },
870
1365
  ],
871
1366
  },
872
- // --- Agent pause errors ---
873
- 6062: {
874
- name: "AgentPaused",
875
- message: "Agent is paused unpause before executing actions",
876
- category: "PERMISSION",
1367
+ /** 6100 R-3 OutputBalanceFloor (attack signal): a token account
1368
+ * that was supposed to receive at least `min_increase` units of its
1369
+ * mint during the sandwich did not. Snapshot at
1370
+ * `validate_and_authorize` against `target_account.amount` (u64 LE at
1371
+ * bytes 64..72), finalize requires (post - pre) >= aux_value.
1372
+ * Counter to "dust-fill" attacks where the agent obtains delegation
1373
+ * authority then runs a swap that returns 1 lamport.
1374
+ */
1375
+ 6091: {
1376
+ name: "ErrOutputBelowFloor",
1377
+ message: "Output balance floor violated — the vault's target ATA gained less than policy.min_increase_usd after the post-execution check.",
1378
+ category: "POLICY_VIOLATION",
877
1379
  retryable: false,
878
1380
  recovery_actions: [
879
1381
  {
880
- action: "unpause_agent",
881
- description: "Ask the vault owner to unpause this agent",
1382
+ action: "audit_output_value",
1383
+ description: "Verify the DeFi instruction's output. Common causes: dust-fill swap, partial fill, wrong destination meta. Audit the agent's slippage settings.",
882
1384
  },
883
1385
  ],
884
1386
  },
885
- 6063: {
886
- name: "AgentAlreadyPaused",
887
- message: "Agent is already paused",
888
- category: "INPUT_VALIDATION",
1387
+ /** 6101 — R-4 DeclarationConsistency (attack signal): the
1388
+ * (recipient, mint) pair declared on a post-assertion entry doesn't
1389
+ * match the SPL token account at the configured CPI account-meta
1390
+ * index. Closes the "declaration dishonesty" attack: agent declares
1391
+ * "recipient: alice" to satisfy a destination-allowlist check, then
1392
+ * inserts attacker_ata into the CPI metas. The recipient who would
1393
+ * receive funds (attacker_ata.owner) ≠ alice, so R-4 rejects.
1394
+ */
1395
+ 6092: {
1396
+ name: "ErrDeclarationInconsistent",
1397
+ message: "Declaration consistency check failed — the CPI account meta at the declared index is not a token account matching the agent's declared recipient + mint.",
1398
+ category: "POLICY_VIOLATION",
889
1399
  retryable: false,
890
1400
  recovery_actions: [
891
1401
  {
892
- action: "check_agent_status",
893
- description: "Agent is already paused no action needed",
1402
+ action: "verify_declaration_matches_ix",
1403
+ description: "Verify the agent's authorized_token + output_mint declaration matches the actual SPL TokenAccount at the declared meta index in the DeFi instruction. Reject the bundle if the agent supplied inconsistent declaration.",
894
1404
  },
895
1405
  ],
896
1406
  },
897
- 6064: {
898
- name: "AgentNotPaused",
899
- message: "Agent is not paused cannot unpause",
900
- category: "INPUT_VALIDATION",
1407
+ // ─── Audit 2026-05-19 (P1 HIGH fixes) ───
1408
+ // §RP-2 H-NEW-2: H-1 hard-reject mapping for the destination-check
1409
+ // meta budget. Previously the helper silently take()-truncated at 16;
1410
+ // 1f569eb made it a hard-reject (POLICY_VIOLATION).
1411
+ /** 6102 — H-1 hard-reject (audit 2026-05-19): the foreign DeFi
1412
+ * instruction passed more account metas than
1413
+ * `MAX_DESTINATION_CHECK_METAS_PER_IX` (16). Previously the helper
1414
+ * silently `take()`-truncated at the bound, leaving slots 17+
1415
+ * uninspected; an attacker hiding a hostile destination at slot 17+
1416
+ * would bypass the allowlist check. Hard-reject closes the
1417
+ * silent-drop. Expansion to 32 metas is v1.1 backlog (~+4K CU).
1418
+ */
1419
+ 6093: {
1420
+ name: "IxMetaCountExceeded",
1421
+ message: "Foreign instruction exceeded the account-meta processing budget (destination check: max 24 writable metas / 64 total; agent_transfer floor-walk: 16). The bundle is rejected rather than partially inspected.",
1422
+ category: "POLICY_VIOLATION",
901
1423
  retryable: false,
902
1424
  recovery_actions: [
903
1425
  {
904
- action: "check_agent_status",
905
- description: "Agent is not pausedno action needed",
1426
+ action: "use_a_shorter_route",
1427
+ description: "The route references more writable accounts than the guard can inspect in one pass. Use a shorter Jupiter route; Sigil never reshapes the route itself an unguardable route atomically reverts.",
906
1428
  },
907
1429
  ],
908
1430
  },
909
- 6065: {
910
- name: "UnauthorizedPostFinalizeInstruction",
911
- message: "Instructions after finalize_session must be ComputeBudget or SystemProgram only",
1431
+ // --- Phase 8 (ownership transfer + freeze hardening) ---
1432
+ // Phase 8 ownership-transfer + freeze-hardening codes (now 6094-6099 post M1-04).
1433
+ 6094: {
1434
+ name: "ErrPendingOwnershipExists",
1435
+ message: "An ownership transfer is already pending for this vault. Cancel the existing transfer before queueing a new target.",
912
1436
  category: "POLICY_VIOLATION",
913
1437
  retryable: false,
914
1438
  recovery_actions: [
915
1439
  {
916
- action: "remove_post_finalize_instructions",
917
- description: "Remove any instructions placed after finalize_session in the transaction. Only ComputeBudget and SystemProgram instructions are allowed after finalize.",
1440
+ action: "cancel_ownership_transfer",
1441
+ description: "Call cancel_ownership_transfer to release the pending PDA before queueing a new transfer.",
918
1442
  },
919
1443
  ],
920
1444
  },
921
- 6066: {
922
- name: "UnexpectedBalanceDecrease",
923
- message: "Vault stablecoin balance decreased more than the session authorized amount. " +
924
- "This indicates a compromised DeFi program attempted to drain vault tokens via CPI.",
925
- category: "FATAL",
926
- retryable: false,
1445
+ 6095: {
1446
+ name: "ErrPendingOwnershipNotReady",
1447
+ message: "Ownership transfer timelock has not elapsed yet (default 48h). The new owner cannot accept until the window passes.",
1448
+ category: "TRANSIENT",
1449
+ retryable: true,
927
1450
  recovery_actions: [
928
1451
  {
929
- action: "investigate_defi_program",
930
- description: "The whitelisted DeFi program may be compromised. The actual vault balance decrease " +
931
- "exceeded the authorized delegation amount (fees + DeFi spend). Freeze the vault, " +
932
- "investigate the DeFi program, and consider removing it from the protocol allowlist.",
933
- },
934
- {
935
- action: "freeze_vault",
936
- description: "Immediately freeze the vault to prevent further transactions until the cause is identified.",
1452
+ action: "wait_timelock",
1453
+ description: "Wait for the timelock window to elapse. The owner can cancel during this window to abort the transfer.",
937
1454
  },
938
1455
  ],
939
1456
  },
940
- // --- TOCTOU + timelock hardening errors ---
941
- 6067: {
942
- name: "TimelockTooShort",
943
- message: "Timelock duration is below the minimum (1800 seconds / 30 minutes).",
1457
+ 6096: {
1458
+ name: "ErrInvalidFreezeReason",
1459
+ message: "Invalid freeze_reason byte (must be 0=Manual, 1=AutoRevoke, or 2=EmergencyBoard).",
944
1460
  category: "INPUT_VALIDATION",
945
1461
  retryable: false,
946
1462
  recovery_actions: [
947
1463
  {
948
- action: "increase_timelock",
949
- description: "Set timelock_duration to at least 1800 seconds (30 minutes).",
1464
+ action: "fix_freeze_reason",
1465
+ description: "Re-call freeze_vault with a valid FreezeReason discriminant.",
950
1466
  },
951
1467
  ],
952
1468
  },
953
- 6068: {
954
- name: "PolicyVersionMismatch",
955
- message: "Policy version changed since agent's last RPC read. Re-resolve vault state and retry.",
1469
+ 6097: {
1470
+ name: "ErrReactivateCooldownActive",
1471
+ message: "Reactivate requires a 5-minute observation cooldown after the vault was frozen. Try again after the cooldown elapses.",
956
1472
  category: "TRANSIENT",
957
1473
  retryable: true,
958
- retry_after_ms: 1000,
1474
+ retry_after_ms: 300_000,
959
1475
  recovery_actions: [
960
1476
  {
961
- action: "re_resolve_state",
962
- description: "Re-fetch vault state via resolveVaultState() to get current policy version, then retry.",
1477
+ action: "wait_cooldown",
1478
+ description: "Wait for the 5-minute observation window to elapse before reactivating.",
963
1479
  },
964
1480
  ],
965
1481
  },
966
- 6069: {
967
- name: "PendingAgentPermsExists",
968
- message: "A pending agent permissions update already exists for this agent.",
969
- category: "RESOURCE_NOT_FOUND",
1482
+ 6098: {
1483
+ name: "ErrInvalidOwnershipTarget",
1484
+ message: "new_owner cannot be a system/program/sysvar address (would permanently brick the vault).",
1485
+ category: "INPUT_VALIDATION",
970
1486
  retryable: false,
971
1487
  recovery_actions: [
972
1488
  {
973
- action: "apply_or_cancel_pending",
974
- description: "Apply or cancel the existing pending update before queuing a new one.",
1489
+ action: "use_signer_pubkey",
1490
+ description: "Pass an EOA pubkey or Squads V4 vault PDA as new_owner not SystemProgram, the program ID, or a sysvar.",
975
1491
  },
976
1492
  ],
977
1493
  },
978
- 6070: {
979
- name: "PendingCloseConstraintsExists",
980
- message: "A pending close constraints operation already exists for this vault.",
1494
+ 6099: {
1495
+ name: "ErrTooManyRevokePairs",
1496
+ message: "freeze_internal received more than MAX_REVOKE_PAIRS (10) session/token pairs in remaining_accounts.",
1497
+ category: "INPUT_VALIDATION",
1498
+ retryable: false,
1499
+ recovery_actions: [
1500
+ {
1501
+ action: "split_revoke_batch",
1502
+ description: "Split the (session_pda, token_account) pairs across multiple freeze_internal calls.",
1503
+ },
1504
+ ],
1505
+ },
1506
+ // H-3 close (pre-redeploy audit 2026-05-21): close_vault rejects if
1507
+ // policy.has_post_assertions != 0 because the 672-byte PostExecutionAssertions
1508
+ // zero-copy PDA must be drained via close_post_assertions first; otherwise it
1509
+ // would be orphaned on close.
1510
+ 6100: {
1511
+ name: "ErrPostAssertionsNotClosed",
1512
+ message: "PostExecutionAssertions PDA still active — call close_post_assertions before close_vault.",
981
1513
  category: "RESOURCE_NOT_FOUND",
982
1514
  retryable: false,
983
1515
  recovery_actions: [
984
1516
  {
985
- action: "apply_or_cancel_pending",
986
- description: "Apply or cancel the existing pending close constraints before queuing a new one.",
1517
+ action: "close_post_assertions",
1518
+ description: "Invoke the close_post_assertions instruction to drain the 672-byte PostExecutionAssertions PDA, then retry close_vault.",
987
1519
  },
988
1520
  ],
989
1521
  },
990
- 6071: {
991
- name: "ActiveSessionsExist",
992
- message: "Cannot close vault with active sessions. Finalize all pending sessions first.",
993
- category: "POLICY_VIOLATION",
994
- retryable: true,
995
- retry_after_ms: 10000,
1522
+ // H-4 close (pre-redeploy audit 2026-05-21, Bucket 1): queue_policy_update
1523
+ // rejects if any allowed_destinations entry is the address of a Sigil-owned
1524
+ // protected PDA for this vault. Closes the owner-self-foot-gun where a
1525
+ // phished owner allowlists a Sigil PDA, enabling an agent to lock funds
1526
+ // at the PDA via a token transfer.
1527
+ 6101: {
1528
+ name: "ErrDestinationIsProtectedPda",
1529
+ message: "allowed_destinations entry is a Sigil-protected PDA — owner attempted to allowlist a vault/policy/pending_* PDA.",
1530
+ category: "INPUT_VALIDATION",
1531
+ retryable: false,
996
1532
  recovery_actions: [
997
1533
  {
998
- action: "finalize_sessions",
999
- description: "Wait for active sessions to finalize or expire, then retry close_vault.",
1534
+ action: "remove_protected_pda_from_destinations",
1535
+ description: "Remove any pubkey from allowed_destinations that matches a Sigil-protected PDA for this vault. Use a plain EOA or external program owner instead.",
1000
1536
  },
1001
1537
  ],
1002
1538
  },
1003
- // --- Post-execution assertions (Phase B scaffolding) ---
1004
- 6072: {
1005
- name: "PostAssertionFailed",
1006
- message: "Post-execution assertion failed: account state did not satisfy constraint.",
1539
+ // D-1 + D-6 close (Bucket 2 audit 2026-05-21): AL3 on-chain scalar intent-
1540
+ // digest mismatch. The wallet's preview-time digest doesn't match the
1541
+ // digest the on-chain verifier recomputed from validate_and_authorize's
1542
+ // args. Most likely: man-in-the-middle (compromised agent / browser ext)
1543
+ // swapped one of the scalar fields (mint, amount, target_protocol)
1544
+ // between preview and submit. Less likely: cross-network replay
1545
+ // (mainnet digest sent through a devnet program).
1546
+ 6102: {
1547
+ name: "ErrIntentDigestMismatch",
1548
+ message: "AL3 intent-digest mismatch — wallet preview digest does not match the executed bundle's scalars.",
1007
1549
  category: "POLICY_VIOLATION",
1008
1550
  retryable: false,
1009
1551
  recovery_actions: [
1010
1552
  {
1011
- action: "review_assertions",
1012
- description: "Review the vault's post-execution assertions. The trade's resulting account state violated a configured assertion.",
1553
+ action: "rebuild_seal_from_fresh_preview",
1554
+ description: "Re-run the wallet preview to refresh the intent digest, then resubmit. If the mismatch persists after a fresh preview, suspect a compromised middleware/agent — pause the agent and investigate.",
1013
1555
  },
1014
1556
  ],
1015
1557
  },
1016
- 6073: {
1017
- name: "InvalidPostAssertionIndex",
1018
- message: "Post-assertion references an invalid instruction index.",
1019
- category: "INPUT_VALIDATION",
1558
+ // M-5 close (Bucket 2 audit 2026-05-21, PEN-CROSS-3): apply_agent_grant
1559
+ // rejected because the recomputed digest of PendingAgentGrant content
1560
+ // doesn't match the queue-time digest. Same digest-binding defense class
1561
+ // as the policy/ownership pending-update digest checks.
1562
+ 6103: {
1563
+ name: "ErrPendingAgentGrantDigestMismatch",
1564
+ message: "PendingAgentGrant content tampered between queue and apply — digest mismatch.",
1565
+ category: "POLICY_VIOLATION",
1020
1566
  retryable: false,
1021
1567
  recovery_actions: [
1022
1568
  {
1023
- action: "fix_assertions",
1024
- description: "Review and update the vault's post-assertion configuration.",
1569
+ action: "cancel_and_requeue_agent_grant",
1570
+ description: "Cancel the pending grant via cancel_agent_grant, then queue a fresh grant with the intended agent + capability.",
1025
1571
  },
1026
1572
  ],
1027
1573
  },
1028
- 6074: {
1029
- name: "UnauthorizedPreValidateInstruction",
1030
- message: "Non-infrastructure instruction detected before validate_and_authorize.",
1031
- category: "PERMISSION",
1574
+ // D-5 close (Bucket 2 audit 2026-05-21, F-RP3-1): reactivate_vault
1575
+ // rejected a FULL_CAPABILITY agent graft because no non-owner signer was
1576
+ // present. Defaults-on safety (NH-1): any FULL_CAPABILITY grant on
1577
+ // reactivate requires a second signer, regardless of whether
1578
+ // policy.cosign_session_pubkey was pre-configured. Closes the phished-
1579
+ // owner freeze→reactivate(attacker, FULL) single-signature foot-gun.
1580
+ 6104: {
1581
+ name: "ErrReactivateCosignRequiredForFullCapability",
1582
+ message: "Reactivate with a FULL_CAPABILITY new agent requires a non-owner cosigner.",
1583
+ category: "ESCALATION_REQUIRED",
1032
1584
  retryable: false,
1033
1585
  recovery_actions: [
1034
1586
  {
1035
- action: "fix_instruction_order",
1036
- description: "Place validate_and_authorize before any DeFi or program instruction.",
1587
+ action: "include_second_signer_in_remaining_accounts",
1588
+ description: "Re-sign the reactivate transaction with a second non-owner signer in remaining_accounts. If policy.cosign_session_pubkey is set, the signer must match it.",
1037
1589
  },
1038
1590
  ],
1039
1591
  },
1040
- 6075: {
1041
- name: "SnapshotNotCaptured",
1042
- message: "Delta assertion snapshot was not captured in validate_and_authorize.",
1043
- category: "INPUT_VALIDATION",
1592
+ 6105: {
1593
+ name: "DestinationAccountUnresolvable",
1594
+ message: "A writable account of the DeFi instruction could not be resolved in validate's remaining_accounts, so the guard cannot classify it (F-Q1a destination completeness — rejected fail-closed rather than silently skipped).",
1595
+ category: "POLICY_VIOLATION",
1044
1596
  retryable: false,
1045
1597
  recovery_actions: [
1046
1598
  {
1047
- action: "fix_assertions",
1048
- description: "Ensure validate_and_authorize captures a snapshot before finalize delta check.",
1599
+ action: "use_seal_to_populate_remaining_accounts",
1600
+ description: "Build the bundle with seal(), which auto-populates validate's (and finalize's) remaining_accounts with every writable account of the DeFi instruction (the fee-payer agent included). Hand-built bundles must mirror this.",
1049
1601
  },
1050
1602
  ],
1051
1603
  },
1052
- 6076: {
1053
- name: "ConstraintIndexOutOfBounds",
1054
- message: "Constraint entry index out of bounds for zero-copy array.",
1055
- category: "INPUT_VALIDATION",
1604
+ 6106: {
1605
+ name: "ErrToken2022OutputMintUnresolvable",
1606
+ message: "A vault-owned Token-2022 token account's mint could not be resolved in validate's remaining_accounts (or the supplied account is not Token-2022-owned), so the guard cannot vet its extensions (F-Q4 — rejected fail-closed). A PermanentDelegate / TransferHook / ConfidentialTransfer mint must be vetted before the vault may acquire the token.",
1607
+ category: "POLICY_VIOLATION",
1056
1608
  retryable: false,
1057
1609
  recovery_actions: [
1058
1610
  {
1059
- action: "fix_constraints",
1060
- description: "Ensure constraint entries do not exceed max 64 entries.",
1611
+ action: "use_seal_to_populate_remaining_accounts",
1612
+ description: "Build the bundle with seal(), which auto-resolves vault-owned Token-2022 output mints (reading each writable account's mint on-chain) and feeds them into validate's remaining_accounts. Hand-built bundles must include the mint account of every vault-owned Token-2022 token account the swap writes.",
1061
1613
  },
1062
1614
  ],
1063
1615
  },
1064
- 6077: {
1065
- name: "InvalidConstraintOperator",
1066
- message: "Constraint operator value is not a valid ConstraintOperator discriminant.",
1067
- category: "INPUT_VALIDATION",
1616
+ 6107: {
1617
+ name: "ErrOperatorGrantRequiresTimelock",
1618
+ message: "An OPERATOR-class agent grant cannot be seated instantly on this vault (single-key, cosign-required-but-unbound, or any vault with a configured operator_grant_delay_seconds > 0). It must route through the timelocked queue_agent_grant → apply_agent_grant path — the time-delay substitutes for the missing 2nd authorization factor (F-Q6).",
1619
+ category: "POLICY_VIOLATION",
1068
1620
  retryable: false,
1069
1621
  recovery_actions: [
1070
1622
  {
1071
- action: "fix_constraints",
1072
- description: "Ensure constraint operators are valid (0-6).",
1623
+ action: "use_queue_agent_grant",
1624
+ description: "Seat the OPERATOR via queue_agent_grant, wait the effective delay (>=10 min for a single-key vault, else the configured operator_grant_delay_seconds), then apply_agent_grant. A cosign-bound vault at zero delay can seat instantly by including the bound cosigner's signature in register_agent.",
1073
1625
  },
1074
1626
  ],
1075
1627
  },
1076
- 6078: {
1077
- name: "ConstraintsVaultMismatch",
1078
- message: "Zero-copy constraints account has wrong vault.",
1079
- category: "INPUT_VALIDATION",
1628
+ 6108: {
1629
+ name: "ErrOperatorGrantDelayTooLong",
1630
+ message: "operator_grant_delay_seconds exceeds the maximum (48h / 172800s). A larger delay could exceed the apply-time freshness ceiling and leave a queued OPERATOR grant permanently unapplyable, so it is rejected at configuration time (F-Q6).",
1631
+ category: "POLICY_VIOLATION",
1080
1632
  retryable: false,
1081
1633
  recovery_actions: [
1082
1634
  {
1083
- action: "verify_pda",
1084
- description: "The constraints PDA does not belong to this vault.",
1635
+ action: "lower_operator_grant_delay",
1636
+ description: "Set operator_grant_delay_seconds to at most 172800 (48h) in the queue_policy_update call.",
1085
1637
  },
1086
1638
  ],
1087
1639
  },
1088
- 6079: {
1089
- name: "ConstraintEntryCountExceeded",
1090
- message: "Cannot pack entries: entry count exceeds MAX_CONSTRAINT_ENTRIES (64).",
1091
- category: "INPUT_VALIDATION",
1640
+ 6109: {
1641
+ name: "InvalidOwnerType",
1642
+ message: "vault.owner_type held a value outside the recognized discriminants (0 = EOA, 1 = multisig) at an OPERATOR-grant read site. Only reachable via on-chain state corruption (the field is program-set to {0,1}); the operation is rejected rather than acting on corrupted authority state (F-Q6).",
1643
+ category: "POLICY_VIOLATION",
1092
1644
  retryable: false,
1093
1645
  recovery_actions: [
1094
1646
  {
1095
- action: "reduce_entries",
1096
- description: "Reduce the number of constraint entries to 64 or fewer.",
1647
+ action: "report_state_corruption",
1648
+ description: "vault.owner_type is program-set to 0 (EOA) or 1 (multisig); an out-of-range value indicates on-chain state corruption and should be unreachable in normal operation. OPERATOR-grant paths are blocked until the vault state is valid — report this.",
1097
1649
  },
1098
1650
  ],
1099
1651
  },
1100
- 6080: {
1101
- name: "BlockedSplOpcode",
1102
- message: "SPL opcode is blocked at runtime and cannot be used in constraints.",
1103
- category: "INPUT_VALIDATION",
1652
+ 6110: {
1653
+ name: "SpendAccountingUnderflow",
1654
+ message: "finalize_session detected collected fees exceeding the realized stablecoin outflow (fees_collected > total_decrease) — an accounting impossibility, since fees are CPI'd out before the DeFi leg. The transaction is rejected fail-closed rather than under-counting the spend against the caps (F-Q9).",
1655
+ category: "POLICY_VIOLATION",
1104
1656
  retryable: false,
1105
1657
  recovery_actions: [
1106
1658
  {
1107
- action: "fix_constraints",
1108
- description: "Remove blocked SPL opcode from the constraint entry use allowlisted opcodes only.",
1659
+ action: "review_swap_construction",
1660
+ description: "This fires when a stablecoin-input action net-returned stablecoin so the measured outflow was smaller than the protocol+developer fees. Verify the DeFi instruction actually spends the declared stablecoin input; a net-return on the stablecoin-input path is anomalous and is rejected.",
1109
1661
  },
1110
1662
  ],
1111
1663
  },
@@ -1609,7 +2161,7 @@ const SDK_ERRORS = {
1609
2161
  * Convert any error into a structured AgentError.
1610
2162
  *
1611
2163
  * Handles:
1612
- * - On-chain Anchor errors (code 6000-6080)
2164
+ * - On-chain Anchor errors (code 6000-6102)
1613
2165
  * - SDK errors (code 7000-7033)
1614
2166
  * - Network/RPC errors (from message patterns)
1615
2167
  * - Unknown errors (wrapped as FATAL)
@@ -1910,8 +2462,11 @@ function extractErrorCode(error) {
1910
2462
  if (!error || typeof error !== "object")
1911
2463
  return null;
1912
2464
  const e = error;
1913
- // Direct code property
1914
- if (typeof e.code === "number" && e.code >= 6000 && e.code <= 6080)
2465
+ // Direct code property — uses SIGIL_ON_CHAIN_ERROR_{MIN,MAX} constants
2466
+ // defined at top of file as single source of truth.
2467
+ if (typeof e.code === "number" &&
2468
+ e.code >= SIGIL_ON_CHAIN_ERROR_MIN &&
2469
+ e.code <= SIGIL_ON_CHAIN_ERROR_MAX)
1915
2470
  return e.code;
1916
2471
  // Anchor error structure
1917
2472
  if (e.error && typeof e.error === "object") {
@@ -1927,7 +2482,7 @@ function extractErrorCode(error) {
1927
2482
  const match = e.message.match(/custom program error: 0x([0-9a-fA-F]+)/);
1928
2483
  if (match) {
1929
2484
  const code = parseInt(match[1], 16);
1930
- if (code >= 6000 && code <= 6080)
2485
+ if (code >= SIGIL_ON_CHAIN_ERROR_MIN && code <= SIGIL_ON_CHAIN_ERROR_MAX)
1931
2486
  return code;
1932
2487
  }
1933
2488
  }
@@ -2084,17 +2639,6 @@ const SDK_ERROR_PATTERNS = [
2084
2639
  },
2085
2640
  ],
2086
2641
  },
2087
- {
2088
- pattern: /Escrow action/,
2089
- category: "INPUT_VALIDATION",
2090
- retryable: false,
2091
- recovery_actions: [
2092
- {
2093
- action: "use_escrow_api",
2094
- description: "Use createEscrow/settleEscrow/refundEscrow instead of wrap().",
2095
- },
2096
- ],
2097
- },
2098
2642
  ];
2099
2643
  // ─── SigilSdkError ──────────────────────────────────────────────────────────
2100
2644
  /**
@@ -2144,11 +2688,37 @@ export class SigilSdkError extends Error {
2144
2688
  * Returns a SigilSdkError (extends Error) so instanceof Error checks still work.
2145
2689
  *
2146
2690
  * Processing order:
2147
- * 1. Try on-chain error extraction via toAgentError() (numeric codes 6000-6080)
2691
+ * 1. Try on-chain error extraction via toAgentError() (numeric codes 6000-6102)
2148
2692
  * 2. Pattern-match SDK error messages (11 patterns from seal.ts throw sites)
2149
2693
  * 3. Fallback to UNKNOWN/FATAL
2150
2694
  */
2151
2695
  export function toSigilAgentError(err) {
2696
+ // Phase 9 Batch M §RP CRIT-1 fix: preserve SigilSdkDomainError and
2697
+ // SigilRpcError instances unmodified. These are the canonical
2698
+ // SDK-domain-typed errors carrying their own `.code`, structured
2699
+ // `.context`, and rich `.message`. Funneling them through the
2700
+ // pattern-matcher + UNKNOWN/FATAL fallback below silently strips
2701
+ // the context the throw site built (vault address, docs URL,
2702
+ // opt-in/opt-out snippets, network identifier, etc.).
2703
+ //
2704
+ // Wrap the domain error in a SigilSdkError that mirrors its code
2705
+ // + context so downstream consumers narrowing on either
2706
+ // `err instanceof SigilSdkDomainError` (the original throw) OR
2707
+ // `err.code === SIGIL_ERROR__SDK__MAINNET_CONFIRMATION_REQUIRED`
2708
+ // (the SigilSdkError surface) both work.
2709
+ if (err instanceof Error &&
2710
+ typeof err.code === "string" &&
2711
+ err.code.startsWith("SIGIL_ERROR__")) {
2712
+ const sigilErr = err;
2713
+ return new SigilSdkError({
2714
+ code: sigilErr.code,
2715
+ message: sigilErr.message,
2716
+ category: "FATAL",
2717
+ retryable: false,
2718
+ recovery_actions: [],
2719
+ context: sigilErr.context ?? {},
2720
+ });
2721
+ }
2152
2722
  // Try on-chain error extraction first
2153
2723
  const onChain = toAgentError(err);
2154
2724
  if (onChain.code !== "UNKNOWN")