@wowok/agent-mcp 2.4.3 → 2.5.1

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 (317) hide show
  1. package/dist/config/runtime.d.ts +4 -0
  2. package/dist/config/runtime.js +29 -5
  3. package/dist/harness/auto-escalation.d.ts +27 -0
  4. package/dist/harness/auto-escalation.js +68 -0
  5. package/dist/index.js +21 -0
  6. package/dist/knowledge/allocation-confirm.d.ts +115 -0
  7. package/dist/knowledge/allocation-confirm.js +534 -0
  8. package/dist/knowledge/allocation-context.d.ts +58 -0
  9. package/dist/knowledge/allocation-context.js +249 -0
  10. package/dist/knowledge/allocation-ledger.d.ts +67 -0
  11. package/dist/knowledge/allocation-ledger.js +463 -0
  12. package/dist/knowledge/allocation-puzzle.d.ts +135 -0
  13. package/dist/knowledge/allocation-puzzle.js +298 -0
  14. package/dist/knowledge/allocation-risk.d.ts +78 -0
  15. package/dist/knowledge/allocation-risk.js +568 -0
  16. package/dist/knowledge/allocation-templates.d.ts +38 -0
  17. package/dist/knowledge/allocation-templates.js +970 -0
  18. package/dist/knowledge/allocation-translation.d.ts +72 -0
  19. package/dist/knowledge/allocation-translation.js +585 -0
  20. package/dist/knowledge/arb-risk.d.ts +37 -0
  21. package/dist/knowledge/arb-risk.js +210 -0
  22. package/dist/knowledge/arbitration-confirm.d.ts +135 -0
  23. package/dist/knowledge/arbitration-confirm.js +559 -0
  24. package/dist/knowledge/arbitration-context.d.ts +81 -0
  25. package/dist/knowledge/arbitration-context.js +505 -0
  26. package/dist/knowledge/arbitration-ledger.d.ts +62 -0
  27. package/dist/knowledge/arbitration-ledger.js +521 -0
  28. package/dist/knowledge/arbitration-puzzle.d.ts +84 -0
  29. package/dist/knowledge/arbitration-puzzle.js +304 -0
  30. package/dist/knowledge/arbitration-risk.d.ts +112 -0
  31. package/dist/knowledge/arbitration-risk.js +433 -0
  32. package/dist/knowledge/arbitration-templates.d.ts +38 -0
  33. package/dist/knowledge/arbitration-templates.js +276 -0
  34. package/dist/knowledge/arbitration-translation.d.ts +91 -0
  35. package/dist/knowledge/arbitration-translation.js +487 -0
  36. package/dist/knowledge/bridge-risk.d.ts +36 -0
  37. package/dist/knowledge/bridge-risk.js +263 -0
  38. package/dist/knowledge/contact-risk.d.ts +32 -0
  39. package/dist/knowledge/contact-risk.js +200 -0
  40. package/dist/knowledge/demand-confirm.d.ts +32 -0
  41. package/dist/knowledge/demand-confirm.js +206 -0
  42. package/dist/knowledge/demand-risk.d.ts +30 -0
  43. package/dist/knowledge/demand-risk.js +240 -0
  44. package/dist/knowledge/demand-translation.d.ts +55 -0
  45. package/dist/knowledge/demand-translation.js +354 -0
  46. package/dist/knowledge/deployment-scanner.d.ts +63 -0
  47. package/dist/knowledge/deployment-scanner.js +762 -0
  48. package/dist/knowledge/examples-scanner-cli.d.ts +1 -0
  49. package/dist/knowledge/examples-scanner-cli.js +26 -0
  50. package/dist/knowledge/examples-scanner.d.ts +121 -0
  51. package/dist/knowledge/examples-scanner.js +825 -0
  52. package/dist/knowledge/flywheel-loop.d.ts +3 -0
  53. package/dist/knowledge/flywheel-loop.js +32 -3
  54. package/dist/knowledge/glossary.js +3 -1
  55. package/dist/knowledge/guard-confirm.d.ts +86 -0
  56. package/dist/knowledge/guard-confirm.js +406 -0
  57. package/dist/knowledge/guard-context.d.ts +56 -0
  58. package/dist/knowledge/guard-context.js +287 -0
  59. package/dist/knowledge/guard-design-patterns.d.ts +37 -0
  60. package/dist/knowledge/guard-design-patterns.js +257 -0
  61. package/dist/knowledge/guard-puzzle.js +3 -2
  62. package/dist/knowledge/guard-risk.d.ts +1 -1
  63. package/dist/knowledge/guard-risk.js +12 -14
  64. package/dist/knowledge/guard-templates.js +1 -1
  65. package/dist/knowledge/guard-translation.js +6 -5
  66. package/dist/knowledge/index.d.ts +342 -0
  67. package/dist/knowledge/index.js +344 -0
  68. package/dist/knowledge/machine-confirm.d.ts +102 -0
  69. package/dist/knowledge/machine-confirm.js +559 -0
  70. package/dist/knowledge/machine-context.d.ts +160 -0
  71. package/dist/knowledge/machine-context.js +812 -0
  72. package/dist/knowledge/machine-ledger.d.ts +41 -0
  73. package/dist/knowledge/machine-ledger.js +315 -0
  74. package/dist/knowledge/machine-puzzle.d.ts +206 -0
  75. package/dist/knowledge/machine-puzzle.js +494 -0
  76. package/dist/knowledge/machine-risk.d.ts +75 -0
  77. package/dist/knowledge/machine-risk.js +644 -0
  78. package/dist/knowledge/machine-templates.d.ts +92 -0
  79. package/dist/knowledge/machine-templates.js +1592 -0
  80. package/dist/knowledge/machine-topology.d.ts +57 -0
  81. package/dist/knowledge/machine-topology.js +234 -0
  82. package/dist/knowledge/machine-translation.d.ts +96 -0
  83. package/dist/knowledge/machine-translation.js +513 -0
  84. package/dist/knowledge/mcp-schema-audit-cli.d.ts +1 -0
  85. package/dist/knowledge/mcp-schema-audit-cli.js +45 -0
  86. package/dist/knowledge/mcp-schema-audit.d.ts +90 -0
  87. package/dist/knowledge/mcp-schema-audit.js +772 -0
  88. package/dist/knowledge/onchain-constants.d.ts +4 -0
  89. package/dist/knowledge/onchain-constants.js +35 -0
  90. package/dist/knowledge/order-confirm.d.ts +115 -0
  91. package/dist/knowledge/order-confirm.js +573 -0
  92. package/dist/knowledge/order-context.d.ts +66 -0
  93. package/dist/knowledge/order-context.js +390 -0
  94. package/dist/knowledge/order-ledger.d.ts +69 -0
  95. package/dist/knowledge/order-ledger.js +341 -0
  96. package/dist/knowledge/order-puzzle.d.ts +159 -0
  97. package/dist/knowledge/order-puzzle.js +255 -0
  98. package/dist/knowledge/order-risk.d.ts +66 -0
  99. package/dist/knowledge/order-risk.js +653 -0
  100. package/dist/knowledge/order-templates.d.ts +50 -0
  101. package/dist/knowledge/order-templates.js +368 -0
  102. package/dist/knowledge/order-translation.d.ts +78 -0
  103. package/dist/knowledge/order-translation.js +550 -0
  104. package/dist/knowledge/passport-confirm.d.ts +130 -0
  105. package/dist/knowledge/passport-confirm.js +531 -0
  106. package/dist/knowledge/passport-context.d.ts +59 -0
  107. package/dist/knowledge/passport-context.js +306 -0
  108. package/dist/knowledge/passport-ledger.d.ts +48 -0
  109. package/dist/knowledge/passport-ledger.js +282 -0
  110. package/dist/knowledge/passport-puzzle.d.ts +108 -0
  111. package/dist/knowledge/passport-puzzle.js +333 -0
  112. package/dist/knowledge/passport-risk.d.ts +70 -0
  113. package/dist/knowledge/passport-risk.js +450 -0
  114. package/dist/knowledge/passport-templates.d.ts +40 -0
  115. package/dist/knowledge/passport-templates.js +568 -0
  116. package/dist/knowledge/passport-translation.d.ts +68 -0
  117. package/dist/knowledge/passport-translation.js +516 -0
  118. package/dist/knowledge/payment-risk.d.ts +33 -0
  119. package/dist/knowledge/payment-risk.js +182 -0
  120. package/dist/knowledge/permission-confirm.d.ts +110 -0
  121. package/dist/knowledge/permission-confirm.js +426 -0
  122. package/dist/knowledge/permission-context.d.ts +58 -0
  123. package/dist/knowledge/permission-context.js +224 -0
  124. package/dist/knowledge/permission-ledger.d.ts +38 -0
  125. package/dist/knowledge/permission-ledger.js +403 -0
  126. package/dist/knowledge/permission-puzzle.d.ts +122 -0
  127. package/dist/knowledge/permission-puzzle.js +173 -0
  128. package/dist/knowledge/permission-risk.d.ts +76 -0
  129. package/dist/knowledge/permission-risk.js +411 -0
  130. package/dist/knowledge/permission-templates.d.ts +38 -0
  131. package/dist/knowledge/permission-templates.js +234 -0
  132. package/dist/knowledge/permission-translation.d.ts +57 -0
  133. package/dist/knowledge/permission-translation.js +350 -0
  134. package/dist/knowledge/personal-risk.d.ts +36 -0
  135. package/dist/knowledge/personal-risk.js +212 -0
  136. package/dist/knowledge/progress-confirm.d.ts +108 -0
  137. package/dist/knowledge/progress-confirm.js +456 -0
  138. package/dist/knowledge/progress-context.d.ts +123 -0
  139. package/dist/knowledge/progress-context.js +452 -0
  140. package/dist/knowledge/progress-ledger.d.ts +63 -0
  141. package/dist/knowledge/progress-ledger.js +327 -0
  142. package/dist/knowledge/progress-puzzle.d.ts +82 -0
  143. package/dist/knowledge/progress-puzzle.js +219 -0
  144. package/dist/knowledge/progress-risk.d.ts +74 -0
  145. package/dist/knowledge/progress-risk.js +461 -0
  146. package/dist/knowledge/progress-templates.d.ts +38 -0
  147. package/dist/knowledge/progress-templates.js +228 -0
  148. package/dist/knowledge/progress-translation.d.ts +52 -0
  149. package/dist/knowledge/progress-translation.js +401 -0
  150. package/dist/knowledge/proof-confirm.d.ts +31 -0
  151. package/dist/knowledge/proof-confirm.js +187 -0
  152. package/dist/knowledge/proof-risk.d.ts +33 -0
  153. package/dist/knowledge/proof-risk.js +207 -0
  154. package/dist/knowledge/proof-translation.d.ts +52 -0
  155. package/dist/knowledge/proof-translation.js +283 -0
  156. package/dist/knowledge/registrar-risk.d.ts +34 -0
  157. package/dist/knowledge/registrar-risk.js +217 -0
  158. package/dist/knowledge/repository-confirm.d.ts +36 -0
  159. package/dist/knowledge/repository-confirm.js +242 -0
  160. package/dist/knowledge/repository-risk.d.ts +40 -0
  161. package/dist/knowledge/repository-risk.js +312 -0
  162. package/dist/knowledge/repository-translation.d.ts +58 -0
  163. package/dist/knowledge/repository-translation.js +422 -0
  164. package/dist/knowledge/resource-risk.d.ts +32 -0
  165. package/dist/knowledge/resource-risk.js +157 -0
  166. package/dist/knowledge/reward-confirm.d.ts +113 -0
  167. package/dist/knowledge/reward-confirm.js +496 -0
  168. package/dist/knowledge/reward-context.d.ts +127 -0
  169. package/dist/knowledge/reward-context.js +504 -0
  170. package/dist/knowledge/reward-ledger.d.ts +96 -0
  171. package/dist/knowledge/reward-ledger.js +502 -0
  172. package/dist/knowledge/reward-puzzle.d.ts +97 -0
  173. package/dist/knowledge/reward-puzzle.js +288 -0
  174. package/dist/knowledge/reward-risk.d.ts +84 -0
  175. package/dist/knowledge/reward-risk.js +545 -0
  176. package/dist/knowledge/reward-translation.d.ts +58 -0
  177. package/dist/knowledge/reward-translation.js +501 -0
  178. package/dist/knowledge/safety-rules.js +11 -3
  179. package/dist/knowledge/scenario-modes.d.ts +53 -0
  180. package/dist/knowledge/scenario-modes.js +302 -0
  181. package/dist/knowledge/service-confirm.d.ts +152 -0
  182. package/dist/knowledge/service-confirm.js +699 -0
  183. package/dist/knowledge/service-context.d.ts +66 -0
  184. package/dist/knowledge/service-context.js +403 -0
  185. package/dist/knowledge/service-ledger.d.ts +71 -0
  186. package/dist/knowledge/service-ledger.js +609 -0
  187. package/dist/knowledge/service-puzzle.d.ts +158 -0
  188. package/dist/knowledge/service-puzzle.js +236 -0
  189. package/dist/knowledge/service-risk.d.ts +108 -0
  190. package/dist/knowledge/service-risk.js +615 -0
  191. package/dist/knowledge/service-templates.d.ts +39 -0
  192. package/dist/knowledge/service-templates.js +418 -0
  193. package/dist/knowledge/service-translation.d.ts +103 -0
  194. package/dist/knowledge/service-translation.js +622 -0
  195. package/dist/knowledge/tools-reference.d.ts +17 -0
  196. package/dist/knowledge/tools-reference.js +151 -0
  197. package/dist/knowledge/treasury-confirm.d.ts +133 -0
  198. package/dist/knowledge/treasury-confirm.js +512 -0
  199. package/dist/knowledge/treasury-context.d.ts +64 -0
  200. package/dist/knowledge/treasury-context.js +363 -0
  201. package/dist/knowledge/treasury-ledger.d.ts +42 -0
  202. package/dist/knowledge/treasury-ledger.js +300 -0
  203. package/dist/knowledge/treasury-puzzle.d.ts +163 -0
  204. package/dist/knowledge/treasury-puzzle.js +216 -0
  205. package/dist/knowledge/treasury-risk.d.ts +86 -0
  206. package/dist/knowledge/treasury-risk.js +440 -0
  207. package/dist/knowledge/treasury-templates.d.ts +38 -0
  208. package/dist/knowledge/treasury-templates.js +316 -0
  209. package/dist/knowledge/treasury-translation.d.ts +78 -0
  210. package/dist/knowledge/treasury-translation.js +498 -0
  211. package/dist/knowledge/util-risk.d.ts +30 -0
  212. package/dist/knowledge/util-risk.js +135 -0
  213. package/dist/project/business-puzzle.d.ts +47 -0
  214. package/dist/project/business-puzzle.js +372 -0
  215. package/dist/project/deployment-doc.d.ts +61 -0
  216. package/dist/project/deployment-doc.js +432 -0
  217. package/dist/project/risk-aggregator.d.ts +50 -0
  218. package/dist/project/risk-aggregator.js +280 -0
  219. package/dist/project/substep-trace.d.ts +130 -0
  220. package/dist/project/substep-trace.js +332 -0
  221. package/dist/schema/call/allocation.d.ts +34 -34
  222. package/dist/schema/call/arbitration.d.ts +141 -141
  223. package/dist/schema/call/base.d.ts +386 -386
  224. package/dist/schema/call/base.js +3 -3
  225. package/dist/schema/call/bridge-handler.d.ts +5 -2
  226. package/dist/schema/call/bridge.d.ts +159 -159
  227. package/dist/schema/call/contact.d.ts +110 -110
  228. package/dist/schema/call/demand.d.ts +76 -76
  229. package/dist/schema/call/handler.d.ts +2 -3
  230. package/dist/schema/call/handler.js +1 -1
  231. package/dist/schema/call/machine.d.ts +58 -58
  232. package/dist/schema/call/order.d.ts +98 -110
  233. package/dist/schema/call/permission-handler.d.ts +5 -0
  234. package/dist/schema/call/permission-handler.js +54 -0
  235. package/dist/schema/call/permission.d.ts +108 -108
  236. package/dist/schema/call/personal.d.ts +14 -14
  237. package/dist/schema/call/progress.d.ts +57 -72
  238. package/dist/schema/call/progress.js +7 -4
  239. package/dist/schema/call/proof.d.ts +18 -18
  240. package/dist/schema/call/proof.js +12 -7
  241. package/dist/schema/call/repository.d.ts +154 -154
  242. package/dist/schema/call/reward.d.ts +55 -55
  243. package/dist/schema/call/service.d.ts +231 -231
  244. package/dist/schema/call/treasury.d.ts +93 -93
  245. package/dist/schema/config/index.d.ts +178 -5
  246. package/dist/schema/config/index.js +52 -1
  247. package/dist/schema/local/index.d.ts +3554 -836
  248. package/dist/schema/local/index.js +2 -1
  249. package/dist/schema/messenger/index.d.ts +162 -162
  250. package/dist/schema/operations.d.ts +1058 -1074
  251. package/dist/schema/operations.js +7 -1
  252. package/dist/schema/project/index.d.ts +1412 -6
  253. package/dist/schema/project/index.js +441 -3
  254. package/dist/schema/query/index.d.ts +672 -672
  255. package/dist/schema/schema-query/index.d.ts +23 -3
  256. package/dist/schema/schema-query/index.js +13 -2
  257. package/dist/schema/sync-layer4.d.ts +21 -0
  258. package/dist/schema/sync-layer4.js +261 -0
  259. package/dist/schema/trust/index.d.ts +26 -26
  260. package/dist/schemas/account_operation.output.json +718 -0
  261. package/dist/schemas/config_operation.output.json +173 -0
  262. package/dist/schemas/index.json +9 -1
  263. package/dist/schemas/local_info_operation.output.json +718 -0
  264. package/dist/schemas/local_mark_operation.output.json +718 -0
  265. package/dist/schemas/onchain_operations.output.json +3 -2
  266. package/dist/schemas/onchain_operations.schema.json +1809 -336
  267. package/dist/schemas/onchain_operations_allocation.schema.json +2 -1
  268. package/dist/schemas/onchain_operations_arbitration.schema.json +2 -1
  269. package/dist/schemas/onchain_operations_contact.schema.json +2 -1
  270. package/dist/schemas/onchain_operations_demand.schema.json +2 -1
  271. package/dist/schemas/onchain_operations_gen_passport.schema.json +878 -872
  272. package/dist/schemas/onchain_operations_gen_proof.schema.json +273 -0
  273. package/dist/schemas/onchain_operations_guard.schema.json +578 -579
  274. package/dist/schemas/onchain_operations_machine.schema.json +2 -1
  275. package/dist/schemas/onchain_operations_order.schema.json +13 -9
  276. package/dist/schemas/onchain_operations_payment.schema.json +0 -514
  277. package/dist/schemas/onchain_operations_permission.schema.json +0 -514
  278. package/dist/schemas/onchain_operations_personal.schema.json +0 -514
  279. package/dist/schemas/onchain_operations_progress.schema.json +14 -10
  280. package/dist/schemas/onchain_operations_proof.schema.json +699 -0
  281. package/dist/schemas/onchain_operations_repository.schema.json +2 -1
  282. package/dist/schemas/onchain_operations_reward.schema.json +2 -1
  283. package/dist/schemas/onchain_operations_service.schema.json +2 -1
  284. package/dist/schemas/onchain_operations_treasury.schema.json +2 -1
  285. package/dist/schemas/onchain_table_data.schema.json +32 -1
  286. package/dist/schemas/project_operation.output.json +918 -0
  287. package/dist/schemas/project_operation.schema.json +474 -3
  288. package/dist/schemas/query_toolkit.output.json +14906 -6
  289. package/dist/schemas/schema_query.output.json +38 -1
  290. package/dist/telemetry/index.d.ts +1 -1
  291. package/dist/tools/handlers/config.d.ts +1 -1
  292. package/dist/tools/handlers/config.js +21 -18
  293. package/dist/tools/handlers/file-export.d.ts +2 -2
  294. package/dist/tools/handlers/local.d.ts +3 -30
  295. package/dist/tools/handlers/local.js +14 -3
  296. package/dist/tools/handlers/messenger.d.ts +1 -1
  297. package/dist/tools/handlers/messenger.js +2 -1
  298. package/dist/tools/handlers/onchain.d.ts +1 -1
  299. package/dist/tools/handlers/onchain.js +24 -22
  300. package/dist/tools/handlers/project.d.ts +1 -1
  301. package/dist/tools/handlers/project.js +262 -18
  302. package/dist/tools/handlers/query.d.ts +4 -4
  303. package/dist/tools/handlers/schema-query.d.ts +1 -1
  304. package/dist/tools/handlers/schema-query.js +21 -20
  305. package/dist/tools/handlers/trust.d.ts +1 -1
  306. package/dist/tools/handlers/trust.js +2 -2
  307. package/dist/tools/handlers/wip.d.ts +1 -1
  308. package/dist/tools/handlers/wip.js +1 -1
  309. package/dist/tools/index.d.ts +1 -1
  310. package/dist/tools/index.js +96 -25
  311. package/dist/tools/rules-hook.d.ts +1 -1
  312. package/dist/tools/rules-hook.js +3 -2
  313. package/dist/tools/shared.d.ts +13 -22
  314. package/dist/tools/types.d.ts +5 -5
  315. package/dist/tools/wrap.d.ts +10 -2
  316. package/dist/tools/wrap.js +212 -0
  317. package/package.json +3 -3
