@usesigil/kit 0.13.0 → 0.16.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 (260) hide show
  1. package/dist/advanced-analytics.d.ts +3 -1
  2. package/dist/advanced-analytics.d.ts.map +1 -1
  3. package/dist/advanced-analytics.js +4 -6
  4. package/dist/advanced-analytics.js.map +1 -1
  5. package/dist/agent-bootstrap.d.ts +118 -0
  6. package/dist/agent-bootstrap.d.ts.map +1 -0
  7. package/dist/agent-bootstrap.js +211 -0
  8. package/dist/agent-bootstrap.js.map +1 -0
  9. package/dist/agent-errors.d.ts +3 -3
  10. package/dist/agent-errors.d.ts.map +1 -1
  11. package/dist/agent-errors.js +230 -206
  12. package/dist/agent-errors.js.map +1 -1
  13. package/dist/build-unsigned.d.ts +152 -0
  14. package/dist/build-unsigned.d.ts.map +1 -0
  15. package/dist/build-unsigned.js +152 -0
  16. package/dist/build-unsigned.js.map +1 -0
  17. package/dist/constraints/index.d.ts +23 -0
  18. package/dist/constraints/index.d.ts.map +1 -0
  19. package/dist/constraints/index.js +24 -0
  20. package/dist/constraints/index.js.map +1 -0
  21. package/dist/create-vault.d.ts +10 -2
  22. package/dist/create-vault.d.ts.map +1 -1
  23. package/dist/create-vault.js +10 -3
  24. package/dist/create-vault.js.map +1 -1
  25. package/dist/dashboard/constraint-builders.d.ts +82 -0
  26. package/dist/dashboard/constraint-builders.d.ts.map +1 -0
  27. package/dist/dashboard/constraint-builders.js +204 -0
  28. package/dist/dashboard/constraint-builders.js.map +1 -0
  29. package/dist/dashboard/errors.d.ts +37 -0
  30. package/dist/dashboard/errors.d.ts.map +1 -1
  31. package/dist/dashboard/errors.js +76 -0
  32. package/dist/dashboard/errors.js.map +1 -1
  33. package/dist/dashboard/from-json.d.ts.map +1 -1
  34. package/dist/dashboard/from-json.js +1 -5
  35. package/dist/dashboard/from-json.js.map +1 -1
  36. package/dist/dashboard/index.d.ts +31 -10
  37. package/dist/dashboard/index.d.ts.map +1 -1
  38. package/dist/dashboard/index.js +40 -10
  39. package/dist/dashboard/index.js.map +1 -1
  40. package/dist/dashboard/mutations.d.ts +60 -3
  41. package/dist/dashboard/mutations.d.ts.map +1 -1
  42. package/dist/dashboard/mutations.js +129 -32
  43. package/dist/dashboard/mutations.js.map +1 -1
  44. package/dist/dashboard/post-assertion-validation.d.ts +88 -0
  45. package/dist/dashboard/post-assertion-validation.d.ts.map +1 -0
  46. package/dist/dashboard/post-assertion-validation.js +191 -0
  47. package/dist/dashboard/post-assertion-validation.js.map +1 -0
  48. package/dist/dashboard/reads.d.ts +93 -1
  49. package/dist/dashboard/reads.d.ts.map +1 -1
  50. package/dist/dashboard/reads.js +244 -40
  51. package/dist/dashboard/reads.js.map +1 -1
  52. package/dist/dashboard/types.d.ts +149 -21
  53. package/dist/dashboard/types.d.ts.map +1 -1
  54. package/dist/errors/codes.js +1 -1
  55. package/dist/event-analytics.d.ts +1 -3
  56. package/dist/event-analytics.d.ts.map +1 -1
  57. package/dist/event-analytics.js +4 -9
  58. package/dist/event-analytics.js.map +1 -1
  59. package/dist/events.js +2 -2
  60. package/dist/events.js.map +1 -1
  61. package/dist/generated/accounts/agentVault.d.ts +0 -20
  62. package/dist/generated/accounts/agentVault.d.ts.map +1 -1
  63. package/dist/generated/accounts/agentVault.js +0 -2
  64. package/dist/generated/accounts/agentVault.js.map +1 -1
  65. package/dist/generated/accounts/pendingAgentPermissionsUpdate.d.ts +12 -0
  66. package/dist/generated/accounts/pendingAgentPermissionsUpdate.d.ts.map +1 -1
  67. package/dist/generated/accounts/pendingAgentPermissionsUpdate.js +3 -1
  68. package/dist/generated/accounts/pendingAgentPermissionsUpdate.js.map +1 -1
  69. package/dist/generated/accounts/pendingCloseConstraints.d.ts +12 -0
  70. package/dist/generated/accounts/pendingCloseConstraints.d.ts.map +1 -1
  71. package/dist/generated/accounts/pendingCloseConstraints.js +4 -2
  72. package/dist/generated/accounts/pendingCloseConstraints.js.map +1 -1
  73. package/dist/generated/accounts/pendingConstraintsUpdate.d.ts +14 -0
  74. package/dist/generated/accounts/pendingConstraintsUpdate.d.ts.map +1 -1
  75. package/dist/generated/accounts/pendingConstraintsUpdate.js +4 -2
  76. package/dist/generated/accounts/pendingConstraintsUpdate.js.map +1 -1
  77. package/dist/generated/accounts/pendingPolicyUpdate.d.ts +24 -8
  78. package/dist/generated/accounts/pendingPolicyUpdate.d.ts.map +1 -1
  79. package/dist/generated/accounts/pendingPolicyUpdate.js +6 -8
  80. package/dist/generated/accounts/pendingPolicyUpdate.js.map +1 -1
  81. package/dist/generated/accounts/policyConfig.d.ts +28 -18
  82. package/dist/generated/accounts/policyConfig.d.ts.map +1 -1
  83. package/dist/generated/accounts/policyConfig.js +4 -8
  84. package/dist/generated/accounts/policyConfig.js.map +1 -1
  85. package/dist/generated/accounts/sessionAuthority.d.ts +18 -8
  86. package/dist/generated/accounts/sessionAuthority.d.ts.map +1 -1
  87. package/dist/generated/accounts/sessionAuthority.js +4 -6
  88. package/dist/generated/accounts/sessionAuthority.js.map +1 -1
  89. package/dist/generated/errors/sigil.d.ts +95 -89
  90. package/dist/generated/errors/sigil.d.ts.map +1 -1
  91. package/dist/generated/errors/sigil.js +107 -98
  92. package/dist/generated/errors/sigil.js.map +1 -1
  93. package/dist/generated/event-discriminators.js +1 -1
  94. package/dist/generated/event-discriminators.js.map +1 -1
  95. package/dist/generated/instructions/cleanupOrphanConstraintsPda.d.ts +67 -0
  96. package/dist/generated/instructions/cleanupOrphanConstraintsPda.d.ts.map +1 -0
  97. package/dist/generated/instructions/cleanupOrphanConstraintsPda.js +120 -0
  98. package/dist/generated/instructions/cleanupOrphanConstraintsPda.js.map +1 -0
  99. package/dist/generated/instructions/freezeVault.d.ts +8 -5
  100. package/dist/generated/instructions/freezeVault.d.ts.map +1 -1
  101. package/dist/generated/instructions/freezeVault.js +14 -3
  102. package/dist/generated/instructions/freezeVault.js.map +1 -1
  103. package/dist/generated/instructions/index.d.ts +1 -1
  104. package/dist/generated/instructions/index.d.ts.map +1 -1
  105. package/dist/generated/instructions/index.js +1 -1
  106. package/dist/generated/instructions/index.js.map +1 -1
  107. package/dist/generated/instructions/initializeVault.d.ts +0 -8
  108. package/dist/generated/instructions/initializeVault.d.ts.map +1 -1
  109. package/dist/generated/instructions/initializeVault.js +0 -4
  110. package/dist/generated/instructions/initializeVault.js.map +1 -1
  111. package/dist/generated/instructions/queuePolicyUpdate.d.ts +8 -16
  112. package/dist/generated/instructions/queuePolicyUpdate.d.ts.map +1 -1
  113. package/dist/generated/instructions/queuePolicyUpdate.js +4 -8
  114. package/dist/generated/instructions/queuePolicyUpdate.js.map +1 -1
  115. package/dist/generated/programs/sigil.d.ts +26 -26
  116. package/dist/generated/programs/sigil.d.ts.map +1 -1
  117. package/dist/generated/programs/sigil.js +34 -34
  118. package/dist/generated/programs/sigil.js.map +1 -1
  119. package/dist/generated/types/accountConstraint.d.ts +16 -1
  120. package/dist/generated/types/accountConstraint.d.ts.map +1 -1
  121. package/dist/generated/types/accountConstraint.js +2 -0
  122. package/dist/generated/types/accountConstraint.js.map +1 -1
  123. package/dist/generated/types/accountConstraintZC.d.ts +7 -0
  124. package/dist/generated/types/accountConstraintZC.d.ts.map +1 -1
  125. package/dist/generated/types/accountConstraintZC.js +4 -2
  126. package/dist/generated/types/accountConstraintZC.js.map +1 -1
  127. package/dist/generated/types/constraintEntry.d.ts +0 -8
  128. package/dist/generated/types/constraintEntry.d.ts.map +1 -1
  129. package/dist/generated/types/constraintEntry.js +1 -5
  130. package/dist/generated/types/constraintEntry.js.map +1 -1
  131. package/dist/generated/types/constraintEntryZC.d.ts +22 -27
  132. package/dist/generated/types/constraintEntryZC.d.ts.map +1 -1
  133. package/dist/generated/types/constraintEntryZC.js +4 -6
  134. package/dist/generated/types/constraintEntryZC.js.map +1 -1
  135. package/dist/generated/types/index.d.ts +1 -1
  136. package/dist/generated/types/index.d.ts.map +1 -1
  137. package/dist/generated/types/index.js +1 -1
  138. package/dist/generated/types/index.js.map +1 -1
  139. package/dist/generated/types/orphanConstraintsPdaCleaned.d.ts +22 -0
  140. package/dist/generated/types/orphanConstraintsPdaCleaned.d.ts.map +1 -0
  141. package/dist/generated/types/{positionsSynced.js → orphanConstraintsPdaCleaned.js} +8 -10
  142. package/dist/generated/types/orphanConstraintsPdaCleaned.js.map +1 -0
  143. package/dist/generated/types/sessionFinalized.d.ts +0 -4
  144. package/dist/generated/types/sessionFinalized.d.ts.map +1 -1
  145. package/dist/generated/types/sessionFinalized.js +1 -3
  146. package/dist/generated/types/sessionFinalized.js.map +1 -1
  147. package/dist/generated/types/vaultFrozen.d.ts +12 -0
  148. package/dist/generated/types/vaultFrozen.d.ts.map +1 -1
  149. package/dist/generated/types/vaultFrozen.js +3 -1
  150. package/dist/generated/types/vaultFrozen.js.map +1 -1
  151. package/dist/index.d.ts +13 -3
  152. package/dist/index.d.ts.map +1 -1
  153. package/dist/index.js +23 -2
  154. package/dist/index.js.map +1 -1
  155. package/dist/inscribe.d.ts +0 -8
  156. package/dist/inscribe.d.ts.map +1 -1
  157. package/dist/inscribe.js +0 -2
  158. package/dist/inscribe.js.map +1 -1
  159. package/dist/kit-adapter.d.ts +1 -1
  160. package/dist/kit-adapter.d.ts.map +1 -1
  161. package/dist/kit-adapter.js +1 -1
  162. package/dist/kit-adapter.js.map +1 -1
  163. package/dist/logger.d.ts +48 -0
  164. package/dist/logger.d.ts.map +1 -1
  165. package/dist/logger.js +36 -0
  166. package/dist/logger.js.map +1 -1
  167. package/dist/owner-transaction.d.ts +8 -0
  168. package/dist/owner-transaction.d.ts.map +1 -1
  169. package/dist/owner-transaction.js +1 -0
  170. package/dist/owner-transaction.js.map +1 -1
  171. package/dist/post-assertions/cross-field-lte.d.ts +134 -0
  172. package/dist/post-assertions/cross-field-lte.d.ts.map +1 -0
  173. package/dist/post-assertions/cross-field-lte.js +129 -0
  174. package/dist/post-assertions/cross-field-lte.js.map +1 -0
  175. package/dist/post-assertions/index.d.ts +28 -0
  176. package/dist/post-assertions/index.d.ts.map +1 -0
  177. package/dist/post-assertions/index.js +28 -0
  178. package/dist/post-assertions/index.js.map +1 -0
  179. package/dist/post-assertions/presets/flash-trade.d.ts +139 -0
  180. package/dist/post-assertions/presets/flash-trade.d.ts.map +1 -0
  181. package/dist/post-assertions/presets/flash-trade.js +154 -0
  182. package/dist/post-assertions/presets/flash-trade.js.map +1 -0
  183. package/dist/presets.d.ts +1 -13
  184. package/dist/presets.d.ts.map +1 -1
  185. package/dist/presets.js +0 -10
  186. package/dist/presets.js.map +1 -1
  187. package/dist/preview-create-vault.d.ts +280 -0
  188. package/dist/preview-create-vault.d.ts.map +1 -0
  189. package/dist/preview-create-vault.js +477 -0
  190. package/dist/preview-create-vault.js.map +1 -0
  191. package/dist/protocol-registry/annotations/drift.json +7 -0
  192. package/dist/protocol-registry/annotations/flash-trade.json +7 -0
  193. package/dist/protocol-registry/annotations/jupiter-borrow.json +7 -0
  194. package/dist/protocol-registry/annotations/jupiter-earn.json +7 -0
  195. package/dist/protocol-registry/annotations/jupiter-lend.json +7 -0
  196. package/dist/protocol-registry/annotations/jupiter.json +7 -0
  197. package/dist/protocol-registry/annotations/kamino.json +7 -0
  198. package/dist/protocol-registry/index.d.ts +45 -0
  199. package/dist/protocol-registry/index.d.ts.map +1 -0
  200. package/dist/protocol-registry/index.js +76 -0
  201. package/dist/protocol-registry/index.js.map +1 -0
  202. package/dist/protocol-tier.d.ts +157 -0
  203. package/dist/protocol-tier.d.ts.map +1 -0
  204. package/dist/protocol-tier.js +104 -0
  205. package/dist/protocol-tier.js.map +1 -0
  206. package/dist/seal.d.ts.map +1 -1
  207. package/dist/seal.js +30 -12
  208. package/dist/seal.js.map +1 -1
  209. package/dist/sigil.d.ts +0 -8
  210. package/dist/sigil.d.ts.map +1 -1
  211. package/dist/simulation.d.ts.map +1 -1
  212. package/dist/simulation.js +131 -82
  213. package/dist/simulation.js.map +1 -1
  214. package/dist/testing/devnet.d.ts.map +1 -1
  215. package/dist/testing/devnet.js +0 -2
  216. package/dist/testing/devnet.js.map +1 -1
  217. package/dist/testing/errors/expect.d.ts +137 -0
  218. package/dist/testing/errors/expect.d.ts.map +1 -0
  219. package/dist/testing/errors/expect.js +372 -0
  220. package/dist/testing/errors/expect.js.map +1 -0
  221. package/dist/testing/errors/index.d.ts +3 -0
  222. package/dist/testing/errors/index.d.ts.map +1 -0
  223. package/dist/testing/errors/index.js +8 -0
  224. package/dist/testing/errors/index.js.map +1 -0
  225. package/dist/testing/errors/names.generated.d.ts +188 -0
  226. package/dist/testing/errors/names.generated.d.ts.map +1 -0
  227. package/dist/testing/errors/names.generated.js +183 -0
  228. package/dist/testing/errors/names.generated.js.map +1 -0
  229. package/dist/testing/index.d.ts +1 -0
  230. package/dist/testing/index.d.ts.map +1 -1
  231. package/dist/testing/index.js +8 -0
  232. package/dist/testing/index.js.map +1 -1
  233. package/dist/testing/mock-rpc.d.ts +8 -0
  234. package/dist/testing/mock-rpc.d.ts.map +1 -1
  235. package/dist/testing/mock-rpc.js +14 -0
  236. package/dist/testing/mock-rpc.js.map +1 -1
  237. package/dist/testing/mock-state.d.ts +0 -2
  238. package/dist/testing/mock-state.d.ts.map +1 -1
  239. package/dist/testing/mock-state.js +2 -5
  240. package/dist/testing/mock-state.js.map +1 -1
  241. package/dist/types.d.ts +1 -3
  242. package/dist/types.d.ts.map +1 -1
  243. package/dist/types.js +5 -9
  244. package/dist/types.js.map +1 -1
  245. package/dist/vault-analytics.d.ts +0 -1
  246. package/dist/vault-analytics.d.ts.map +1 -1
  247. package/dist/vault-analytics.js +0 -1
  248. package/dist/vault-analytics.js.map +1 -1
  249. package/package.json +15 -3
  250. package/dist/generated/instructions/syncPositions.d.ts +0 -44
  251. package/dist/generated/instructions/syncPositions.d.ts.map +0 -1
  252. package/dist/generated/instructions/syncPositions.js +0 -72
  253. package/dist/generated/instructions/syncPositions.js.map +0 -1
  254. package/dist/generated/types/positionsSynced.d.ts +0 -24
  255. package/dist/generated/types/positionsSynced.d.ts.map +0 -1
  256. package/dist/generated/types/positionsSynced.js.map +0 -1
  257. package/dist/integrations/protocol-handler.d.ts +0 -59
  258. package/dist/integrations/protocol-handler.d.ts.map +0 -1
  259. package/dist/integrations/protocol-handler.js +0 -9
  260. package/dist/integrations/protocol-handler.js.map +0 -1
