@wowok/agent-mcp 2.7.8 → 3.0.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 (393) hide show
  1. package/README.md +2 -2
  2. package/dist/config/runtime.d.ts +1 -1
  3. package/dist/config/runtime.js +1 -1
  4. package/dist/examples/rental-ziroom-machine-create.json +1 -2
  5. package/dist/examples/rental-ziroom-permission-create.json +1 -2
  6. package/dist/examples/rental-ziroom-service-create.json +1 -2
  7. package/dist/experience/experience-reuse.js +1 -1
  8. package/dist/experience/index.d.ts +2 -1
  9. package/dist/experience/index.js +1 -1
  10. package/dist/experience/persistence-config.d.ts +6 -0
  11. package/dist/experience/persistence-config.js +1 -0
  12. package/dist/experience/persistence.d.ts +21 -0
  13. package/dist/experience/persistence.js +1 -0
  14. package/dist/experience/realtime-feedback.js +1 -1
  15. package/dist/experience/user-profile.js +1 -1
  16. package/dist/extensions/business-modules.d.ts +1 -1
  17. package/dist/extensions/capability-manifest.d.ts +2 -83
  18. package/dist/extensions/capability-manifest.js +1 -1
  19. package/dist/extensions/constraint-registry.d.ts +6 -4
  20. package/dist/extensions/constraint-registry.js +1 -1
  21. package/dist/extensions/index.d.ts +4 -5
  22. package/dist/extensions/index.js +1 -1
  23. package/dist/extensions/industry-pack.js +1 -1
  24. package/dist/extensions/metric-registry.d.ts +6 -4
  25. package/dist/extensions/metric-registry.js +1 -1
  26. package/dist/extensions/mode-evaluator.d.ts +2 -3
  27. package/dist/extensions/mode-evaluator.js +1 -1
  28. package/dist/extensions/registry.d.ts +3 -25
  29. package/dist/extensions/registry.js +1 -1
  30. package/dist/extensions/types.d.ts +1 -69
  31. package/dist/goal/GoalClassifier.d.ts +17 -0
  32. package/dist/goal/GoalClassifier.js +1 -0
  33. package/dist/goal/GoalEngine.d.ts +155 -0
  34. package/dist/goal/GoalEngine.js +1 -0
  35. package/dist/goal/GoalStore.d.ts +27 -0
  36. package/dist/goal/GoalStore.js +1 -0
  37. package/dist/goal/plan-approval.d.ts +5 -0
  38. package/dist/goal/plan-approval.js +1 -0
  39. package/dist/goal/types.d.ts +80 -0
  40. package/dist/goal/types.js +1 -0
  41. package/dist/harness/index.d.ts +2 -7
  42. package/dist/harness/index.js +1 -1
  43. package/dist/harness/plan.d.ts +1 -1
  44. package/dist/harness/types.d.ts +0 -35
  45. package/dist/index.js +1 -1
  46. package/dist/knowledge/account-marks.d.ts +36 -0
  47. package/dist/knowledge/account-marks.js +1 -0
  48. package/dist/knowledge/audit-rules.d.ts +3 -1
  49. package/dist/knowledge/audit-rules.js +1 -1
  50. package/dist/knowledge/examples-scanner-cli.js +1 -1
  51. package/dist/knowledge/examples-scanner.js +1 -1
  52. package/dist/knowledge/fund-layer.d.ts +13 -9
  53. package/dist/knowledge/fund-layer.js +1 -1
  54. package/dist/knowledge/goal-completion.d.ts +19 -0
  55. package/dist/knowledge/goal-completion.js +1 -0
  56. package/dist/knowledge/guard-bindings.d.ts +21 -0
  57. package/dist/knowledge/guard-bindings.js +1 -0
  58. package/dist/knowledge/guard-translation.js +1 -1
  59. package/dist/knowledge/index.d.ts +6 -3
  60. package/dist/knowledge/index.js +1 -1
  61. package/dist/knowledge/industry-registry.js +1 -1
  62. package/dist/knowledge/mcp-schema-audit-cli.js +1 -1
  63. package/dist/knowledge/mcp-schema-audit.js +1 -1
  64. package/dist/knowledge/operation-dictionary.js +1 -1
  65. package/dist/knowledge/passport-confirm.js +1 -1
  66. package/dist/knowledge/passport-puzzle.js +1 -1
  67. package/dist/knowledge/passport-translation.js +1 -1
  68. package/dist/knowledge/proof-risk.js +1 -1
  69. package/dist/knowledge/reward-risk.d.ts +1 -1
  70. package/dist/knowledge/reward-risk.js +1 -1
  71. package/dist/knowledge/safety-rules.d.ts +2 -1
  72. package/dist/knowledge/safety-rules.js +1 -1
  73. package/dist/knowledge/scenario-topology.d.ts +43 -0
  74. package/dist/knowledge/scenario-topology.js +1 -0
  75. package/dist/knowledge/service-translation.js +1 -1
  76. package/dist/knowledge/supply-chain.js +1 -1
  77. package/dist/knowledge/template-registry.js +1 -1
  78. package/dist/knowledge/tools-reference.js +1 -1
  79. package/dist/knowledge/workflow-guidance.d.ts +36 -0
  80. package/dist/knowledge/workflow-guidance.js +1 -1
  81. package/dist/knowledge/workspace-lists.d.ts +57 -0
  82. package/dist/knowledge/workspace-lists.js +1 -0
  83. package/dist/loop-engineering/context-collect.d.ts +1 -1
  84. package/dist/monitor/EventRouter.d.ts +10 -0
  85. package/dist/monitor/EventRouter.js +1 -0
  86. package/dist/monitor/EventStore.d.ts +32 -12
  87. package/dist/monitor/EventStore.js +1 -1
  88. package/dist/monitor/MonitorLoop.d.ts +81 -0
  89. package/dist/monitor/MonitorLoop.js +1 -0
  90. package/dist/monitor/ProblemBridge.d.ts +32 -0
  91. package/dist/monitor/ProblemBridge.js +1 -0
  92. package/dist/monitor/ScopeResolver.d.ts +59 -0
  93. package/dist/monitor/ScopeResolver.js +1 -0
  94. package/dist/monitor/SubscriptionStore.d.ts +13 -0
  95. package/dist/monitor/SubscriptionStore.js +1 -0
  96. package/dist/monitor/SuggestionBridge.d.ts +38 -0
  97. package/dist/monitor/SuggestionBridge.js +1 -0
  98. package/dist/monitor/normalize.d.ts +8 -0
  99. package/dist/monitor/normalize.js +1 -0
  100. package/dist/monitor/types.d.ts +89 -0
  101. package/dist/monitor/types.js +1 -0
  102. package/dist/participation/arbitrator-interest.d.ts +20 -0
  103. package/dist/participation/arbitrator-interest.js +1 -0
  104. package/dist/participation/demander-interest.d.ts +23 -0
  105. package/dist/participation/demander-interest.js +1 -0
  106. package/dist/persona/address-format.d.ts +1 -1
  107. package/dist/persona/address-format.js +1 -1
  108. package/dist/persona/distill-goal.d.ts +20 -0
  109. package/dist/persona/distill-goal.js +1 -0
  110. package/dist/persona/index.d.ts +2 -0
  111. package/dist/persona/index.js +1 -1
  112. package/dist/persona/model.js +1 -1
  113. package/dist/playbooks/service-build/business-puzzle.js +1 -0
  114. package/dist/{project → playbooks/service-build}/context-assembly.d.ts +9 -4
  115. package/dist/playbooks/service-build/context-assembly.js +1 -0
  116. package/dist/{project → playbooks/service-build}/game-theory.d.ts +1 -1
  117. package/dist/playbooks/service-build/index.d.ts +14 -0
  118. package/dist/playbooks/service-build/index.js +1 -0
  119. package/dist/{project → playbooks/service-build}/intent-analyzer.d.ts +1 -1
  120. package/dist/playbooks/service-build/intent-analyzer.js +1 -0
  121. package/dist/playbooks/service-build/machine-nodes.js +1 -0
  122. package/dist/{project → playbooks/service-build}/machine-panorama.d.ts +5 -3
  123. package/dist/playbooks/service-build/machine-panorama.js +1 -0
  124. package/dist/{project → playbooks/service-build}/merchant-guide.d.ts +21 -1
  125. package/dist/playbooks/service-build/merchant-guide.js +1 -0
  126. package/dist/{project → playbooks/service-build}/mode-actions.d.ts +32 -8
  127. package/dist/playbooks/service-build/mode-actions.js +1 -0
  128. package/dist/playbooks/service-build/namespace.d.ts +2 -0
  129. package/dist/playbooks/service-build/namespace.js +1 -0
  130. package/dist/{project → playbooks/service-build}/object-panorama.d.ts +2 -3
  131. package/dist/playbooks/service-build/object-panorama.js +1 -0
  132. package/dist/{project → playbooks/service-build}/participation-radar.d.ts +4 -5
  133. package/dist/playbooks/service-build/participation-radar.js +1 -0
  134. package/dist/{project → playbooks/service-build}/pipeline-actions.d.ts +9 -9
  135. package/dist/playbooks/service-build/pipeline-actions.js +1 -0
  136. package/dist/playbooks/service-build/process.d.ts +6 -0
  137. package/dist/playbooks/service-build/process.js +1 -0
  138. package/dist/playbooks/service-build/relationship-profile.d.ts +2 -0
  139. package/dist/playbooks/service-build/relationship-profile.js +1 -0
  140. package/dist/playbooks/service-build/risk-aggregator.js +1 -0
  141. package/dist/{project → playbooks/service-build}/semantic-graph.d.ts +7 -3
  142. package/dist/playbooks/service-build/semantic-graph.js +1 -0
  143. package/dist/{project → playbooks/service-build}/service-panorama.d.ts +3 -19
  144. package/dist/playbooks/service-build/service-panorama.js +1 -0
  145. package/dist/relationship/derivation.d.ts +88 -0
  146. package/dist/relationship/derivation.js +1 -0
  147. package/dist/relationship/incentive.d.ts +38 -0
  148. package/dist/relationship/incentive.js +1 -0
  149. package/dist/relationship/index.d.ts +4 -0
  150. package/dist/relationship/index.js +1 -0
  151. package/dist/relationship/registry.d.ts +13 -0
  152. package/dist/relationship/registry.js +1 -0
  153. package/dist/relationship/types.d.ts +45 -0
  154. package/dist/relationship/types.js +1 -0
  155. package/dist/review/arb.d.ts +6 -0
  156. package/dist/review/arb.js +1 -0
  157. package/dist/review/demand.d.ts +3 -0
  158. package/dist/review/demand.js +1 -0
  159. package/dist/review/index.d.ts +3 -0
  160. package/dist/review/index.js +1 -0
  161. package/dist/review/machine.d.ts +3 -0
  162. package/dist/review/machine.js +1 -0
  163. package/dist/review/order.d.ts +9 -0
  164. package/dist/review/order.js +1 -0
  165. package/dist/review/progress.d.ts +3 -0
  166. package/dist/review/progress.js +1 -0
  167. package/dist/review/repository.d.ts +3 -0
  168. package/dist/review/repository.js +1 -0
  169. package/dist/review/service.d.ts +5 -0
  170. package/dist/review/service.js +1 -0
  171. package/dist/review/types.d.ts +156 -0
  172. package/dist/review/types.js +1 -0
  173. package/dist/rules.d.ts +2 -2
  174. package/dist/rules.js +1 -1
  175. package/dist/safety/confirm-gate.js +1 -1
  176. package/dist/safety/index.d.ts +1 -1
  177. package/dist/safety/index.js +1 -1
  178. package/dist/safety/preview.d.ts +1 -0
  179. package/dist/safety/preview.js +1 -1
  180. package/dist/schema/call/allocation.d.ts +1 -1
  181. package/dist/schema/call/arbitration.d.ts +1 -1
  182. package/dist/schema/call/base.d.ts +1 -1
  183. package/dist/schema/call/base.js +1 -1
  184. package/dist/schema/call/bridge.d.ts +29 -7
  185. package/dist/schema/call/bridge.js +1 -1
  186. package/dist/schema/call/contact.d.ts +1 -1
  187. package/dist/schema/call/contact.js +1 -1
  188. package/dist/schema/call/demand.d.ts +1 -1
  189. package/dist/schema/call/demand.js +1 -1
  190. package/dist/schema/call/guard.d.ts +3 -3
  191. package/dist/schema/call/handler.d.ts +0 -3
  192. package/dist/schema/call/handler.js +1 -1
  193. package/dist/schema/call/machine.d.ts +2 -2
  194. package/dist/schema/call/order.d.ts +1 -1
  195. package/dist/schema/call/payment.d.ts +1 -1
  196. package/dist/schema/call/permission.d.ts +1 -1
  197. package/dist/schema/call/personal.d.ts +1 -1
  198. package/dist/schema/call/progress.d.ts +1 -1
  199. package/dist/schema/call/proof.d.ts +2 -2
  200. package/dist/schema/call/repository.d.ts +1 -1
  201. package/dist/schema/call/repository.js +1 -1
  202. package/dist/schema/call/reward.d.ts +1 -1
  203. package/dist/schema/call/semantic.js +1 -1
  204. package/dist/schema/call/service.d.ts +1 -1
  205. package/dist/schema/call/service.js +1 -1
  206. package/dist/schema/call/treasury.d.ts +1 -1
  207. package/dist/schema/common/index.js +1 -1
  208. package/dist/schema/goal/index.d.ts +343 -0
  209. package/dist/schema/goal/index.js +1 -0
  210. package/dist/schema/goal/planning.d.ts +465 -0
  211. package/dist/schema/goal/planning.js +1 -0
  212. package/dist/schema/index.d.ts +1 -2
  213. package/dist/schema/index.js +1 -1
  214. package/dist/schema/industry-pack/index.d.ts +323 -1
  215. package/dist/schema/industry-pack/index.js +1 -1
  216. package/dist/schema/industry-pack/modes.d.ts +326 -0
  217. package/dist/schema/industry-pack/modes.js +1 -0
  218. package/dist/schema/intent-radar/index.d.ts +19 -19
  219. package/dist/schema/local/index.d.ts +11 -0
  220. package/dist/schema/local/index.js +1 -1
  221. package/dist/schema/operations.d.ts +258 -19
  222. package/dist/schema/operations.js +1 -1
  223. package/dist/schema/permission/index.d.ts +1 -0
  224. package/dist/schema/permission/index.js +1 -1
  225. package/dist/schema/persona/index.d.ts +40 -0
  226. package/dist/schema/persona/index.js +1 -1
  227. package/dist/schema/query/bi.d.ts +912 -0
  228. package/dist/schema/query/bi.js +1 -0
  229. package/dist/schema/query/index.d.ts +663 -2
  230. package/dist/schema/query/index.js +1 -1
  231. package/dist/schema/schema-version.js +1 -1
  232. package/dist/schema/utils/skills-recommendation.d.ts +0 -1
  233. package/dist/schema/utils/skills-recommendation.js +1 -1
  234. package/dist/schema-query-impl/index.js +1 -1
  235. package/dist/schemas/account_operation.output.json +32 -3
  236. package/dist/schemas/account_operation.schema.json +8 -4
  237. package/dist/schemas/bridge_operation.output.json +26 -3
  238. package/dist/schemas/bridge_operation.schema.json +85 -13
  239. package/dist/schemas/config_operation.output.json +1 -1
  240. package/dist/schemas/config_operation.schema.json +1 -1
  241. package/dist/schemas/goal_operation.schema.json +1092 -0
  242. package/dist/schemas/guard2file.schema.json +3 -3
  243. package/dist/schemas/index.json +12 -13
  244. package/dist/schemas/industry_pack_operation.output.json +1073 -0
  245. package/dist/schemas/industry_pack_operation.schema.json +236 -2
  246. package/dist/schemas/local_info_operation.output.json +2 -2
  247. package/dist/schemas/local_mark_operation.output.json +2 -2
  248. package/dist/schemas/machineNode2file.schema.json +3 -3
  249. package/dist/schemas/messenger_operation.output.json +2 -2
  250. package/dist/schemas/monitor_events.output.json +78 -3
  251. package/dist/schemas/monitor_events.schema.json +24 -1
  252. package/dist/schemas/monitor_subscription.output.json +1462 -0
  253. package/dist/schemas/monitor_subscription.schema.json +327 -0
  254. package/dist/schemas/onchain_events.output.json +5 -5
  255. package/dist/schemas/onchain_operations.output.json +2 -2
  256. package/dist/schemas/onchain_operations.schema.json +100 -100
  257. package/dist/schemas/onchain_operations_allocation.schema.json +7 -7
  258. package/dist/schemas/onchain_operations_arbitration.schema.json +6 -6
  259. package/dist/schemas/onchain_operations_contact.schema.json +6 -6
  260. package/dist/schemas/onchain_operations_demand.schema.json +6 -6
  261. package/dist/schemas/onchain_operations_gen_passport.schema.json +3 -3
  262. package/dist/schemas/onchain_operations_gen_proof.schema.json +3 -3
  263. package/dist/schemas/onchain_operations_guard.schema.json +3 -3
  264. package/dist/schemas/onchain_operations_machine.schema.json +5 -5
  265. package/dist/schemas/onchain_operations_order.schema.json +5 -5
  266. package/dist/schemas/onchain_operations_payment.schema.json +4 -4
  267. package/dist/schemas/onchain_operations_permission.schema.json +5 -5
  268. package/dist/schemas/onchain_operations_personal.schema.json +3 -3
  269. package/dist/schemas/onchain_operations_progress.schema.json +5 -5
  270. package/dist/schemas/onchain_operations_proof.schema.json +3 -3
  271. package/dist/schemas/onchain_operations_repository.schema.json +7 -7
  272. package/dist/schemas/onchain_operations_reward.schema.json +9 -9
  273. package/dist/schemas/onchain_operations_service.schema.json +11 -11
  274. package/dist/schemas/onchain_operations_treasury.schema.json +9 -9
  275. package/dist/schemas/onchain_table_data.output.json +399 -2
  276. package/dist/schemas/onchain_table_data.schema.json +22 -22
  277. package/dist/schemas/permission_operation.schema.json +6 -2
  278. package/dist/schemas/persona_operation.output.json +145 -0
  279. package/dist/schemas/persona_operation.schema.json +28 -2
  280. package/dist/schemas/query_toolkit.output.json +1514 -22
  281. package/dist/schemas/query_toolkit.schema.json +465 -11
  282. package/dist/schemas/workflow_operation.schema.json +4 -4
  283. package/dist/task/ProcessStore.d.ts +98 -0
  284. package/dist/task/ProcessStore.js +1 -0
  285. package/dist/task/playbook.d.ts +11 -0
  286. package/dist/task/playbook.js +1 -0
  287. package/dist/task/stage-gate.d.ts +22 -0
  288. package/dist/task/stage-gate.js +1 -0
  289. package/dist/{project → task}/substep-trace.d.ts +6 -45
  290. package/dist/task/types.d.ts +144 -0
  291. package/dist/task/types.js +1 -0
  292. package/dist/tools/handlers/config.js +1 -1
  293. package/dist/tools/handlers/evaluation.js +1 -1
  294. package/dist/tools/handlers/goal.d.ts +4 -0
  295. package/dist/tools/handlers/goal.js +1 -0
  296. package/dist/tools/handlers/industry-pack.js +1 -1
  297. package/dist/tools/handlers/local.d.ts +4 -3
  298. package/dist/tools/handlers/local.js +1 -1
  299. package/dist/tools/handlers/monitor.d.ts +24 -0
  300. package/dist/tools/handlers/monitor.js +1 -1
  301. package/dist/tools/handlers/network.d.ts +1 -0
  302. package/dist/tools/handlers/network.js +1 -0
  303. package/dist/tools/handlers/onchain.js +1 -1
  304. package/dist/tools/handlers/permission.js +1 -1
  305. package/dist/tools/handlers/persona.js +1 -1
  306. package/dist/tools/handlers/query.js +1 -1
  307. package/dist/tools/handlers/watch.js +1 -1
  308. package/dist/tools/handlers/workflow.js +1 -1
  309. package/dist/tools/index.d.ts +2 -0
  310. package/dist/tools/index.js +1 -1
  311. package/dist/tools/rules-hook.d.ts +1 -0
  312. package/dist/tools/rules-hook.js +1 -1
  313. package/dist/tools/shared.js +1 -1
  314. package/dist/tools/wrap.js +1 -1
  315. package/package.json +5 -4
  316. package/dist/harness/checkpoint.d.ts +0 -8
  317. package/dist/harness/checkpoint.js +0 -1
  318. package/dist/knowledge/deployment-scanner.d.ts +0 -66
  319. package/dist/knowledge/deployment-scanner.js +0 -1
  320. package/dist/mode-market/index.d.ts +0 -3
  321. package/dist/mode-market/index.js +0 -1
  322. package/dist/mode-market/registry.d.ts +0 -53
  323. package/dist/mode-market/registry.js +0 -1
  324. package/dist/mode-market/review.d.ts +0 -27
  325. package/dist/mode-market/review.js +0 -1
  326. package/dist/mode-market/submission.d.ts +0 -25
  327. package/dist/mode-market/submission.js +0 -1
  328. package/dist/project/business-puzzle.js +0 -1
  329. package/dist/project/context-assembly.js +0 -1
  330. package/dist/project/deployment-bridge.d.ts +0 -5
  331. package/dist/project/deployment-bridge.js +0 -1
  332. package/dist/project/deployment-doc.d.ts +0 -190
  333. package/dist/project/deployment-doc.js +0 -1
  334. package/dist/project/edit-planner.d.ts +0 -123
  335. package/dist/project/edit-planner.js +0 -1
  336. package/dist/project/evaluation-fix.spec.d.ts +0 -1
  337. package/dist/project/evaluation-fix.spec.js +0 -1
  338. package/dist/project/evaluation.d.ts +0 -127
  339. package/dist/project/evaluation.js +0 -1
  340. package/dist/project/graph-builder.d.ts +0 -51
  341. package/dist/project/graph-builder.js +0 -1
  342. package/dist/project/graph.d.ts +0 -70
  343. package/dist/project/graph.js +0 -1
  344. package/dist/project/handlers.d.ts +0 -524
  345. package/dist/project/handlers.js +0 -1
  346. package/dist/project/index.d.ts +0 -91
  347. package/dist/project/index.js +0 -1
  348. package/dist/project/intent-analyzer.js +0 -1
  349. package/dist/project/machine-nodes.js +0 -1
  350. package/dist/project/machine-panorama.js +0 -1
  351. package/dist/project/merchant-guide.js +0 -1
  352. package/dist/project/mode-actions.js +0 -1
  353. package/dist/project/namespace.d.ts +0 -72
  354. package/dist/project/namespace.js +0 -1
  355. package/dist/project/object-panorama.js +0 -1
  356. package/dist/project/participation-radar.js +0 -1
  357. package/dist/project/pipeline-actions.js +0 -1
  358. package/dist/project/project-store.d.ts +0 -110
  359. package/dist/project/project-store.js +0 -1
  360. package/dist/project/query.d.ts +0 -43
  361. package/dist/project/query.js +0 -1
  362. package/dist/project/risk-aggregator.js +0 -1
  363. package/dist/project/semantic-assembler.d.ts +0 -93
  364. package/dist/project/semantic-assembler.js +0 -1
  365. package/dist/project/semantic-graph.js +0 -1
  366. package/dist/project/service-panorama.js +0 -1
  367. package/dist/project/stage-gate.d.ts +0 -52
  368. package/dist/project/stage-gate.js +0 -1
  369. package/dist/project/task-tracker.d.ts +0 -30
  370. package/dist/project/task-tracker.js +0 -1
  371. package/dist/schema/project/index.d.ts +0 -2021
  372. package/dist/schema/project/index.js +0 -1
  373. package/dist/schema/task-status.d.ts +0 -62
  374. package/dist/schema/task-status.js +0 -1
  375. package/dist/schemas/project_operation.output.json +0 -7877
  376. package/dist/schemas/project_operation.schema.json +0 -1139
  377. package/dist/schemas/query_task_status.output.json +0 -211
  378. package/dist/schemas/query_task_status.schema.json +0 -18
  379. package/dist/tools/handlers/project.d.ts +0 -2
  380. package/dist/tools/handlers/project.js +0 -1
  381. package/dist/tools/handlers/task-status.d.ts +0 -2
  382. package/dist/tools/handlers/task-status.js +0 -1
  383. /package/dist/{project → playbooks/service-build}/business-puzzle.d.ts +0 -0
  384. /package/dist/{project → playbooks/service-build}/game-theory.js +0 -0
  385. /package/dist/{project → playbooks/service-build}/machine-nodes.d.ts +0 -0
  386. /package/dist/{project → playbooks/service-build}/object-type.d.ts +0 -0
  387. /package/dist/{project → playbooks/service-build}/object-type.js +0 -0
  388. /package/dist/{project → playbooks/service-build}/reverse-mapping.d.ts +0 -0
  389. /package/dist/{project → playbooks/service-build}/reverse-mapping.js +0 -0
  390. /package/dist/{project → playbooks/service-build}/risk-aggregator.d.ts +0 -0
  391. /package/dist/{project → playbooks/service-build}/workflow-design-assessment.d.ts +0 -0
  392. /package/dist/{project → playbooks/service-build}/workflow-design-assessment.js +0 -0
  393. /package/dist/{project → task}/substep-trace.js +0 -0