@@ -0,0 +1,559 @@
1
+ import { MAX_VOTING_GUARD_COUNT, } from "@wowok/wowok";
2
+ import { isTerminalArbStatus, isValidArbStatusTransition, } from "./arbitration-ledger.js";
3
+ import { assessArbitrationRisks, } from "./arbitration-risk.js";
4
+ export const ARBITRATION_OPERATION_CHECKLIST = [
5
+ { id: "C-AB-01", description: "object field present (STRING for existing, OBJECT for new)", passed: false, message: "" },
6
+ { id: "C-AB-02", description: "coin_type valid for new Arbitration (e.g. 0x2::wow::WOW)", passed: false, message: "" },
7
+ { id: "C-AB-03", description: "permission_address valid (Contact/Permission object)", passed: false, message: "" },
8
+ { id: "C-AB-04", description: "fee (u64) non-negative; dispute fee >= Arbitration.fee", passed: false, message: "" },
9
+ { id: "C-AB-05", description: "voting_guard count <= MAX_VOTING_GUARD_COUNT (50)", passed: false, message: "" },
10
+ { id: "C-AB-06", description: "voting_guard no duplicate addresses", passed: false, message: "" },
11
+ { id: "C-AB-07", description: "Arb status transition valid (7-state flow)", passed: false, message: "" },
12
+ { id: "C-AB-08", description: "Operation allowed in current Arb status (not terminal-blocked)", passed: false, message: "" },
13
+ { id: "C-AB-09", description: "voting_guard / usage_guard dual-Guard coherent with operation", passed: false, message: "" },
14
+ { id: "C-AB-10", description: "VoteValue weight type valid (GuardIdentifier u8 / FixedValue u32)", passed: false, message: "" },
15
+ { id: "C-AB-11", description: "Order op permission verified (for dispute)", passed: false, message: "" },
16
+ { id: "C-AB-12", description: "Ownership transfer (builder) double-confirmed", passed: false, message: "" },
17
+ ];
18
+ function runStaticChecklist(input) {
19
+ const items = ARBITRATION_OPERATION_CHECKLIST.map(c => ({ ...c }));
20
+ const data = input.arbitration_json;
21
+ const objValid = data.object !== undefined && data.object !== null;
22
+ const c01 = items.find(i => i.id === "C-AB-01");
23
+ c01.passed = objValid;
24
+ c01.message = objValid ? "" : "object field is required (STRING for existing, OBJECT for new)";
25
+ const c02 = items.find(i => i.id === "C-AB-02");
26
+ if (typeof data.object === "object" && data.object !== null) {
27
+ const obj = data.object;
28
+ const valid = !!obj.type_parameter && obj.type_parameter.includes("::");
29
+ c02.passed = valid;
30
+ c02.message = valid ? "" : "type_parameter must be a valid Coin type (e.g. 0x2::wow::WOW)";
31
+ }
32
+ else {
33
+ c02.passed = true;
34
+ }
35
+ const c03 = items.find(i => i.id === "C-AB-03");
36
+ if (typeof data.object === "object" && data.object !== null) {
37
+ const obj = data.object;
38
+ const valid = !!obj.permission;
39
+ c03.passed = valid;
40
+ c03.message = valid ? "" : "permission is required for new Arbitration";
41
+ }
42
+ else {
43
+ c03.passed = true;
44
+ }
45
+ const c04 = items.find(i => i.id === "C-AB-04");
46
+ if (data.fee !== undefined) {
47
+ const feeNum = typeof data.fee === "string" ? BigInt(data.fee) : BigInt(data.fee);
48
+ const valid = feeNum >= 0;
49
+ c04.passed = valid;
50
+ c04.message = valid ? "" : `fee ${data.fee} must be >= 0`;
51
+ }
52
+ else if (data.dispute && input.current_arbitration_fee !== undefined) {
53
+ const required = typeof input.current_arbitration_fee === "string"
54
+ ? BigInt(input.current_arbitration_fee)
55
+ : BigInt(input.current_arbitration_fee);
56
+ const provided = data.dispute.fee && typeof data.dispute.fee === "object" && "balance" in data.dispute.fee
57
+ ? BigInt(data.dispute.fee.balance ?? 0)
58
+ : BigInt(0);
59
+ const valid = provided >= required;
60
+ c04.passed = valid;
61
+ c04.message = valid ? "" : `dispute fee ${provided.toString()} < required ${required.toString()}`;
62
+ }
63
+ else {
64
+ c04.passed = true;
65
+ }
66
+ const c05 = items.find(i => i.id === "C-AB-05");
67
+ if (data.voting_guard && (data.voting_guard.op === "add" || data.voting_guard.op === "set") && data.voting_guard.guards) {
68
+ const newCount = data.voting_guard.op === "set"
69
+ ? data.voting_guard.guards.length
70
+ : (input.current_voting_guard_count ?? 0) + data.voting_guard.guards.length;
71
+ const valid = newCount <= MAX_VOTING_GUARD_COUNT;
72
+ c05.passed = valid;
73
+ c05.message = valid ? "" : `voting_guard count ${newCount} > ${MAX_VOTING_GUARD_COUNT}`;
74
+ }
75
+ else {
76
+ c05.passed = true;
77
+ }
78
+ const c06 = items.find(i => i.id === "C-AB-06");
79
+ if (data.voting_guard && (data.voting_guard.op === "add" || data.voting_guard.op === "set") && data.voting_guard.guards) {
80
+ const addrs = data.voting_guard.guards.map(g => g.guard);
81
+ const dupes = addrs.filter((a, i) => addrs.indexOf(a) !== i);
82
+ const valid = dupes.length === 0;
83
+ c06.passed = valid;
84
+ c06.message = valid ? "" : `Duplicate guards: ${dupes.join(", ")}`;
85
+ }
86
+ else {
87
+ c06.passed = true;
88
+ }
89
+ const c07 = items.find(i => i.id === "C-AB-07");
90
+ if (input.current_arb_status && input.expected_arb_status) {
91
+ if (input.current_arb_status === input.expected_arb_status) {
92
+ c07.passed = true;
93
+ }
94
+ else {
95
+ const valid = isValidArbStatusTransition(input.current_arb_status, input.expected_arb_status);
96
+ c07.passed = valid;
97
+ c07.message = valid ? "" : `Invalid transition: ${input.current_arb_status} → ${input.expected_arb_status}`;
98
+ }
99
+ }
100
+ else {
101
+ c07.passed = true;
102
+ }
103
+ const c08 = items.find(i => i.id === "C-AB-08");
104
+ if (input.current_arb_status && isTerminalArbStatus(input.current_arb_status)) {
105
+ const allowedOp = !!data.arb_withdraw;
106
+ const blockedOp = !!(data.vote || data.confirm || data.arbitration || data.reset || data.feedback);
107
+ const valid = allowedOp && !blockedOp;
108
+ c08.passed = valid;
109
+ c08.message = valid ? "" : `Terminal status ${input.current_arb_status} only allows arb_withdraw`;
110
+ }
111
+ else {
112
+ c08.passed = true;
113
+ }
114
+ const c09 = items.find(i => i.id === "C-AB-09");
115
+ if (data.vote && data.vote.voting_guard) {
116
+ if (!input.current_voting_guard_addresses || input.current_voting_guard_addresses.length === 0) {
117
+ c09.passed = false;
118
+ c09.message = "vote.voting_guard provided but Arbitration.voting_guard is empty";
119
+ }
120
+ else if (!input.current_voting_guard_addresses.includes(data.vote.voting_guard)) {
121
+ c09.passed = false;
122
+ c09.message = `vote.voting_guard ${data.vote.voting_guard} not in list`;
123
+ }
124
+ else {
125
+ c09.passed = true;
126
+ }
127
+ }
128
+ else if (data.vote && !data.vote.voting_guard && input.current_voting_guard_addresses && input.current_voting_guard_addresses.length > 0) {
129
+ c09.passed = false;
130
+ c09.message = "vote without voting_guard but Arbitration.voting_guard is non-empty (use vote_with_voting_guard)";
131
+ }
132
+ else {
133
+ c09.passed = true;
134
+ }
135
+ const c10 = items.find(i => i.id === "C-AB-10");
136
+ if (data.voting_guard && (data.voting_guard.op === "add" || data.voting_guard.op === "set") && data.voting_guard.guards) {
137
+ let valid = true;
138
+ let msg = "";
139
+ for (const g of data.voting_guard.guards) {
140
+ const vw = g.vote_weight;
141
+ if (!vw) {
142
+ valid = false;
143
+ msg = "Missing vote_weight";
144
+ break;
145
+ }
146
+ if ("GuardIdentifier" in vw && vw.GuardIdentifier !== undefined) {
147
+ if (vw.GuardIdentifier > 255) {
148
+ valid = false;
149
+ msg = `GuardIdentifier ${vw.GuardIdentifier} > u8 max (255)`;
150
+ break;
151
+ }
152
+ }
153
+ if ("FixedValue" in vw && vw.FixedValue !== undefined) {
154
+ if (vw.FixedValue > 4294967295) {
155
+ valid = false;
156
+ msg = `FixedValue ${vw.FixedValue} > u32 max`;
157
+ break;
158
+ }
159
+ }
160
+ }
161
+ c10.passed = valid;
162
+ c10.message = msg;
163
+ }
164
+ else {
165
+ c10.passed = true;
166
+ }
167
+ const c11 = items.find(i => i.id === "C-AB-11");
168
+ if (data.dispute) {
169
+ c11.passed = false;
170
+ c11.message = "Pending environment verification (Layer 4)";
171
+ }
172
+ else {
173
+ c11.passed = true;
174
+ }
175
+ const c12 = items.find(i => i.id === "C-AB-12");
176
+ if (data.builder) {
177
+ c12.passed = false;
178
+ c12.message = "Pending user confirmation in Layer 3";
179
+ }
180
+ else {
181
+ c12.passed = true;
182
+ }
183
+ return {
184
+ all_passed: items.filter(i => i.id !== "C-AB-11" && i.id !== "C-AB-12").every(i => i.passed),
185
+ items,
186
+ };
187
+ }
188
+ function adaptRiskAssessment(input) {
189
+ const ctx = {
190
+ object: typeof input.arbitration_json.object === "string" ? input.arbitration_json.object : null,
191
+ description: input.arbitration_json.description,
192
+ location: input.arbitration_json.location,
193
+ fee: input.arbitration_json.fee,
194
+ pause: input.arbitration_json.pause,
195
+ dispute: input.arbitration_json.dispute,
196
+ confirm: input.arbitration_json.confirm,
197
+ voting_deadline_change: input.arbitration_json.voting_deadline_change,
198
+ vote: input.arbitration_json.vote,
199
+ feedback: input.arbitration_json.feedback,
200
+ arbitration: input.arbitration_json.arbitration,
201
+ reset: input.arbitration_json.reset,
202
+ arb_withdraw: input.arbitration_json.arb_withdraw,
203
+ fees_transfer: input.arbitration_json.fees_transfer,
204
+ usage_guard: input.arbitration_json.usage_guard,
205
+ voting_guard: input.arbitration_json.voting_guard,
206
+ um: input.arbitration_json.um,
207
+ builder: input.arbitration_json.builder,
208
+ current_arb_status: input.current_arb_status,
209
+ expected_arb_status: input.expected_arb_status,
210
+ current_voting_guard_count: input.current_voting_guard_count,
211
+ current_voting_guard_addresses: input.current_voting_guard_addresses,
212
+ current_arbitration_fee: input.current_arbitration_fee,
213
+ current_bPaused: input.current_bPaused,
214
+ current_timestamp_ms: input.current_timestamp_ms,
215
+ target_objects_types: input.target_objects_types,
216
+ };
217
+ return assessArbitrationRisks(ctx);
218
+ }
219
+ export const ARBITRATION_CONFIRMATION_QUESTIONS = [
220
+ {
221
+ id: "QAB1",
222
+ question: "Are all arbiter/voter addresses correctly granted ARBITRATION_VOTE (358) on the Permission object?",
223
+ requires_explicit_yes: true,
224
+ },
225
+ {
226
+ id: "QAB2",
227
+ question: "Is the voting_guard configuration correct? (Each guard address is a valid Guard object that arbiters can submit Passport for)",
228
+ requires_explicit_yes: true,
229
+ related_risk_ids: ["R-AB-2-01"],
230
+ },
231
+ {
232
+ id: "QAB3",
233
+ question: "If filing a dispute: have you verified the Order op permission (signer must have Order's dispute permission)?",
234
+ requires_explicit_yes: true,
235
+ related_risk_ids: ["R-AB-5-02"],
236
+ },
237
+ {
238
+ id: "QAB4",
239
+ question: "If making a ruling (arbitration op): is the indemnity amount correct? This will be paid via order::compensate (IRREVERSIBLE).",
240
+ requires_explicit_yes: true,
241
+ related_risk_ids: ["R-AB-3-03"],
242
+ },
243
+ {
244
+ id: "QAB5",
245
+ question: "⚠️ If transferring ownership (builder field): do you confirm the new owner address is correct? This operation is IRREVERSIBLE.",
246
+ requires_explicit_yes: true,
247
+ related_risk_ids: ["R-AB-3-02"],
248
+ },
249
+ {
250
+ id: "QAB6",
251
+ question: "If allocating fees (fees_transfer): have you verified the destination Allocation/Treasury has a fair distribution policy for arbiters?",
252
+ requires_explicit_yes: true,
253
+ related_risk_ids: ["R-AB-5-01"],
254
+ },
255
+ ];
256
+ function processUserConfirmation(input, assessment) {
257
+ const questions = [...ARBITRATION_CONFIRMATION_QUESTIONS];
258
+ if (!input.arbitration_json.dispute) {
259
+ const idx = questions.findIndex(q => q.id === "QAB3");
260
+ if (idx >= 0)
261
+ questions.splice(idx, 1);
262
+ }
263
+ if (!input.arbitration_json.arbitration) {
264
+ const idx = questions.findIndex(q => q.id === "QAB4");
265
+ if (idx >= 0)
266
+ questions.splice(idx, 1);
267
+ }
268
+ if (!input.arbitration_json.builder) {
269
+ const idx = questions.findIndex(q => q.id === "QAB5");
270
+ if (idx >= 0)
271
+ questions.splice(idx, 1);
272
+ }
273
+ if (!input.arbitration_json.fees_transfer) {
274
+ const idx = questions.findIndex(q => q.id === "QAB6");
275
+ if (idx >= 0)
276
+ questions.splice(idx, 1);
277
+ }
278
+ if (input.skip_user_confirmation) {
279
+ return {
280
+ questions_asked: questions,
281
+ responses: questions.map(q => ({ question_id: q.id, response: "yes" })),
282
+ all_confirmed: true,
283
+ };
284
+ }
285
+ return {
286
+ questions_asked: questions,
287
+ responses: [],
288
+ all_confirmed: false,
289
+ };
290
+ }
291
+ function verifyEnvironment(input) {
292
+ const checks = [];
293
+ if (typeof input.arbitration_json.object === "string") {
294
+ checks.push({
295
+ name: "object_exists",
296
+ passed: true,
297
+ message: `Arbitration object ${input.arbitration_json.object} assumed to exist`,
298
+ });
299
+ }
300
+ const op = input.arbitration_json;
301
+ const requiresPerm = !!(op.description || op.location || op.fee || op.pause || op.confirm ||
302
+ op.vote || op.feedback || op.arbitration || op.reset || op.arb_withdraw ||
303
+ op.fees_transfer || op.usage_guard !== undefined || op.voting_guard ||
304
+ op.um !== undefined);
305
+ if (requiresPerm) {
306
+ checks.push({
307
+ name: "signer_has_permission",
308
+ passed: true,
309
+ message: "Signer must have the relevant ARBITRATION_* permission index (350-368)",
310
+ });
311
+ }
312
+ const arbOp = op.confirm || op.vote || op.feedback || op.arbitration || op.reset || op.arb_withdraw;
313
+ if (arbOp) {
314
+ checks.push({
315
+ name: "arb_belongs_to_arbitration",
316
+ passed: true,
317
+ message: "Arb.arbitration_address must match this Arbitration (else E_ARBITRATION_ARB_NOT_MATCH)",
318
+ });
319
+ }
320
+ if (op.dispute) {
321
+ checks.push({
322
+ name: "order_op_permission",
323
+ passed: false,
324
+ message: `Signer must have Order ${op.dispute.order} dispute operation permission`,
325
+ });
326
+ }
327
+ if (op.dispute && input.current_bPaused !== undefined) {
328
+ checks.push({
329
+ name: "arbitration_not_paused",
330
+ passed: !input.current_bPaused,
331
+ message: input.current_bPaused ? "Arbitration is paused — dispute will fail (E_PAUSED)" : "OK",
332
+ });
333
+ }
334
+ if (op.vote && input.current_timestamp_ms !== undefined && input.current_arb_status === "Voting") {
335
+ checks.push({
336
+ name: "voting_deadline_not_expired",
337
+ passed: true,
338
+ message: "Verify Arb.voting_deadline > current time (else vote rejected)",
339
+ });
340
+ }
341
+ const allPassed = checks.every(c => c.passed);
342
+ return { passed: allPassed, checks };
343
+ }
344
+ export const ARBITRATION_CONFIRM_VERSION = "1.0.0";
345
+ export function runArbitrationConfirmGate(input) {
346
+ const layersPassed = [];
347
+ const layersFailed = [];
348
+ const checklist = runStaticChecklist(input);
349
+ if (!checklist.all_passed) {
350
+ layersFailed.push("L1_checklist");
351
+ return {
352
+ status: "blocked_checklist",
353
+ checklist_result: checklist,
354
+ confirmation_text: generateConfirmationText(input, checklist),
355
+ block_reason: `Checklist failed: ${checklist.items.filter(i => !i.passed && i.id !== "C-AB-11" && i.id !== "C-AB-12").map(i => i.id).join(", ")}`,
356
+ decision_record: {
357
+ timestamp: new Date().toISOString(),
358
+ gate_version: ARBITRATION_CONFIRM_VERSION,
359
+ final_status: "blocked_checklist",
360
+ layers_passed: layersPassed,
361
+ layers_failed: layersFailed,
362
+ },
363
+ };
364
+ }
365
+ layersPassed.push("L1_checklist");
366
+ const assessment = adaptRiskAssessment(input);
367
+ const hasCritical = assessment.risks.some(r => r.level === "CRITICAL");
368
+ if (hasCritical) {
369
+ layersFailed.push("L2_risk");
370
+ return {
371
+ status: "blocked_risk",
372
+ checklist_result: checklist,
373
+ risk_result: assessment,
374
+ confirmation_text: generateConfirmationText(input, checklist, assessment),
375
+ block_reason: `CRITICAL risks: ${assessment.risks.filter(r => r.level === "CRITICAL").map(r => r.id).join(", ")}`,
376
+ decision_record: {
377
+ timestamp: new Date().toISOString(),
378
+ gate_version: ARBITRATION_CONFIRM_VERSION,
379
+ final_status: "blocked_risk",
380
+ layers_passed: layersPassed,
381
+ layers_failed: layersFailed,
382
+ },
383
+ };
384
+ }
385
+ layersPassed.push("L2_risk");
386
+ const userConf = processUserConfirmation(input, assessment);
387
+ if (!userConf.all_confirmed) {
388
+ if (input.arbitration_json.builder) {
389
+ const cab12 = checklist.items.find(i => i.id === "C-AB-12");
390
+ if (cab12) {
391
+ const qab5 = userConf.responses.find(r => r.question_id === "QAB5");
392
+ cab12.passed = qab5?.response === "yes";
393
+ cab12.message = cab12.passed ? "" : "Transfer not confirmed by user";
394
+ }
395
+ }
396
+ if (input.arbitration_json.builder) {
397
+ const cab12 = checklist.items.find(i => i.id === "C-AB-12");
398
+ if (cab12 && !cab12.passed) {
399
+ layersFailed.push("L3_user");
400
+ return {
401
+ status: "blocked_user",
402
+ checklist_result: checklist,
403
+ risk_result: assessment,
404
+ user_confirmation: userConf,
405
+ confirmation_text: generateConfirmationText(input, checklist, assessment),
406
+ block_reason: "User did not confirm ownership transfer",
407
+ decision_record: {
408
+ timestamp: new Date().toISOString(),
409
+ gate_version: ARBITRATION_CONFIRM_VERSION,
410
+ final_status: "blocked_user",
411
+ layers_passed: layersPassed,
412
+ layers_failed: layersFailed,
413
+ },
414
+ };
415
+ }
416
+ }
417
+ }
418
+ layersPassed.push("L3_user");
419
+ if (input.skip_environment_check) {
420
+ layersPassed.push("L4_environment");
421
+ }
422
+ else {
423
+ const env = verifyEnvironment(input);
424
+ if (!env.passed) {
425
+ layersFailed.push("L4_environment");
426
+ return {
427
+ status: "blocked_environment",
428
+ checklist_result: checklist,
429
+ risk_result: assessment,
430
+ user_confirmation: userConf,
431
+ environment_result: env,
432
+ confirmation_text: generateConfirmationText(input, checklist, assessment),
433
+ block_reason: `Environment check failed: ${env.checks.filter(c => !c.passed).map(c => c.name).join(", ")}`,
434
+ decision_record: {
435
+ timestamp: new Date().toISOString(),
436
+ gate_version: ARBITRATION_CONFIRM_VERSION,
437
+ final_status: "blocked_environment",
438
+ layers_passed: layersPassed,
439
+ layers_failed: layersFailed,
440
+ },
441
+ };
442
+ }
443
+ layersPassed.push("L4_environment");
444
+ }
445
+ return {
446
+ status: "approved",
447
+ checklist_result: checklist,
448
+ risk_result: assessment,
449
+ user_confirmation: userConf,
450
+ confirmation_text: generateConfirmationText(input, checklist, assessment),
451
+ decision_record: {
452
+ timestamp: new Date().toISOString(),
453
+ gate_version: ARBITRATION_CONFIRM_VERSION,
454
+ final_status: "approved",
455
+ layers_passed: layersPassed,
456
+ layers_failed: layersFailed,
457
+ },
458
+ };
459
+ }
460
+ function generateConfirmationText(input, checklist, assessment) {
461
+ const lines = [];
462
+ const data = input.arbitration_json;
463
+ lines.push("═══ Arbitration Confirmation ═══");
464
+ lines.push("");
465
+ if (typeof data.object === "string") {
466
+ lines.push(`Arbitration: ${data.object}`);
467
+ }
468
+ else if (typeof data.object === "object" && data.object !== null) {
469
+ const obj = data.object;
470
+ lines.push(`Arbitration: NEW '${obj.name ?? "?"}' (T=${obj.type_parameter ?? "?"})`);
471
+ }
472
+ else {
473
+ lines.push("Arbitration: (not specified)");
474
+ }
475
+ if (data.description)
476
+ lines.push(`Description: ${data.description}`);
477
+ if (input.current_arb_status)
478
+ lines.push(`Current Arb status: ${input.current_arb_status}`);
479
+ if (input.expected_arb_status)
480
+ lines.push(`Expected Arb status: ${input.expected_arb_status}`);
481
+ lines.push("");
482
+ lines.push("─ Checklist ──────────────────");
483
+ for (const item of checklist.items) {
484
+ const mark = item.passed ? "✓" : "✗";
485
+ lines.push(` ${mark} ${item.id}: ${item.description}${item.message ? " — " + item.message : ""}`);
486
+ }
487
+ lines.push("");
488
+ if (assessment) {
489
+ lines.push("─ Risk Assessment ──────────────────");
490
+ lines.push(`Overall: ${assessment.overall_risk}`);
491
+ lines.push(`Detected: ${assessment.risks.length} risk(s)`);
492
+ for (const r of assessment.risks) {
493
+ lines.push(` [${r.level}] ${r.id}: ${r.title}`);
494
+ }
495
+ lines.push("");
496
+ }
497
+ lines.push("─ Operations ──────────────────");
498
+ if (data.dispute)
499
+ lines.push(`- DISPUTE on Order ${data.dispute.order} (${data.dispute.proposition.length} propositions)`);
500
+ if (data.confirm)
501
+ lines.push(`- CONFIRM Arb ${data.confirm.arb} (deadline=${data.confirm.voting_deadline ?? "none"})`);
502
+ if (data.vote)
503
+ lines.push(`- VOTE on Arb ${data.vote.arb} (${data.vote.voting_guard ? "weighted" : "open"})`);
504
+ if (data.feedback)
505
+ lines.push(`- FEEDBACK on Arb ${data.feedback.arb}`);
506
+ if (data.arbitration)
507
+ lines.push(`- ⚖️ RULING on Arb ${data.arbitration.arb} (indemnity=${data.arbitration.indemnity})`);
508
+ if (data.reset)
509
+ lines.push(`- ↻ RESET Arb ${data.reset.arb}`);
510
+ if (data.arb_withdraw)
511
+ lines.push(`- WITHDRAW from Arb ${data.arb_withdraw.arb}`);
512
+ if (data.fees_transfer) {
513
+ const dest = data.fees_transfer.to.allocation ? `Allocation ${data.fees_transfer.to.allocation}` : `Treasury ${data.fees_transfer.to.treasury}`;
514
+ lines.push(`- 💰 FEES → ${dest}`);
515
+ }
516
+ if (data.voting_guard)
517
+ lines.push(`- voting_guard ${data.voting_guard.op}`);
518
+ if (data.usage_guard !== undefined)
519
+ lines.push(`- usage_guard: ${data.usage_guard ?? "clear"}`);
520
+ if (data.builder)
521
+ lines.push(`- ⚠️ TRANSFER to: ${data.builder}`);
522
+ if (data.um !== undefined)
523
+ lines.push(`- UM: ${data.um ?? "(revoke)"}`);
524
+ lines.push("");
525
+ return lines.join("\n");
526
+ }
527
+ export function progressiveArbitrationCheck(input) {
528
+ const checklist = runStaticChecklist(input);
529
+ if (!checklist.all_passed) {
530
+ return {
531
+ stage: "checklist",
532
+ status: "fail",
533
+ message: `Checklist failed: ${checklist.items.filter(i => !i.passed && i.id !== "C-AB-11" && i.id !== "C-AB-12").map(i => i.id).join(", ")}`,
534
+ next_action: "Fix failing checklist items",
535
+ };
536
+ }
537
+ const assessment = adaptRiskAssessment(input);
538
+ if (assessment.risks.some(r => r.level === "CRITICAL")) {
539
+ return {
540
+ stage: "risk",
541
+ status: "fail",
542
+ message: `CRITICAL risks: ${assessment.risks.filter(r => r.level === "CRITICAL").map(r => r.id).join(", ")}`,
543
+ next_action: "Resolve CRITICAL risks before proceeding",
544
+ };
545
+ }
546
+ if (assessment.needs_human_review) {
547
+ return {
548
+ stage: "confirmation",
549
+ status: "pending",
550
+ message: "Human review required for HIGH risks",
551
+ next_action: "Confirm risk acceptance",
552
+ };
553
+ }
554
+ return {
555
+ stage: "complete",
556
+ status: "pass",
557
+ message: "All checks passed",
558
+ };
559
+ }
@@ -0,0 +1,81 @@
1
+ import { type ArbitrationScene, type ArbitrationPermissionEntry, type ArbStatus, type DualGuardMatrix } from "./arbitration-ledger.js";
2
+ import { type ArbitrationTemplate } from "./arbitration-templates.js";
3
+ import { type SemanticToSchemaRule, type ArbitrationConstraintRule } from "./arbitration-translation.js";
4
+ import { type RiskRule, type ArbitrationStakeholder, type ArbitrationRiskAssessment } from "./arbitration-risk.js";
5
+ import { type ArbitrationPuzzle, type PuzzleCompleteness } from "./arbitration-puzzle.js";
6
+ import { type ChecklistItem, type ConfirmationQuestion, type ArbitrationJsonForConfirm } from "./arbitration-confirm.js";
7
+ export declare const ARBITRATION_CONTEXT_VERSION = "1.0.0";
8
+ export type ArbitrationInjectionMode = "initial_design" | "mid_design_review" | "pre_publish" | "post_publish_modify" | "stakeholder_review" | "apply_check";
9
+ export type ArbitrationStakeholderPerspective = ArbitrationStakeholder | "system";
10
+ export interface ArbitrationContextBundle {
11
+ version: string;
12
+ mode: ArbitrationInjectionMode;
13
+ stakeholder_perspective?: ArbitrationStakeholderPerspective;
14
+ matched_scene?: ArbitrationScene;
15
+ matched_template?: ArbitrationTemplate;
16
+ matched_pattern?: SemanticToSchemaRule;
17
+ puzzle_state?: ArbitrationPuzzle;
18
+ puzzle_completeness?: PuzzleCompleteness;
19
+ relevant_risks: RiskRule[];
20
+ risk_assessment?: ArbitrationRiskAssessment;
21
+ relevant_checklist: ChecklistItem[];
22
+ relevant_questions: ConfirmationQuestion[];
23
+ relevant_permissions: ArbitrationPermissionEntry[];
24
+ relevant_constraints: ArbitrationConstraintRule[];
25
+ dual_guard_matrix_entry?: DualGuardMatrix;
26
+ arb_lifecycle_context?: ArbLifecycleContext;
27
+ cross_object_refs: ArbitrationCrossObjectRef[];
28
+ onchain_constraints: ArbitrationOnchainConstraint[];
29
+ rendering_hints: ArbitrationRenderingHints;
30
+ }
31
+ export interface ArbLifecycleContext {
32
+ current_status?: ArbStatus;
33
+ current_status_code?: number;
34
+ is_terminal: boolean;
35
+ valid_next_statuses: ArbStatus[];
36
+ valid_operations_from_here: string[];
37
+ }
38
+ export interface ArbitrationCrossObjectRef {
39
+ object: "Order" | "Service" | "Arb" | "Allocation" | "Treasury" | "Guard" | "Contact" | "Payment";
40
+ field: string;
41
+ scene_id: string;
42
+ description: string;
43
+ direction: "references" | "referenced_by";
44
+ }
45
+ export interface ArbitrationOnchainConstraint {
46
+ name: string;
47
+ value: string | number;
48
+ description: string;
49
+ }
50
+ export interface ArbitrationRenderingHints {
51
+ include_puzzle_template: boolean;
52
+ include_risk_details: boolean;
53
+ include_questions: boolean;
54
+ include_dual_guard_matrix: boolean;
55
+ include_arb_lifecycle: boolean;
56
+ include_immutability_warning: boolean;
57
+ include_indemnity_warning: boolean;
58
+ include_ownership_transfer_warning: boolean;
59
+ max_length: number;
60
+ }
61
+ export interface BuildArbitrationContextInput {
62
+ mode: ArbitrationInjectionMode;
63
+ intent?: string;
64
+ arbitration_json?: ArbitrationJsonForConfirm;
65
+ stakeholder?: ArbitrationStakeholderPerspective;
66
+ target_permission_index?: number;
67
+ target_operation_category?: ArbitrationScene["operation_category"];
68
+ current_arb_status?: ArbStatus;
69
+ voting_guard_empty?: boolean;
70
+ usage_guard_none?: boolean;
71
+ max_length?: number;
72
+ }
73
+ export declare function buildArbitrationContext(input: BuildArbitrationContextInput): ArbitrationContextBundle;
74
+ export declare function buildPromptFromArbitrationContext(bundle: ArbitrationContextBundle): string;
75
+ export declare function getArbitrationContextSummary(bundle: ArbitrationContextBundle): string;
76
+ export { ARBITRATION_LEDGER_VERSION, ARBITRATION_SCENES, ARBITRATION_PERMISSIONS, DUAL_GUARD_MATRIX, ARB_STATUS_CODE, ARB_TERMINAL_STATUSES, findSceneById, findSceneByPermissionIndex, inferSceneFromIntent, getScenesByCategory, getDualGuardMatrixEntry, isValidArbStatusTransition, isTerminalArbStatus, getActiveArbitrationPermissions, getAllArbitrationPermissions, } from "./arbitration-ledger.js";
77
+ export { ARBITRATION_TEMPLATES_VERSION, ARBITRATION_TEMPLATES, suggestTemplateForScene, getTemplatesByScene, getTemplateById, } from "./arbitration-templates.js";
78
+ export { ARBITRATION_TRANSLATION_VERSION, SEMANTIC_TO_SCHEMA_RULES, ARBITRATION_CONSTRAINT_RULES, matchSemanticPattern, explainArbitrationCallData, explainPermissionIndex, explainArbStatus, } from "./arbitration-translation.js";
79
+ export { ARBITRATION_RISK_VERSION, getAllRiskRules, assessArbitrationRisks, } from "./arbitration-risk.js";
80
+ export { ARBITRATION_CONFIRM_VERSION, ARBITRATION_OPERATION_CHECKLIST, ARBITRATION_CONFIRMATION_QUESTIONS, runArbitrationConfirmGate, } from "./arbitration-confirm.js";
81
+ export { initPuzzleFromIntent, checkPuzzleCompleteness, validateConstraints, } from "./arbitration-puzzle.js";