@@ -5,7 +5,7 @@
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 85 on-chain error codes (6000-6084) plus 34 SDK
8
+ * Maps all 88 on-chain error codes (6000-6087) plus 34 SDK
9
9
  * error codes (7000-7033) to AgentError with machine-readable metadata.
10
10
  *
11
11
  * Zero dependency on @solana/web3.js or @coral-xyz/anchor.
@@ -130,49 +130,6 @@ export const ON_CHAIN_ERROR_MAP = {
130
130
  ],
131
131
  },
132
132
  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
- name: "TooManyPositions",
151
- message: "Maximum concurrent open positions reached",
152
- category: "RESOURCE_NOT_FOUND",
153
- retryable: false,
154
- recovery_actions: [
155
- {
156
- action: "close_position",
157
- description: "Close an existing position before opening a new one",
158
- tool: "sigil_close_position",
159
- },
160
- ],
161
- },
162
- 6009: {
163
- name: "PositionOpeningDisallowed",
164
- message: "Vault policy does not allow opening new positions",
165
- category: "POLICY_VIOLATION",
166
- retryable: false,
167
- recovery_actions: [
168
- {
169
- action: "check_policy",
170
- description: "Verify canOpenPositions is enabled in vault policy",
171
- tool: "sigil_check_vault",
172
- },
173
- ],
174
- },
175
- 6010: {
176
133
  name: "SessionNotAuthorized",
177
134
  message: "Session authority not authorized for this action",
178
135
  category: "PERMISSION",
@@ -184,7 +141,7 @@ export const ON_CHAIN_ERROR_MAP = {
184
141
  },
185
142
  ],