@@ -1 +1 @@
1
- import*as a141a from'fs';import*as a141b from'path';import{CONCEPT_GLOSSARY}from'./glossary.js';export const TRAE_MCPS_ROOT='c:\x5cUsers\x5czhou\x5c.trae-cn\x5cmcps';export const GENERATED_SCHEMAS_DIR='d:\x5cwowok\x5cagent\x5cmcp\x5cdist\x5cschemas';export const MCP_SRC_SCHEMA_DIR='d:\x5cwowok\x5cagent\x5cmcp\x5csrc\x5cschema';export const MCP_SRC_TOOLS_DIR='d:\x5cwowok\x5cagent\x5cmcp\x5csrc\x5ctools';export const GENERATION_SCRIPT='d:\x5cwowok\x5cagent\x5cmcp\x5cscripts\x5cgenerate-json-schemas.ts';export const TOOLS_INDEX_FILE='d:\x5cwowok\x5cagent\x5cmcp\x5csrc\x5ctools\x5cindex.ts';export const MCP_SCHEMA_AUDIT_VERSION='2.1.0';export const ALL_TOOLS=[{'name':'onchain_operations','input_schema_export':'OnchainOperationsSchema','output_schema_export':'CallOutputSchema'},{'name':'account_operation','input_schema_export':'AccountOperationSchema','output_schema_export':'AccountOperationOutputWrappedSchema'},{'name':'local_mark_operation','input_schema_export':'LocalMarkOperationSchema','output_schema_export':'LocalMarkOperationOutputWrappedSchema'},{'name':'local_info_operation','input_schema_export':'LocalInfoOperationSchema','output_schema_export':'LocalInfoOperationOutputWrappedSchema'},{'name':'wip_file','input_schema_export':'WipOperationsSchema','output_schema_export':'WipOperationOutputSchema'},{'name':'messenger_operation','input_schema_export':'MessengerOperationInputSchema','output_schema_export':'MessengerOperationOutputSchema'},{'name':'guard2file','input_schema_export':'Guard2File_InputSchema','output_schema_export':'Guard2File_OutputWrappedSchema'},{'name':'machineNode2file','input_schema_export':'MachineNode2File_InputSchema','output_schema_export':'MachineNode2File_OutputWrappedSchema'},{'name':'query_toolkit','input_schema_export':'WatchQueryOperationsSchema','output_schema_export':'WatchQueryOperationsResultSchema'},{'name':'onchain_table_data','input_schema_export':'OnchainTableDataSchema','output_schema_export':'OnchainTableDataResultSchema'},{'name':'onchain_events','input_schema_export':'OnchainEventsInputSchema','output_schema_export':'OnchainEventsResultSchema'},{'name':'wowok_buildin_info','input_schema_export':'ProtocolInfoQuerySchema','output_schema_export':'ProtocolInfoResultSchema'},{'name':'schema_query','input_schema_export':'SchemaQueryInputSchema','output_schema_export':'SchemaQueryOutputSchema'},{'name':'bridge_operation','input_schema_export':'BridgeOperationsSchema','output_schema_export':'BridgeCallOutputSchema'},{'name':'project_operation','input_schema_export':'ProjectOperationInputSchema','output_schema_export':'ProjectOperationOutputSchema'},{'name':'config_operation','input_schema_export':'ConfigOperationInputSchema','output_schema_export':'ConfigOperationOutputSchema'},{'name':'trust_score','input_schema_export':'TrustScoreInputSchema','output_schema_export':'TrustScoreOutputSchema'},{'name':'query_task_status','input_schema_export':'QueryTaskStatusInputSchema','output_schema_export':'QueryTaskStatusOutputSchema'},{'name':'evaluation_operation','input_schema_export':'EvaluationOperationInputSchema','output_schema_export':'EvaluationOperationOutputSchema'},{'name':'persona_operation','input_schema_export':'PersonaOperationInputSchema','output_schema_export':'PersonaOperationOutputSchema'},{'name':'intent_radar','input_schema_export':'IntentRadarInputSchema','output_schema_export':'IntentRadarOutputSchema'},{'name':'employee_operation','input_schema_export':'EmployeeOperationInputSchema','output_schema_export':'EmployeeOperationOutputSchema'},{'name':'industry_pack_operation','input_schema_export':'IndustryPackOperationInputSchema','output_schema_export':'IndustryPackOperationOutputSchema'},{'name':'workspace_operation','input_schema_export':'WorkspaceOperationInputSchema','output_schema_export':'WorkspaceOperationOutputSchema'}];export function discoverDeployedGatewayMounts(){const a=[];if(!a141a['existsSync'](TRAE_MCPS_ROOT))return[];for(const b of a141a['readdirSync'](TRAE_MCPS_ROOT,{'withFileTypes':!![]})){if(!b['isDirectory']())continue;const c=a141b['join'](TRAE_MCPS_ROOT,b['name'],'solo_agent','mcp_wagent','tools','wowok.json');try{const d=a141a['statSync'](c);if(d['isFile']())a['push']({'file':c,'mtime':d['mtimeMs']});}catch{}}return a['sort']((e,f)=>f['mtime']-e['mtime']),a['map'](e=>e['file']);}const GATEWAY_MISSING={'gateway_file':a141b['join'](TRAE_MCPS_ROOT,'<none>','solo_agent','mcp_wagent','tools','wowok.json'),'file_exists':![],'gateway_name':null,'has_definitions':![],'definitions_count':0x0,'has_properties':![],'has_tool_field':![],'has_data_field':![],'is_strict':![],'has_schema_hint':![],'size_bytes':0x0,'all_mounts':[]};export function loadLayer4Gateway(){const a=discoverDeployedGatewayMounts();if(a['length']===0x0)return GATEWAY_MISSING;const b=a[0x0];try{const c=a141a['readFileSync'](b,'utf-8'),d=JSON['parse'](c),e=d['arguments']??{},f=e['definitions']??{},g=Object['keys'](f)['length'];let h=e;const i=e['$ref'];if(i&&i['startsWith']('#/definitions/')){const l=i['slice']('#/definitions/'['length']),m=f[l];if(m&&typeof m==='object')h=m;}const j=h['properties']??{},k=d['description']??'';return{'gateway_file':b,'file_exists':!![],'gateway_name':d['name']??null,'has_definitions':g>0x0,'definitions_count':g,'has_properties':Object['keys'](j)['length']>0x0,'has_tool_field':'tool'in j,'has_data_field':'data'in j,'is_strict':h['additionalProperties']===![],'has_schema_hint':k['includes']('schema_query'),'size_bytes':Buffer['byteLength'](c,'utf-8'),'all_mounts':a};}catch{return{...GATEWAY_MISSING,'gateway_file':b,'all_mounts':a};}}export function loadLayer3Generated(a){const b=a141b['join'](GENERATED_SCHEMAS_DIR,a+'.schema.json'),c=a141b['join'](GENERATED_SCHEMAS_DIR,a+'.output.json'),d=a141a['existsSync'](b),e=a141a['existsSync'](c),f=d?a141a['statSync'](b)['size']:0x0,g=e?a141a['statSync'](c)['size']:0x0;return{'input_schema_file':b,'output_schema_file':c,'input_exists':d,'output_exists':e,'input_size_bytes':f,'output_size_bytes':g};}export function analyzeLayerCensus(){const a=[];for(const b of ALL_TOOLS){a['push']({'name':b['name'],'layer2_zod':{'input_schema_export':b['input_schema_export'],'output_schema_export':b['output_schema_export'],'schema_dir':MCP_SRC_SCHEMA_DIR},'layer3_generated':loadLayer3Generated(b['name'])});}return a;}export function analyzeGatewayDeployment(a){const b=[],c='(gateway)';if(!a['file_exists'])return b['push']({'rule_id':'MCP-GATEWAY-001','severity':'critical','category':'gateway_deployment','tool_name':c,'description':'No\x20deployed\x20wowok.json\x20gateway\x20descriptor\x20found\x20under\x20any\x20Trae\x20mount\x20in\x20'+TRAE_MCPS_ROOT+'.\x20The\x20MCP\x20server\x20is\x20not\x20loaded\x20by\x20any\x20Trae\x20session,\x20or\x20tools/list\x20failed.','fix':'Load\x20the\x20WoWok\x20MCP\x20server\x20in\x20a\x20Trae\x20session\x20and\x20verify\x20tools/list\x20returns\x20the\x20single\x20\x27wowok\x27\x20tool.'}),b;return a['gateway_name']!=='wowok'&&b['push']({'rule_id':'MCP-GATEWAY-002','severity':'high','category':'gateway_deployment','tool_name':c,'description':'Deployed\x20gateway\x20descriptor\x20name\x20is\x20\x27'+a['gateway_name']+'\x27\x20—\x20expected\x20\x27wowok\x27\x20(the\x20single\x20unified\x20tool\x20registered\x20by\x20the\x20server).','location':a['gateway_file'],'fix':'Restart\x20the\x20Trae\x20session\x20so\x20Trae\x20regenerates\x20wowok.json\x20from\x20the\x20server\x27s\x20tools/list.'}),!a['has_definitions']&&a['definitions_count']===0x0&&!a['has_properties']&&b['push']({'rule_id':'MCP-GATEWAY-003','severity':'high','category':'gateway_deployment','tool_name':c,'description':'Deployed\x20gateway\x20descriptor\x20carries\x20no\x20argument\x20schema\x20(no\x20definitions\x20and\x20no\x20properties)\x20—\x20the\x20LLM\x20has\x20no\x20parameter\x20structure\x20at\x20all.','location':a['gateway_file'],'fix':'Ensure\x20listTools()\x20advertises\x20WowokToolDisplaySchema\x20and\x20restart\x20the\x20Trae\x20session.'}),!a['has_schema_hint']&&b['push']({'rule_id':'MCP-GATEWAY-004','severity':'medium','category':'gateway_deployment','tool_name':c,'description':'Gateway\x20descriptor\x20description\x20does\x20not\x20mention\x20schema_query\x20—\x20the\x20LLM\x20is\x20not\x20told\x20about\x20the\x20schema\x20self-correction\x20path\x20(sub-tool\x20schemas\x20are\x20returned\x20on\x20validation\x20mismatch).','location':a['gateway_file'],'fix':'Keep\x20the\x20schema_query\x20mention\x20in\x20WOWOK_TOOL_DESCRIPTION\x20(src/tools/index.ts).'}),b;}export function analyzeGatewayDispatchContract(a){const b=[],c='(gateway)';if(!a['file_exists'])return b;const d=[];if(!a['has_tool_field'])d['push']('tool');if(!a['has_data_field'])d['push']('data');return d['length']>0x0&&b['push']({'rule_id':'MCP-PARITY-001','severity':'high','category':'layer_parity','tool_name':c,'description':'Deployed\x20gateway\x20argument\x20schema\x20is\x20missing\x20dispatch\x20field(s):\x20'+d['join'](',\x20')+'.\x20Calls\x20of\x20the\x20form\x20wowok({\x20tool,\x20data\x20})\x20cannot\x20be\x20validated.','location':a['gateway_file'],'fix':'Ensure\x20WowokToolDisplaySchema\x20exposes\x20tool/data\x20properties\x20and\x20restart\x20the\x20Trae\x20session.'}),!a['is_strict']&&b['push']({'rule_id':'MCP-PARITY-002','severity':'medium','category':'layer_parity','tool_name':c,'description':'Deployed\x20gateway\x20root\x20schema\x20is\x20not\x20strict\x20(additionalProperties\x20!==\x20false)\x20—\x20unknown\x20keys\x20silently\x20pass\x20the\x20client-side\x20check.','location':a['gateway_file'],'fix':'Keep\x20additionalProperties:false\x20on\x20WowokToolDisplaySchema\x20(aliases\x20are\x20explicit\x20properties).'}),b;}export function analyzeAnyUnknownCensus(){const a=[],b=[MCP_SRC_SCHEMA_DIR,MCP_SRC_TOOLS_DIR];for(const c of b){const d=listTypeScriptFiles(c);for(const e of d){const f=a141a['readFileSync'](e,'utf-8')['split']('\x0a');for(let g=0x0;g<f['length'];g++){const h=f[g],j=h['trim']();if(j['startsWith']('//')||j['startsWith']('*'))continue;const k=[{'regex':/z\.any\(\)/g,'pattern':'z.any()'},{'regex':/z\.unknown\(\)/g,'pattern':'z.unknown()'},{'regex':/args\s*:\s*any\b/g,'pattern':'args:\x20any'},{'regex':/Promise\s*<\s*any\s*>/g,'pattern':'Promise<any>'},{'regex':/Record\s*<\s*string\s*,\s*any\s*>/g,'pattern':'Record<string,\x20any>'},{'regex':/\bas\s+any\b/g,'pattern':'as\x20any'}];for(const {regex:l,pattern:n}of k){l['lastIndex']=0x0;let o;while((o=l['exec'](h))!==null){const p=categorizeAnyInstance(e,g+0x1,h,n);a['push']({'file':e,'line':g+0x1,'code':j['length']>0x78?j['slice'](0x0,0x75)+'...':j,'pattern':n,'category':p['category'],'reason':p['reason'],'fix_suggestion':p['fix']});}}}}}return a;}function listTypeScriptFiles(a){const b=[];if(!a141a['existsSync'](a))return b;const c=a141a['readdirSync'](a,{'withFileTypes':!![]});for(const d of c){const e=a141b['join'](a,d['name']);if(d['isDirectory']()){if(d['name']==='__tests__'||d['name']==='node_modules')continue;b['push'](...listTypeScriptFiles(e));}else d['isFile']()&&d['name']['endsWith']('.ts')&&b['push'](e);}return b;}function categorizeAnyInstance(a,b,c,d){const e=a141b['basename'](a),f=c['trim']();if(d==='z.any()'&&/SemanticSummarySchema\s*=\s*z\.any\(\)/['test'](f))return{'category':'fixable','reason':'Circular-dependency\x20workaround\x20for\x20SemanticSummarySchema\x20—\x20can\x20use\x20z.lazy()\x20or\x20refactor\x20to\x20break\x20the\x20cycle.','fix':'Define\x20SemanticSummarySchema\x20with\x20z.lazy(()\x20=>\x20SemanticSummarySchemaReal)\x20or\x20restructure\x20imports\x20to\x20break\x20the\x20cycle.'};if(d==='z.any()'&&/result\s*:\s*z\.any\(\)/['test'](f)&&/[\\/]config[\\/]|[\\/]project[\\/]/['test'](a))return{'category':'fixable','reason':'Result\x20shape\x20depends\x20on\x20action\x20—\x20can\x20use\x20z.discriminatedUnion(\x27action\x27,\x20[...])\x20to\x20type\x20each\x20action\x27s\x20result.','fix':'Define\x20discriminated\x20union:\x20z.discriminatedUnion(\x27action\x27,\x20[z.object({action:\x20z.literal(\x27list\x27),\x20result:\x20...}),\x20...]).'};if(d==='z.unknown()'&&/result\s*:\s*z\.unknown\(\)/['test'](f)&&/index\.ts/['test'](e))return{'category':'fixable','reason':'query_toolkit\x20output\x20result\x20depends\x20on\x20query_type\x20—\x20can\x20use\x20z.discriminatedUnion(\x27query_type\x27,\x20[...]).','fix':'Define\x20discriminated\x20union:\x20z.discriminatedUnion(\x27query_type\x27,\x20[z.object({query_type:\x20z.literal(\x27local_mark_list\x27),\x20result:\x20z.array(MarkDataSchema)}),\x20...]).'};if(d==='z.any()'&&/data\s*:\s*z\.any\(\)/['test'](f)&&/[\\/]schema-query[\\/]/['test'](a))return{'category':'fixable','reason':'SchemaQuery\x20output\x20data\x20depends\x20on\x20action\x20—\x20can\x20use\x20discriminated\x20union\x20by\x20action.','fix':'Define\x20discriminated\x20union:\x20action=\x27get\x27\x20returns\x20JSON\x20Schema,\x20action=\x27list\x27\x20returns\x20array\x20of\x20items.'};if(d==='args:\x20any'&&/handlers[\\/]/['test'](a))return{'category':'fixable','reason':'Handler\x20args\x20can\x20use\x20`unknown`\x20(forces\x20runtime\x20validation)\x20or\x20a\x20typed\x20input\x20schema.','fix':'Replace\x20`args:\x20any`\x20with\x20`args:\x20unknown`\x20and\x20use\x20strictParse(schema,\x20args)\x20at\x20the\x20top\x20of\x20the\x20handler.'};if(d==='args:\x20any'&&/tools[\\/]index\.ts/['test'](a))return{'category':'fixable','reason':'dispatchToolCall\x20args\x20is\x20`any`\x20—\x20can\x20be\x20`unknown`\x20since\x20each\x20tool\x20parses\x20with\x20its\x20own\x20schema.','fix':'Change\x20`args:\x20any`\x20to\x20`args:\x20unknown`\x20in\x20dispatchToolCall\x20signature.'};if(d==='args:\x20any'&&/types\.ts/['test'](e)&&/handler/['test'](f))return{'category':'fixable','reason':'ToolEntry.handler\x20args\x20is\x20`any`\x20—\x20can\x20be\x20`unknown`\x20(each\x20handler\x20parses\x20with\x20its\x20own\x20schema).','fix':'Change\x20`handler:\x20(args:\x20any)\x20=>\x20...`\x20to\x20`handler:\x20(args:\x20unknown)\x20=>\x20...`.'};if(d==='z.any()'&&/claimReceipt|ethReceipt|wowReceipt/['test'](f))return{'category':'legitimate','reason':'EVM\x20transaction\x20receipts\x20have\x20an\x20externally-defined\x20shape\x20from\x20viem/ethers\x20—\x20z.any()\x20is\x20acceptable\x20(receipt\x20is\x20informational,\x20not\x20validated).'};if(d==='z.any()'&&/content_raw/['test'](f))return{'category':'legitimate','reason':'content_raw\x20holds\x20raw\x20content\x20for\x20unknown\x20object\x20types\x20—\x20by\x20definition\x20untyped.\x20z.any()\x20is\x20acceptable\x20here.'};if((d==='z.unknown()'||d==='z.any()')&&/parsedJson/['test'](f))return{'category':'legitimate','reason':'Event\x20parsedJson\x20is\x20arbitrary\x20on-chain\x20event\x20data\x20—\x20z.record(z.string(),\x20z.unknown())\x20is\x20appropriate.'};if(d==='z.any()'&&/key_value/['test'](f))return{'category':'fixable','reason':'Repository\x20key_value\x20depends\x20on\x20key_type\x20—\x20could\x20use\x20discriminated\x20union\x20by\x20key_type\x20(string→z.string(),\x20u64→z.bigint()/number,\x20etc.).','fix':'Define\x20z.discriminatedUnion(\x27key_type\x27,\x20[...])\x20with\x20each\x20variant\x20typed.'};if(d==='z.unknown()'&&/data\s*:\s*z\.unknown\(\)/['test'](f)&&/[\\/]bridge/['test'](a))return{'category':'legitimate','reason':'Bridge\x20operation\x20result\x20data\x20varies\x20by\x20operation_type\x20—\x20currently\x209\x20different\x20shapes.\x20Discriminated\x20union\x20would\x20be\x20ideal\x20but\x20high\x20refactor\x20cost.'};if(d==='z.unknown()'&&/adjusted_params/['test'](f))return{'category':'legitimate','reason':'adjusted_params\x20are\x20free-form\x20key-value\x20pairs\x20suggested\x20by\x20AI\x20—\x20z.record(z.string(),\x20z.unknown())\x20is\x20appropriate.'};if(d==='z.any()'&&/object\s*:\s*z\.union.*z\.record\(z\.any\(\)/['test'](f))return{'category':'fixable','reason':'Creation\x20vs\x20reference\x20object\x20union\x20—\x20z.record(z.any())\x20should\x20be\x20replaced\x20with\x20NamedObjectSchema\x20(structured\x20creation\x20input).','fix':'Replace\x20z.record(z.any())\x20with\x20NamedObjectSchema\x20(already\x20defined\x20in\x20base.ts).'};if(d==='z.any()'&&/result\s*:\s*z\.any\(\)\.optional\(\)/['test'](f)&&/[\\/]bridge/['test'](a))return{'category':'legitimate','reason':'Bridge\x20result\x20is\x20operation-specific\x20(manage_evm_rpc\x20has\x20different\x20result\x20per\x20operation)\x20—\x20z.any().optional()\x20is\x20acceptable\x20here.'};if(d==='Promise<any>'&&/[\\/](wrap|shared)\.ts/['test'](a))return{'category':'fixable','reason':'Generic\x20wrappers\x20in\x20wrap.ts/shared.ts\x20use\x20Promise<any>\x20—\x20could\x20be\x20made\x20generic\x20<T>.','fix':'Replace\x20`Promise<any>`\x20with\x20`Promise<ToolDispatchResult>`\x20(the\x20actual\x20return\x20shape).'};if(d==='Record<string,\x20any>'&&/types\.ts/['test'](e)&&/_meta|structuredContent/['test'](f))return{'category':'fixable','reason':'ToolConfig._meta\x20and\x20ToolDispatchResult.structuredContent\x20could\x20use\x20structured\x20types.','fix':'Define\x20ToolMeta\x20interface\x20(category,\x20tags)\x20and\x20replace\x20structuredContent:\x20any\x20with\x20structured\x20type.'};if(d==='as\x20any')return{'category':'legitimate','reason':'`as\x20any`\x20cast\x20—\x20usually\x20for\x20third-party\x20type\x20mismatches\x20(MCP\x20SDK).\x20Acceptable\x20if\x20isolated.'};return{'category':'legitimate','reason':'Unclassified\x20any/unknown\x20usage\x20—\x20review\x20manually.\x20Defaulting\x20to\x20legitimate\x20(no\x20auto-fix).'};}export function analyzeHandlerTypeSafety(a){const b=[];for(const c of a){if(c['pattern']!=='args:\x20any')continue;if(!/tools[\\/]/['test'](c['file']))continue;b['push']({'rule_id':'MCP-HANDLER-001','severity':'medium','category':'handler_types','tool_name':a141b['basename'](c['file'],'.ts'),'description':'Handler\x20uses\x20`args:\x20any`\x20—\x20bypasses\x20TypeScript\x20type\x20checking.\x20'+c['reason'],'location':c['file']+':'+c['line'],'fix':c['fix_suggestion']});}return b;}export function analyzeOutputSchemaCoverage(a){const b=[];for(const d of a){!d['layer3_generated']['output_exists']&&d['name']!=='onchain_operations'&&b['push']({'rule_id':'MCP-OUTPUT-001','severity':'high','category':'output_coverage','tool_name':d['name'],'description':'Layer\x203\x20output\x20schema\x20file\x20does\x20not\x20exist:\x20'+d['layer3_generated']['output_schema_file'],'fix':'Add\x20outputSchema\x20to\x20'+d['name']+'\x27s\x20tool\x20definition\x20and\x20regenerate\x20schemas.'}),d['layer2_zod']['output_schema_export']===null&&b['push']({'rule_id':'MCP-OUTPUT-002','severity':'medium','category':'output_coverage','tool_name':d['name'],'description':'Layer\x202\x20outputSchema\x20is\x20defined\x20inline\x20(not\x20exported\x20with\x20a\x20stable\x20name).\x20This\x20makes\x20it\x20harder\x20to\x20reference\x20from\x20tests.','fix':'Export\x20the\x20outputSchema\x20with\x20a\x20stable\x20name\x20(e.g.,\x20'+d['name']+'OutputSchema).'});}return b;}export function analyzeGenerationScriptSync(){const a=[];if(!a141a['existsSync'](GENERATION_SCRIPT))return a['push']({'rule_id':'MCP-GENSYNC-001','severity':'critical','category':'generation_sync','tool_name':'(all)','description':'Generation\x20script\x20not\x20found:\x20'+GENERATION_SCRIPT}),a;const b=a141a['readFileSync'](GENERATION_SCRIPT,'utf-8'),c=/name:\s*["']([^"']+)["']/g,d=new Set();let e;while((e=c['exec'](b))!==null){ALL_TOOLS['some'](f=>f['name']===e[0x1])&&d['add'](e[0x1]);}for(const f of ALL_TOOLS){!d['has'](f['name'])&&a['push']({'rule_id':'MCP-GENSYNC-002','severity':'high','category':'generation_sync','tool_name':f['name'],'description':'Tool\x20\x22'+f['name']+'\x22\x20is\x20in\x20TOOL_REGISTRY\x20but\x20missing\x20from\x20generate-json-schemas.ts.\x20Layer\x203\x20schemas\x20will\x20not\x20be\x20generated.','location':GENERATION_SCRIPT,'fix':'Add\x20a\x20get'+toPascalCase(f['name'])+'Tool()\x20function\x20and\x20add\x20it\x20to\x20the\x20tools\x20array.'});}return a;}function toPascalCase(a){return a['split']('_')['map'](b=>b['charAt'](0x0)['toUpperCase']()+b['slice'](0x1)['toLowerCase']())['join']('');}export function analyzeSchemaQueryReflection(a){const b=[];for(const e of a){!e['layer3_generated']['input_exists']&&b['push']({'rule_id':'MCP-REFLECT-001','severity':'high','category':'reflection','tool_name':e['name'],'description':'schema_query(action=\x27get\x27,\x20name=\x27'+e['name']+'\x27)\x20would\x20fail\x20—\x20Layer\x203\x20input\x20schema\x20missing.','fix':'Run\x20pnpm\x20generate:schemas.'}),!e['layer3_generated']['output_exists']&&e['name']!=='onchain_operations'&&b['push']({'rule_id':'MCP-REFLECT-002','severity':'medium','category':'reflection','tool_name':e['name'],'description':'schema_query(action=\x27get_output\x27,\x20name=\x27'+e['name']+'\x27)\x20would\x20fail\x20—\x20Layer\x203\x20output\x20schema\x20missing.','fix':'Run\x20pnpm\x20generate:schemas.'});}const d=['permission','service','machine','progress','guard','arbitration','repository','contact','treasury','reward','allocation','personal','payment','demand','order','gen_passport','proof','gen_proof'];for(const f of d){const g=a141b['join'](GENERATED_SCHEMAS_DIR,'onchain_operations_'+f+'.schema.json');!a141a['existsSync'](g)&&b['push']({'rule_id':'MCP-REFLECT-003','severity':'medium','category':'reflection','tool_name':'onchain_operations_'+f,'description':'Individual\x20operation\x20schema\x20missing:\x20'+g+'.\x20schema_query(action=\x27get\x27,\x20name=\x27onchain_operations_'+f+'\x27)\x20would\x20fail.','fix':'Run\x20pnpm\x20generate:schemas.'});}return b;}function normalizeGlossaryTerm(a){return a['toLowerCase']()['replace'](/[-_\s]/g,'');}const GLOSSARY_ALIAS_INDEX=((()=>{const a=new Set(CONCEPT_GLOSSARY['map'](c=>normalizeGlossaryTerm(c['term']))),b=new Map();for(const c of CONCEPT_GLOSSARY){for(const d of c['aliases']){const e=normalizeGlossaryTerm(d);if(a['has'](e))continue;if(!b['has'](e))b['set'](e,c['term']);}}return b;})());function collectSchemaProperties(a,b,c){if(!a||typeof a!=='object')return;const d=a;if(d['properties']&&typeof d['properties']==='object')for(const e of Object['keys'](d['properties'])){c['push']({'file':b,'property':e}),collectSchemaProperties(d['properties'][e],b,c);}if(d['definitions']&&typeof d['definitions']==='object')for(const f of Object['keys'](d['definitions'])){collectSchemaProperties(d['definitions'][f],b,c);}if(d['items'])collectSchemaProperties(d['items'],b,c);if(Array['isArray'](d['anyOf']))d['anyOf']['forEach'](g=>collectSchemaProperties(g,b,c));if(Array['isArray'](d['oneOf']))d['oneOf']['forEach'](g=>collectSchemaProperties(g,b,c));d['additionalProperties']&&typeof d['additionalProperties']==='object'&&collectSchemaProperties(d['additionalProperties'],b,c);}export function analyzeGlossaryAlignment(){const a=[];if(!a141a['existsSync'](GENERATED_SCHEMAS_DIR))return a;const b=a141a['readdirSync'](GENERATED_SCHEMAS_DIR)['filter'](d=>d['endsWith']('.schema.json')||d['endsWith']('.output.json')),c=new Set();for(const d of b){const e=a141b['join'](GENERATED_SCHEMAS_DIR,d);let f;try{f=JSON['parse'](a141a['readFileSync'](e,'utf-8'));}catch{continue;}const g=[];collectSchemaProperties(f,d,g);for(const h of g){const i=normalizeGlossaryTerm(h['property']),j=GLOSSARY_ALIAS_INDEX['get'](i);if(!j)continue;const k=h['file']+'::'+h['property'];if(c['has'](k))continue;c['add'](k),a['push']({'rule_id':'MCP-GLOSSARY-001','severity':'medium','category':'glossary_alignment','tool_name':d['replace'](/\.(schema|output)\.json$/,''),'description':'Schema\x20field\x20\x27'+h['property']+'\x27\x20uses\x20a\x20deprecated\x20glossary\x20alias\x20—\x20the\x20canonical\x20term\x20is\x20\x27'+j+'\x27.','location':e,'fix':'Rename\x20the\x20field\x20to\x20the\x20canonical\x20term\x20(camelCase/snake_case\x20of\x20\x27'+j+'\x27).'});}}return a;}export function scanAllMcpSchemas(){const a=analyzeLayerCensus(),b=loadLayer4Gateway(),c=analyzeAnyUnknownCensus(),d=[...analyzeGatewayDeployment(b),...analyzeGatewayDispatchContract(b),...analyzeHandlerTypeSafety(c),...analyzeOutputSchemaCoverage(a),...analyzeGenerationScriptSync(),...analyzeSchemaQueryReflection(a),...analyzeGlossaryAlignment()],e=new Map(),g=new Map();for(const k of d){if(!e['has'](k['severity']))e['set'](k['severity'],[]);e['get'](k['severity'])['push'](k);if(!g['has'](k['category']))g['set'](k['category'],[]);g['get'](k['category'])['push'](k);}const h=c['filter'](l=>l['category']==='fixable')['length'],i=c['filter'](l=>l['category']==='legitimate')['length'],j=c['filter'](l=>l['category']==='external')['length'];return{'census':a,'gateway':b,'findings':d,'any_unknown_instances':c,'findings_by_severity':e,'findings_by_category':g,'total_findings':d['length'],'fixable_any_count':h,'legitimate_any_count':i,'external_any_count':j};}export function formatAuditReport(a){const b=[];b['push']('#\x20MCP\x20Schema\x20Audit\x20Report\x20—\x20'+a['census']['length']+'\x20WoWok\x20Sub-Tools\x20+\x20Unified\x20Gateway'),b['push'](''),b['push']('>\x20Auto-generated\x20by\x20`mcp-schema-audit.ts`\x20v'+MCP_SCHEMA_AUDIT_VERSION+'\x20—\x20comprehensive'),b['push']('>\x204-layer\x20audit\x20of\x20schema\x20consistency,\x20any/unknown\x20usage,\x20and\x20I/O\x20coverage.'),b['push'](''),b['push']('##\x20Summary'),b['push'](''),b['push']('-\x20**Tools\x20audited**:\x20'+a['census']['length']),b['push']('-\x20**Total\x20findings**:\x20'+a['total_findings']),b['push']('-\x20**Gateway\x20deployed**:\x20'+(a['gateway']['file_exists']?'yes\x20('+a['gateway']['all_mounts']['length']+'\x20Trae\x20mount(s))':'NO')),b['push']('-\x20**any/unknown\x20instances**:\x20'+a['any_unknown_instances']['length']+'\x20total'),b['push']('\x20\x20-\x20Fixable:\x20'+a['fixable_any_count']),b['push']('\x20\x20-\x20Legitimate:\x20'+a['legitimate_any_count']),b['push']('\x20\x20-\x20External:\x20'+a['external_any_count']),b['push']('-\x20**Glossary\x20alignment**:\x20'+(a['findings_by_category']['get']('glossary_alignment')??[])['length']+'\x20deprecated-alias\x20schema\x20field(s)'),b['push'](''),b['push']('###\x20Findings\x20by\x20Severity'),b['push'](''),b['push']('|\x20Severity\x20|\x20Count\x20|'),b['push']('|----------|-------|');for(const h of['critical','high','medium','low','info']){const i=a['findings_by_severity']['get'](h)??[];b['push']('|\x20'+h+'\x20|\x20'+i['length']+'\x20|');}b['push'](''),b['push']('###\x20Findings\x20by\x20Category'),b['push'](''),b['push']('|\x20Category\x20|\x20Count\x20|'),b['push']('|----------|-------|');for(const j of['gateway_deployment','layer_parity','handler_types','output_coverage','generation_sync','reflection','glossary_alignment']){const k=a['findings_by_category']['get'](j)??[];b['push']('|\x20'+j+'\x20|\x20'+k['length']+'\x20|');}b['push'](''),b['push']('##\x20Layer\x204\x20—\x20Deployed\x20Gateway'),b['push']('');a['gateway']['file_exists']?(b['push']('-\x20**Descriptor**:\x20`'+a['gateway']['gateway_file']+'`\x20('+(a['gateway']['size_bytes']/0x400)['toFixed'](0x1)+'KB)'),b['push']('-\x20**Name**:\x20'+a['gateway']['gateway_name']),b['push']('-\x20**Dispatch\x20contract**:\x20tool='+(a['gateway']['has_tool_field']?'✓':'✗')+'\x20data='+(a['gateway']['has_data_field']?'✓':'✗')+'\x20strict='+(a['gateway']['is_strict']?'✓':'✗')),b['push']('-\x20**Definitions**:\x20'+a['gateway']['definitions_count']),b['push']('-\x20**schema_query\x20hint**:\x20'+(a['gateway']['has_schema_hint']?'✓':'✗')),b['push']('-\x20**Trae\x20mounts**:\x20'+a['gateway']['all_mounts']['length'])):b['push']('-\x20✗\x20No\x20wowok.json\x20found\x20under\x20any\x20Trae\x20mount\x20in\x20'+TRAE_MCPS_ROOT);b['push'](''),b['push']('##\x20Layer\x20Census\x20—\x20All\x20'+a['census']['length']+'\x20Sub-Tools\x20(dispatched\x20via\x20the\x20wowok\x20gateway)'),b['push'](''),b['push']('|\x20Tool\x20|\x20L3\x20Input\x20|\x20L3\x20Output\x20|'),b['push']('|------|----------|-----------|');for(const l of a['census']){const m=l['layer3_generated']['input_exists']?'✓\x20'+(l['layer3_generated']['input_size_bytes']/0x400)['toFixed'](0x1)+'KB':'✗\x20MISSING',n=l['layer3_generated']['output_exists']?'✓\x20'+(l['layer3_generated']['output_size_bytes']/0x400)['toFixed'](0x1)+'KB':'✗\x20MISSING';b['push']('|\x20'+l['name']+'\x20|\x20'+m+'\x20|\x20'+n+'\x20|');}b['push'](''),b['push']('##\x20Findings\x20Detail'),b['push']('');const d=['critical','high','medium','low','info'];for(const o of d){const p=a['findings_by_severity']['get'](o)??[];if(p['length']===0x0)continue;const q=o['toUpperCase']();b['push']('###\x20'+q+'\x20('+p['length']+')'),b['push']('');for(const r of p){b['push']('-\x20**['+r['rule_id']+']\x20'+r['description']);if(r['location'])b['push']('\x20\x20-\x20Location:\x20`'+r['location']+'`');if(r['fix'])b['push']('\x20\x20-\x20Fix:\x20'+r['fix']);b['push']('');}}b['push']('##\x20any/unknown\x20Census\x20Detail'),b['push'](''),b['push']('Total\x20instances:\x20'+a['any_unknown_instances']['length']),b['push'](''),b['push']('###\x20By\x20Pattern'),b['push'](''),b['push']('|\x20Pattern\x20|\x20Total\x20|\x20Fixable\x20|\x20Legitimate\x20|\x20External\x20|'),b['push']('|---------|-------|---------|------------|----------|');const e=new Map();for(const s of a['any_unknown_instances']){if(!e['has'](s['pattern']))e['set'](s['pattern'],[]);e['get'](s['pattern'])['push'](s);}for(const [t,u]of[...e['entries']()]['sort']((v,w)=>w[0x1]['length']-v[0x1]['length'])){const v=u['filter'](y=>y['category']==='fixable')['length'],w=u['filter'](y=>y['category']==='legitimate')['length'],x=u['filter'](y=>y['category']==='external')['length'];b['push']('|\x20`'+t+'`\x20|\x20'+u['length']+'\x20|\x20'+v+'\x20|\x20'+w+'\x20|\x20'+x+'\x20|');}b['push']('');const g=a['any_unknown_instances']['filter'](y=>y['category']==='fixable');if(g['length']>0x0){b['push']('###\x20Fixable\x20Instances\x20(Priority\x20List)'),b['push']('');for(const y of g){b['push']('-\x20**'+a141b['basename'](y['file'])+':'+y['line']+'**\x20[`'+y['pattern']+'`]'),b['push']('\x20\x20-\x20Code:\x20`'+y['code']+'`'),b['push']('\x20\x20-\x20Reason:\x20'+y['reason']);if(y['fix_suggestion'])b['push']('\x20\x20-\x20Fix:\x20'+y['fix_suggestion']);b['push']('');}}return b['push']('##\x20Recommended\x20Action\x20Plan'),b['push'](''),b['push']('###\x20Phase\x201:\x20Keep\x20the\x20Layer\x203\x20schema\x20set\x20regenerable'),b['push'](''),b['push']('Layer\x204\x20(the\x20deployed\x20wowok.json\x20gateway)\x20is\x20CLIENT-generated\x20from\x20our\x20tools/list\x20—\x20keep\x20Layer\x203\x20in\x20sync\x20so\x20schema_query\x20reflection\x20always\x20serves\x20fresh\x20schemas:'),b['push'](''),b['push']('```bash'),b['push']('cd\x20d:/wowok/agent/mcp\x20&&\x20pnpm\x20generate:schemas'),b['push']('```'),b['push'](''),b['push']('###\x20Phase\x202:\x20Type\x20the\x20'+a['fixable_any_count']+'\x20fixable\x20any/unknown\x20instances'),b['push'](''),b['push']('Priority\x20order:'),b['push'](''),b['push']('1.\x20**SemanticSummarySchema**\x20(src/schema/local/index.ts:6)\x20—\x20use\x20`z.lazy()`'),b['push']('2.\x20**ConfigOperationOutputSchema.result**\x20(src/schema/config/index.ts:17)\x20—\x20discriminated\x20union\x20by\x20action'),b['push']('3.\x20**ProjectOperationOutputSchema.result**\x20(src/schema/project/index.ts:34)\x20—\x20discriminated\x20union\x20by\x20action'),b['push']('4.\x20**query_toolkit\x20output\x20result**\x20(src/tools/index.ts:250)\x20—\x20discriminated\x20union\x20by\x20query_type'),b['push']('5.\x20**SchemaQueryOutputSchema.data**\x20(src/schema/schema-query/index.ts:34)\x20—\x20discriminated\x20union\x20by\x20action'),b['push']('6.\x20**RepositoryKeyValueSchema.key_value**\x20(src/schema/operations.ts:331)\x20—\x20discriminated\x20union\x20by\x20key_type'),b['push']('7.\x20**Handler\x20args:\x20any**\x20—\x20replace\x20with\x20`unknown`\x20(forces\x20strictParse\x20at\x20top\x20of\x20handler)'),b['push']('8.\x20**dispatchToolCall(name,\x20args:\x20any)**\x20—\x20replace\x20with\x20`unknown`'),b['push'](''),b['push']('###\x20Phase\x203:\x20Verify\x20I/O\x20Schema\x20Match'),b['push'](''),b['push']('For\x20each\x20tool,\x20write\x20a\x20parity\x20test\x20that:'),b['push']('1.\x20Calls\x20the\x20handler\x20with\x20a\x20minimal\x20valid\x20input'),b['push']('2.\x20Captures\x20the\x20structuredContent'),b['push']('3.\x20Validates\x20structuredContent\x20against\x20outputSchema'),b['push']('4.\x20Reports\x20any\x20mismatch'),b['push'](''),b['join']('\x0a');}
1
+ import*as a149a from'fs';import*as a149b from'path';import{CONCEPT_GLOSSARY}from'./glossary.js';export const TRAE_MCPS_ROOT='c:\x5cUsers\x5czhou\x5c.trae-cn\x5cmcps';export const GENERATED_SCHEMAS_DIR='d:\x5cwowok\x5cagent\x5cmcp\x5cdist\x5cschemas';export const MCP_SRC_SCHEMA_DIR='d:\x5cwowok\x5cagent\x5cmcp\x5csrc\x5cschema';export const MCP_SRC_TOOLS_DIR='d:\x5cwowok\x5cagent\x5cmcp\x5csrc\x5ctools';export const GENERATION_SCRIPT='d:\x5cwowok\x5cagent\x5cmcp\x5cscripts\x5cgenerate-json-schemas.ts';export const TOOLS_INDEX_FILE='d:\x5cwowok\x5cagent\x5cmcp\x5csrc\x5ctools\x5cindex.ts';export const MCP_SCHEMA_AUDIT_VERSION='2.1.0';export const ALL_TOOLS=[{'name':'onchain_operations','input_schema_export':'OnchainOperationsSchema','output_schema_export':'CallOutputSchema'},{'name':'account_operation','input_schema_export':'AccountOperationSchema','output_schema_export':'AccountOperationOutputWrappedSchema'},{'name':'local_mark_operation','input_schema_export':'LocalMarkOperationSchema','output_schema_export':'LocalMarkOperationOutputWrappedSchema'},{'name':'local_info_operation','input_schema_export':'LocalInfoOperationSchema','output_schema_export':'LocalInfoOperationOutputWrappedSchema'},{'name':'wip_file','input_schema_export':'WipOperationsSchema','output_schema_export':'WipOperationOutputSchema'},{'name':'messenger_operation','input_schema_export':'MessengerOperationInputSchema','output_schema_export':'MessengerOperationOutputSchema'},{'name':'guard2file','input_schema_export':'Guard2File_InputSchema','output_schema_export':'Guard2File_OutputWrappedSchema'},{'name':'machineNode2file','input_schema_export':'MachineNode2File_InputSchema','output_schema_export':'MachineNode2File_OutputWrappedSchema'},{'name':'query_toolkit','input_schema_export':'WatchQueryOperationsSchema','output_schema_export':'WatchQueryOperationsResultSchema'},{'name':'onchain_table_data','input_schema_export':'OnchainTableDataSchema','output_schema_export':'OnchainTableDataResultSchema'},{'name':'onchain_events','input_schema_export':'OnchainEventsInputSchema','output_schema_export':'OnchainEventsResultSchema'},{'name':'wowok_buildin_info','input_schema_export':'ProtocolInfoQuerySchema','output_schema_export':'ProtocolInfoResultSchema'},{'name':'schema_query','input_schema_export':'SchemaQueryInputSchema','output_schema_export':'SchemaQueryOutputSchema'},{'name':'bridge_operation','input_schema_export':'BridgeOperationsSchema','output_schema_export':'BridgeCallOutputSchema'},{'name':'config_operation','input_schema_export':'ConfigOperationInputSchema','output_schema_export':'ConfigOperationOutputSchema'},{'name':'trust_score','input_schema_export':'TrustScoreInputSchema','output_schema_export':'TrustScoreOutputSchema'},{'name':'evaluation_operation','input_schema_export':'EvaluationOperationInputSchema','output_schema_export':'EvaluationOperationOutputSchema'},{'name':'persona_operation','input_schema_export':'PersonaOperationInputSchema','output_schema_export':'PersonaOperationOutputSchema'},{'name':'intent_radar','input_schema_export':'IntentRadarInputSchema','output_schema_export':'IntentRadarOutputSchema'},{'name':'employee_operation','input_schema_export':'EmployeeOperationInputSchema','output_schema_export':'EmployeeOperationOutputSchema'},{'name':'industry_pack_operation','input_schema_export':'IndustryPackOperationInputSchema','output_schema_export':'IndustryPackOperationOutputSchema'},{'name':'workspace_operation','input_schema_export':'WorkspaceOperationInputSchema','output_schema_export':'WorkspaceOperationOutputSchema'}];export function discoverDeployedGatewayMounts(){const a=[];if(!a149a['existsSync'](TRAE_MCPS_ROOT))return[];for(const b of a149a['readdirSync'](TRAE_MCPS_ROOT,{'withFileTypes':!![]})){if(!b['isDirectory']())continue;const c=a149b['join'](TRAE_MCPS_ROOT,b['name'],'solo_agent','mcp_wagent','tools','wowok.json');try{const d=a149a['statSync'](c);if(d['isFile']())a['push']({'file':c,'mtime':d['mtimeMs']});}catch{}}return a['sort']((e,f)=>f['mtime']-e['mtime']),a['map'](e=>e['file']);}const GATEWAY_MISSING={'gateway_file':a149b['join'](TRAE_MCPS_ROOT,'<none>','solo_agent','mcp_wagent','tools','wowok.json'),'file_exists':![],'gateway_name':null,'has_definitions':![],'definitions_count':0x0,'has_properties':![],'has_tool_field':![],'has_data_field':![],'is_strict':![],'has_schema_hint':![],'size_bytes':0x0,'all_mounts':[]};export function loadLayer4Gateway(){const a=discoverDeployedGatewayMounts();if(a['length']===0x0)return GATEWAY_MISSING;const b=a[0x0];try{const c=a149a['readFileSync'](b,'utf-8'),d=JSON['parse'](c),e=d['arguments']??{},f=e['definitions']??{},g=Object['keys'](f)['length'];let h=e;const i=e['$ref'];if(i&&i['startsWith']('#/definitions/')){const l=i['slice']('#/definitions/'['length']),m=f[l];if(m&&typeof m==='object')h=m;}const j=h['properties']??{},k=d['description']??'';return{'gateway_file':b,'file_exists':!![],'gateway_name':d['name']??null,'has_definitions':g>0x0,'definitions_count':g,'has_properties':Object['keys'](j)['length']>0x0,'has_tool_field':'tool'in j,'has_data_field':'data'in j,'is_strict':h['additionalProperties']===![],'has_schema_hint':k['includes']('schema_query'),'size_bytes':Buffer['byteLength'](c,'utf-8'),'all_mounts':a};}catch{return{...GATEWAY_MISSING,'gateway_file':b,'all_mounts':a};}}export function loadLayer3Generated(a){const b=a149b['join'](GENERATED_SCHEMAS_DIR,a+'.schema.json'),c=a149b['join'](GENERATED_SCHEMAS_DIR,a+'.output.json'),d=a149a['existsSync'](b),e=a149a['existsSync'](c),f=d?a149a['statSync'](b)['size']:0x0,g=e?a149a['statSync'](c)['size']:0x0;return{'input_schema_file':b,'output_schema_file':c,'input_exists':d,'output_exists':e,'input_size_bytes':f,'output_size_bytes':g};}export function analyzeLayerCensus(){const a=[];for(const b of ALL_TOOLS){a['push']({'name':b['name'],'layer2_zod':{'input_schema_export':b['input_schema_export'],'output_schema_export':b['output_schema_export'],'schema_dir':MCP_SRC_SCHEMA_DIR},'layer3_generated':loadLayer3Generated(b['name'])});}return a;}export function analyzeGatewayDeployment(a){const b=[],c='(gateway)';if(!a['file_exists'])return b['push']({'rule_id':'MCP-GATEWAY-001','severity':'critical','category':'gateway_deployment','tool_name':c,'description':'No\x20deployed\x20wowok.json\x20gateway\x20descriptor\x20found\x20under\x20any\x20Trae\x20mount\x20in\x20'+TRAE_MCPS_ROOT+'.\x20The\x20MCP\x20server\x20is\x20not\x20loaded\x20by\x20any\x20Trae\x20session,\x20or\x20tools/list\x20failed.','fix':'Load\x20the\x20WoWok\x20MCP\x20server\x20in\x20a\x20Trae\x20session\x20and\x20verify\x20tools/list\x20returns\x20the\x20single\x20\x27wowok\x27\x20tool.'}),b;return a['gateway_name']!=='wowok'&&b['push']({'rule_id':'MCP-GATEWAY-002','severity':'high','category':'gateway_deployment','tool_name':c,'description':'Deployed\x20gateway\x20descriptor\x20name\x20is\x20\x27'+a['gateway_name']+'\x27\x20—\x20expected\x20\x27wowok\x27\x20(the\x20single\x20unified\x20tool\x20registered\x20by\x20the\x20server).','location':a['gateway_file'],'fix':'Restart\x20the\x20Trae\x20session\x20so\x20Trae\x20regenerates\x20wowok.json\x20from\x20the\x20server\x27s\x20tools/list.'}),!a['has_definitions']&&a['definitions_count']===0x0&&!a['has_properties']&&b['push']({'rule_id':'MCP-GATEWAY-003','severity':'high','category':'gateway_deployment','tool_name':c,'description':'Deployed\x20gateway\x20descriptor\x20carries\x20no\x20argument\x20schema\x20(no\x20definitions\x20and\x20no\x20properties)\x20—\x20the\x20LLM\x20has\x20no\x20parameter\x20structure\x20at\x20all.','location':a['gateway_file'],'fix':'Ensure\x20listTools()\x20advertises\x20WowokToolDisplaySchema\x20and\x20restart\x20the\x20Trae\x20session.'}),!a['has_schema_hint']&&b['push']({'rule_id':'MCP-GATEWAY-004','severity':'medium','category':'gateway_deployment','tool_name':c,'description':'Gateway\x20descriptor\x20description\x20does\x20not\x20mention\x20schema_query\x20—\x20the\x20LLM\x20is\x20not\x20told\x20about\x20the\x20schema\x20self-correction\x20path\x20(sub-tool\x20schemas\x20are\x20returned\x20on\x20validation\x20mismatch).','location':a['gateway_file'],'fix':'Keep\x20the\x20schema_query\x20mention\x20in\x20WOWOK_TOOL_DESCRIPTION\x20(src/tools/index.ts).'}),b;}export function analyzeGatewayDispatchContract(a){const b=[],c='(gateway)';if(!a['file_exists'])return b;const d=[];if(!a['has_tool_field'])d['push']('tool');if(!a['has_data_field'])d['push']('data');return d['length']>0x0&&b['push']({'rule_id':'MCP-PARITY-001','severity':'high','category':'layer_parity','tool_name':c,'description':'Deployed\x20gateway\x20argument\x20schema\x20is\x20missing\x20dispatch\x20field(s):\x20'+d['join'](',\x20')+'.\x20Calls\x20of\x20the\x20form\x20wowok({\x20tool,\x20data\x20})\x20cannot\x20be\x20validated.','location':a['gateway_file'],'fix':'Ensure\x20WowokToolDisplaySchema\x20exposes\x20tool/data\x20properties\x20and\x20restart\x20the\x20Trae\x20session.'}),!a['is_strict']&&b['push']({'rule_id':'MCP-PARITY-002','severity':'medium','category':'layer_parity','tool_name':c,'description':'Deployed\x20gateway\x20root\x20schema\x20is\x20not\x20strict\x20(additionalProperties\x20!==\x20false)\x20—\x20unknown\x20keys\x20silently\x20pass\x20the\x20client-side\x20check.','location':a['gateway_file'],'fix':'Keep\x20additionalProperties:false\x20on\x20WowokToolDisplaySchema\x20(aliases\x20are\x20explicit\x20properties).'}),b;}export function analyzeAnyUnknownCensus(){const a=[],b=[MCP_SRC_SCHEMA_DIR,MCP_SRC_TOOLS_DIR];for(const c of b){const d=listTypeScriptFiles(c);for(const e of d){const f=a149a['readFileSync'](e,'utf-8')['split']('\x0a');for(let g=0x0;g<f['length'];g++){const h=f[g],j=h['trim']();if(j['startsWith']('//')||j['startsWith']('*'))continue;const k=[{'regex':/z\.any\(\)/g,'pattern':'z.any()'},{'regex':/z\.unknown\(\)/g,'pattern':'z.unknown()'},{'regex':/args\s*:\s*any\b/g,'pattern':'args:\x20any'},{'regex':/Promise\s*<\s*any\s*>/g,'pattern':'Promise<any>'},{'regex':/Record\s*<\s*string\s*,\s*any\s*>/g,'pattern':'Record<string,\x20any>'},{'regex':/\bas\s+any\b/g,'pattern':'as\x20any'}];for(const {regex:l,pattern:n}of k){l['lastIndex']=0x0;let o;while((o=l['exec'](h))!==null){const p=categorizeAnyInstance(e,g+0x1,h,n);a['push']({'file':e,'line':g+0x1,'code':j['length']>0x78?j['slice'](0x0,0x75)+'...':j,'pattern':n,'category':p['category'],'reason':p['reason'],'fix_suggestion':p['fix']});}}}}}return a;}function listTypeScriptFiles(a){const b=[];if(!a149a['existsSync'](a))return b;const c=a149a['readdirSync'](a,{'withFileTypes':!![]});for(const d of c){const e=a149b['join'](a,d['name']);if(d['isDirectory']()){if(d['name']==='__tests__'||d['name']==='node_modules')continue;b['push'](...listTypeScriptFiles(e));}else d['isFile']()&&d['name']['endsWith']('.ts')&&b['push'](e);}return b;}function categorizeAnyInstance(a,b,c,d){const e=a149b['basename'](a),f=c['trim']();if(d==='z.any()'&&/SemanticSummarySchema\s*=\s*z\.any\(\)/['test'](f))return{'category':'fixable','reason':'Circular-dependency\x20workaround\x20for\x20SemanticSummarySchema\x20—\x20can\x20use\x20z.lazy()\x20or\x20refactor\x20to\x20break\x20the\x20cycle.','fix':'Define\x20SemanticSummarySchema\x20with\x20z.lazy(()\x20=>\x20SemanticSummarySchemaReal)\x20or\x20restructure\x20imports\x20to\x20break\x20the\x20cycle.'};if(d==='z.any()'&&/result\s*:\s*z\.any\(\)/['test'](f)&&/[\\/]config[\\/]/['test'](a))return{'category':'fixable','reason':'Result\x20shape\x20depends\x20on\x20action\x20—\x20can\x20use\x20z.discriminatedUnion(\x27action\x27,\x20[...])\x20to\x20type\x20each\x20action\x27s\x20result.','fix':'Define\x20discriminated\x20union:\x20z.discriminatedUnion(\x27action\x27,\x20[z.object({action:\x20z.literal(\x27list\x27),\x20result:\x20...}),\x20...]).'};if(d==='z.unknown()'&&/result\s*:\s*z\.unknown\(\)/['test'](f)&&/index\.ts/['test'](e))return{'category':'fixable','reason':'query_toolkit\x20output\x20result\x20depends\x20on\x20query_type\x20—\x20can\x20use\x20z.discriminatedUnion(\x27query_type\x27,\x20[...]).','fix':'Define\x20discriminated\x20union:\x20z.discriminatedUnion(\x27query_type\x27,\x20[z.object({query_type:\x20z.literal(\x27local_mark_list\x27),\x20result:\x20z.array(MarkDataSchema)}),\x20...]).'};if(d==='z.any()'&&/data\s*:\s*z\.any\(\)/['test'](f)&&/[\\/]schema-query[\\/]/['test'](a))return{'category':'fixable','reason':'SchemaQuery\x20output\x20data\x20depends\x20on\x20action\x20—\x20can\x20use\x20discriminated\x20union\x20by\x20action.','fix':'Define\x20discriminated\x20union:\x20action=\x27get\x27\x20returns\x20JSON\x20Schema,\x20action=\x27list\x27\x20returns\x20array\x20of\x20items.'};if(d==='args:\x20any'&&/handlers[\\/]/['test'](a))return{'category':'fixable','reason':'Handler\x20args\x20can\x20use\x20`unknown`\x20(forces\x20runtime\x20validation)\x20or\x20a\x20typed\x20input\x20schema.','fix':'Replace\x20`args:\x20any`\x20with\x20`args:\x20unknown`\x20and\x20use\x20strictParse(schema,\x20args)\x20at\x20the\x20top\x20of\x20the\x20handler.'};if(d==='args:\x20any'&&/tools[\\/]index\.ts/['test'](a))return{'category':'fixable','reason':'dispatchToolCall\x20args\x20is\x20`any`\x20—\x20can\x20be\x20`unknown`\x20since\x20each\x20tool\x20parses\x20with\x20its\x20own\x20schema.','fix':'Change\x20`args:\x20any`\x20to\x20`args:\x20unknown`\x20in\x20dispatchToolCall\x20signature.'};if(d==='args:\x20any'&&/types\.ts/['test'](e)&&/handler/['test'](f))return{'category':'fixable','reason':'ToolEntry.handler\x20args\x20is\x20`any`\x20—\x20can\x20be\x20`unknown`\x20(each\x20handler\x20parses\x20with\x20its\x20own\x20schema).','fix':'Change\x20`handler:\x20(args:\x20any)\x20=>\x20...`\x20to\x20`handler:\x20(args:\x20unknown)\x20=>\x20...`.'};if(d==='z.any()'&&/claimReceipt|ethReceipt|wowReceipt/['test'](f))return{'category':'legitimate','reason':'EVM\x20transaction\x20receipts\x20have\x20an\x20externally-defined\x20shape\x20from\x20viem/ethers\x20—\x20z.any()\x20is\x20acceptable\x20(receipt\x20is\x20informational,\x20not\x20validated).'};if(d==='z.any()'&&/content_raw/['test'](f))return{'category':'legitimate','reason':'content_raw\x20holds\x20raw\x20content\x20for\x20unknown\x20object\x20types\x20—\x20by\x20definition\x20untyped.\x20z.any()\x20is\x20acceptable\x20here.'};if((d==='z.unknown()'||d==='z.any()')&&/parsedJson/['test'](f))return{'category':'legitimate','reason':'Event\x20parsedJson\x20is\x20arbitrary\x20on-chain\x20event\x20data\x20—\x20z.record(z.string(),\x20z.unknown())\x20is\x20appropriate.'};if(d==='z.any()'&&/key_value/['test'](f))return{'category':'fixable','reason':'Repository\x20key_value\x20depends\x20on\x20key_type\x20—\x20could\x20use\x20discriminated\x20union\x20by\x20key_type\x20(string→z.string(),\x20u64→z.bigint()/number,\x20etc.).','fix':'Define\x20z.discriminatedUnion(\x27key_type\x27,\x20[...])\x20with\x20each\x20variant\x20typed.'};if(d==='z.unknown()'&&/data\s*:\s*z\.unknown\(\)/['test'](f)&&/[\\/]bridge/['test'](a))return{'category':'legitimate','reason':'Bridge\x20operation\x20result\x20data\x20varies\x20by\x20operation_type\x20—\x20currently\x209\x20different\x20shapes.\x20Discriminated\x20union\x20would\x20be\x20ideal\x20but\x20high\x20refactor\x20cost.'};if(d==='z.unknown()'&&/adjusted_params/['test'](f))return{'category':'legitimate','reason':'adjusted_params\x20are\x20free-form\x20key-value\x20pairs\x20suggested\x20by\x20AI\x20—\x20z.record(z.string(),\x20z.unknown())\x20is\x20appropriate.'};if(d==='z.any()'&&/object\s*:\s*z\.union.*z\.record\(z\.any\(\)/['test'](f))return{'category':'fixable','reason':'Creation\x20vs\x20reference\x20object\x20union\x20—\x20z.record(z.any())\x20should\x20be\x20replaced\x20with\x20NamedObjectSchema\x20(structured\x20creation\x20input).','fix':'Replace\x20z.record(z.any())\x20with\x20NamedObjectSchema\x20(already\x20defined\x20in\x20base.ts).'};if(d==='z.any()'&&/result\s*:\s*z\.any\(\)\.optional\(\)/['test'](f)&&/[\\/]bridge/['test'](a))return{'category':'legitimate','reason':'Bridge\x20result\x20is\x20operation-specific\x20(manage_evm_rpc\x20has\x20different\x20result\x20per\x20operation)\x20—\x20z.any().optional()\x20is\x20acceptable\x20here.'};if(d==='Promise<any>'&&/[\\/](wrap|shared)\.ts/['test'](a))return{'category':'fixable','reason':'Generic\x20wrappers\x20in\x20wrap.ts/shared.ts\x20use\x20Promise<any>\x20—\x20could\x20be\x20made\x20generic\x20<T>.','fix':'Replace\x20`Promise<any>`\x20with\x20`Promise<ToolDispatchResult>`\x20(the\x20actual\x20return\x20shape).'};if(d==='Record<string,\x20any>'&&/types\.ts/['test'](e)&&/_meta|structuredContent/['test'](f))return{'category':'fixable','reason':'ToolConfig._meta\x20and\x20ToolDispatchResult.structuredContent\x20could\x20use\x20structured\x20types.','fix':'Define\x20ToolMeta\x20interface\x20(category,\x20tags)\x20and\x20replace\x20structuredContent:\x20any\x20with\x20structured\x20type.'};if(d==='as\x20any')return{'category':'legitimate','reason':'`as\x20any`\x20cast\x20—\x20usually\x20for\x20third-party\x20type\x20mismatches\x20(MCP\x20SDK).\x20Acceptable\x20if\x20isolated.'};return{'category':'legitimate','reason':'Unclassified\x20any/unknown\x20usage\x20—\x20review\x20manually.\x20Defaulting\x20to\x20legitimate\x20(no\x20auto-fix).'};}export function analyzeHandlerTypeSafety(a){const b=[];for(const c of a){if(c['pattern']!=='args:\x20any')continue;if(!/tools[\\/]/['test'](c['file']))continue;b['push']({'rule_id':'MCP-HANDLER-001','severity':'medium','category':'handler_types','tool_name':a149b['basename'](c['file'],'.ts'),'description':'Handler\x20uses\x20`args:\x20any`\x20—\x20bypasses\x20TypeScript\x20type\x20checking.\x20'+c['reason'],'location':c['file']+':'+c['line'],'fix':c['fix_suggestion']});}return b;}export function analyzeOutputSchemaCoverage(a){const b=[];for(const d of a){!d['layer3_generated']['output_exists']&&d['name']!=='onchain_operations'&&b['push']({'rule_id':'MCP-OUTPUT-001','severity':'high','category':'output_coverage','tool_name':d['name'],'description':'Layer\x203\x20output\x20schema\x20file\x20does\x20not\x20exist:\x20'+d['layer3_generated']['output_schema_file'],'fix':'Add\x20outputSchema\x20to\x20'+d['name']+'\x27s\x20tool\x20definition\x20and\x20regenerate\x20schemas.'}),d['layer2_zod']['output_schema_export']===null&&b['push']({'rule_id':'MCP-OUTPUT-002','severity':'medium','category':'output_coverage','tool_name':d['name'],'description':'Layer\x202\x20outputSchema\x20is\x20defined\x20inline\x20(not\x20exported\x20with\x20a\x20stable\x20name).\x20This\x20makes\x20it\x20harder\x20to\x20reference\x20from\x20tests.','fix':'Export\x20the\x20outputSchema\x20with\x20a\x20stable\x20name\x20(e.g.,\x20'+d['name']+'OutputSchema).'});}return b;}export function analyzeGenerationScriptSync(){const a=[];if(!a149a['existsSync'](GENERATION_SCRIPT))return a['push']({'rule_id':'MCP-GENSYNC-001','severity':'critical','category':'generation_sync','tool_name':'(all)','description':'Generation\x20script\x20not\x20found:\x20'+GENERATION_SCRIPT}),a;const b=a149a['readFileSync'](GENERATION_SCRIPT,'utf-8'),c=/name:\s*["']([^"']+)["']/g,d=new Set();let e;while((e=c['exec'](b))!==null){ALL_TOOLS['some'](f=>f['name']===e[0x1])&&d['add'](e[0x1]);}for(const f of ALL_TOOLS){!d['has'](f['name'])&&a['push']({'rule_id':'MCP-GENSYNC-002','severity':'high','category':'generation_sync','tool_name':f['name'],'description':'Tool\x20\x22'+f['name']+'\x22\x20is\x20in\x20TOOL_REGISTRY\x20but\x20missing\x20from\x20generate-json-schemas.ts.\x20Layer\x203\x20schemas\x20will\x20not\x20be\x20generated.','location':GENERATION_SCRIPT,'fix':'Add\x20a\x20get'+toPascalCase(f['name'])+'Tool()\x20function\x20and\x20add\x20it\x20to\x20the\x20tools\x20array.'});}return a;}function toPascalCase(a){return a['split']('_')['map'](b=>b['charAt'](0x0)['toUpperCase']()+b['slice'](0x1)['toLowerCase']())['join']('');}export function analyzeSchemaQueryReflection(a){const b=[];for(const e of a){!e['layer3_generated']['input_exists']&&b['push']({'rule_id':'MCP-REFLECT-001','severity':'high','category':'reflection','tool_name':e['name'],'description':'schema_query(action=\x27get\x27,\x20name=\x27'+e['name']+'\x27)\x20would\x20fail\x20—\x20Layer\x203\x20input\x20schema\x20missing.','fix':'Run\x20pnpm\x20generate:schemas.'}),!e['layer3_generated']['output_exists']&&e['name']!=='onchain_operations'&&b['push']({'rule_id':'MCP-REFLECT-002','severity':'medium','category':'reflection','tool_name':e['name'],'description':'schema_query(action=\x27get_output\x27,\x20name=\x27'+e['name']+'\x27)\x20would\x20fail\x20—\x20Layer\x203\x20output\x20schema\x20missing.','fix':'Run\x20pnpm\x20generate:schemas.'});}const d=['permission','service','machine','progress','guard','arbitration','repository','contact','treasury','reward','allocation','personal','payment','demand','order','gen_passport','proof','gen_proof'];for(const f of d){const g=a149b['join'](GENERATED_SCHEMAS_DIR,'onchain_operations_'+f+'.schema.json');!a149a['existsSync'](g)&&b['push']({'rule_id':'MCP-REFLECT-003','severity':'medium','category':'reflection','tool_name':'onchain_operations_'+f,'description':'Individual\x20operation\x20schema\x20missing:\x20'+g+'.\x20schema_query(action=\x27get\x27,\x20name=\x27onchain_operations_'+f+'\x27)\x20would\x20fail.','fix':'Run\x20pnpm\x20generate:schemas.'});}return b;}function normalizeGlossaryTerm(a){return a['toLowerCase']()['replace'](/[-_\s]/g,'');}const GLOSSARY_ALIAS_INDEX=((()=>{const a=new Set(CONCEPT_GLOSSARY['map'](c=>normalizeGlossaryTerm(c['term']))),b=new Map();for(const c of CONCEPT_GLOSSARY){for(const d of c['aliases']){const e=normalizeGlossaryTerm(d);if(a['has'](e))continue;if(!b['has'](e))b['set'](e,c['term']);}}return b;})());function collectSchemaProperties(a,b,c){if(!a||typeof a!=='object')return;const d=a;if(d['properties']&&typeof d['properties']==='object')for(const e of Object['keys'](d['properties'])){c['push']({'file':b,'property':e}),collectSchemaProperties(d['properties'][e],b,c);}if(d['definitions']&&typeof d['definitions']==='object')for(const f of Object['keys'](d['definitions'])){collectSchemaProperties(d['definitions'][f],b,c);}if(d['items'])collectSchemaProperties(d['items'],b,c);if(Array['isArray'](d['anyOf']))d['anyOf']['forEach'](g=>collectSchemaProperties(g,b,c));if(Array['isArray'](d['oneOf']))d['oneOf']['forEach'](g=>collectSchemaProperties(g,b,c));d['additionalProperties']&&typeof d['additionalProperties']==='object'&&collectSchemaProperties(d['additionalProperties'],b,c);}export function analyzeGlossaryAlignment(){const a=[];if(!a149a['existsSync'](GENERATED_SCHEMAS_DIR))return a;const b=a149a['readdirSync'](GENERATED_SCHEMAS_DIR)['filter'](d=>d['endsWith']('.schema.json')||d['endsWith']('.output.json')),c=new Set();for(const d of b){const e=a149b['join'](GENERATED_SCHEMAS_DIR,d);let f;try{f=JSON['parse'](a149a['readFileSync'](e,'utf-8'));}catch{continue;}const g=[];collectSchemaProperties(f,d,g);for(const h of g){const i=normalizeGlossaryTerm(h['property']),j=GLOSSARY_ALIAS_INDEX['get'](i);if(!j)continue;const k=h['file']+'::'+h['property'];if(c['has'](k))continue;c['add'](k),a['push']({'rule_id':'MCP-GLOSSARY-001','severity':'medium','category':'glossary_alignment','tool_name':d['replace'](/\.(schema|output)\.json$/,''),'description':'Schema\x20field\x20\x27'+h['property']+'\x27\x20uses\x20a\x20deprecated\x20glossary\x20alias\x20—\x20the\x20canonical\x20term\x20is\x20\x27'+j+'\x27.','location':e,'fix':'Rename\x20the\x20field\x20to\x20the\x20canonical\x20term\x20(camelCase/snake_case\x20of\x20\x27'+j+'\x27).'});}}return a;}export function scanAllMcpSchemas(){const a=analyzeLayerCensus(),b=loadLayer4Gateway(),c=analyzeAnyUnknownCensus(),d=[...analyzeGatewayDeployment(b),...analyzeGatewayDispatchContract(b),...analyzeHandlerTypeSafety(c),...analyzeOutputSchemaCoverage(a),...analyzeGenerationScriptSync(),...analyzeSchemaQueryReflection(a),...analyzeGlossaryAlignment()],e=new Map(),g=new Map();for(const k of d){if(!e['has'](k['severity']))e['set'](k['severity'],[]);e['get'](k['severity'])['push'](k);if(!g['has'](k['category']))g['set'](k['category'],[]);g['get'](k['category'])['push'](k);}const h=c['filter'](l=>l['category']==='fixable')['length'],i=c['filter'](l=>l['category']==='legitimate')['length'],j=c['filter'](l=>l['category']==='external')['length'];return{'census':a,'gateway':b,'findings':d,'any_unknown_instances':c,'findings_by_severity':e,'findings_by_category':g,'total_findings':d['length'],'fixable_any_count':h,'legitimate_any_count':i,'external_any_count':j};}export function formatAuditReport(a){const b=[];b['push']('#\x20MCP\x20Schema\x20Audit\x20Report\x20—\x20'+a['census']['length']+'\x20WoWok\x20Sub-Tools\x20+\x20Unified\x20Gateway'),b['push'](''),b['push']('>\x20Auto-generated\x20by\x20`mcp-schema-audit.ts`\x20v'+MCP_SCHEMA_AUDIT_VERSION+'\x20—\x20comprehensive'),b['push']('>\x204-layer\x20audit\x20of\x20schema\x20consistency,\x20any/unknown\x20usage,\x20and\x20I/O\x20coverage.'),b['push'](''),b['push']('##\x20Summary'),b['push'](''),b['push']('-\x20**Tools\x20audited**:\x20'+a['census']['length']),b['push']('-\x20**Total\x20findings**:\x20'+a['total_findings']),b['push']('-\x20**Gateway\x20deployed**:\x20'+(a['gateway']['file_exists']?'yes\x20('+a['gateway']['all_mounts']['length']+'\x20Trae\x20mount(s))':'NO')),b['push']('-\x20**any/unknown\x20instances**:\x20'+a['any_unknown_instances']['length']+'\x20total'),b['push']('\x20\x20-\x20Fixable:\x20'+a['fixable_any_count']),b['push']('\x20\x20-\x20Legitimate:\x20'+a['legitimate_any_count']),b['push']('\x20\x20-\x20External:\x20'+a['external_any_count']),b['push']('-\x20**Glossary\x20alignment**:\x20'+(a['findings_by_category']['get']('glossary_alignment')??[])['length']+'\x20deprecated-alias\x20schema\x20field(s)'),b['push'](''),b['push']('###\x20Findings\x20by\x20Severity'),b['push'](''),b['push']('|\x20Severity\x20|\x20Count\x20|'),b['push']('|----------|-------|');for(const h of['critical','high','medium','low','info']){const i=a['findings_by_severity']['get'](h)??[];b['push']('|\x20'+h+'\x20|\x20'+i['length']+'\x20|');}b['push'](''),b['push']('###\x20Findings\x20by\x20Category'),b['push'](''),b['push']('|\x20Category\x20|\x20Count\x20|'),b['push']('|----------|-------|');for(const j of['gateway_deployment','layer_parity','handler_types','output_coverage','generation_sync','reflection','glossary_alignment']){const k=a['findings_by_category']['get'](j)??[];b['push']('|\x20'+j+'\x20|\x20'+k['length']+'\x20|');}b['push'](''),b['push']('##\x20Layer\x204\x20—\x20Deployed\x20Gateway'),b['push']('');a['gateway']['file_exists']?(b['push']('-\x20**Descriptor**:\x20`'+a['gateway']['gateway_file']+'`\x20('+(a['gateway']['size_bytes']/0x400)['toFixed'](0x1)+'KB)'),b['push']('-\x20**Name**:\x20'+a['gateway']['gateway_name']),b['push']('-\x20**Dispatch\x20contract**:\x20tool='+(a['gateway']['has_tool_field']?'✓':'✗')+'\x20data='+(a['gateway']['has_data_field']?'✓':'✗')+'\x20strict='+(a['gateway']['is_strict']?'✓':'✗')),b['push']('-\x20**Definitions**:\x20'+a['gateway']['definitions_count']),b['push']('-\x20**schema_query\x20hint**:\x20'+(a['gateway']['has_schema_hint']?'✓':'✗')),b['push']('-\x20**Trae\x20mounts**:\x20'+a['gateway']['all_mounts']['length'])):b['push']('-\x20✗\x20No\x20wowok.json\x20found\x20under\x20any\x20Trae\x20mount\x20in\x20'+TRAE_MCPS_ROOT);b['push'](''),b['push']('##\x20Layer\x20Census\x20—\x20All\x20'+a['census']['length']+'\x20Sub-Tools\x20(dispatched\x20via\x20the\x20wowok\x20gateway)'),b['push'](''),b['push']('|\x20Tool\x20|\x20L3\x20Input\x20|\x20L3\x20Output\x20|'),b['push']('|------|----------|-----------|');for(const l of a['census']){const m=l['layer3_generated']['input_exists']?'✓\x20'+(l['layer3_generated']['input_size_bytes']/0x400)['toFixed'](0x1)+'KB':'✗\x20MISSING',n=l['layer3_generated']['output_exists']?'✓\x20'+(l['layer3_generated']['output_size_bytes']/0x400)['toFixed'](0x1)+'KB':'✗\x20MISSING';b['push']('|\x20'+l['name']+'\x20|\x20'+m+'\x20|\x20'+n+'\x20|');}b['push'](''),b['push']('##\x20Findings\x20Detail'),b['push']('');const d=['critical','high','medium','low','info'];for(const o of d){const p=a['findings_by_severity']['get'](o)??[];if(p['length']===0x0)continue;const q=o['toUpperCase']();b['push']('###\x20'+q+'\x20('+p['length']+')'),b['push']('');for(const r of p){b['push']('-\x20**['+r['rule_id']+']\x20'+r['description']);if(r['location'])b['push']('\x20\x20-\x20Location:\x20`'+r['location']+'`');if(r['fix'])b['push']('\x20\x20-\x20Fix:\x20'+r['fix']);b['push']('');}}b['push']('##\x20any/unknown\x20Census\x20Detail'),b['push'](''),b['push']('Total\x20instances:\x20'+a['any_unknown_instances']['length']),b['push'](''),b['push']('###\x20By\x20Pattern'),b['push'](''),b['push']('|\x20Pattern\x20|\x20Total\x20|\x20Fixable\x20|\x20Legitimate\x20|\x20External\x20|'),b['push']('|---------|-------|---------|------------|----------|');const e=new Map();for(const s of a['any_unknown_instances']){if(!e['has'](s['pattern']))e['set'](s['pattern'],[]);e['get'](s['pattern'])['push'](s);}for(const [t,u]of[...e['entries']()]['sort']((v,w)=>w[0x1]['length']-v[0x1]['length'])){const v=u['filter'](y=>y['category']==='fixable')['length'],w=u['filter'](y=>y['category']==='legitimate')['length'],x=u['filter'](y=>y['category']==='external')['length'];b['push']('|\x20`'+t+'`\x20|\x20'+u['length']+'\x20|\x20'+v+'\x20|\x20'+w+'\x20|\x20'+x+'\x20|');}b['push']('');const g=a['any_unknown_instances']['filter'](y=>y['category']==='fixable');if(g['length']>0x0){b['push']('###\x20Fixable\x20Instances\x20(Priority\x20List)'),b['push']('');for(const y of g){b['push']('-\x20**'+a149b['basename'](y['file'])+':'+y['line']+'**\x20[`'+y['pattern']+'`]'),b['push']('\x20\x20-\x20Code:\x20`'+y['code']+'`'),b['push']('\x20\x20-\x20Reason:\x20'+y['reason']);if(y['fix_suggestion'])b['push']('\x20\x20-\x20Fix:\x20'+y['fix_suggestion']);b['push']('');}}return b['push']('##\x20Recommended\x20Action\x20Plan'),b['push'](''),b['push']('###\x20Phase\x201:\x20Keep\x20the\x20Layer\x203\x20schema\x20set\x20regenerable'),b['push'](''),b['push']('Layer\x204\x20(the\x20deployed\x20wowok.json\x20gateway)\x20is\x20CLIENT-generated\x20from\x20our\x20tools/list\x20—\x20keep\x20Layer\x203\x20in\x20sync\x20so\x20schema_query\x20reflection\x20always\x20serves\x20fresh\x20schemas:'),b['push'](''),b['push']('```bash'),b['push']('cd\x20d:/wowok/agent/mcp\x20&&\x20pnpm\x20generate:schemas'),b['push']('```'),b['push'](''),b['push']('###\x20Phase\x202:\x20Type\x20the\x20'+a['fixable_any_count']+'\x20fixable\x20any/unknown\x20instances'),b['push'](''),b['push']('Priority\x20order:'),b['push'](''),b['push']('1.\x20**SemanticSummarySchema**\x20(src/schema/local/index.ts:6)\x20—\x20use\x20`z.lazy()`'),b['push']('2.\x20**ConfigOperationOutputSchema.result**\x20(src/schema/config/index.ts:17)\x20—\x20discriminated\x20union\x20by\x20action'),b['push']('3.\x20**query_toolkit\x20output\x20result**\x20(src/tools/index.ts:250)\x20—\x20discriminated\x20union\x20by\x20query_type'),b['push']('4.\x20**SchemaQueryOutputSchema.data**\x20(src/schema/schema-query/index.ts:34)\x20—\x20discriminated\x20union\x20by\x20action'),b['push']('5.\x20**RepositoryKeyValueSchema.key_value**\x20(src/schema/operations.ts:331)\x20—\x20discriminated\x20union\x20by\x20key_type'),b['push']('6.\x20**Handler\x20args:\x20any**\x20—\x20replace\x20with\x20`unknown`\x20(forces\x20strictParse\x20at\x20top\x20of\x20handler)'),b['push']('7.\x20**dispatchToolCall(name,\x20args:\x20any)**\x20—\x20replace\x20with\x20`unknown`'),b['push'](''),b['push']('###\x20Phase\x203:\x20Verify\x20I/O\x20Schema\x20Match'),b['push'](''),b['push']('For\x20each\x20tool,\x20write\x20a\x20parity\x20test\x20that:'),b['push']('1.\x20Calls\x20the\x20handler\x20with\x20a\x20minimal\x20valid\x20input'),b['push']('2.\x20Captures\x20the\x20structuredContent'),b['push']('3.\x20Validates\x20structuredContent\x20against\x20outputSchema'),b['push']('4.\x20Reports\x20any\x20mismatch'),b['push'](''),b['join']('\x0a');}
@@ -1 +1 @@
1
- import{fieldMutabilityOf}from'./contract-invariants.js';import{REPOSITORY_PERMISSIONS,REWARD_PERMISSIONS,MACHINE_PERMISSIONS,PROGRESS_PERMISSIONS,TREASURY_PERMISSIONS,SERVICE_PERMISSIONS,ARBITRATION_PERMISSIONS,DEMAND_PERMISSIONS,CONTACT_PERMISSIONS}from'./permission-ledger.js';const BUILTIN_PERMISSIONS_BY_TYPE={'Repository':REPOSITORY_PERMISSIONS,'Reward':REWARD_PERMISSIONS,'Machine':MACHINE_PERMISSIONS,'Progress':PROGRESS_PERMISSIONS,'Treasury':TREASURY_PERMISSIONS,'Service':SERVICE_PERMISSIONS,'Arbitration':ARBITRATION_PERMISSIONS,'Demand':DEMAND_PERMISSIONS,'Contact':CONTACT_PERMISSIONS},CATEGORY={'Service':'permission_index','Machine':'permission_index','Treasury':'permission_index','Reward':'permission_index','Repository':'permission_index','Arbitration':'permission_index','Demand':'permission_index','Contact':'permission_index','Progress':'permission_index','Order':'guard','Allocation':'guard','Permission':'special','Guard':'special','Payment':'special','Proof':'special','Personal':'special','GenPassport':'special','GenProof':'special'},COMPLEXITY={'Service':{'level':'L1','reads':0x2,'note':'target\x20+\x20Permission\x20(admin/table)'},'Machine':{'level':'L1','reads':0x2,'note':'target\x20+\x20Permission\x20(admin/table)'},'Treasury':{'level':'L1','reads':0x2,'note':'target\x20+\x20Permission\x20(admin/table)'},'Reward':{'level':'L1','reads':0x2,'note':'target\x20+\x20Permission\x20(admin/table)'},'Repository':{'level':'L1','reads':0x2,'note':'target\x20+\x20Permission\x20(admin/table)'},'Arbitration':{'level':'L1','reads':0x2,'note':'target\x20+\x20Permission\x20(admin/table)'},'Demand':{'level':'L1','reads':0x2,'note':'target\x20+\x20Permission\x20(admin/table)'},'Contact':{'level':'L1','reads':0x2,'note':'target\x20+\x20Permission\x20(admin/table)'},'Progress':{'level':'L3','reads':0x8,'note':'machine\x20nodes\x20+\x20order\x20+\x20machine\x20Permission\x20+\x20named\x20operators'},'Order':{'level':'L0','reads':0x1,'note':'order\x20builder/agent\x20fields\x20suffice'},'Allocation':{'level':'L2','reads':0x5,'note':'allocation\x20+\x20guard\x20+\x20payment\x20+\x20recipient'},'Permission':{'level':'L0','reads':0x1,'note':'owner/admin\x20fields\x20suffice'},'Guard':{'level':'L1','reads':0x2,'note':'guard\x20table\x20+\x20dependency\x20state'},'Payment':{'level':'L0','reads':0x1,'note':'payment\x20signer\x20field\x20suffices'},'Proof':{'level':'L0','reads':0x1,'note':'proof\x20creator\x20field\x20suffices'},'Personal':{'level':'L0','reads':0x1,'note':'signer-owned\x20local\x20data'},'GenPassport':{'level':'L0','reads':0x1,'note':'signer-generated\x20credential'},'GenProof':{'level':'L0','reads':0x1,'note':'signer-generated\x20proof'}};function isCreateEntry(a){return a['name']['endsWith']('_NEW');}function addrOf(a){return typeof a==='string'&&a['length']>0x0?a['toLowerCase']():undefined;}function listHas(a,b){if(!Array['isArray'](a))return![];return a['some'](c=>String(c)['toLowerCase']()===b);}function enumeratePermissionIndexOps(a,b,c){const d=BUILTIN_PERMISSIONS_BY_TYPE[a];if(!d)return[];const f=c?.['admin']['has'](b)??![],g=c?.['table']['get'](b),h=[];for(const i of d){if(isCreateEntry(i))continue;const j=g?.['has'](i['index'])??![],k=f||j,l=f?i['name']+'\x20—\x20admin\x20(full\x20rights)':k?i['name']+'\x20—\x20holds\x20permission\x20'+i['index']:i['name']+'\x20—\x20requires\x20permission\x20'+i['index']+'\x20(not\x20held)';h['push']({'operation':i['governed_operation'],'can_execute':k,'path':'permission_index','note':l});}return h;}function orderOperations(a,b){const c=addrOf(a['builder']??a['owner']),d=c===b||listHas(a['agent'],b),e='order_holder',f=d?'account\x20is\x20the\x20order\x20holder\x20(builder)\x20or\x20an\x20agent':'not\x20the\x20order\x20holder';return[{'operation':'order::required_info_update','can_execute':d,'path':e,'note':f},{'operation':'order::agent_set','can_execute':c===b,'path':e,'note':c===b?'holder\x20may\x20manage\x20agents':'only\x20the\x20holder\x20(builder)\x20may\x20manage\x20agents'},{'operation':'order::owner_change','can_execute':c===b,'path':e,'note':c===b?'holder\x20may\x20transfer\x20the\x20order':'only\x20the\x20holder\x20(builder)\x20may\x20transfer\x20the\x20order'},{'operation':'order::owner_receive','can_execute':d,'path':e,'note':f}];}function permissionOperations(a,b){const c=addrOf(a['builder']??a['owner']),d=c===b,e=listHas(a['admin'],b),f=d?'permission\x20owner':'only\x20the\x20permission\x20owner',g=e?'permission\x20admin':d?'owner\x20(owner\x20may\x20not\x20admin-gate\x20without\x20admin)':'requires\x20admin';return[{'operation':'permission::admin_add','can_execute':d,'path':'owner','note':f},{'operation':'permission::admin_remove','can_execute':d,'path':'owner','note':f},{'operation':'permission::admin_set','can_execute':d,'path':'owner','note':f},{'operation':'permission::transfer','can_execute':d,'path':'owner','note':d?'irreversible\x20ownership\x20transfer':'only\x20the\x20owner'},{'operation':'permission::um_set','can_execute':d,'path':'owner','note':f},{'operation':'permission::description_set','can_execute':e,'path':'admin','note':g},{'operation':'permission::perm_add','can_execute':e,'path':'admin','note':g},{'operation':'permission::perm_remove','can_execute':e,'path':'admin','note':g},{'operation':'permission::perm_set','can_execute':e,'path':'admin','note':g},{'operation':'permission::entity_set','can_execute':e,'path':'admin','note':g},{'operation':'permission::entity_del','can_execute':e,'path':'admin','note':g},{'operation':'permission::remark_set','can_execute':e,'path':'admin','note':g}];}function specialOperations(a,b,c){const d=addrOf(b['builder']??b['owner']??b['signer']),e=d===c;switch(a){case'Guard':return[{'operation':'guard::relies_add','can_execute':![],'path':'signer','note':'guard\x20dependency\x20management\x20—\x20runtime-validated\x20against\x20guard\x20state'},{'operation':'guard::relies_logic_and','can_execute':![],'path':'signer','note':'guard\x20dependency\x20logic\x20—\x20runtime-validated\x20against\x20guard\x20state'}];case'Payment':return[{'operation':'payment::unwrap','can_execute':e,'path':'signer','note':e?'recipient\x20may\x20unwrap\x20the\x20CoinWrapper':'only\x20the\x20payment\x20recipient\x20(signer)'}];case'Proof':return[{'operation':'proof::create_wowok_proof','can_execute':e,'path':'signer','note':e?'creator\x20may\x20issue\x20the\x20proof':'only\x20the\x20proof\x20creator'}];case'Allocation':return[{'operation':'allocation::alloc','can_execute':![],'path':'guard_submission','note':'requires\x20Guard\x20+\x20Passport\x20verification\x20at\x20runtime'},{'operation':'allocation::receive','can_execute':e,'path':'signer','note':e?'recipient\x20may\x20receive\x20the\x20CoinWrapper':'only\x20the\x20allocation\x20recipient'}];default:return[{'operation':a['toLowerCase']()+'_operation','can_execute':e,'path':'signer','note':e?'signer-owned\x20object':'no\x20on-chain\x20mutative\x20operation\x20for\x20this\x20account'}];}}export function operationCategoryOf(a){return CATEGORY[a]??'special';}export function operationComplexityOf(a){return COMPLEXITY[a]??{'level':'L1','reads':0x2,'note':'unknown\x20type\x20—\x20assume\x20target\x20+\x20Permission'};}export function isPermissionIndexType(a){return BUILTIN_PERMISSIONS_BY_TYPE[a]!==undefined;}export function enumerateObjectOperations(a,b,c,d,e){const f=operationCategoryOf(a);if(f==='permission_index')return applyContractInvariants(a,b,enumeratePermissionIndexOps(a,c,d),e);if(a==='Order')return orderOperations(b,c);if(a==='Permission')return permissionOperations(b,c);return specialOperations(a,b,c);}function applyContractInvariants(a,b,c,d){const e=b['bPublished']===!![];if(!e)return c;return c['map'](f=>{const g=fieldFromGovernedOperation(f['operation']);if(!g)return f;const h=fieldMutabilityOf(a,g);if(!h||h['frozen_when']===null)return f;if(h['unfreeze']===null)return{...f,'can_execute':![],'note':((f['note']??'')+'\x20—\x20frozen:\x20forbidden\x20after\x20'+h['frozen_when']+'\x20('+h['move_anchor']+')')['trim']()};if(d!=null){const i=toNumberOrNull(b['paused_time']),j=toNumberOrNull(b['setting_lock_duration']),k=i!==null&&j!==null&&i+j<=d;if(k)return{...f,'note':((f['note']??'')+'\x20—\x20lock\x20elapsed\x20(paused_time\x20+\x20setting_lock_duration\x20<=\x20clock)')['trim']()};return{...f,'can_execute':![],'note':((f['note']??'')+'\x20—\x20locked:\x20needs\x20pause\x20and\x20paused_time\x20+\x20setting_lock_duration\x20<=\x20clock\x20before\x20remove/clear')['trim']()};}return{...f,'note':((f['note']??'')+'\x20—\x20after\x20'+h['frozen_when']+'\x20remove/clear\x20needs\x20'+h['unfreeze']+'\x20(add\x20still\x20allowed)')['trim']()};});}function toNumberOrNull(a){if(a===null||a===undefined)return null;const b=Number(a);return Number['isFinite'](b)?b:null;}function fieldFromGovernedOperation(a){const b=a['toLowerCase']();if(b['includes']('arbitration'))return'arbitrations';if(b['includes']('reward'))return'rewards';if(b['includes']('repository'))return'repositories';if(b['includes']('buy_guard'))return'buy_guard';if(b['includes']('machine'))return'machine';if(b['includes']('sales'))return'sales';if(b['includes']('order_allocator'))return'order_allocators';return undefined;}
1
+ import{fieldMutabilityOf}from'./contract-invariants.js';import{REPOSITORY_PERMISSIONS,REWARD_PERMISSIONS,MACHINE_PERMISSIONS,PROGRESS_PERMISSIONS,TREASURY_PERMISSIONS,SERVICE_PERMISSIONS,ARBITRATION_PERMISSIONS,DEMAND_PERMISSIONS,CONTACT_PERMISSIONS}from'./permission-ledger.js';const BUILTIN_PERMISSIONS_BY_TYPE={'Repository':REPOSITORY_PERMISSIONS,'Reward':REWARD_PERMISSIONS,'Machine':MACHINE_PERMISSIONS,'Progress':PROGRESS_PERMISSIONS,'Treasury':TREASURY_PERMISSIONS,'Service':SERVICE_PERMISSIONS,'Arbitration':ARBITRATION_PERMISSIONS,'Demand':DEMAND_PERMISSIONS,'Contact':CONTACT_PERMISSIONS},CATEGORY={'Service':'permission_index','Machine':'permission_index','Treasury':'permission_index','Reward':'permission_index','Repository':'permission_index','Arbitration':'permission_index','Demand':'permission_index','Contact':'permission_index','Progress':'permission_index','Order':'guard','Allocation':'guard','Permission':'special','Guard':'special','Payment':'special','Proof':'special','Personal':'special','GenPassport':'special','GenProof':'special'},COMPLEXITY={'Service':{'level':'L1','reads':0x2,'note':'target\x20+\x20Permission\x20(admin/table)'},'Machine':{'level':'L1','reads':0x2,'note':'target\x20+\x20Permission\x20(admin/table)'},'Treasury':{'level':'L1','reads':0x2,'note':'target\x20+\x20Permission\x20(admin/table)'},'Reward':{'level':'L1','reads':0x2,'note':'target\x20+\x20Permission\x20(admin/table)'},'Repository':{'level':'L1','reads':0x2,'note':'target\x20+\x20Permission\x20(admin/table)'},'Arbitration':{'level':'L1','reads':0x2,'note':'target\x20+\x20Permission\x20(admin/table)'},'Demand':{'level':'L1','reads':0x2,'note':'target\x20+\x20Permission\x20(admin/table)'},'Contact':{'level':'L1','reads':0x2,'note':'target\x20+\x20Permission\x20(admin/table)'},'Progress':{'level':'L3','reads':0x8,'note':'machine\x20nodes\x20+\x20order\x20+\x20machine\x20Permission\x20+\x20named\x20operators'},'Order':{'level':'L0','reads':0x1,'note':'order\x20builder/agent\x20fields\x20suffice'},'Allocation':{'level':'L2','reads':0x5,'note':'allocation\x20+\x20guard\x20+\x20payment\x20+\x20recipient'},'Permission':{'level':'L0','reads':0x1,'note':'owner/admin\x20fields\x20suffice'},'Guard':{'level':'L1','reads':0x2,'note':'guard\x20table\x20+\x20dependency\x20state'},'Payment':{'level':'L0','reads':0x1,'note':'payment\x20signer\x20field\x20suffices'},'Proof':{'level':'L0','reads':0x1,'note':'proof\x20creator\x20field\x20suffices'},'Personal':{'level':'L0','reads':0x1,'note':'signer-owned\x20local\x20data'},'GenPassport':{'level':'L0','reads':0x1,'note':'signer-generated\x20credential'},'GenProof':{'level':'L0','reads':0x1,'note':'signer-generated\x20proof'}};function isCreateEntry(a){return a['name']['endsWith']('_NEW');}function addrOf(a){return typeof a==='string'&&a['length']>0x0?a['toLowerCase']():undefined;}function listHas(a,b){if(!Array['isArray'](a))return![];return a['some'](c=>String(c)['toLowerCase']()===b);}function enumeratePermissionIndexOps(a,b,c){const d=BUILTIN_PERMISSIONS_BY_TYPE[a];if(!d)return[];const f=c?.['admin']['has'](b)??![],g=c?.['table']['get'](b),h=[];for(const i of d){if(isCreateEntry(i))continue;const j=g?.['has'](i['index'])??![],k=f||j,l=f?i['name']+'\x20—\x20admin\x20(full\x20rights)':k?i['name']+'\x20—\x20holds\x20permission\x20'+i['index']:i['name']+'\x20—\x20requires\x20permission\x20'+i['index']+'\x20(not\x20held)';h['push']({'operation':i['governed_operation'],'can_execute':k,'path':'permission_index','note':l});}return h;}function orderOperations(a,b){const c=addrOf(a['builder']??a['owner']),d=c===b||listHas(a['agent'],b),e='order_holder',f=d?'account\x20is\x20the\x20order\x20holder\x20(builder)\x20or\x20an\x20agent':'not\x20the\x20order\x20holder';return[{'operation':'order::required_info_update','can_execute':d,'path':e,'note':f},{'operation':'order::agent_set','can_execute':c===b,'path':e,'note':c===b?'holder\x20may\x20manage\x20agents':'only\x20the\x20holder\x20(builder)\x20may\x20manage\x20agents'},{'operation':'order::owner_change','can_execute':c===b,'path':e,'note':c===b?'holder\x20may\x20transfer\x20the\x20order':'only\x20the\x20holder\x20(builder)\x20may\x20transfer\x20the\x20order'},{'operation':'order::owner_receive','can_execute':d,'path':e,'note':f}];}function permissionOperations(a,b){const c=addrOf(a['builder']??a['owner']),d=c===b,e=listHas(a['admin'],b),f=d?'permission\x20owner':'only\x20the\x20permission\x20owner',g=e?'permission\x20admin':d?'owner\x20(owner\x20may\x20not\x20admin-gate\x20without\x20admin)':'requires\x20admin';return[{'operation':'permission::admin_add','can_execute':d,'path':'owner','note':f},{'operation':'permission::admin_remove','can_execute':d,'path':'owner','note':f},{'operation':'permission::admin_set','can_execute':d,'path':'owner','note':f},{'operation':'permission::transfer','can_execute':d,'path':'owner','note':d?'irreversible\x20ownership\x20transfer':'only\x20the\x20owner'},{'operation':'permission::um_set','can_execute':d,'path':'owner','note':f},{'operation':'permission::description_set','can_execute':e,'path':'admin','note':g},{'operation':'permission::perm_add','can_execute':e,'path':'admin','note':g},{'operation':'permission::perm_remove','can_execute':e,'path':'admin','note':g},{'operation':'permission::perm_set','can_execute':e,'path':'admin','note':g},{'operation':'permission::entity_set','can_execute':e,'path':'admin','note':g},{'operation':'permission::entity_del','can_execute':e,'path':'admin','note':g},{'operation':'permission::remark_set','can_execute':e,'path':'admin','note':g}];}function specialOperations(a,b,c){const d=addrOf(b['builder']??b['owner']??b['signer']),e=d===c;switch(a){case'Guard':return[{'operation':'guard::relies_add','can_execute':![],'path':'signer','note':'guard\x20dependency\x20management\x20—\x20runtime-validated\x20against\x20guard\x20state'},{'operation':'guard::relies_logic_and','can_execute':![],'path':'signer','note':'guard\x20dependency\x20logic\x20—\x20runtime-validated\x20against\x20guard\x20state'}];case'Payment':return[{'operation':'payment::unwrap','can_execute':e,'path':'signer','note':e?'recipient\x20may\x20unwrap\x20the\x20CoinWrapper':'only\x20the\x20payment\x20recipient\x20(signer)'}];case'Proof':return[{'operation':'proof::create_wowok_proof_v2','can_execute':e,'path':'signer','note':e?'creator\x20may\x20issue\x20the\x20proof\x20(registers\x20creator\x20in\x20ObjectLinkerTx)':'only\x20the\x20proof\x20creator'}];case'Allocation':return[{'operation':'allocation::alloc','can_execute':![],'path':'guard_submission','note':'requires\x20Guard\x20+\x20Passport\x20verification\x20at\x20runtime'},{'operation':'allocation::receive','can_execute':e,'path':'signer','note':e?'recipient\x20may\x20receive\x20the\x20CoinWrapper':'only\x20the\x20allocation\x20recipient'}];default:return[{'operation':a['toLowerCase']()+'_operation','can_execute':e,'path':'signer','note':e?'signer-owned\x20object':'no\x20on-chain\x20mutative\x20operation\x20for\x20this\x20account'}];}}export function operationCategoryOf(a){return CATEGORY[a]??'special';}export function operationComplexityOf(a){return COMPLEXITY[a]??{'level':'L1','reads':0x2,'note':'unknown\x20type\x20—\x20assume\x20target\x20+\x20Permission'};}export function isPermissionIndexType(a){return BUILTIN_PERMISSIONS_BY_TYPE[a]!==undefined;}export function enumerateObjectOperations(a,b,c,d,e){const f=operationCategoryOf(a);if(f==='permission_index')return applyContractInvariants(a,b,enumeratePermissionIndexOps(a,c,d),e);if(a==='Order')return orderOperations(b,c);if(a==='Permission')return permissionOperations(b,c);return specialOperations(a,b,c);}function applyContractInvariants(a,b,c,d){const e=b['bPublished']===!![];if(!e)return c;return c['map'](f=>{const g=fieldFromGovernedOperation(f['operation']);if(!g)return f;const h=fieldMutabilityOf(a,g);if(!h||h['frozen_when']===null)return f;if(h['unfreeze']===null)return{...f,'can_execute':![],'note':((f['note']??'')+'\x20—\x20frozen:\x20forbidden\x20after\x20'+h['frozen_when']+'\x20('+h['move_anchor']+')')['trim']()};if(d!=null){const i=toNumberOrNull(b['paused_time']),j=toNumberOrNull(b['setting_lock_duration']),k=i!==null&&j!==null&&i+j<=d;if(k)return{...f,'note':((f['note']??'')+'\x20—\x20lock\x20elapsed\x20(paused_time\x20+\x20setting_lock_duration\x20<=\x20clock)')['trim']()};return{...f,'can_execute':![],'note':((f['note']??'')+'\x20—\x20locked:\x20needs\x20pause\x20and\x20paused_time\x20+\x20setting_lock_duration\x20<=\x20clock\x20before\x20remove/clear')['trim']()};}return{...f,'note':((f['note']??'')+'\x20—\x20after\x20'+h['frozen_when']+'\x20remove/clear\x20needs\x20'+h['unfreeze']+'\x20(add\x20still\x20allowed)')['trim']()};});}function toNumberOrNull(a){if(a===null||a===undefined)return null;const b=Number(a);return Number['isFinite'](b)?b:null;}function fieldFromGovernedOperation(a){const b=a['toLowerCase']();if(b['includes']('arbitration'))return'arbitrations';if(b['includes']('reward'))return'rewards';if(b['includes']('repository'))return'repositories';if(b['includes']('buy_guard'))return'buy_guard';if(b['includes']('machine'))return'machine';if(b['includes']('sales'))return'sales';if(b['includes']('order_allocator'))return'order_allocators';return undefined;}
@@ -1 +1 @@
1
- import{MAX_GUARD_COUNT_PASSPORT,MAX_SUBMISSION_SIZE_PASSPORT,PASSPORT_ERROR_CODES}from'./passport-ledger.js';import{assessPassportRisks}from'./passport-risk.js';export const PASSPORT_CONFIRMATION_RULES={'creation':[{'id':'C-PASS-01','check':'Confirm\x20Clock\x20object\x20is\x20accessible\x20(new\x20requires\x20Clock\x20argument)','severity':'HIGH','action':'block','layer':'creation'},{'id':'C-PASS-02','check':'Confirm\x20current\x20transaction\x20context\x20is\x20valid\x20(tx_hash\x20will\x20bind\x20to\x20this\x20transaction)','severity':'CRITICAL','action':'block','layer':'creation'}],'operation':[{'id':'C-PASS-03','check':'guard_add:\x20confirm\x20has_verified=false\x20(E_HAS_VERIFIED)','severity':'CRITICAL','action':'block','related_error':'E_HAS_VERIFIED\x20(4)','layer':'operation'},{'id':'C-PASS-04','check':'guard_add:\x20confirm\x20tx_hash\x20matches\x20current\x20transaction\x20(E_DIGEST_NOT_MATCH)','severity':'CRITICAL','action':'block','related_error':'E_DIGEST_NOT_MATCH\x20(11)','layer':'operation'},{'id':'C-PASS-05','check':'guard_add:\x20confirm\x20depended-on\x20Guards\x20already\x20added\x20(E_RELIES_GUARD_NOT_ADDED)','severity':'HIGH','action':'block','related_error':'E_RELIES_GUARD_NOT_ADDED\x20(2)','layer':'operation'},{'id':'C-PASS-06','check':'guard_add:\x20warn\x20Guard\x20count\x20approaching\x20MAX_GUARD_COUNT=20\x20limit','severity':'MEDIUM','action':'warn','related_error':'E_GUARD_COUNT_EXCEEDED\x20(1)','layer':'operation'},{'id':'C-PASS-07','check':'guard_add:\x20warn\x20impack\x20Guard\x20failure\x20will\x20cause\x20overall\x20result=false','severity':'HIGH','action':'warn','layer':'operation'},{'id':'C-PASS-08','check':'guard_add:\x20warn\x20submission\x20serialized\x20size\x20must\x20be\x20≤\x20256\x20bytes','severity':'MEDIUM','action':'warn','related_error':'E_SUBMISSION_SIZE_EXCEEDED\x20(3)','layer':'operation'},{'id':'C-PASS-09','check':'verify:\x20warn\x20this\x20is\x20a\x20one-time\x20operation;\x20after\x20verify,\x20configuration\x20cannot\x20be\x20modified','severity':'HIGH','action':'confirm_twice','related_error':'E_HAS_VERIFIED\x20(4)','layer':'operation'},{'id':'C-PASS-10','check':'verify:\x20confirm\x20at\x20least\x201\x20impack\x20Guard\x20exists\x20(E_IMPACK_GUARD_NOT_FOUND)','severity':'CRITICAL','action':'block','related_error':'E_IMPACK_GUARD_NOT_FOUND\x20(9)','layer':'operation'},{'id':'C-PASS-11','check':'guard_clear:\x20warn\x20this\x20will\x20clear\x20all\x20Guards\x20(allowed\x20before\x20verify)','severity':'MEDIUM','action':'confirm_twice','layer':'operation'},{'id':'C-PASS-12','check':'freezen:\x20warn\x20after\x20freezing,\x20Passport\x20is\x20permanently\x20retained\x20and\x20cannot\x20be\x20destroyed','severity':'MEDIUM','action':'confirm_twice','layer':'operation'},{'id':'C-PASS-13','check':'destroy:\x20warn\x20Passport\x20cannot\x20be\x20recovered\x20after\x20destruction\x20(must\x20be\x20before\x20freeze)','severity':'HIGH','action':'confirm_twice','layer':'operation'}],'consistency':[{'id':'C-PASS-14','check':'Confirm\x20Passport\x20object\x20is\x20not\x20frozen\x20(no\x20operations\x20allowed\x20after\x20freeze)','severity':'HIGH','action':'block','layer':'consistency'},{'id':'C-PASS-15','check':'Confirm\x20referenced\x20Guard\x20objects\x20have\x20not\x20been\x20deleted','severity':'HIGH','action':'block','layer':'consistency'},{'id':'C-PASS-16','check':'Confirm\x20has_verified=true\x20when\x20querying\x20result\x20(E_NOT_VERIFIED)','severity':'HIGH','action':'block','related_error':'E_NOT_VERIFIED\x20(5)','layer':'consistency'},{'id':'C-PASS-17','check':'Confirm\x20tx_hash\x20matches\x20current\x20transaction\x20when\x20querying\x20result\x20(E_TX_NOT_MATCH)','severity':'CRITICAL','action':'block','related_error':'E_TX_NOT_MATCH\x20(8)','layer':'consistency'},{'id':'C-PASS-18','check':'Info:\x20relies\x20dependencies\x20(avoid\x20circular\x20dependencies)','severity':'INFO','action':'info','layer':'consistency'},{'id':'C-PASS-19','check':'Warn:\x20non-impack\x20Guard\x20result\x20does\x20not\x20affect\x20final\x20result','severity':'INFO','action':'info','layer':'consistency'},{'id':'C-PASS-20','check':'Info:\x20Passport\x20emits\x20no\x20events;\x20status\x20must\x20be\x20queried\x20actively','severity':'INFO','action':'info','layer':'consistency'}]};export function preCheckPassportCreation(a){const b=[],c=[],d=[];return!a['clock']&&b['push']('Clock\x20object\x20is\x20required\x20for\x20Passport\x20creation\x20(C-PASS-01,\x20passport::new\x20requires\x20Clock\x20argument)'),!a['txDigest']&&b['push']('Valid\x20transaction\x20context\x20required\x20—\x20tx_hash\x20will\x20bind\x20to\x20this\x20transaction\x20(C-PASS-02)'),{'errors':b,'warnings':c,'requiresConfirmation':d,'canProceed':b['length']===0x0};}export function preCheckPassportOperation(a){const b=[],c=[],d=[],{passport:e,operation:f,guardObjects:g}=a;switch(f['type']){case'guard_add':{if(e['has_verified']){b['push']('Passport\x20already\x20verified,\x20cannot\x20add\x20guard\x20(C-PASS-03,\x20E_HAS_VERIFIED='+PASSPORT_ERROR_CODES['E_HAS_VERIFIED']+')');break;}c['push']('tx_hash\x20must\x20match\x20current\x20transaction\x20(C-PASS-04,\x20E_DIGEST_NOT_MATCH='+PASSPORT_ERROR_CODES['E_DIGEST_NOT_MATCH']+')');const h=g['get'](f['guard']);if(h?.['relies']&&h['relies']['length']>0x0)for(const i of h['relies']){const j=e['info']['some'](k=>k['guard']===i);!j&&b['push']('Dependency\x20Guard\x20'+i+'\x20not\x20added\x20yet\x20(C-PASS-05,\x20E_RELIES_GUARD_NOT_ADDED='+PASSPORT_ERROR_CODES['E_RELIES_GUARD_NOT_ADDED']+')');}if(e['info']['length']>=MAX_GUARD_COUNT_PASSPORT)b['push']('Guard\x20count\x20'+e['info']['length']+'\x20>=\x20MAX_GUARD_COUNT_PASSPORT='+MAX_GUARD_COUNT_PASSPORT+'\x20(C-PASS-06,\x20E_GUARD_COUNT_EXCEEDED='+PASSPORT_ERROR_CODES['E_GUARD_COUNT_EXCEEDED']+')');else e['info']['length']>=MAX_GUARD_COUNT_PASSPORT-0x5&&c['push']('Guard\x20count\x20'+e['info']['length']+'\x20approaching\x20limit\x20'+MAX_GUARD_COUNT_PASSPORT+'\x20(C-PASS-06)');f['impack']&&c['push']('impack=true\x20Guard\x20failure\x20will\x20cause\x20overall\x20result=false\x20(C-PASS-07)');if(f['submission']){const k=estimateSubmissionSize(f['submission']);if(k>MAX_SUBMISSION_SIZE_PASSPORT)b['push']('Submission\x20size\x20'+k+'\x20>\x20MAX_SUBMISSION_SIZE_PASSPORT='+MAX_SUBMISSION_SIZE_PASSPORT+'\x20(C-PASS-08,\x20E_SUBMISSION_SIZE_EXCEEDED='+PASSPORT_ERROR_CODES['E_SUBMISSION_SIZE_EXCEEDED']+')');else k>MAX_SUBMISSION_SIZE_PASSPORT*0.8&&c['push']('Submission\x20size\x20'+k+'\x20approaching\x20limit\x20'+MAX_SUBMISSION_SIZE_PASSPORT+'\x20(C-PASS-08)');}break;}case'verify':{d['push']('WARNING:\x20verify\x20is\x20ONE-TIME\x20operation.\x20After\x20verify,\x20guard\x20configuration\x20cannot\x20be\x20modified.\x20Type\x20\x27CONFIRM\x27\x20to\x20proceed.\x20(C-PASS-09)');const l=e['info']['some'](m=>m['impack']);!l&&b['push']('No\x20impack\x20Guard\x20found,\x20verify\x20will\x20fail\x20(C-PASS-10,\x20E_IMPACK_GUARD_NOT_FOUND='+PASSPORT_ERROR_CODES['E_IMPACK_GUARD_NOT_FOUND']+')');break;}case'guard_clear':{d['push']('WARNING:\x20guard_clear\x20will\x20remove\x20all\x20'+e['info']['length']+'\x20guards.\x20Type\x20\x27CONFIRM\x27\x20to\x20proceed.\x20(C-PASS-11)');e['has_verified']&&b['push']('Passport\x20already\x20verified,\x20cannot\x20clear\x20guards\x20(C-PASS-11,\x20E_HAS_VERIFIED='+PASSPORT_ERROR_CODES['E_HAS_VERIFIED']+')');break;}case'freezen':{d['push']('WARNING:\x20freezen\x20will\x20PERMANENTLY\x20freeze\x20the\x20Passport.\x20It\x20cannot\x20be\x20destroyed\x20after\x20freezing.\x20Type\x20\x27CONFIRM\x27\x20to\x20proceed.\x20(C-PASS-12)');break;}case'destroy':{d['push']('WARNING:\x20destroy\x20will\x20delete\x20the\x20Passport\x20permanently.\x20This\x20must\x20be\x20done\x20BEFORE\x20freezing.\x20Type\x20\x27CONFIRM\x27\x20to\x20proceed.\x20(C-PASS-13)');break;}case'result_query':case'result_for_guard':case'result_for_permission':{!e['has_verified']&&b['push']('result\x20query\x20requires\x20has_verified=true\x20(C-PASS-16,\x20E_NOT_VERIFIED='+PASSPORT_ERROR_CODES['E_NOT_VERIFIED']+')');c['push']('result\x20query\x20requires\x20tx_hash\x20match\x20current\x20transaction\x20(C-PASS-17,\x20E_TX_NOT_MATCH='+PASSPORT_ERROR_CODES['E_TX_NOT_MATCH']+')');if(f['type']==='result_for_guard'){const m=e['info']['find'](n=>n['guard']===f['guard']);if(!m)b['push']('Guard\x20'+f['guard']+'\x20not\x20found\x20in\x20Passport\x20(C-PASS-15)');else!m['impack']&&b['push']('Guard\x20'+f['guard']+'\x20is\x20not\x20impack,\x20result_for_guard\x20will\x20abort\x20(C-PASS-10,\x20E_NOT_IMPACK_GUARD='+PASSPORT_ERROR_CODES['E_NOT_IMPACK_GUARD']+')');}break;}case'submission_get':{break;}}return{'errors':b,'warnings':c,'requiresConfirmation':d,'canProceed':b['length']===0x0};}export function checkPassportStateConsistency(a){const b=[],c=[],{passport:d,guardObjects:e,isFrozen:f}=a;f&&b['push']('Passport\x20is\x20frozen\x20(immutable),\x20no\x20write\x20operations\x20permitted\x20(C-PASS-14)');for(const i of d['info']){!e['has'](i['guard'])&&c['push']('Guard\x20'+i['guard']+'\x20not\x20found,\x20verification\x20may\x20fail\x20(C-PASS-15)');}!d['has_verified']&&c['push']('Passport\x20not\x20yet\x20verified\x20—\x20result\x20queries\x20will\x20fail\x20(C-PASS-16,\x20E_NOT_VERIFIED)');for(const j of d['info']){const k=e['get'](j['guard']);if(k?.['relies']&&k['relies']['length']>0x0){const l=k['relies_logic_and']===![]?'OR':'AND';c['push']('Guard\x20'+j['guard']+'\x20relies\x20on\x20'+k['relies']['length']+'\x20guards\x20('+l+'\x20logic)\x20(C-PASS-18)');}}const h=d['info']['filter'](m=>!m['impack']);return h['length']>0x0&&c['push'](h['length']+'\x20non-impack\x20guards\x20will\x20not\x20affect\x20final\x20result\x20(C-PASS-19)'),c['push']('Passport\x20does\x20not\x20emit\x20events,\x20must\x20query\x20object\x20state\x20directly\x20(C-PASS-20)'),{'errors':b,'warnings':c,'requiresConfirmation':[],'canProceed':b['length']===0x0};}export const PASSPORT_CONFIRM_VERSION='1.0.0';export function runPassportConfirmGate(a){const b=[],c=[];let d;if(a['creation_input']){const e=preCheckPassportCreation(a['creation_input']);if(!e['canProceed'])return c['push']('L1_creation'),{'status':'blocked_creation','creation_result':e,'risk_assessment':d,'confirmation_text':generateConfirmationText(a,e),'block_reason':'Creation\x20blocked:\x20'+e['errors']['join'](';\x20'),'decision_record':{'timestamp':new Date()['toISOString'](),'gate_version':PASSPORT_CONFIRM_VERSION,'final_status':'blocked_creation','layers_passed':b,'layers_failed':c}};b['push']('L1_creation');}if(a['operation_input']){const f=preCheckPassportOperation(a['operation_input']);if(!f['canProceed'])return c['push']('L2_operation'),{'status':'blocked_operation','operation_result':f,'risk_assessment':d,'confirmation_text':generateConfirmationText(a,undefined,f),'block_reason':'Operation\x20blocked:\x20'+f['errors']['join'](';\x20'),'decision_record':{'timestamp':new Date()['toISOString'](),'gate_version':PASSPORT_CONFIRM_VERSION,'final_status':'blocked_operation','layers_passed':b,'layers_failed':c}};if(!a['skip_user_confirmation']&&f['requiresConfirmation']['length']>0x0)return c['push']('L2_operation_pending_confirmation'),{'status':'pending_confirmation','operation_result':f,'risk_assessment':d,'confirmation_text':generateConfirmationText(a,undefined,f),'block_reason':'User\x20confirmation\x20required:\x20'+f['requiresConfirmation']['length']+'\x20item(s)','decision_record':{'timestamp':new Date()['toISOString'](),'gate_version':PASSPORT_CONFIRM_VERSION,'final_status':'pending_confirmation','layers_passed':b,'layers_failed':c}};b['push']('L2_operation');}if(a['consistency_input']){const g=checkPassportStateConsistency(a['consistency_input']);if(!g['canProceed'])return c['push']('L3_consistency'),{'status':'blocked_consistency','consistency_result':g,'risk_assessment':d,'confirmation_text':generateConfirmationText(a,undefined,undefined,g),'block_reason':'Consistency\x20blocked:\x20'+g['errors']['join'](';\x20'),'decision_record':{'timestamp':new Date()['toISOString'](),'gate_version':PASSPORT_CONFIRM_VERSION,'final_status':'blocked_consistency','layers_passed':b,'layers_failed':c}};b['push']('L3_consistency');}if(!a['skip_risk_assessment']&&a['operation_input']){const h={'object':a['operation_input']['passport']['object'],'has_verified':a['operation_input']['passport']['has_verified'],'guard_count':a['operation_input']['passport']['info']['length'],'has_impack_guard':a['operation_input']['passport']['info']['some'](i=>i['impack']),'operation_type':a['operation_input']['operation']['type']==='guard_add'?'guard_add':a['operation_input']['operation']['type']==='verify'?'verify':a['operation_input']['operation']['type']==='freezen'?'freezen':a['operation_input']['operation']['type']==='destroy'?'destroy':'use','is_frozen':a['consistency_input']?.['isFrozen']??![],'matched_scenario':a['scenario'],'constants_synced':!![],'knowledge_files_present':!![]};d=assessPassportRisks(h);}return{'status':'approved','creation_result':a['creation_input']?preCheckPassportCreation(a['creation_input']):undefined,'operation_result':a['operation_input']?preCheckPassportOperation(a['operation_input']):undefined,'consistency_result':a['consistency_input']?checkPassportStateConsistency(a['consistency_input']):undefined,'risk_assessment':d,'confirmation_text':generateConfirmationText(a),'decision_record':{'timestamp':new Date()['toISOString'](),'gate_version':PASSPORT_CONFIRM_VERSION,'final_status':'approved','layers_passed':b,'layers_failed':c}};}function generateConfirmationText(a,b,d,f){const g=[];g['push']('═══\x20Passport\x20Confirmation\x20═══'),g['push']('');a['scenario']&&(g['push']('Scenario:\x20'+a['scenario']['name']),g['push']('Consumer:\x20'+a['scenario']['consumer_object']+'\x20('+a['scenario']['sdk_entry']+')'),g['push']('Purpose:\x20'+a['scenario']['passport_purpose']),g['push'](''));if(b){g['push']('─\x20Layer\x201:\x20Creation\x20──────────────');if(b['errors']['length']>0x0){for(const h of b['errors'])g['push']('\x20\x20✗\x20'+h);}else g['push']('\x20\x20✓\x20All\x20creation\x20checks\x20passed');g['push']('');}if(d){g['push']('─\x20Layer\x202:\x20Operation\x20──────────────');if(d['errors']['length']>0x0){for(const i of d['errors'])g['push']('\x20\x20✗\x20'+i);}if(d['warnings']['length']>0x0){for(const j of d['warnings'])g['push']('\x20\x20⚠\x20'+j);}if(d['requiresConfirmation']['length']>0x0){for(const k of d['requiresConfirmation'])g['push']('\x20\x20?\x20'+k);}d['errors']['length']===0x0&&d['warnings']['length']===0x0&&d['requiresConfirmation']['length']===0x0&&g['push']('\x20\x20✓\x20All\x20operation\x20checks\x20passed'),g['push']('');}if(f){g['push']('─\x20Layer\x203:\x20Consistency\x20──────────────');if(f['errors']['length']>0x0){for(const l of f['errors'])g['push']('\x20\x20✗\x20'+l);}if(f['warnings']['length']>0x0){for(const m of f['warnings'])g['push']('\x20\x20⚠\x20'+m);}f['errors']['length']===0x0&&f['warnings']['length']===0x0&&g['push']('\x20\x20✓\x20All\x20consistency\x20checks\x20passed'),g['push']('');}return g['push']('─\x20Error\x20Code\x20Reference\x20──────────────'),g['push']('\x20\x20E_GUARD_COUNT_EXCEEDED='+PASSPORT_ERROR_CODES['E_GUARD_COUNT_EXCEEDED']+',\x20E_RELIES_GUARD_NOT_ADDED='+PASSPORT_ERROR_CODES['E_RELIES_GUARD_NOT_ADDED']+',\x20E_SUBMISSION_SIZE_EXCEEDED='+PASSPORT_ERROR_CODES['E_SUBMISSION_SIZE_EXCEEDED']),g['push']('\x20\x20E_HAS_VERIFIED='+PASSPORT_ERROR_CODES['E_HAS_VERIFIED']+',\x20E_NOT_VERIFIED='+PASSPORT_ERROR_CODES['E_NOT_VERIFIED']+',\x20E_NOT_IMPACK_GUARD='+PASSPORT_ERROR_CODES['E_NOT_IMPACK_GUARD']),g['push']('\x20\x20E_VERIFY_FAILED='+PASSPORT_ERROR_CODES['E_VERIFY_FAILED']+',\x20E_TX_NOT_MATCH='+PASSPORT_ERROR_CODES['E_TX_NOT_MATCH']+',\x20E_IMPACK_GUARD_NOT_FOUND='+PASSPORT_ERROR_CODES['E_IMPACK_GUARD_NOT_FOUND']),g['push']('\x20\x20E_SUBMISSION_NOT_FOUND='+PASSPORT_ERROR_CODES['E_SUBMISSION_NOT_FOUND']+',\x20E_DIGEST_NOT_MATCH='+PASSPORT_ERROR_CODES['E_DIGEST_NOT_MATCH']),g['push'](''),g['join']('\x0a');}export function estimateSubmissionSize(a){let b=0x0;for(const c of a){b+=0x1;switch(c['value_type']){case'bool':b+=0x1;break;case'u8':b+=0x1;break;case'u64':b+=0x8;break;case'address':b+=0x20;break;case'string':{const d=typeof c['value']==='string'?c['value']['length']:0x0;b+=0x1+d;break;}case'vector<u8>':{const e=Array['isArray'](c['value'])?c['value']['length']:0x0;b+=0x1+e;break;}default:b+=0x40;}}return b;}export function getAllConfirmationRules(){return[...PASSPORT_CONFIRMATION_RULES['creation'],...PASSPORT_CONFIRMATION_RULES['operation'],...PASSPORT_CONFIRMATION_RULES['consistency']];}export function getConfirmationRulesByLayer(a){return PASSPORT_CONFIRMATION_RULES[a];}export function getConfirmationRuleById(a){return getAllConfirmationRules()['find'](b=>b['id']===a);}
1
+ import{MAX_GUARD_COUNT_PASSPORT,MAX_SUBMISSION_SIZE_PASSPORT,PASSPORT_ERROR_CODES}from'./passport-ledger.js';import{assessPassportRisks}from'./passport-risk.js';export const PASSPORT_CONFIRMATION_RULES={'creation':[{'id':'C-PASS-01','check':'Confirm\x20Clock\x20object\x20is\x20accessible\x20(new\x20requires\x20Clock\x20argument)','severity':'HIGH','action':'block','layer':'creation'},{'id':'C-PASS-02','check':'Confirm\x20current\x20transaction\x20context\x20is\x20valid\x20(tx_hash\x20will\x20bind\x20to\x20this\x20transaction)','severity':'CRITICAL','action':'block','layer':'creation'}],'operation':[{'id':'C-PASS-03','check':'guard_add:\x20confirm\x20has_verified=false\x20(E_HAS_VERIFIED)','severity':'CRITICAL','action':'block','related_error':'E_HAS_VERIFIED\x20(4)','layer':'operation'},{'id':'C-PASS-04','check':'guard_add:\x20confirm\x20tx_hash\x20matches\x20current\x20transaction\x20(E_DIGEST_NOT_MATCH)','severity':'CRITICAL','action':'block','related_error':'E_DIGEST_NOT_MATCH\x20(11)','layer':'operation'},{'id':'C-PASS-05','check':'guard_add:\x20confirm\x20depended-on\x20Guards\x20already\x20added\x20(E_RELIES_GUARD_NOT_ADDED)','severity':'HIGH','action':'block','related_error':'E_RELIES_GUARD_NOT_ADDED\x20(2)','layer':'operation'},{'id':'C-PASS-06','check':'guard_add:\x20warn\x20Guard\x20count\x20approaching\x20MAX_GUARD_COUNT=20\x20limit','severity':'MEDIUM','action':'warn','related_error':'E_GUARD_COUNT_EXCEEDED\x20(1)','layer':'operation'},{'id':'C-PASS-07','check':'guard_add:\x20warn\x20impack\x20Guard\x20failure\x20will\x20cause\x20overall\x20result=false','severity':'HIGH','action':'warn','layer':'operation'},{'id':'C-PASS-08','check':'guard_add:\x20warn\x20submission\x20serialized\x20size\x20must\x20be\x20≤\x20256\x20bytes','severity':'MEDIUM','action':'warn','related_error':'E_SUBMISSION_SIZE_EXCEEDED\x20(3)','layer':'operation'},{'id':'C-PASS-09','check':'verify:\x20warn\x20this\x20is\x20a\x20one-time\x20operation;\x20after\x20verify,\x20configuration\x20cannot\x20be\x20modified','severity':'HIGH','action':'confirm_twice','related_error':'E_HAS_VERIFIED\x20(4)','layer':'operation'},{'id':'C-PASS-10','check':'verify:\x20confirm\x20at\x20least\x201\x20impack\x20Guard\x20exists\x20(E_IMPACK_GUARD_NOT_FOUND)','severity':'CRITICAL','action':'block','related_error':'E_IMPACK_GUARD_NOT_FOUND\x20(9)','layer':'operation'},{'id':'C-PASS-11','check':'guard_clear:\x20warn\x20this\x20will\x20clear\x20all\x20Guards\x20(allowed\x20before\x20verify)','severity':'MEDIUM','action':'confirm_twice','layer':'operation'},{'id':'C-PASS-12','check':'freezen:\x20warn\x20after\x20freezing,\x20Passport\x20is\x20permanently\x20retained\x20and\x20cannot\x20be\x20destroyed','severity':'MEDIUM','action':'confirm_twice','layer':'operation'},{'id':'C-PASS-13','check':'destroy:\x20warn\x20Passport\x20cannot\x20be\x20recovered\x20after\x20destruction\x20(must\x20be\x20before\x20freeze)','severity':'HIGH','action':'confirm_twice','layer':'operation'}],'consistency':[{'id':'C-PASS-14','check':'Confirm\x20Passport\x20object\x20is\x20not\x20frozen\x20(no\x20operations\x20allowed\x20after\x20freeze)','severity':'HIGH','action':'block','layer':'consistency'},{'id':'C-PASS-15','check':'Confirm\x20referenced\x20Guard\x20objects\x20have\x20not\x20been\x20deleted','severity':'HIGH','action':'block','layer':'consistency'},{'id':'C-PASS-16','check':'Confirm\x20has_verified=true\x20when\x20querying\x20result\x20(E_NOT_VERIFIED)','severity':'HIGH','action':'block','related_error':'E_NOT_VERIFIED\x20(5)','layer':'consistency'},{'id':'C-PASS-17','check':'Confirm\x20tx_hash\x20matches\x20current\x20transaction\x20when\x20querying\x20result\x20(E_TX_NOT_MATCH)','severity':'CRITICAL','action':'block','related_error':'E_TX_NOT_MATCH\x20(8)','layer':'consistency'},{'id':'C-PASS-18','check':'Info:\x20relies\x20dependencies\x20(avoid\x20circular\x20dependencies)','severity':'INFO','action':'info','layer':'consistency'},{'id':'C-PASS-19','check':'Warn:\x20non-impack\x20Guard\x20result\x20does\x20not\x20affect\x20final\x20result','severity':'INFO','action':'info','layer':'consistency'},{'id':'C-PASS-20','check':'Info:\x20Passport\x20emits\x20no\x20events;\x20status\x20must\x20be\x20queried\x20actively','severity':'INFO','action':'info','layer':'consistency'}]};export function preCheckPassportCreation(a){const b=[],c=[],d=[];return!a['clock']&&b['push']('Clock\x20object\x20is\x20required\x20for\x20Passport\x20creation\x20(C-PASS-01,\x20passport::new_v2\x20requires\x20Clock\x20argument)'),!a['txDigest']&&b['push']('Valid\x20transaction\x20context\x20required\x20—\x20tx_hash\x20will\x20bind\x20to\x20this\x20transaction\x20(C-PASS-02)'),{'errors':b,'warnings':c,'requiresConfirmation':d,'canProceed':b['length']===0x0};}export function preCheckPassportOperation(a){const b=[],c=[],d=[],{passport:e,operation:f,guardObjects:g}=a;switch(f['type']){case'guard_add':{if(e['has_verified']){b['push']('Passport\x20already\x20verified,\x20cannot\x20add\x20guard\x20(C-PASS-03,\x20E_HAS_VERIFIED='+PASSPORT_ERROR_CODES['E_HAS_VERIFIED']+')');break;}c['push']('tx_hash\x20must\x20match\x20current\x20transaction\x20(C-PASS-04,\x20E_DIGEST_NOT_MATCH='+PASSPORT_ERROR_CODES['E_DIGEST_NOT_MATCH']+')');const h=g['get'](f['guard']);if(h?.['relies']&&h['relies']['length']>0x0)for(const i of h['relies']){const j=e['info']['some'](k=>k['guard']===i);!j&&b['push']('Dependency\x20Guard\x20'+i+'\x20not\x20added\x20yet\x20(C-PASS-05,\x20E_RELIES_GUARD_NOT_ADDED='+PASSPORT_ERROR_CODES['E_RELIES_GUARD_NOT_ADDED']+')');}if(e['info']['length']>=MAX_GUARD_COUNT_PASSPORT)b['push']('Guard\x20count\x20'+e['info']['length']+'\x20>=\x20MAX_GUARD_COUNT_PASSPORT='+MAX_GUARD_COUNT_PASSPORT+'\x20(C-PASS-06,\x20E_GUARD_COUNT_EXCEEDED='+PASSPORT_ERROR_CODES['E_GUARD_COUNT_EXCEEDED']+')');else e['info']['length']>=MAX_GUARD_COUNT_PASSPORT-0x5&&c['push']('Guard\x20count\x20'+e['info']['length']+'\x20approaching\x20limit\x20'+MAX_GUARD_COUNT_PASSPORT+'\x20(C-PASS-06)');f['impack']&&c['push']('impack=true\x20Guard\x20failure\x20will\x20cause\x20overall\x20result=false\x20(C-PASS-07)');if(f['submission']){const k=estimateSubmissionSize(f['submission']);if(k>MAX_SUBMISSION_SIZE_PASSPORT)b['push']('Submission\x20size\x20'+k+'\x20>\x20MAX_SUBMISSION_SIZE_PASSPORT='+MAX_SUBMISSION_SIZE_PASSPORT+'\x20(C-PASS-08,\x20E_SUBMISSION_SIZE_EXCEEDED='+PASSPORT_ERROR_CODES['E_SUBMISSION_SIZE_EXCEEDED']+')');else k>MAX_SUBMISSION_SIZE_PASSPORT*0.8&&c['push']('Submission\x20size\x20'+k+'\x20approaching\x20limit\x20'+MAX_SUBMISSION_SIZE_PASSPORT+'\x20(C-PASS-08)');}break;}case'verify':{d['push']('WARNING:\x20verify\x20is\x20ONE-TIME\x20operation.\x20After\x20verify,\x20guard\x20configuration\x20cannot\x20be\x20modified.\x20Type\x20\x27CONFIRM\x27\x20to\x20proceed.\x20(C-PASS-09)');const l=e['info']['some'](m=>m['impack']);!l&&b['push']('No\x20impack\x20Guard\x20found,\x20verify\x20will\x20fail\x20(C-PASS-10,\x20E_IMPACK_GUARD_NOT_FOUND='+PASSPORT_ERROR_CODES['E_IMPACK_GUARD_NOT_FOUND']+')');break;}case'guard_clear':{d['push']('WARNING:\x20guard_clear\x20will\x20remove\x20all\x20'+e['info']['length']+'\x20guards.\x20Type\x20\x27CONFIRM\x27\x20to\x20proceed.\x20(C-PASS-11)');e['has_verified']&&b['push']('Passport\x20already\x20verified,\x20cannot\x20clear\x20guards\x20(C-PASS-11,\x20E_HAS_VERIFIED='+PASSPORT_ERROR_CODES['E_HAS_VERIFIED']+')');break;}case'freezen':{d['push']('WARNING:\x20freezen\x20will\x20PERMANENTLY\x20freeze\x20the\x20Passport.\x20It\x20cannot\x20be\x20destroyed\x20after\x20freezing.\x20Type\x20\x27CONFIRM\x27\x20to\x20proceed.\x20(C-PASS-12)');break;}case'destroy':{d['push']('WARNING:\x20destroy\x20will\x20delete\x20the\x20Passport\x20permanently.\x20This\x20must\x20be\x20done\x20BEFORE\x20freezing.\x20Type\x20\x27CONFIRM\x27\x20to\x20proceed.\x20(C-PASS-13)');break;}case'result_query':case'result_for_guard':case'result_for_permission':{!e['has_verified']&&b['push']('result\x20query\x20requires\x20has_verified=true\x20(C-PASS-16,\x20E_NOT_VERIFIED='+PASSPORT_ERROR_CODES['E_NOT_VERIFIED']+')');c['push']('result\x20query\x20requires\x20tx_hash\x20match\x20current\x20transaction\x20(C-PASS-17,\x20E_TX_NOT_MATCH='+PASSPORT_ERROR_CODES['E_TX_NOT_MATCH']+')');if(f['type']==='result_for_guard'){const m=e['info']['find'](n=>n['guard']===f['guard']);if(!m)b['push']('Guard\x20'+f['guard']+'\x20not\x20found\x20in\x20Passport\x20(C-PASS-15)');else!m['impack']&&b['push']('Guard\x20'+f['guard']+'\x20is\x20not\x20impack,\x20result_for_guard\x20will\x20abort\x20(C-PASS-10,\x20E_NOT_IMPACK_GUARD='+PASSPORT_ERROR_CODES['E_NOT_IMPACK_GUARD']+')');}break;}case'submission_get':{break;}}return{'errors':b,'warnings':c,'requiresConfirmation':d,'canProceed':b['length']===0x0};}export function checkPassportStateConsistency(a){const b=[],c=[],{passport:d,guardObjects:e,isFrozen:f}=a;f&&b['push']('Passport\x20is\x20frozen\x20(immutable),\x20no\x20write\x20operations\x20permitted\x20(C-PASS-14)');for(const i of d['info']){!e['has'](i['guard'])&&c['push']('Guard\x20'+i['guard']+'\x20not\x20found,\x20verification\x20may\x20fail\x20(C-PASS-15)');}!d['has_verified']&&c['push']('Passport\x20not\x20yet\x20verified\x20—\x20result\x20queries\x20will\x20fail\x20(C-PASS-16,\x20E_NOT_VERIFIED)');for(const j of d['info']){const k=e['get'](j['guard']);if(k?.['relies']&&k['relies']['length']>0x0){const l=k['relies_logic_and']===![]?'OR':'AND';c['push']('Guard\x20'+j['guard']+'\x20relies\x20on\x20'+k['relies']['length']+'\x20guards\x20('+l+'\x20logic)\x20(C-PASS-18)');}}const h=d['info']['filter'](m=>!m['impack']);return h['length']>0x0&&c['push'](h['length']+'\x20non-impack\x20guards\x20will\x20not\x20affect\x20final\x20result\x20(C-PASS-19)'),c['push']('Passport\x20does\x20not\x20emit\x20events,\x20must\x20query\x20object\x20state\x20directly\x20(C-PASS-20)'),{'errors':b,'warnings':c,'requiresConfirmation':[],'canProceed':b['length']===0x0};}export const PASSPORT_CONFIRM_VERSION='1.0.0';export function runPassportConfirmGate(a){const b=[],c=[];let d;if(a['creation_input']){const e=preCheckPassportCreation(a['creation_input']);if(!e['canProceed'])return c['push']('L1_creation'),{'status':'blocked_creation','creation_result':e,'risk_assessment':d,'confirmation_text':generateConfirmationText(a,e),'block_reason':'Creation\x20blocked:\x20'+e['errors']['join'](';\x20'),'decision_record':{'timestamp':new Date()['toISOString'](),'gate_version':PASSPORT_CONFIRM_VERSION,'final_status':'blocked_creation','layers_passed':b,'layers_failed':c}};b['push']('L1_creation');}if(a['operation_input']){const f=preCheckPassportOperation(a['operation_input']);if(!f['canProceed'])return c['push']('L2_operation'),{'status':'blocked_operation','operation_result':f,'risk_assessment':d,'confirmation_text':generateConfirmationText(a,undefined,f),'block_reason':'Operation\x20blocked:\x20'+f['errors']['join'](';\x20'),'decision_record':{'timestamp':new Date()['toISOString'](),'gate_version':PASSPORT_CONFIRM_VERSION,'final_status':'blocked_operation','layers_passed':b,'layers_failed':c}};if(!a['skip_user_confirmation']&&f['requiresConfirmation']['length']>0x0)return c['push']('L2_operation_pending_confirmation'),{'status':'pending_confirmation','operation_result':f,'risk_assessment':d,'confirmation_text':generateConfirmationText(a,undefined,f),'block_reason':'User\x20confirmation\x20required:\x20'+f['requiresConfirmation']['length']+'\x20item(s)','decision_record':{'timestamp':new Date()['toISOString'](),'gate_version':PASSPORT_CONFIRM_VERSION,'final_status':'pending_confirmation','layers_passed':b,'layers_failed':c}};b['push']('L2_operation');}if(a['consistency_input']){const g=checkPassportStateConsistency(a['consistency_input']);if(!g['canProceed'])return c['push']('L3_consistency'),{'status':'blocked_consistency','consistency_result':g,'risk_assessment':d,'confirmation_text':generateConfirmationText(a,undefined,undefined,g),'block_reason':'Consistency\x20blocked:\x20'+g['errors']['join'](';\x20'),'decision_record':{'timestamp':new Date()['toISOString'](),'gate_version':PASSPORT_CONFIRM_VERSION,'final_status':'blocked_consistency','layers_passed':b,'layers_failed':c}};b['push']('L3_consistency');}if(!a['skip_risk_assessment']&&a['operation_input']){const h={'object':a['operation_input']['passport']['object'],'has_verified':a['operation_input']['passport']['has_verified'],'guard_count':a['operation_input']['passport']['info']['length'],'has_impack_guard':a['operation_input']['passport']['info']['some'](i=>i['impack']),'operation_type':a['operation_input']['operation']['type']==='guard_add'?'guard_add':a['operation_input']['operation']['type']==='verify'?'verify':a['operation_input']['operation']['type']==='freezen'?'freezen':a['operation_input']['operation']['type']==='destroy'?'destroy':'use','is_frozen':a['consistency_input']?.['isFrozen']??![],'matched_scenario':a['scenario'],'constants_synced':!![],'knowledge_files_present':!![]};d=assessPassportRisks(h);}return{'status':'approved','creation_result':a['creation_input']?preCheckPassportCreation(a['creation_input']):undefined,'operation_result':a['operation_input']?preCheckPassportOperation(a['operation_input']):undefined,'consistency_result':a['consistency_input']?checkPassportStateConsistency(a['consistency_input']):undefined,'risk_assessment':d,'confirmation_text':generateConfirmationText(a),'decision_record':{'timestamp':new Date()['toISOString'](),'gate_version':PASSPORT_CONFIRM_VERSION,'final_status':'approved','layers_passed':b,'layers_failed':c}};}function generateConfirmationText(a,b,d,f){const g=[];g['push']('═══\x20Passport\x20Confirmation\x20═══'),g['push']('');a['scenario']&&(g['push']('Scenario:\x20'+a['scenario']['name']),g['push']('Consumer:\x20'+a['scenario']['consumer_object']+'\x20('+a['scenario']['sdk_entry']+')'),g['push']('Purpose:\x20'+a['scenario']['passport_purpose']),g['push'](''));if(b){g['push']('─\x20Layer\x201:\x20Creation\x20──────────────');if(b['errors']['length']>0x0){for(const h of b['errors'])g['push']('\x20\x20✗\x20'+h);}else g['push']('\x20\x20✓\x20All\x20creation\x20checks\x20passed');g['push']('');}if(d){g['push']('─\x20Layer\x202:\x20Operation\x20──────────────');if(d['errors']['length']>0x0){for(const i of d['errors'])g['push']('\x20\x20✗\x20'+i);}if(d['warnings']['length']>0x0){for(const j of d['warnings'])g['push']('\x20\x20⚠\x20'+j);}if(d['requiresConfirmation']['length']>0x0){for(const k of d['requiresConfirmation'])g['push']('\x20\x20?\x20'+k);}d['errors']['length']===0x0&&d['warnings']['length']===0x0&&d['requiresConfirmation']['length']===0x0&&g['push']('\x20\x20✓\x20All\x20operation\x20checks\x20passed'),g['push']('');}if(f){g['push']('─\x20Layer\x203:\x20Consistency\x20──────────────');if(f['errors']['length']>0x0){for(const l of f['errors'])g['push']('\x20\x20✗\x20'+l);}if(f['warnings']['length']>0x0){for(const m of f['warnings'])g['push']('\x20\x20⚠\x20'+m);}f['errors']['length']===0x0&&f['warnings']['length']===0x0&&g['push']('\x20\x20✓\x20All\x20consistency\x20checks\x20passed'),g['push']('');}return g['push']('─\x20Error\x20Code\x20Reference\x20──────────────'),g['push']('\x20\x20E_GUARD_COUNT_EXCEEDED='+PASSPORT_ERROR_CODES['E_GUARD_COUNT_EXCEEDED']+',\x20E_RELIES_GUARD_NOT_ADDED='+PASSPORT_ERROR_CODES['E_RELIES_GUARD_NOT_ADDED']+',\x20E_SUBMISSION_SIZE_EXCEEDED='+PASSPORT_ERROR_CODES['E_SUBMISSION_SIZE_EXCEEDED']),g['push']('\x20\x20E_HAS_VERIFIED='+PASSPORT_ERROR_CODES['E_HAS_VERIFIED']+',\x20E_NOT_VERIFIED='+PASSPORT_ERROR_CODES['E_NOT_VERIFIED']+',\x20E_NOT_IMPACK_GUARD='+PASSPORT_ERROR_CODES['E_NOT_IMPACK_GUARD']),g['push']('\x20\x20E_VERIFY_FAILED='+PASSPORT_ERROR_CODES['E_VERIFY_FAILED']+',\x20E_TX_NOT_MATCH='+PASSPORT_ERROR_CODES['E_TX_NOT_MATCH']+',\x20E_IMPACK_GUARD_NOT_FOUND='+PASSPORT_ERROR_CODES['E_IMPACK_GUARD_NOT_FOUND']),g['push']('\x20\x20E_SUBMISSION_NOT_FOUND='+PASSPORT_ERROR_CODES['E_SUBMISSION_NOT_FOUND']+',\x20E_DIGEST_NOT_MATCH='+PASSPORT_ERROR_CODES['E_DIGEST_NOT_MATCH']),g['push'](''),g['join']('\x0a');}export function estimateSubmissionSize(a){let b=0x0;for(const c of a){b+=0x1;switch(c['value_type']){case'bool':b+=0x1;break;case'u8':b+=0x1;break;case'u64':b+=0x8;break;case'address':b+=0x20;break;case'string':{const d=typeof c['value']==='string'?c['value']['length']:0x0;b+=0x1+d;break;}case'vector<u8>':{const e=Array['isArray'](c['value'])?c['value']['length']:0x0;b+=0x1+e;break;}default:b+=0x40;}}return b;}export function getAllConfirmationRules(){return[...PASSPORT_CONFIRMATION_RULES['creation'],...PASSPORT_CONFIRMATION_RULES['operation'],...PASSPORT_CONFIRMATION_RULES['consistency']];}export function getConfirmationRulesByLayer(a){return PASSPORT_CONFIRMATION_RULES[a];}export function getConfirmationRuleById(a){return getAllConfirmationRules()['find'](b=>b['id']===a);}
@@ -1 +1 @@
1
- import{MAX_GUARD_COUNT_PASSPORT,MAX_SUBMISSION_SIZE_PASSPORT}from'./passport-ledger.js';export function initPuzzleFromIntent(a){const b={};return(a['protected_operation']||a['verification_rules']||a['consumer_object'])&&(b['intent']={'protected_operation':a['protected_operation']??'','consumer_object':a['consumer_object']??'Service','verification_rules':a['verification_rules']??[],'failure_conditions':a['failure_conditions']??[]}),b['verify']={'tx_hash_binding':!![],'has_verified':![],'verify_flow':buildDefaultVerifyFlow()},b['lifecycle']={'stages':buildDefaultLifecycleStages(),'terminal_state':'undecided','destroy_before_freeze':!![]},b;}export function checkPuzzleCompleteness(a){const b=[],c=[];if(!a['intent'])b['push']('A'),c['push']({'dimension':'A','reason':'Intent\x20not\x20specified\x20(protected_operation\x20+\x20verification_rules)'});else{if(!a['intent']['protected_operation'])b['push']('A'),c['push']({'dimension':'A','reason':'protected_operation\x20is\x20empty'});else a['intent']['verification_rules']['length']===0x0&&(b['push']('A'),c['push']({'dimension':'A','reason':'verification_rules\x20is\x20empty\x20—\x20what\x20should\x20each\x20Guard\x20check?'}));}if(!a['binding'])b['push']('B'),c['push']({'dimension':'B','reason':'Binding\x20not\x20specified\x20(guard_objects\x20+\x20impack_flags\x20+\x20relies)'});else{if(a['binding']['guard_objects']['length']===0x0)b['push']('B'),c['push']({'dimension':'B','reason':'guard_objects\x20is\x20empty\x20—\x20at\x20least\x201\x20Guard\x20required'});else{if(!a['binding']['impack_flags']['some'](d=>d))b['push']('B'),c['push']({'dimension':'B','reason':'No\x20impack=true\x20Guard\x20—\x20at\x20least\x201\x20required\x20(E_IMPACK_GUARD_NOT_FOUND)'});else a['binding']['guard_objects']['length']>MAX_GUARD_COUNT_PASSPORT&&(b['push']('B'),c['push']({'dimension':'B','reason':'guard_objects\x20count\x20'+a['binding']['guard_objects']['length']+'\x20>\x20MAX_GUARD_COUNT_PASSPORT='+MAX_GUARD_COUNT_PASSPORT}));}}if(!a['submission'])b['push']('C'),c['push']({'dimension':'C','reason':'Submission\x20not\x20specified\x20(per-Guard\x20identifier\x20+\x20value\x20+\x20value_type)'});else!a['submission']['size_ok']&&(b['push']('C'),c['push']({'dimension':'C','reason':'max_entry_size\x20'+a['submission']['max_entry_size']+'\x20>\x20MAX_SUBMISSION_SIZE_PASSPORT='+MAX_SUBMISSION_SIZE_PASSPORT}));return!a['verify']&&(b['push']('D'),c['push']({'dimension':'D','reason':'Verify\x20dimension\x20not\x20initialized\x20(should\x20be\x20auto-filled)'})),!a['result']&&(b['push']('E'),c['push']({'dimension':'E','reason':'Result\x20computation\x20not\x20derived\x20(call\x20buildResultPuzzle\x20from\x20binding)'})),!a['lifecycle']&&(b['push']('F'),c['push']({'dimension':'F','reason':'Lifecycle\x20not\x20initialized\x20(should\x20be\x20auto-filled)'})),{'dimensions':['A','B','C','D','E','F'],'missing':b,'missing_details':c,'complete':b['length']===0x0,'next_step':b['length']===0x0?'Puzzle\x20complete\x20—\x20ready\x20for\x20confirmation\x20text\x20generation':'Next:\x20complete\x20dimension\x20'+b[0x0]+'\x20—\x20'+c[0x0]['reason']};}export function validateConstraints(a){const b=[];a['binding']&&a['binding']['guard_objects']['length']>MAX_GUARD_COUNT_PASSPORT&&b['push']({'constraint_id':'F-PASS-04','severity':'CRITICAL','message':'Guard\x20count\x20'+a['binding']['guard_objects']['length']+'\x20exceeds\x20MAX_GUARD_COUNT_PASSPORT='+MAX_GUARD_COUNT_PASSPORT,'current_value':a['binding']['guard_objects']['length'],'limit':MAX_GUARD_COUNT_PASSPORT,'related_move_error':'E_GUARD_COUNT_EXCEEDED\x20(1)'});a['binding']&&!a['binding']['impack_flags']['some'](c=>c)&&b['push']({'constraint_id':'F-PASS-07','severity':'CRITICAL','message':'No\x20impack=true\x20Guard\x20—\x20verify()\x20will\x20abort\x20E_IMPACK_GUARD_NOT_FOUND','related_move_error':'E_IMPACK_GUARD_NOT_FOUND\x20(9)'});if(a['binding']){const c=new Set();for(let d=0x0;d<a['binding']['guard_objects']['length'];d++){const e=a['binding']['guard_objects'][d],f=a['binding']['relies_dependencies'][d]??[];for(const g of f){!c['has'](g)&&b['push']({'constraint_id':'F-PASS-06','severity':'HIGH','message':'Guard\x20'+e+'\x20(index\x20'+d+')\x20relies\x20on\x20'+g+',\x20but\x20'+g+'\x20is\x20not\x20added\x20before\x20it\x20(topological\x20order\x20violated)','related_move_error':'E_RELIES_GUARD_NOT_ADDED\x20(2)'});}c['add'](e);}}a['submission']&&!a['submission']['size_ok']&&b['push']({'constraint_id':'F-PASS-05','severity':'HIGH','message':'Submission\x20max\x20entry\x20size\x20'+a['submission']['max_entry_size']+'\x20>\x20MAX_SUBMISSION_SIZE_PASSPORT='+MAX_SUBMISSION_SIZE_PASSPORT,'current_value':a['submission']['max_entry_size'],'limit':MAX_SUBMISSION_SIZE_PASSPORT,'related_move_error':'E_SUBMISSION_SIZE_EXCEEDED\x20(3)'});if(a['binding']){const h=new Map();for(let j=0x0;j<a['binding']['guard_objects']['length'];j++){h['set'](a['binding']['guard_objects'][j],a['binding']['relies_dependencies'][j]??[]);}for(let k=0x0;k<a['binding']['guard_objects']['length'];k++){const l=a['binding']['guard_objects'][k],m=a['binding']['relies_dependencies'][k]??[];for(const n of m){const o=h['get'](n)??[];o['length']>0x0&&b['push']({'constraint_id':'F-PASS-12','severity':'LOW','message':'Guard\x20'+l+'\x20relies\x20on\x20'+n+',\x20but\x20'+n+'\x20itself\x20has\x20relies\x20'+JSON['stringify'](o)+'\x20—\x20transitive\x20dependencies\x20are\x20not\x20allowed'});}}}return b;}export function buildResultPuzzle(a){const b=a['guard_objects']['filter']((e,f)=>a['impack_flags'][f]),c=a['guard_objects']['map']((e,f)=>{const g=a['impack_flags'][f]?'impack':'non_impack',h=a['relies_logic'][f]??'AND',j=a['relies_dependencies'][f]??[],k=j['length']===0x0?'(no\x20relies)':j['map'](m=>m+'.result')['join']('\x20'+h+'\x20'),l=j['length']===0x0?e+'.result\x20(standalone)':k+'\x20'+h+'\x20'+e+'.result';return{'guard':e,'impack':g,'relies_logic':h,'relies_guards':j,'computation':l};}),d=b['length']===0x0?'result\x20=\x20false\x20(no\x20impack\x20Guard\x20—\x20E_IMPACK_GUARD_NOT_FOUND)':'result\x20=\x20AND('+b['map'](e=>e+'.result')['join'](',\x20')+')';return{'decision_rule':'impack_mechanism','impack_guards':b,'per_guard_logic':c,'overall_formula':d};}export function buildDefaultVerifyFlow(){return[{'step':0x1,'action':'pre_check','description':'assert\x20!has_verified\x20(E_HAS_VERIFIED),\x20tx_hash\x20matches\x20(E_DIGEST_NOT_MATCH)'},{'step':0x2,'action':'iterate_guards','description':'for\x20each\x20GuardInfo\x20in\x20self.guard\x20(in\x20addition\x20order)'},{'step':0x3,'action':'calc_relies_result','description':'calculate\x20relies\x20result\x20via\x20AND/OR\x20logic;\x20short-circuit\x20on\x20AND-false\x20or\x20OR-true'},{'step':0x4,'action':'verify_guard_native','description':'guard::verify_guard(guard,\x20submission,\x20impack)\x20—\x20native\x20function,\x20opaque'},{'step':0x5,'action':'check_submission_size','description':'assert\x20BCS\x20submission\x20size\x20≤\x20MAX_SUBMISSION_SIZE_PASSPORT=256\x20(E_SUBMISSION_SIZE_EXCEEDED)'},{'step':0x6,'action':'impack_decision','description':'if\x20impack=true\x20and\x20result=false\x20→\x20set\x20self.result=false,\x20return\x20immediately'},{'step':0x7,'action':'finalize','description':'assert\x20at\x20least\x201\x20impack\x20Guard\x20(E_IMPACK_GUARD_NOT_FOUND);\x20set\x20has_verified=true,\x20self.result=true'}];}export function buildDefaultLifecycleStages(){return[{'stage':'new','description':'passport::new(clock,\x20ctx)\x20—\x20create\x20Passport,\x20bind\x20tx_hash','completed':![]},{'stage':'guard_add','description':'passport::guard_add(self,\x20guard,\x20identifiers,\x20values,\x20impack,\x20ctx)\x20—\x20add\x20Guards\x20(repeatable,\x20pre-verify)','completed':![]},{'stage':'verify','description':'passport::verify(self,\x20ctx)\x20—\x20one-time\x20verification,\x20sets\x20has_verified=true','completed':![]},{'stage':'use','description':'passport::result\x20/\x20result_for_guard\x20/\x20result_for_permission\x20/\x20submission_get\x20—\x20query\x20results','completed':![]},{'stage':'freeze_or_destroy','description':'passport::freezen(self)\x20[permanent]\x20OR\x20passport::destroy(self)\x20[release]','completed':![]}];}export function generateConfirmationText(a){const c=[];c['push']('═══\x20Passport\x20Confirmation\x20═══'),c['push']('');if(a['intent']){c['push']('─\x20A.\x20Intent\x20──────────────'),c['push']('Protected\x20operation:\x20'+a['intent']['protected_operation']),c['push']('Consumer\x20object:\x20'+a['intent']['consumer_object']);if(a['intent']['verification_rules']['length']>0x0){c['push']('Verification\x20rules:');for(const e of a['intent']['verification_rules'])c['push']('\x20\x20-\x20'+e);}if(a['intent']['failure_conditions']['length']>0x0){c['push']('Failure\x20conditions:');for(const f of a['intent']['failure_conditions'])c['push']('\x20\x20-\x20'+f);}c['push']('');}if(a['binding']){const g=a['binding'];c['push']('─\x20B.\x20Binding\x20──────────────'),c['push']('Guards\x20('+g['guard_objects']['length']+'/'+MAX_GUARD_COUNT_PASSPORT+'):'),g['guard_objects']['forEach']((h,j)=>{const k=g['impack_flags'][j]?'IMPACK':'non-impack',m=g['relies_dependencies'][j]??[],n=g['relies_logic'][j]??'AND',o=m['length']===0x0?'':'\x20relies='+JSON['stringify'](m)+'\x20('+n+')';c['push']('\x20\x20['+j+']\x20'+h+'\x20—\x20'+k+o);}),g['topological_order']['length']>0x0&&c['push']('Topological\x20order:\x20'+g['topological_order']['join']('\x20→\x20')),c['push']('');}if(a['submission']){const h=a['submission'];c['push']('─\x20C.\x20Submission\x20──────────────'),c['push']('Entries:\x20'+h['submissions']['length']+',\x20max\x20entry\x20size:\x20'+h['max_entry_size']+'/'+MAX_SUBMISSION_SIZE_PASSPORT+'\x20bytes\x20('+(h['size_ok']?'OK':'EXCEEDS')+')');for(const i of h['submissions']){c['push']('\x20\x20-\x20guard='+i['guard']+',\x20identifier='+i['identifier']+',\x20value_type='+i['value_type']+',\x20size='+i['estimated_size']);}c['push']('');}if(a['verify']){const j=a['verify'];c['push']('─\x20D.\x20Verify\x20──────────────'),c['push']('tx_hash\x20binding:\x20'+(j['tx_hash_binding']?'YES\x20(Move-level\x20hard-coded)':'NO')),c['push']('has_verified:\x20'+j['has_verified']),c['push']('Verify\x20flow\x20('+j['verify_flow']['length']+'\x20steps):');for(const k of j['verify_flow']){c['push']('\x20\x20'+k['step']+'.\x20'+k['action']+':\x20'+k['description']);}c['push']('');}if(a['result']){const m=a['result'];c['push']('─\x20E.\x20Result\x20──────────────'),c['push']('Decision\x20rule:\x20'+m['decision_rule']),c['push']('impack\x20Guards:\x20'+(m['impack_guards']['length']===0x0?'(none\x20—\x20will\x20fail\x20verify)':m['impack_guards']['join'](',\x20'))),c['push']('Overall\x20formula:\x20'+m['overall_formula']);if(m['per_guard_logic']['length']>0x0){c['push']('Per-Guard\x20logic:');for(const n of m['per_guard_logic']){c['push']('\x20\x20-\x20'+n['guard']+'\x20('+n['impack']+',\x20'+n['relies_logic']+'):\x20'+n['computation']);}}c['push']('');}if(a['lifecycle']){const o=a['lifecycle'];c['push']('─\x20F.\x20Lifecycle\x20──────────────'),c['push']('Terminal\x20state:\x20'+o['terminal_state']);for(const p of o['stages']){const q=p['completed']?'✓':'○';c['push']('\x20\x20'+q+'\x20'+p['stage']+':\x20'+p['description']);}c['push']('');}const d=validateConstraints(a);if(d['length']>0x0){c['push']('─\x20Constraint\x20Violations\x20──────────────');for(const t of d){c['push']('\x20\x20['+t['severity']+']\x20'+t['constraint_id']+':\x20'+t['message']);}c['push']('');}return c['join']('\x0a');}export function buildPassportPuzzle(a){const b=initPuzzleFromIntent(a['intent']),c=computeTopologicalOrder(a['binding']['guard_objects'],a['binding']['relies_dependencies']??a['binding']['guard_objects']['map'](()=>[]));b['binding']={'guard_objects':a['binding']['guard_objects'],'impack_flags':a['binding']['impack_flags'],'relies_dependencies':a['binding']['relies_dependencies']??a['binding']['guard_objects']['map'](()=>[]),'relies_logic':a['binding']['relies_logic']??a['binding']['guard_objects']['map'](()=>'AND'),'topological_order':c};const d=a['submission']['reduce']((e,f)=>Math['max'](e,f['estimated_size']),0x0);return b['submission']={'submissions':a['submission'],'max_entry_size':d,'size_ok':d<=MAX_SUBMISSION_SIZE_PASSPORT},b['result']=buildResultPuzzle(b['binding']),a['terminal_state']&&(b['lifecycle']['terminal_state']=a['terminal_state']),b;}function computeTopologicalOrder(a,b){const c=[],d=new Set();for(let e=0x0;e<a['length'];e++){const f=a[e],g=b[e]??[];for(const h of g){!d['has'](h)&&a['includes'](h)&&(c['push'](h),d['add'](h));}!d['has'](f)&&(c['push'](f),d['add'](f));}return c;}export const PASSPORT_PUZZLE_VERSION='1.0.0';
1
+ import{MAX_GUARD_COUNT_PASSPORT,MAX_SUBMISSION_SIZE_PASSPORT}from'./passport-ledger.js';export function initPuzzleFromIntent(a){const b={};return(a['protected_operation']||a['verification_rules']||a['consumer_object'])&&(b['intent']={'protected_operation':a['protected_operation']??'','consumer_object':a['consumer_object']??'Service','verification_rules':a['verification_rules']??[],'failure_conditions':a['failure_conditions']??[]}),b['verify']={'tx_hash_binding':!![],'has_verified':![],'verify_flow':buildDefaultVerifyFlow()},b['lifecycle']={'stages':buildDefaultLifecycleStages(),'terminal_state':'undecided','destroy_before_freeze':!![]},b;}export function checkPuzzleCompleteness(a){const b=[],c=[];if(!a['intent'])b['push']('A'),c['push']({'dimension':'A','reason':'Intent\x20not\x20specified\x20(protected_operation\x20+\x20verification_rules)'});else{if(!a['intent']['protected_operation'])b['push']('A'),c['push']({'dimension':'A','reason':'protected_operation\x20is\x20empty'});else a['intent']['verification_rules']['length']===0x0&&(b['push']('A'),c['push']({'dimension':'A','reason':'verification_rules\x20is\x20empty\x20—\x20what\x20should\x20each\x20Guard\x20check?'}));}if(!a['binding'])b['push']('B'),c['push']({'dimension':'B','reason':'Binding\x20not\x20specified\x20(guard_objects\x20+\x20impack_flags\x20+\x20relies)'});else{if(a['binding']['guard_objects']['length']===0x0)b['push']('B'),c['push']({'dimension':'B','reason':'guard_objects\x20is\x20empty\x20—\x20at\x20least\x201\x20Guard\x20required'});else{if(!a['binding']['impack_flags']['some'](d=>d))b['push']('B'),c['push']({'dimension':'B','reason':'No\x20impack=true\x20Guard\x20—\x20at\x20least\x201\x20required\x20(E_IMPACK_GUARD_NOT_FOUND)'});else a['binding']['guard_objects']['length']>MAX_GUARD_COUNT_PASSPORT&&(b['push']('B'),c['push']({'dimension':'B','reason':'guard_objects\x20count\x20'+a['binding']['guard_objects']['length']+'\x20>\x20MAX_GUARD_COUNT_PASSPORT='+MAX_GUARD_COUNT_PASSPORT}));}}if(!a['submission'])b['push']('C'),c['push']({'dimension':'C','reason':'Submission\x20not\x20specified\x20(per-Guard\x20identifier\x20+\x20value\x20+\x20value_type)'});else!a['submission']['size_ok']&&(b['push']('C'),c['push']({'dimension':'C','reason':'max_entry_size\x20'+a['submission']['max_entry_size']+'\x20>\x20MAX_SUBMISSION_SIZE_PASSPORT='+MAX_SUBMISSION_SIZE_PASSPORT}));return!a['verify']&&(b['push']('D'),c['push']({'dimension':'D','reason':'Verify\x20dimension\x20not\x20initialized\x20(should\x20be\x20auto-filled)'})),!a['result']&&(b['push']('E'),c['push']({'dimension':'E','reason':'Result\x20computation\x20not\x20derived\x20(call\x20buildResultPuzzle\x20from\x20binding)'})),!a['lifecycle']&&(b['push']('F'),c['push']({'dimension':'F','reason':'Lifecycle\x20not\x20initialized\x20(should\x20be\x20auto-filled)'})),{'dimensions':['A','B','C','D','E','F'],'missing':b,'missing_details':c,'complete':b['length']===0x0,'next_step':b['length']===0x0?'Puzzle\x20complete\x20—\x20ready\x20for\x20confirmation\x20text\x20generation':'Next:\x20complete\x20dimension\x20'+b[0x0]+'\x20—\x20'+c[0x0]['reason']};}export function validateConstraints(a){const b=[];a['binding']&&a['binding']['guard_objects']['length']>MAX_GUARD_COUNT_PASSPORT&&b['push']({'constraint_id':'F-PASS-04','severity':'CRITICAL','message':'Guard\x20count\x20'+a['binding']['guard_objects']['length']+'\x20exceeds\x20MAX_GUARD_COUNT_PASSPORT='+MAX_GUARD_COUNT_PASSPORT,'current_value':a['binding']['guard_objects']['length'],'limit':MAX_GUARD_COUNT_PASSPORT,'related_move_error':'E_GUARD_COUNT_EXCEEDED\x20(1)'});a['binding']&&!a['binding']['impack_flags']['some'](c=>c)&&b['push']({'constraint_id':'F-PASS-07','severity':'CRITICAL','message':'No\x20impack=true\x20Guard\x20—\x20verify()\x20will\x20abort\x20E_IMPACK_GUARD_NOT_FOUND','related_move_error':'E_IMPACK_GUARD_NOT_FOUND\x20(9)'});if(a['binding']){const c=new Set();for(let d=0x0;d<a['binding']['guard_objects']['length'];d++){const e=a['binding']['guard_objects'][d],f=a['binding']['relies_dependencies'][d]??[];for(const g of f){!c['has'](g)&&b['push']({'constraint_id':'F-PASS-06','severity':'HIGH','message':'Guard\x20'+e+'\x20(index\x20'+d+')\x20relies\x20on\x20'+g+',\x20but\x20'+g+'\x20is\x20not\x20added\x20before\x20it\x20(topological\x20order\x20violated)','related_move_error':'E_RELIES_GUARD_NOT_ADDED\x20(2)'});}c['add'](e);}}a['submission']&&!a['submission']['size_ok']&&b['push']({'constraint_id':'F-PASS-05','severity':'HIGH','message':'Submission\x20max\x20entry\x20size\x20'+a['submission']['max_entry_size']+'\x20>\x20MAX_SUBMISSION_SIZE_PASSPORT='+MAX_SUBMISSION_SIZE_PASSPORT,'current_value':a['submission']['max_entry_size'],'limit':MAX_SUBMISSION_SIZE_PASSPORT,'related_move_error':'E_SUBMISSION_SIZE_EXCEEDED\x20(3)'});if(a['binding']){const h=new Map();for(let j=0x0;j<a['binding']['guard_objects']['length'];j++){h['set'](a['binding']['guard_objects'][j],a['binding']['relies_dependencies'][j]??[]);}for(let k=0x0;k<a['binding']['guard_objects']['length'];k++){const l=a['binding']['guard_objects'][k],m=a['binding']['relies_dependencies'][k]??[];for(const n of m){const o=h['get'](n)??[];o['length']>0x0&&b['push']({'constraint_id':'F-PASS-12','severity':'LOW','message':'Guard\x20'+l+'\x20relies\x20on\x20'+n+',\x20but\x20'+n+'\x20itself\x20has\x20relies\x20'+JSON['stringify'](o)+'\x20—\x20transitive\x20dependencies\x20are\x20not\x20allowed'});}}}return b;}export function buildResultPuzzle(a){const b=a['guard_objects']['filter']((e,f)=>a['impack_flags'][f]),c=a['guard_objects']['map']((e,f)=>{const g=a['impack_flags'][f]?'impack':'non_impack',h=a['relies_logic'][f]??'AND',j=a['relies_dependencies'][f]??[],k=j['length']===0x0?'(no\x20relies)':j['map'](m=>m+'.result')['join']('\x20'+h+'\x20'),l=j['length']===0x0?e+'.result\x20(standalone)':k+'\x20'+h+'\x20'+e+'.result';return{'guard':e,'impack':g,'relies_logic':h,'relies_guards':j,'computation':l};}),d=b['length']===0x0?'result\x20=\x20false\x20(no\x20impack\x20Guard\x20—\x20E_IMPACK_GUARD_NOT_FOUND)':'result\x20=\x20AND('+b['map'](e=>e+'.result')['join'](',\x20')+')';return{'decision_rule':'impack_mechanism','impack_guards':b,'per_guard_logic':c,'overall_formula':d};}export function buildDefaultVerifyFlow(){return[{'step':0x1,'action':'pre_check','description':'assert\x20!has_verified\x20(E_HAS_VERIFIED),\x20tx_hash\x20matches\x20(E_DIGEST_NOT_MATCH)'},{'step':0x2,'action':'iterate_guards','description':'for\x20each\x20GuardInfo\x20in\x20self.guard\x20(in\x20addition\x20order)'},{'step':0x3,'action':'calc_relies_result','description':'calculate\x20relies\x20result\x20via\x20AND/OR\x20logic;\x20short-circuit\x20on\x20AND-false\x20or\x20OR-true'},{'step':0x4,'action':'verify_guard_native','description':'guard::verify_guard(guard,\x20submission,\x20impack)\x20—\x20native\x20function,\x20opaque'},{'step':0x5,'action':'check_submission_size','description':'assert\x20BCS\x20submission\x20size\x20≤\x20MAX_SUBMISSION_SIZE_PASSPORT=256\x20(E_SUBMISSION_SIZE_EXCEEDED)'},{'step':0x6,'action':'impack_decision','description':'if\x20impack=true\x20and\x20result=false\x20→\x20set\x20self.result=false,\x20return\x20immediately'},{'step':0x7,'action':'finalize','description':'assert\x20at\x20least\x201\x20impack\x20Guard\x20(E_IMPACK_GUARD_NOT_FOUND);\x20set\x20has_verified=true,\x20self.result=true'}];}export function buildDefaultLifecycleStages(){return[{'stage':'new','description':'passport::new_v2(clock,\x20object_linker_tx,\x20ctx)\x20—\x20create\x20Passport,\x20bind\x20tx_hash,\x20register\x20creator\x20reverse\x20lookup','completed':![]},{'stage':'guard_add','description':'passport::guard_add(self,\x20guard,\x20identifiers,\x20values,\x20impack,\x20ctx)\x20—\x20add\x20Guards\x20(repeatable,\x20pre-verify)','completed':![]},{'stage':'verify','description':'passport::verify(self,\x20ctx)\x20—\x20one-time\x20verification,\x20sets\x20has_verified=true','completed':![]},{'stage':'use','description':'passport::result\x20/\x20result_for_guard\x20/\x20result_for_permission\x20/\x20submission_get\x20—\x20query\x20results','completed':![]},{'stage':'freeze_or_destroy','description':'passport::freezen(self)\x20[permanent]\x20OR\x20passport::destroy(self)\x20[release]','completed':![]}];}export function generateConfirmationText(a){const c=[];c['push']('═══\x20Passport\x20Confirmation\x20═══'),c['push']('');if(a['intent']){c['push']('─\x20A.\x20Intent\x20──────────────'),c['push']('Protected\x20operation:\x20'+a['intent']['protected_operation']),c['push']('Consumer\x20object:\x20'+a['intent']['consumer_object']);if(a['intent']['verification_rules']['length']>0x0){c['push']('Verification\x20rules:');for(const e of a['intent']['verification_rules'])c['push']('\x20\x20-\x20'+e);}if(a['intent']['failure_conditions']['length']>0x0){c['push']('Failure\x20conditions:');for(const f of a['intent']['failure_conditions'])c['push']('\x20\x20-\x20'+f);}c['push']('');}if(a['binding']){const g=a['binding'];c['push']('─\x20B.\x20Binding\x20──────────────'),c['push']('Guards\x20('+g['guard_objects']['length']+'/'+MAX_GUARD_COUNT_PASSPORT+'):'),g['guard_objects']['forEach']((h,j)=>{const k=g['impack_flags'][j]?'IMPACK':'non-impack',m=g['relies_dependencies'][j]??[],n=g['relies_logic'][j]??'AND',o=m['length']===0x0?'':'\x20relies='+JSON['stringify'](m)+'\x20('+n+')';c['push']('\x20\x20['+j+']\x20'+h+'\x20—\x20'+k+o);}),g['topological_order']['length']>0x0&&c['push']('Topological\x20order:\x20'+g['topological_order']['join']('\x20→\x20')),c['push']('');}if(a['submission']){const h=a['submission'];c['push']('─\x20C.\x20Submission\x20──────────────'),c['push']('Entries:\x20'+h['submissions']['length']+',\x20max\x20entry\x20size:\x20'+h['max_entry_size']+'/'+MAX_SUBMISSION_SIZE_PASSPORT+'\x20bytes\x20('+(h['size_ok']?'OK':'EXCEEDS')+')');for(const i of h['submissions']){c['push']('\x20\x20-\x20guard='+i['guard']+',\x20identifier='+i['identifier']+',\x20value_type='+i['value_type']+',\x20size='+i['estimated_size']);}c['push']('');}if(a['verify']){const j=a['verify'];c['push']('─\x20D.\x20Verify\x20──────────────'),c['push']('tx_hash\x20binding:\x20'+(j['tx_hash_binding']?'YES\x20(Move-level\x20hard-coded)':'NO')),c['push']('has_verified:\x20'+j['has_verified']),c['push']('Verify\x20flow\x20('+j['verify_flow']['length']+'\x20steps):');for(const k of j['verify_flow']){c['push']('\x20\x20'+k['step']+'.\x20'+k['action']+':\x20'+k['description']);}c['push']('');}if(a['result']){const m=a['result'];c['push']('─\x20E.\x20Result\x20──────────────'),c['push']('Decision\x20rule:\x20'+m['decision_rule']),c['push']('impack\x20Guards:\x20'+(m['impack_guards']['length']===0x0?'(none\x20—\x20will\x20fail\x20verify)':m['impack_guards']['join'](',\x20'))),c['push']('Overall\x20formula:\x20'+m['overall_formula']);if(m['per_guard_logic']['length']>0x0){c['push']('Per-Guard\x20logic:');for(const n of m['per_guard_logic']){c['push']('\x20\x20-\x20'+n['guard']+'\x20('+n['impack']+',\x20'+n['relies_logic']+'):\x20'+n['computation']);}}c['push']('');}if(a['lifecycle']){const o=a['lifecycle'];c['push']('─\x20F.\x20Lifecycle\x20──────────────'),c['push']('Terminal\x20state:\x20'+o['terminal_state']);for(const p of o['stages']){const q=p['completed']?'✓':'○';c['push']('\x20\x20'+q+'\x20'+p['stage']+':\x20'+p['description']);}c['push']('');}const d=validateConstraints(a);if(d['length']>0x0){c['push']('─\x20Constraint\x20Violations\x20──────────────');for(const t of d){c['push']('\x20\x20['+t['severity']+']\x20'+t['constraint_id']+':\x20'+t['message']);}c['push']('');}return c['join']('\x0a');}export function buildPassportPuzzle(a){const b=initPuzzleFromIntent(a['intent']),c=computeTopologicalOrder(a['binding']['guard_objects'],a['binding']['relies_dependencies']??a['binding']['guard_objects']['map'](()=>[]));b['binding']={'guard_objects':a['binding']['guard_objects'],'impack_flags':a['binding']['impack_flags'],'relies_dependencies':a['binding']['relies_dependencies']??a['binding']['guard_objects']['map'](()=>[]),'relies_logic':a['binding']['relies_logic']??a['binding']['guard_objects']['map'](()=>'AND'),'topological_order':c};const d=a['submission']['reduce']((e,f)=>Math['max'](e,f['estimated_size']),0x0);return b['submission']={'submissions':a['submission'],'max_entry_size':d,'size_ok':d<=MAX_SUBMISSION_SIZE_PASSPORT},b['result']=buildResultPuzzle(b['binding']),a['terminal_state']&&(b['lifecycle']['terminal_state']=a['terminal_state']),b;}function computeTopologicalOrder(a,b){const c=[],d=new Set();for(let e=0x0;e<a['length'];e++){const f=a[e],g=b[e]??[];for(const h of g){!d['has'](h)&&a['includes'](h)&&(c['push'](h),d['add'](h));}!d['has'](f)&&(c['push'](f),d['add'](f));}return c;}export const PASSPORT_PUZZLE_VERSION='1.0.0';