186
143
  },
187
- 6011: {
144
+ 6008: {
188
145
  name: "InvalidSession",
189
146
  message: "Session does not belong to this vault or is invalid",
190
147
  category: "PERMISSION",
@@ -196,20 +153,7 @@ export const ON_CHAIN_ERROR_MAP = {
196
153
  },
197
154
  ],
198
155
  },
199
- 6012: {
200
- name: "OpenPositionsExist",
201
- message: "Vault has open positions and cannot be closed",
202
- category: "RESOURCE_NOT_FOUND",
203
- retryable: false,
204
- recovery_actions: [
205
- {
206
- action: "close_positions",
207
- description: "Close all open positions before closing the vault",
208
- tool: "sigil_close_position",
209
- },
210
- ],
211
- },
212
- 6013: {
156
+ 6009: {
213
157
  name: "TooManyAllowedProtocols",
214
158
  message: "Policy configuration has too many allowed protocols (max 10)",
215
159
  category: "INPUT_VALIDATION",
@@ -221,7 +165,7 @@ export const ON_CHAIN_ERROR_MAP = {
221
165
  },
222
166
  ],
223
167
  },
224
- 6014: {
168
+ 6010: {
225
169
  name: "AgentAlreadyRegistered",
226
170
  message: "Agent is already registered on this vault",
227
171
  category: "INPUT_VALIDATION",
@@ -234,7 +178,7 @@ export const ON_CHAIN_ERROR_MAP = {
234
178
  },
235
179
  ],
236
180
  },
237
- 6015: {
181
+ 6011: {
238
182
  name: "NoAgentRegistered",
239
183
  message: "No agent registered on this vault",
240
184
  category: "RESOURCE_NOT_FOUND",
@@ -247,7 +191,7 @@ export const ON_CHAIN_ERROR_MAP = {
247
191
  },
248
192
  ],
249
193
  },
250
- 6016: {
194
+ 6012: {
251
195
  name: "VaultNotFrozen",
252
196
  message: "Vault is not frozen (expected frozen for reactivation)",
253
197
  category: "INPUT_VALIDATION",
@@ -260,7 +204,7 @@ export const ON_CHAIN_ERROR_MAP = {
260
204
  },
261
205
  ],
262
206
  },
263
- 6017: {
207
+ 6013: {
264
208
  name: "VaultAlreadyClosed",
265
209
  message: "Vault is permanently closed",
266
210
  category: "INPUT_VALIDATION",
@@ -273,7 +217,7 @@ export const ON_CHAIN_ERROR_MAP = {
273
217
  },
274
218
  ],
275
219
  },
276
- 6018: {
220
+ 6014: {
277
221
  name: "InsufficientBalance",
278
222
  message: "Insufficient vault balance for this operation",
279
223
  category: "SPENDING_CAP",
@@ -294,7 +238,7 @@ export const ON_CHAIN_ERROR_MAP = {
294
238
  },
295
239
  ],
296
240
  },
297
- 6019: {
241
+ 6015: {
298
242
  name: "DeveloperFeeTooHigh",
299
243
  message: "Developer fee rate exceeds maximum (500 / 1,000,000 = 5 BPS)",
300
244
  category: "INPUT_VALIDATION",
@@ -306,7 +250,7 @@ export const ON_CHAIN_ERROR_MAP = {
306
250
  },
307
251
  ],
308
252
  },
309
- 6020: {
253
+ 6016: {
310
254
  name: "InvalidFeeDestination",
311
255
  message: "Fee destination account is invalid",
312
256
  category: "INPUT_VALIDATION",
@@ -318,7 +262,7 @@ export const ON_CHAIN_ERROR_MAP = {
318
262
  },
319
263
  ],
320
264
  },
321
- 6021: {
265
+ 6017: {
322
266
  name: "InvalidProtocolTreasury",
323
267
  message: "Protocol treasury account does not match expected address",
324
268
  category: "INPUT_VALIDATION",
@@ -330,7 +274,7 @@ export const ON_CHAIN_ERROR_MAP = {
330
274
  },
331
275
  ],
332
276
  },
333
- 6022: {
277
+ 6018: {
334
278
  name: "InvalidAgentKey",
335
279
  message: "Agent cannot be the zero address",
336
280
  category: "INPUT_VALIDATION",
@@ -342,7 +286,7 @@ export const ON_CHAIN_ERROR_MAP = {
342
286
  },
343
287
  ],
344
288
  },
345
- 6023: {
289
+ 6019: {
346
290
  name: "AgentIsOwner",
347
291
  message: "Agent cannot be the vault owner",
348
292
  category: "INPUT_VALIDATION",
@@ -354,7 +298,7 @@ export const ON_CHAIN_ERROR_MAP = {
354
298
  },
355
299
  ],
356
300
  },
357
- 6024: {
301
+ 6020: {
358
302
  name: "Overflow",
359
303
  message: "Arithmetic overflow in on-chain computation",
360
304
  category: "FATAL",
@@ -366,7 +310,7 @@ export const ON_CHAIN_ERROR_MAP = {
366
310
  },
367
311
  ],
368
312
  },
369
- 6025: {
313
+ 6021: {
370
314
  name: "InvalidTokenAccount",
371
315
  message: "Token account does not belong to vault or has wrong mint",
372
316
  category: "INPUT_VALIDATION",
@@ -379,7 +323,7 @@ export const ON_CHAIN_ERROR_MAP = {
379
323
  ],
380
324
  },
381
325
  // --- Timelock + Destination errors ---
382
- 6026: {
326
+ 6022: {
383
327
  name: "TimelockNotExpired",
384
328
  message: "Timelock period has not expired yet",
385
329
  category: "POLICY_VIOLATION",
@@ -392,7 +336,7 @@ export const ON_CHAIN_ERROR_MAP = {
392
336
  },
393
337
  ],
394
338
  },
395
- 6027: {
339
+ 6023: {
396
340
  name: "NoTimelockConfigured",
397
341
  message: "No timelock configured on this vault",
398
342
  category: "INPUT_VALIDATION",
@@ -404,7 +348,7 @@ export const ON_CHAIN_ERROR_MAP = {
404
348
  },
405
349
  ],
406
350
  },
407
- 6028: {
351
+ 6024: {
408
352
  name: "DestinationNotAllowed",
409
353
  message: "Destination address not in vault's allowed destinations list",
410
354
  category: "POLICY_VIOLATION",
@@ -421,7 +365,7 @@ export const ON_CHAIN_ERROR_MAP = {
421
365
  },
422
366
  ],
423
367
  },
424
- 6029: {
368
+ 6025: {
425
369
  name: "TooManyDestinations",
426
370
  message: "Too many destinations in allowlist (max 10)",
427
371
  category: "INPUT_VALIDATION",
@@ -433,7 +377,7 @@ export const ON_CHAIN_ERROR_MAP = {
433
377
  },
434
378
  ],
435
379
  },
436
- 6030: {
380
+ 6026: {
437
381
  name: "InvalidProtocolMode",
438
382
  message: "Invalid protocol mode (must be 0=all, 1=allowlist, or 2=denylist)",
439
383
  category: "INPUT_VALIDATION",
@@ -446,32 +390,7 @@ export const ON_CHAIN_ERROR_MAP = {
446
390
  ],
447
391
  },
448
392
  // --- Flash Trade expansion errors ---
449
- 6031: {
450
- name: "InvalidNonSpendingAmount",
451
- message: "Non-spending action must have amount = 0",
452
- category: "INPUT_VALIDATION",
453
- retryable: false,
454
- recovery_actions: [
455
- {
456
- action: "set_zero_amount",
457
- description: "Set amount to 0 for non-spending actions (close, cancel, etc.)",
458
- },
459
- ],
460
- },
461
- 6032: {
462
- name: "NoPositionsToClose",
463
- message: "No open positions to close or cancel",
464
- category: "RESOURCE_NOT_FOUND",
465
- retryable: false,
466
- recovery_actions: [
467
- {
468
- action: "check_positions",
469
- description: "Verify you have open positions before closing",
470
- tool: "sigil_check_vault",
471
- },
472
- ],
473
- },
474
- 6033: {
393
+ 6027: {
475
394
  name: "CpiCallNotAllowed",
476
395
  message: "Instruction must be top-level (CPI calls not allowed for validate/finalize)",
477
396
  category: "FATAL",
@@ -483,7 +402,7 @@ export const ON_CHAIN_ERROR_MAP = {
483
402
  },
484
403
  ],
485
404
  },
486
- 6034: {
405
+ 6028: {
487
406
  name: "MissingFinalizeInstruction",
488
407
  message: "Transaction must include finalize_session after validate_and_authorize",
489
408
  category: "INPUT_VALIDATION",
@@ -496,7 +415,7 @@ export const ON_CHAIN_ERROR_MAP = {
496
415
  ],
497
416
  },
498
417
  // --- Stablecoin-only enforcement errors ---
499
- 6035: {
418
+ 6029: {
500
419
  name: "NonTrackedSwapMustReturnStablecoin",
501
420
  message: "Non-stablecoin swap must return stablecoin (vault stablecoin balance did not increase)",
502
421
  category: "INPUT_VALIDATION",
@@ -508,7 +427,7 @@ export const ON_CHAIN_ERROR_MAP = {
508
427
  },
509
428
  ],
510
429
  },
511
- 6036: {
430
+ 6030: {
512
431
  name: "SwapSlippageExceeded",
513
432
  message: "Swap slippage exceeds policy max_slippage_bps or quoted output is zero",
514
433
  category: "POLICY_VIOLATION",
@@ -525,7 +444,7 @@ export const ON_CHAIN_ERROR_MAP = {
525
444
  },
526
445
  ],
527
446
  },
528
- 6037: {
447
+ 6031: {
529
448
  name: "InvalidJupiterInstruction",
530
449
  message: "Cannot parse Jupiter swap instruction data",
531
450
  category: "INPUT_VALIDATION",
@@ -537,7 +456,7 @@ export const ON_CHAIN_ERROR_MAP = {
537
456
  },
538
457
  ],
539
458
  },
540
- 6038: {
459
+ 6032: {
541
460
  name: "UnauthorizedTokenTransfer",
542
461
  message: "Top-level SPL Token transfer not allowed between validate and finalize",
543
462
  category: "POLICY_VIOLATION",
@@ -549,7 +468,7 @@ export const ON_CHAIN_ERROR_MAP = {
549
468
  },
550
469
  ],
551
470
  },
552
- 6039: {
471
+ 6033: {
553
472
  name: "SlippageBpsTooHigh",
554
473
  message: "Slippage BPS exceeds maximum allowed (5000 = 50%)",
555
474
  category: "INPUT_VALIDATION",
@@ -561,7 +480,7 @@ export const ON_CHAIN_ERROR_MAP = {
561
480
  },
562
481
  ],
563
482
  },
564
- 6040: {
483
+ 6034: {
565
484
  name: "ProtocolMismatch",
566
485
  message: "DeFi instruction program does not match the declared target_protocol",
567
486
  category: "INPUT_VALIDATION",
@@ -573,7 +492,7 @@ export const ON_CHAIN_ERROR_MAP = {
573
492
  },
574
493
  ],
575
494
  },
576
- 6041: {
495
+ 6035: {
577
496
  name: "TooManyDeFiInstructions",
578
497
  message: "Non-stablecoin swap allows exactly one DeFi instruction",
579
498
  category: "INPUT_VALIDATION",
@@ -586,7 +505,7 @@ export const ON_CHAIN_ERROR_MAP = {
586
505
  ],
587
506
  },
588
507
  // --- Multi-Agent errors ---
589
- 6042: {
508
+ 6036: {
590
509
  name: "MaxAgentsReached",
591
510
  message: "Maximum agents per vault reached (limit: 10)",
592
511
  category: "INPUT_VALIDATION",
@@ -599,7 +518,7 @@ export const ON_CHAIN_ERROR_MAP = {
599
518
  },
600
519
  ],
601
520
  },
602
- 6043: {
521
+ 6037: {
603
522
  name: "InsufficientPermissions",
604
523
  message: "Agent lacks permission for this action type",
605
524
  category: "PERMISSION",
@@ -616,7 +535,7 @@ export const ON_CHAIN_ERROR_MAP = {
616
535
  },
617
536
  ],
618
537
  },
619
- 6044: {
538
+ 6038: {
620
539
  name: "InvalidPermissions",
621
540
  message: "Capability exceeds the on-chain maximum (valid values: 0 = Disabled, 1 = Observer, 2 = Operator)",
622
541
  category: "INPUT_VALIDATION",
@@ -629,7 +548,7 @@ export const ON_CHAIN_ERROR_MAP = {
629
548
  ],
630
549
  },
631
550
  // --- Escrow errors ---
632
- 6045: {
551
+ 6039: {
633
552
  name: "EscrowNotActive",
634
553
  message: "Escrow is not in Active status",
635
554
  category: "RESOURCE_NOT_FOUND",
@@ -641,7 +560,7 @@ export const ON_CHAIN_ERROR_MAP = {
641
560
  },
642
561
  ],
643
562
  },
644
- 6046: {
563
+ 6040: {
645
564
  name: "EscrowExpired",
646
565
  message: "Escrow has expired — can only be refunded now",
647
566
  category: "RESOURCE_NOT_FOUND",
@@ -654,7 +573,7 @@ export const ON_CHAIN_ERROR_MAP = {
654
573
  },
655
574
  ],
656
575
  },
657
- 6047: {
576
+ 6041: {
658
577
  name: "EscrowNotExpired",
659
578
  message: "Escrow has not expired yet — cannot refund before expiry",
660
579
  category: "INPUT_VALIDATION",
@@ -671,7 +590,7 @@ export const ON_CHAIN_ERROR_MAP = {
671
590
  },
672
591
  ],
673
592
  },
674
- 6048: {
593
+ 6042: {
675
594
  name: "InvalidEscrowVault",
676
595
  message: "Invalid escrow vault — source or destination vault mismatch",
677
596
  category: "INPUT_VALIDATION",
@@ -683,7 +602,7 @@ export const ON_CHAIN_ERROR_MAP = {
683
602
  },
684
603
  ],
685
604
  },
686
- 6049: {
605
+ 6043: {
687
606
  name: "EscrowConditionsNotMet",
688
607
  message: "Escrow settlement conditions not met (SHA-256 proof invalid)",
689
608
  category: "INPUT_VALIDATION",
@@ -695,7 +614,7 @@ export const ON_CHAIN_ERROR_MAP = {
695
614
  },
696
615
  ],
697
616
  },
698
- 6050: {
617
+ 6044: {
699
618
  name: "EscrowDurationExceeded",
700
619
  message: "Escrow duration exceeds maximum (30 days)",
701
620
  category: "INPUT_VALIDATION",
@@ -708,7 +627,7 @@ export const ON_CHAIN_ERROR_MAP = {
708
627
  ],
709
628
  },
710
629
  // --- Instruction constraints errors ---
711
- 6051: {
630
+ 6045: {
712
631
  name: "InvalidConstraintConfig",
713
632
  message: "Invalid constraint configuration: bounds exceeded",
714
633
  category: "INPUT_VALIDATION",
@@ -720,7 +639,7 @@ export const ON_CHAIN_ERROR_MAP = {
720
639
  },
721
640
  ],
722
641
  },
723
- 6052: {
642
+ 6046: {
724
643
  name: "ConstraintViolated",
725
644
  message: "Instruction violated a configured constraint",
726
645
  category: "POLICY_VIOLATION",
@@ -737,7 +656,7 @@ export const ON_CHAIN_ERROR_MAP = {
737
656
  },
738
657
  ],
739
658
  },
740
- 6053: {
659
+ 6047: {
741
660
  name: "InvalidConstraintsPda",
742
661
  message: "Invalid constraints PDA: wrong owner or vault",
743
662
  category: "INPUT_VALIDATION",
@@ -749,7 +668,7 @@ export const ON_CHAIN_ERROR_MAP = {
749
668
  },
750
669
  ],
751
670
  },
752
- 6054: {
671
+ 6048: {
753
672
  name: "InvalidPendingConstraintsPda",
754
673
  message: "Invalid pending constraints PDA: wrong owner or vault",
755
674
  category: "INPUT_VALIDATION",
@@ -762,7 +681,7 @@ export const ON_CHAIN_ERROR_MAP = {
762
681
  ],
763
682
  },
764
683
  // --- Per-agent spend limit errors ---
765
- 6055: {
684
+ 6049: {
766
685
  name: "AgentSpendLimitExceeded",
767
686
  message: "Agent's rolling 24h spend exceeds their individual spending limit",
768
687
  category: "SPENDING_CAP",
@@ -784,7 +703,7 @@ export const ON_CHAIN_ERROR_MAP = {
784
703
  },
785
704
  ],
786
705
  },
787
- 6056: {
706
+ 6050: {
788
707
  name: "OverlaySlotExhausted",
789
708
  message: "Per-agent overlay is full — cannot register agent with spending limit",
790
709
  category: "INPUT_VALIDATION",
@@ -797,7 +716,7 @@ export const ON_CHAIN_ERROR_MAP = {
797
716
  },
798
717
  ],
799
718
  },
800
- 6057: {
719
+ 6051: {
801
720
  name: "AgentSlotNotFound",
802
721
  message: "Agent has per-agent spending limit but no overlay tracking slot",
803
722
  category: "RESOURCE_NOT_FOUND",
@@ -809,7 +728,7 @@ export const ON_CHAIN_ERROR_MAP = {
809
728
  },
810
729
  ],
811
730
  },
812
- 6058: {
731
+ 6052: {
813
732
  name: "UnauthorizedTokenApproval",
814
733
  message: "Unauthorized SPL Token Approve detected between validate and finalize",
815
734
  category: "POLICY_VIOLATION",
@@ -821,7 +740,7 @@ export const ON_CHAIN_ERROR_MAP = {
821
740
  },
822
741
  ],
823
742
  },
824
- 6059: {
743
+ 6053: {
825
744
  name: "InvalidSessionExpiry",
826
745
  message: "Session expiry slots out of range (10-450)",
827
746
  category: "INPUT_VALIDATION",
@@ -833,7 +752,7 @@ export const ON_CHAIN_ERROR_MAP = {
833
752
  },
834
753
  ],
835
754
  },
836
- 6060: {
755
+ 6054: {
837
756
  name: "UnconstrainedProgramBlocked",
838
757
  message: "Program has no constraint entry and strict mode is enabled",
839
758
  category: "POLICY_VIOLATION",
@@ -851,7 +770,7 @@ export const ON_CHAIN_ERROR_MAP = {
851
770
  ],
852
771
  },
853
772
  // --- Per-protocol spend cap errors ---
854
- 6061: {
773
+ 6055: {
855
774
  name: "ProtocolCapExceeded",
856
775
  message: "Per-protocol rolling 24h spending cap would be exceeded",
857
776
  category: "SPENDING_CAP",
@@ -872,7 +791,7 @@ export const ON_CHAIN_ERROR_MAP = {
872
791
  },
873
792
  ],
874
793
  },
875
- 6062: {
794
+ 6056: {
876
795
  name: "ProtocolCapsMismatch",
877
796
  message: "protocol_caps length must match protocols length when has_protocol_caps is true",
878
797
  category: "INPUT_VALIDATION",
@@ -885,7 +804,7 @@ export const ON_CHAIN_ERROR_MAP = {
885
804
  ],
886
805
  },
887
806
  // --- Vault closure guard errors ---
888
- 6063: {
807
+ 6057: {
889
808
  name: "ActiveEscrowsExist",
890
809
  message: "Active escrow deposits exist — close them before closing vault",
891
810
  category: "RESOURCE_NOT_FOUND",
@@ -897,7 +816,7 @@ export const ON_CHAIN_ERROR_MAP = {
897
816
  },
898
817
  ],
899
818
  },
900
- 6064: {
819
+ 6058: {
901
820
  name: "ConstraintsNotClosed",
902
821
  message: "Instruction constraints PDA still exists — close it before closing vault",
903
822
  category: "RESOURCE_NOT_FOUND",
@@ -909,7 +828,7 @@ export const ON_CHAIN_ERROR_MAP = {
909
828
  },
910
829
  ],
911
830
  },
912
- 6065: {
831
+ 6059: {
913
832
  name: "PendingPolicyExists",
914
833
  message: "A pending policy update exists — apply or cancel it before closing vault",
915
834
  category: "RESOURCE_NOT_FOUND",
@@ -922,7 +841,7 @@ export const ON_CHAIN_ERROR_MAP = {
922
841
  ],
923
842
  },
924
843
  // --- Agent pause errors ---
925
- 6066: {
844
+ 6060: {
926
845
  name: "AgentPaused",
927
846
  message: "Agent is paused — unpause before executing actions",
928
847
  category: "PERMISSION",
@@ -934,7 +853,7 @@ export const ON_CHAIN_ERROR_MAP = {
934
853
  },
935
854
  ],
936
855
  },
937
- 6067: {
856
+ 6061: {
938
857
  name: "AgentAlreadyPaused",
939
858
  message: "Agent is already paused",
940
859
  category: "INPUT_VALIDATION",
@@ -946,7 +865,7 @@ export const ON_CHAIN_ERROR_MAP = {
946
865
  },
947
866
  ],
948
867
  },
949
- 6068: {
868
+ 6062: {
950
869
  name: "AgentNotPaused",
951
870
  message: "Agent is not paused — cannot unpause",
952
871
  category: "INPUT_VALIDATION",
@@ -958,7 +877,7 @@ export const ON_CHAIN_ERROR_MAP = {
958
877
  },
959
878
  ],
960
879
  },
961
- 6069: {
880
+ 6063: {
962
881
  name: "UnauthorizedPostFinalizeInstruction",
963
882
  message: "Instructions after finalize_session must be ComputeBudget or SystemProgram only",
964
883
  category: "POLICY_VIOLATION",
@@ -970,7 +889,7 @@ export const ON_CHAIN_ERROR_MAP = {
970
889
  },
971
890
  ],
972
891
  },
973
- 6070: {
892
+ 6064: {
974
893
  name: "UnexpectedBalanceDecrease",
975
894
  message: "Vault stablecoin balance decreased more than the session authorized amount. " +
976
895
  "This indicates a compromised DeFi program attempted to drain vault tokens via CPI.",
@@ -990,7 +909,7 @@ export const ON_CHAIN_ERROR_MAP = {
990
909
  ],
991
910
  },
992
911
  // --- TOCTOU + timelock hardening errors ---
993
- 6071: {
912
+ 6065: {
994
913
  name: "TimelockTooShort",
995
914
  message: "Timelock duration is below the minimum (1800 seconds / 30 minutes).",
996
915
  category: "INPUT_VALIDATION",
@@ -1002,7 +921,7 @@ export const ON_CHAIN_ERROR_MAP = {
1002
921
  },
1003
922
  ],
1004
923
  },
1005
- 6072: {
924
+ 6066: {
1006
925
  name: "PolicyVersionMismatch",
1007
926
  message: "Policy version changed since agent's last RPC read. Re-resolve vault state and retry.",
1008
927
  category: "TRANSIENT",
@@ -1015,31 +934,7 @@ export const ON_CHAIN_ERROR_MAP = {
1015
934
  },
1016
935
  ],
1017
936
  },
1018
- 6073: {
1019
- name: "PendingAgentPermsExists",
1020
- message: "A pending agent permissions update already exists for this agent.",
1021
- category: "RESOURCE_NOT_FOUND",
1022
- retryable: false,
1023
- recovery_actions: [
1024
- {
1025
- action: "apply_or_cancel_pending",
1026
- description: "Apply or cancel the existing pending update before queuing a new one.",
1027
- },
1028
- ],
1029
- },
1030
- 6074: {
1031
- name: "PendingCloseConstraintsExists",
1032
- message: "A pending close constraints operation already exists for this vault.",
1033
- category: "RESOURCE_NOT_FOUND",
1034
- retryable: false,
1035
- recovery_actions: [
1036
- {
1037
- action: "apply_or_cancel_pending",
1038
- description: "Apply or cancel the existing pending close constraints before queuing a new one.",
1039
- },
1040
- ],
1041
- },
1042
- 6075: {
937
+ 6067: {
1043
938
  name: "ActiveSessionsExist",
1044
939
  message: "Cannot close vault with active sessions. Finalize all pending sessions first.",
1045
940
  category: "POLICY_VIOLATION",
@@ -1053,7 +948,7 @@ export const ON_CHAIN_ERROR_MAP = {
1053
948
  ],
1054
949
  },
1055
950
  // --- Post-execution assertions (Phase B scaffolding) ---
1056
- 6076: {
951
+ 6068: {
1057
952
  name: "PostAssertionFailed",
1058
953
  message: "Post-execution assertion failed: account state did not satisfy constraint.",
1059
954
  category: "POLICY_VIOLATION",
@@ -1065,7 +960,7 @@ export const ON_CHAIN_ERROR_MAP = {
1065
960
  },
1066
961
  ],
1067
962
  },
1068
- 6077: {
963
+ 6069: {
1069
964
  name: "InvalidPostAssertionIndex",
1070
965
  message: "Post-assertion references an invalid instruction index.",
1071
966
  category: "INPUT_VALIDATION",
@@ -1077,7 +972,7 @@ export const ON_CHAIN_ERROR_MAP = {
1077
972
  },
1078
973
  ],
1079
974
  },
1080
- 6078: {
975
+ 6070: {
1081
976
  name: "UnauthorizedPreValidateInstruction",
1082
977
  message: "Non-infrastructure instruction detected before validate_and_authorize.",
1083
978
  category: "PERMISSION",
@@ -1089,7 +984,7 @@ export const ON_CHAIN_ERROR_MAP = {
1089
984
  },
1090
985
  ],
1091
986
  },
1092
- 6079: {
987
+ 6071: {
1093
988
  name: "SnapshotNotCaptured",
1094
989
  message: "Delta assertion snapshot was not captured in validate_and_authorize.",
1095
990
  category: "INPUT_VALIDATION",
@@ -1101,63 +996,201 @@ export const ON_CHAIN_ERROR_MAP = {
1101
996
  },
1102
997
  ],
1103
998
  },
1104
- 6080: {
1105
- name: "ConstraintIndexOutOfBounds",
1106
- message: "Constraint entry index out of bounds for zero-copy array.",
999
+ 6072: {
1000
+ name: "InvalidConstraintOperator",
1001
+ message: "Constraint operator value is not a valid ConstraintOperator discriminant.",
1107
1002
  category: "INPUT_VALIDATION",
1108
1003
  retryable: false,
1109
1004
  recovery_actions: [
1110
1005
  {
1111
1006
  action: "fix_constraints",
1112
- description: "Ensure constraint entries do not exceed max 64 entries.",
1007
+ description: "Ensure constraint operators are valid (0-6).",
1113
1008
  },
1114
1009
  ],
1115
1010
  },
1116
- 6081: {
1117
- name: "InvalidConstraintOperator",
1118
- message: "Constraint operator value is not a valid ConstraintOperator discriminant.",
1011
+ 6073: {
1012
+ name: "ConstraintsVaultMismatch",
1013
+ message: "Zero-copy constraints account has wrong vault.",
1014
+ category: "INPUT_VALIDATION",
1015
+ retryable: false,
1016
+ recovery_actions: [
1017
+ {
1018
+ action: "verify_pda",
1019
+ description: "The constraints PDA does not belong to this vault.",
1020
+ },
1021
+ ],
1022
+ },
1023
+ 6074: {
1024
+ name: "BlockedSplOpcode",
1025
+ message: "SPL opcode is blocked at runtime and cannot be used in constraints.",
1119
1026
  category: "INPUT_VALIDATION",
1120
1027
  retryable: false,
1121
1028
  recovery_actions: [
1122
1029
  {
1123
1030
  action: "fix_constraints",
1124
- description: "Ensure constraint operators are valid (0-6).",
1031
+ description: "Remove blocked SPL opcode from the constraint entry use allowlisted opcodes only.",
1125
1032
  },
1126
1033
  ],
1127
1034
  },
1128
- 6082: {
1129
- name: "ConstraintsVaultMismatch",
1130
- message: "Zero-copy constraints account has wrong vault.",
1035
+ // F-10 audit fix: durable-nonce pre-signing defense
1036
+ 6075: {
1037
+ name: "QueuedUpdateExpired",
1038
+ message: "Queued update is too old (>MAX_APPLY_AGE_SLOTS) — re-queue to apply. Defends against durable-nonce pre-signing.",
1039
+ category: "POLICY_VIOLATION",
1040
+ retryable: false,
1041
+ recovery_actions: [
1042
+ {
1043
+ action: "requeue",
1044
+ description: "Re-queue the update via queue_policy_update / queue_constraints_update / queue_close_constraints / queue_agent_permissions_update — the original queued update is past the freshness window.",
1045
+ },
1046
+ ],
1047
+ },
1048
+ 6076: {
1049
+ name: "AccountWritabilityMismatch",
1050
+ message: "Account writability flag does not match the constraint requirement (read-only vs writable).",
1051
+ category: "INPUT_VALIDATION",
1052
+ retryable: false,
1053
+ recovery_actions: [
1054
+ {
1055
+ action: "fix_constraints",
1056
+ description: "Match the writability flag (read-only or writable) of the account passed to the instruction with the constraint's is_writable_required value.",
1057
+ },
1058
+ ],
1059
+ },
1060
+ // M11 SIMD-0296 pad-attack DoS guard
1061
+ 6077: {
1062
+ name: "SysvarScanBoundExceeded",
1063
+ message: "Sysvar instruction scan exceeded the per-tx safety bound (MAX_SYSVAR_SCAN_ITERATIONS=64).",
1064
+ category: "INPUT_VALIDATION",
1065
+ retryable: false,
1066
+ recovery_actions: [
1067
+ {
1068
+ action: "fix_transaction_shape",
1069
+ 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.",
1070
+ },
1071
+ ],
1072
+ },
1073
+ // C4 audit fix: async-fulfillment program deny
1074
+ 6078: {
1075
+ name: "AsyncFulfillmentNotPermitted",
1076
+ 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.",
1077
+ category: "POLICY_VIOLATION",
1078
+ retryable: false,
1079
+ recovery_actions: [
1080
+ {
1081
+ action: "use_supported_protocol",
1082
+ 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.",
1083
+ },
1084
+ ],
1085
+ },
1086
+ // Orphan constraints PDA cleanup (F3-H1 audit fix)
1087
+ 6079: {
1088
+ name: "ConstraintsAlreadyPopulated",
1089
+ message: "Cannot clean an active constraints PDA via cleanup_orphan_constraints_pda — use queue_close_constraints + apply_close_constraints instead.",
1090
+ category: "INPUT_VALIDATION",
1091
+ retryable: false,
1092
+ recovery_actions: [
1093
+ {
1094
+ action: "use_close_path",
1095
+ description: "Route through the timelocked close-constraints path; the orphan-cleanup instruction only operates on never-populated PDAs (partial allocate+extend chain).",
1096
+ },
1097
+ ],
1098
+ },
1099
+ 6080: {
1100
+ name: "OrphanPdaWrongOwner",
1101
+ message: "PDA at the constraints seeds is not owned by the Sigil program.",
1131
1102
  category: "INPUT_VALIDATION",
1132
1103
  retryable: false,
1133
1104
  recovery_actions: [
1134
1105
  {
1135
1106
  action: "verify_pda",
1136
- description: "The constraints PDA does not belong to this vault.",
1107
+ description: "Verify the PDA derivation: it must be owned by the Sigil program and match seeds (vault, constraints).",
1137
1108
  },
1138
1109
  ],
1139
1110
  },
1140
- 6083: {
1141
- name: "ConstraintEntryCountExceeded",
1142
- message: "Cannot pack entries: entry count exceeds MAX_CONSTRAINT_ENTRIES (64).",
1111
+ 6081: {
1112
+ name: "OrphanPdaPopulated",
1113
+ message: "PDA is fully populated (carries the Anchor discriminator) — not an orphan; cannot be cleaned.",
1143
1114
  category: "INPUT_VALIDATION",
1144
1115
  retryable: false,
1145
1116
  recovery_actions: [
1146
1117
  {
1147
- action: "reduce_entries",
1148
- description: "Reduce the number of constraint entries to 64 or fewer.",
1118
+ action: "use_close_path",
1119
+ description: "Route fully-populated constraints PDAs through queue_close_constraints + apply_close_constraints.",
1120
+ },
1121
+ ],
1122
+ },
1123
+ // PR 7: Token-2022 opcode blocks (M3 + Pentester HIGH/MED + third-pass audit)
1124
+ 6082: {
1125
+ name: "ConfidentialTransferBlocked",
1126
+ message: "Token-2022 ConfidentialTransfer is not permitted between validate_and_authorize and finalize_session.",
1127
+ category: "POLICY_VIOLATION",
1128
+ retryable: false,
1129
+ recovery_actions: [
1130
+ {
1131
+ action: "use_supported_protocol",
1132
+ 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.",
1133
+ },
1134
+ ],
1135
+ },
1136
+ 6083: {
1137
+ name: "PermanentDelegateBlocked",
1138
+ message: "Token-2022 PermanentDelegate is not permitted between validate_and_authorize and finalize_session.",
1139
+ category: "POLICY_VIOLATION",
1140
+ retryable: false,
1141
+ recovery_actions: [
1142
+ {
1143
+ action: "use_supported_protocol",
1144
+ description: "Token-2022 PermanentDelegate (opcode 35) installs a session-bound delegate that survives finalize. Reject up-front; use a per-tx Approve instead.",
1149
1145
  },
1150
1146
  ],
1151
1147
  },
1152
1148
  6084: {
1153
- name: "BlockedSplOpcode",
1154
- message: "SPL opcode is blocked at runtime and cannot be used in constraints.",
1149
+ name: "TransferHookBlocked",
1150
+ message: "Token-2022 TransferHook is not permitted between validate_and_authorize and finalize_session.",
1151
+ category: "POLICY_VIOLATION",
1152
+ retryable: false,
1153
+ recovery_actions: [
1154
+ {
1155
+ action: "use_supported_protocol",
1156
+ 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.",
1157
+ },
1158
+ ],
1159
+ },
1160
+ 6085: {
1161
+ name: "LamportDrainBlocked",
1162
+ message: "Token-2022 destructive-balance instruction (opcode 38/45/46) is not permitted between validate_and_authorize and finalize_session.",
1163
+ category: "POLICY_VIOLATION",
1164
+ retryable: false,
1165
+ recovery_actions: [
1166
+ {
1167
+ action: "use_supported_protocol",
1168
+ 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.",
1169
+ },
1170
+ ],
1171
+ },
1172
+ 6086: {
1173
+ name: "BatchInstructionBlocked",
1174
+ message: "Token-2022 Batch instruction (opcode 255) is blocked outright — wraps inner instructions and bypasses the byte-0 blocklist.",
1175
+ category: "POLICY_VIOLATION",
1176
+ retryable: false,
1177
+ recovery_actions: [
1178
+ {
1179
+ action: "use_supported_protocol",
1180
+ 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.",
1181
+ },
1182
+ ],
1183
+ },
1184
+ // F-4 audit fix: explicit destination_mode (default Restricted closes default-allow drain)
1185
+ 6087: {
1186
+ name: "InvalidDestinationMode",
1187
+ message: "Invalid destination mode (must be 0 = Restricted or 1 = OpenWithCap).",
1155
1188
  category: "INPUT_VALIDATION",
1156
1189
  retryable: false,
1157
1190
  recovery_actions: [
1158
1191
  {
1159
- action: "fix_constraints",
1160
- description: "Remove blocked SPL opcode from the constraint entry use allowlisted opcodes only.",
1192
+ action: "fix_policy",
1193
+ description: "Pass destination_mode = 0 (Restricted, default) or 1 (OpenWithCap, explicit opt-in to drain blast radius).",
1161
1194
  },
1162
1195
  ],
1163
1196
  },
@@ -1661,7 +1694,7 @@ const SDK_ERRORS = {
1661
1694
  * Convert any error into a structured AgentError.
1662
1695
  *
1663
1696
  * Handles:
1664
- * - On-chain Anchor errors (code 6000-6084)
1697
+ * - On-chain Anchor errors (code 6000-6087)
1665
1698
  * - SDK errors (code 7000-7033)
1666
1699
  * - Network/RPC errors (from message patterns)
1667
1700
  * - Unknown errors (wrapped as FATAL)
@@ -1963,7 +1996,7 @@ function extractErrorCode(error) {
1963
1996
  return null;
1964
1997
  const e = error;
1965
1998
  // Direct code property
1966
- if (typeof e.code === "number" && e.code >= 6000 && e.code <= 6084)
1999
+ if (typeof e.code === "number" && e.code >= 6000 && e.code <= 6087)
1967
2000
  return e.code;
1968
2001
  // Anchor error structure
1969
2002
  if (e.error && typeof e.error === "object") {
@@ -1979,7 +2012,7 @@ function extractErrorCode(error) {
1979
2012
  const match = e.message.match(/custom program error: 0x([0-9a-fA-F]+)/);
1980
2013
  if (match) {
1981
2014
  const code = parseInt(match[1], 16);
1982
- if (code >= 6000 && code <= 6084)
2015
+ if (code >= 6000 && code <= 6087)
1983
2016
  return code;
1984
2017
  }
1985
2018
  }
@@ -2101,17 +2134,8 @@ const SDK_ERROR_PATTERNS = [
2101
2134
  },
2102
2135
  ],
2103
2136
  },
2104
- {
2105
- pattern: /Position limit reached/,
2106
- category: "POLICY_VIOLATION",
2107
- retryable: true,
2108
- recovery_actions: [
2109
- {
2110
- action: "close_position",
2111
- description: "Close an existing position before opening a new one.",
2112
- },
2113
- ],
2114
- },
2137
+ // "Position limit reached" pattern DELETED — position counter system removed
2138
+ // per council decision (9-1 vote, 2026-04-19).
2115
2139
  {
2116
2140
  pattern: /Spending action .+ requires amount > 0/,
2117
2141
  category: "INPUT_VALIDATION",
@@ -2205,7 +2229,7 @@ export class SigilSdkError extends Error {
2205
2229
  * Returns a SigilSdkError (extends Error) so instanceof Error checks still work.
2206
2230
  *
2207
2231
  * Processing order:
2208
- * 1. Try on-chain error extraction via toAgentError() (numeric codes 6000-6084)
2232
+ * 1. Try on-chain error extraction via toAgentError() (numeric codes 6000-6087)
2209
2233
  * 2. Pattern-match SDK error messages (11 patterns from seal.ts throw sites)
2210
2234
  * 3. Fallback to UNKNOWN/FATAL
2211
2235
  */