@wowok/agent-mcp 3.4.2 → 3.4.3

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 (308) hide show
  1. package/dist/.build-stamp.json +5 -0
  2. package/dist/chain-semantics/composition-truth.js +1 -1
  3. package/dist/chain-semantics/eval-order.js +1 -1
  4. package/dist/chain-semantics/field-capability.js +1 -1
  5. package/dist/chain-semantics/freeze-map.js +1 -1
  6. package/dist/chain-semantics/fund-flow.js +1 -1
  7. package/dist/chain-semantics/guard-verbs.js +1 -1
  8. package/dist/chain-semantics/object-graph.js +1 -1
  9. package/dist/composition/audit.js +1 -1
  10. package/dist/composition/compile.d.ts +10 -3
  11. package/dist/composition/compile.js +1 -1
  12. package/dist/composition/emit-phases.d.ts +30 -2
  13. package/dist/composition/emit-phases.js +1 -1
  14. package/dist/composition/guard-fill.d.ts +8 -0
  15. package/dist/composition/guard-fill.js +1 -1
  16. package/dist/composition/inflight.js +1 -1
  17. package/dist/composition/input-normalize.js +1 -1
  18. package/dist/composition/materialize.d.ts +2 -0
  19. package/dist/composition/materialize.js +1 -1
  20. package/dist/composition/mode-gates.js +1 -1
  21. package/dist/composition/param-disclosure.js +1 -1
  22. package/dist/composition/plan-retry-ledger.d.ts +16 -0
  23. package/dist/composition/plan-retry-ledger.js +1 -1
  24. package/dist/composition/plan.d.ts +15 -1
  25. package/dist/composition/plan.js +1 -1
  26. package/dist/config/config-audit.spec.js +1 -1
  27. package/dist/config/judgment.d.ts +5 -0
  28. package/dist/config/judgment.js +1 -1
  29. package/dist/evaluation/builtins/arbitration-score.d.ts +1 -0
  30. package/dist/evaluation/builtins/arbitration-score.js +1 -1
  31. package/dist/evaluation/builtins/demand-match.js +1 -1
  32. package/dist/evaluation/builtins/graph-service.d.ts +8 -0
  33. package/dist/evaluation/builtins/graph-service.js +1 -1
  34. package/dist/evaluation/capability.d.ts +9 -0
  35. package/dist/evaluation/engine.js +1 -1
  36. package/dist/evaluation/extract.d.ts +9 -1
  37. package/dist/evaluation/extract.js +1 -1
  38. package/dist/evaluation/match-operation.js +1 -1
  39. package/dist/evaluation/match-policy.d.ts +5 -3
  40. package/dist/evaluation/match-policy.js +1 -1
  41. package/dist/evaluation/standards.d.ts +1 -0
  42. package/dist/evaluation/standards.js +1 -1
  43. package/dist/evaluation/structured-lines.js +1 -1
  44. package/dist/evaluation/types.d.ts +1 -0
  45. package/dist/extensions/capability.js +1 -1
  46. package/dist/harness/recover.js +1 -1
  47. package/dist/index.js +1 -1
  48. package/dist/intent/types.d.ts +1 -1
  49. package/dist/intent/types.js +1 -1
  50. package/dist/knowledge/allocation-ledger.js +1 -1
  51. package/dist/knowledge/allocator-rail-verifier.d.ts +17 -1
  52. package/dist/knowledge/allocator-rail-verifier.js +1 -1
  53. package/dist/knowledge/arb-fund-facts.d.ts +7 -0
  54. package/dist/knowledge/arb-fund-facts.js +1 -1
  55. package/dist/knowledge/arbitration-rail-verifier.d.ts +35 -0
  56. package/dist/knowledge/arbitration-rail-verifier.js +1 -0
  57. package/dist/knowledge/audit-rules.d.ts +11 -0
  58. package/dist/knowledge/audit-rules.js +1 -1
  59. package/dist/knowledge/baselines/judgment-baselines.json +1 -0
  60. package/dist/knowledge/baselines/rules/guard.json +7 -6
  61. package/dist/knowledge/baselines/rules/progress.json +4 -4
  62. package/dist/knowledge/baselines/rules/reward.json +118 -3
  63. package/dist/knowledge/builtin-templates.d.ts +3 -2
  64. package/dist/knowledge/builtin-templates.js +1 -1
  65. package/dist/knowledge/chain-query-registry.d.ts +14 -0
  66. package/dist/knowledge/chain-query-registry.js +1 -0
  67. package/dist/knowledge/event-semantics.js +1 -1
  68. package/dist/knowledge/fee-param-bindings.d.ts +2 -0
  69. package/dist/knowledge/fee-param-bindings.js +1 -1
  70. package/dist/knowledge/getting-started.js +1 -1
  71. package/dist/knowledge/guard-binding-table.js +1 -1
  72. package/dist/knowledge/guard-binding-verifier.d.ts +7 -0
  73. package/dist/knowledge/guard-binding-verifier.js +1 -1
  74. package/dist/knowledge/guard-design-patterns.d.ts +1 -1
  75. package/dist/knowledge/guard-design-patterns.js +1 -1
  76. package/dist/knowledge/guard-host-context.js +1 -1
  77. package/dist/knowledge/guard-lint.js +1 -1
  78. package/dist/knowledge/guard-node-gates.d.ts +3 -1
  79. package/dist/knowledge/guard-node-gates.js +1 -1
  80. package/dist/knowledge/guard-puzzle.js +1 -1
  81. package/dist/knowledge/guard-render.js +1 -1
  82. package/dist/knowledge/guard-risk.js +1 -1
  83. package/dist/knowledge/guard-templates.d.ts +2 -1
  84. package/dist/knowledge/guard-templates.js +1 -1
  85. package/dist/knowledge/guard-translation.js +1 -1
  86. package/dist/knowledge/index.d.ts +2 -0
  87. package/dist/knowledge/index.js +1 -1
  88. package/dist/knowledge/industry-registry.js +1 -1
  89. package/dist/knowledge/jsonrpc-enum.js +1 -1
  90. package/dist/knowledge/knob-docs.js +1 -1
  91. package/dist/knowledge/param-schema.d.ts +1 -1
  92. package/dist/knowledge/param-schema.js +1 -1
  93. package/dist/knowledge/param-tiers.d.ts +2 -0
  94. package/dist/knowledge/param-tiers.js +1 -1
  95. package/dist/knowledge/path-oracle/products/food-delivery.js +1 -1
  96. package/dist/knowledge/pattern-resolutions.d.ts +2 -0
  97. package/dist/knowledge/pattern-resolutions.js +1 -1
  98. package/dist/knowledge/product-detail-source.d.ts +37 -0
  99. package/dist/knowledge/product-detail-source.js +1 -0
  100. package/dist/knowledge/product-doc-b5.d.ts +16 -0
  101. package/dist/knowledge/product-doc-b5.js +1 -0
  102. package/dist/knowledge/progress-ledger.js +1 -1
  103. package/dist/knowledge/projection.spec.js +1 -1
  104. package/dist/knowledge/publish-gate.d.ts +20 -0
  105. package/dist/knowledge/publish-gate.js +1 -0
  106. package/dist/knowledge/publish-readiness.d.ts +25 -0
  107. package/dist/knowledge/publish-readiness.js +1 -0
  108. package/dist/knowledge/publish-surface-contract.d.ts +16 -0
  109. package/dist/knowledge/publish-surface-contract.js +1 -0
  110. package/dist/knowledge/rail-exit-satisfiability.d.ts +25 -0
  111. package/dist/knowledge/rail-exit-satisfiability.js +1 -0
  112. package/dist/knowledge/reward-ledger.d.ts +1 -1
  113. package/dist/knowledge/reward-ledger.js +1 -1
  114. package/dist/knowledge/reward-risk.d.ts +1 -1
  115. package/dist/knowledge/reward-risk.js +1 -1
  116. package/dist/knowledge/service-ledger.d.ts +3 -1
  117. package/dist/knowledge/service-ledger.js +1 -1
  118. package/dist/knowledge/template-loader.d.ts +41 -2
  119. package/dist/knowledge/template-loader.js +1 -1
  120. package/dist/knowledge/template-registry.js +1 -1
  121. package/dist/knowledge/template-scanner.d.ts +17 -0
  122. package/dist/knowledge/template-scanner.js +1 -1
  123. package/dist/knowledge/workflow-guidance.d.ts +4 -0
  124. package/dist/knowledge/workflow-guidance.js +1 -1
  125. package/dist/monitor/MonitorLoop.js +1 -1
  126. package/dist/monitor/normalize.d.ts +1 -1
  127. package/dist/monitor/normalize.js +1 -1
  128. package/dist/monitor/types.js +1 -1
  129. package/dist/participation/game-context.js +1 -1
  130. package/dist/participation/radar-core.js +1 -1
  131. package/dist/playbooks/service-build/business-puzzle.js +1 -1
  132. package/dist/playbooks/service-build/machine-panorama.js +1 -1
  133. package/dist/playbooks/service-build/merchant-guide.d.ts +28 -3
  134. package/dist/playbooks/service-build/merchant-guide.js +1 -1
  135. package/dist/playbooks/service-build/object-panorama.d.ts +4 -0
  136. package/dist/playbooks/service-build/object-panorama.js +1 -1
  137. package/dist/playbooks/service-build/participation-radar.js +1 -1
  138. package/dist/playbooks/service-build/relationship-profile.js +1 -1
  139. package/dist/playbooks/service-build/service-panorama.js +1 -1
  140. package/dist/playbooks/service-build/service-quote.js +1 -1
  141. package/dist/review/index.js +1 -1
  142. package/dist/review/order.js +1 -1
  143. package/dist/safety/confirm-gate.js +1 -1
  144. package/dist/schema/benchmark-migration/index.d.ts +24 -0
  145. package/dist/schema/benchmark-migration/index.js +1 -1
  146. package/dist/schema/call/allocation.d.ts +11 -7
  147. package/dist/schema/call/allocation.js +1 -1
  148. package/dist/schema/call/arbitration.d.ts +4 -0
  149. package/dist/schema/call/arbitration.js +1 -1
  150. package/dist/schema/call/base.d.ts +28 -0
  151. package/dist/schema/call/base.js +1 -1
  152. package/dist/schema/call/bridge.d.ts +21 -0
  153. package/dist/schema/call/contact.d.ts +4 -0
  154. package/dist/schema/call/demand.d.ts +4 -0
  155. package/dist/schema/call/guard.d.ts +12 -0
  156. package/dist/schema/call/handler.d.ts +1 -0
  157. package/dist/schema/call/handler.js +1 -1
  158. package/dist/schema/call/machine.d.ts +16 -8
  159. package/dist/schema/call/normalize-error.d.ts +1 -0
  160. package/dist/schema/call/normalize-error.js +1 -0
  161. package/dist/schema/call/order.d.ts +7 -3
  162. package/dist/schema/call/order.js +1 -1
  163. package/dist/schema/call/payment.d.ts +7 -3
  164. package/dist/schema/call/permission.d.ts +4 -0
  165. package/dist/schema/call/personal.d.ts +4 -0
  166. package/dist/schema/call/progress.d.ts +4 -0
  167. package/dist/schema/call/progress.js +1 -1
  168. package/dist/schema/call/proof.d.ts +8 -0
  169. package/dist/schema/call/receipt.js +1 -1
  170. package/dist/schema/call/repository.d.ts +4 -0
  171. package/dist/schema/call/reward.d.ts +6 -2
  172. package/dist/schema/call/reward.js +1 -1
  173. package/dist/schema/call/semantic.d.ts +2 -2
  174. package/dist/schema/call/semantic.js +1 -1
  175. package/dist/schema/call/service.d.ts +6 -2
  176. package/dist/schema/call/treasury.d.ts +10 -6
  177. package/dist/schema/common/index.js +1 -1
  178. package/dist/schema/envelope-unify.d.ts +1 -0
  179. package/dist/schema/envelope-unify.js +1 -1
  180. package/dist/schema/evaluation/index.d.ts +43 -0
  181. package/dist/schema/evaluation/index.js +1 -1
  182. package/dist/schema/goal/index.d.ts +14 -2
  183. package/dist/schema/goal/planning.d.ts +18 -0
  184. package/dist/schema/goal/planning.js +1 -1
  185. package/dist/schema/intent-radar/index.d.ts +12 -0
  186. package/dist/schema/intent-radar/index.js +1 -1
  187. package/dist/schema/keeper/index.d.ts +1 -0
  188. package/dist/schema/local/index.d.ts +10 -0
  189. package/dist/schema/local/index.js +1 -1
  190. package/dist/schema/local/wip.js +1 -1
  191. package/dist/schema/messenger/index.d.ts +1 -0
  192. package/dist/schema/messenger/index.js +1 -1
  193. package/dist/schema/operations.d.ts +95 -12
  194. package/dist/schema/operations.js +1 -1
  195. package/dist/schema/persona/index.d.ts +22 -0
  196. package/dist/schema/query/bi.d.ts +28 -2
  197. package/dist/schema/query/bi.js +1 -1
  198. package/dist/schema/query/index.d.ts +67 -61
  199. package/dist/schema/query/index.js +1 -1
  200. package/dist/schema/schema-version.js +1 -1
  201. package/dist/schema/workflow/index.js +1 -1
  202. package/dist/schema-query-impl/index.d.ts +1 -0
  203. package/dist/schema-query-impl/index.js +1 -1
  204. package/dist/schemas/account_operation.output.json +2 -1
  205. package/dist/schemas/benchmark_migration_operation.output.json +74 -0
  206. package/dist/schemas/benchmark_migration_operation.schema.json +32 -0
  207. package/dist/schemas/bridge_operation.output.json +2 -1
  208. package/dist/schemas/bridge_operation.schema.json +40 -0
  209. package/dist/schemas/evaluation_operation.output.json +96 -0
  210. package/dist/schemas/evaluation_operation.schema.json +39 -0
  211. package/dist/schemas/goal_operation.schema.json +32 -0
  212. package/dist/schemas/guard2file.schema.json +8 -0
  213. package/dist/schemas/index.json +1 -1
  214. package/dist/schemas/intent_radar.output.json +10 -2
  215. package/dist/schemas/intent_radar.schema.json +5 -1
  216. package/dist/schemas/keeper_operation.output.json +2 -1
  217. package/dist/schemas/local_cache_operation.output.json +2 -1
  218. package/dist/schemas/local_history_operation.output.json +2 -1
  219. package/dist/schemas/local_info_operation.output.json +2 -1
  220. package/dist/schemas/local_mark_operation.output.json +2 -1
  221. package/dist/schemas/local_mark_operation.schema.json +10 -1
  222. package/dist/schemas/machineNode2file.schema.json +8 -0
  223. package/dist/schemas/messenger_operation.output.json +2 -1
  224. package/dist/schemas/messenger_operation.schema.json +2 -1
  225. package/dist/schemas/monitor_events.output.json +2 -1
  226. package/dist/schemas/monitor_subscription.output.json +2 -1
  227. package/dist/schemas/onchain_events.output.json +206 -13
  228. package/dist/schemas/onchain_events.schema.json +16 -0
  229. package/dist/schemas/onchain_operations.output.json +22 -3
  230. package/dist/schemas/onchain_operations.schema.json +971 -326
  231. package/dist/schemas/onchain_operations_allocation.schema.json +19 -12
  232. package/dist/schemas/onchain_operations_arbitration.schema.json +9 -1
  233. package/dist/schemas/onchain_operations_contact.schema.json +8 -0
  234. package/dist/schemas/onchain_operations_demand.schema.json +8 -0
  235. package/dist/schemas/onchain_operations_gen_passport.schema.json +8 -0
  236. package/dist/schemas/onchain_operations_gen_proof.schema.json +8 -0
  237. package/dist/schemas/onchain_operations_guard.schema.json +654 -114
  238. package/dist/schemas/onchain_operations_machine.schema.json +11 -3
  239. package/dist/schemas/onchain_operations_order.schema.json +14 -11
  240. package/dist/schemas/onchain_operations_payment.schema.json +12 -9
  241. package/dist/schemas/onchain_operations_permission.schema.json +8 -0
  242. package/dist/schemas/onchain_operations_personal.schema.json +8 -0
  243. package/dist/schemas/onchain_operations_progress.schema.json +9 -1
  244. package/dist/schemas/onchain_operations_proof.schema.json +8 -0
  245. package/dist/schemas/onchain_operations_repository.schema.json +8 -0
  246. package/dist/schemas/onchain_operations_reward.schema.json +14 -11
  247. package/dist/schemas/onchain_operations_service.schema.json +13 -10
  248. package/dist/schemas/onchain_operations_treasury.schema.json +17 -19
  249. package/dist/schemas/onchain_table_data.output.json +52 -10
  250. package/dist/schemas/persona_operation.output.json +57 -0
  251. package/dist/schemas/persona_operation.schema.json +9 -0
  252. package/dist/schemas/query_toolkit.output.json +325 -22
  253. package/dist/schemas/query_toolkit.schema.json +18 -5
  254. package/dist/schemas/wip_file.output.json +2 -2
  255. package/dist/schemas/wip_file.schema.json +2 -2
  256. package/dist/schemas/workflow_operation.schema.json +1 -1
  257. package/dist/tools/error-catalog.d.ts +17 -0
  258. package/dist/tools/error-catalog.js +1 -0
  259. package/dist/tools/handlers/benchmark-migration.d.ts +20 -8
  260. package/dist/tools/handlers/benchmark-migration.js +1 -1
  261. package/dist/tools/handlers/config.js +1 -1
  262. package/dist/tools/handlers/entry-edge-recipe.d.ts +101 -0
  263. package/dist/tools/handlers/entry-edge-recipe.js +1 -0
  264. package/dist/tools/handlers/escrow-deficit.d.ts +10 -0
  265. package/dist/tools/handlers/escrow-deficit.js +1 -0
  266. package/dist/tools/handlers/evaluation.js +1 -1
  267. package/dist/tools/handlers/fund-rail-recipe.d.ts +10 -0
  268. package/dist/tools/handlers/fund-rail-recipe.js +1 -0
  269. package/dist/tools/handlers/intent-radar.js +1 -1
  270. package/dist/tools/handlers/local.js +1 -1
  271. package/dist/tools/handlers/mark-namespace.d.ts +30 -0
  272. package/dist/tools/handlers/mark-namespace.js +1 -0
  273. package/dist/tools/handlers/messenger.js +1 -1
  274. package/dist/tools/handlers/onchain-name-registration.d.ts +1 -0
  275. package/dist/tools/handlers/onchain-name-registration.js +1 -1
  276. package/dist/tools/handlers/onchain-name-registration.spec.js +1 -1
  277. package/dist/tools/handlers/onchain.d.ts +30 -1
  278. package/dist/tools/handlers/onchain.js +1 -1
  279. package/dist/tools/handlers/publish-binding-echo.d.ts +22 -0
  280. package/dist/tools/handlers/publish-binding-echo.js +1 -0
  281. package/dist/tools/handlers/query.d.ts +1 -1
  282. package/dist/tools/handlers/query.js +1 -1
  283. package/dist/tools/handlers/review-chain.d.ts +1 -0
  284. package/dist/tools/handlers/review-chain.js +1 -1
  285. package/dist/tools/handlers/schema-query.js +1 -1
  286. package/dist/tools/handlers/stale-build-check.d.ts +9 -0
  287. package/dist/tools/handlers/stale-build-check.js +1 -0
  288. package/dist/tools/handlers/submission-assembly.d.ts +55 -0
  289. package/dist/tools/handlers/submission-assembly.js +1 -0
  290. package/dist/tools/handlers/wip.js +1 -1
  291. package/dist/tools/index.d.ts +1 -0
  292. package/dist/tools/index.js +1 -1
  293. package/dist/tools/move-fn-index.gen.js +1 -1
  294. package/dist/tools/publish-gate-state.d.ts +5 -0
  295. package/dist/tools/publish-gate-state.js +1 -0
  296. package/dist/tools/registry/business.js +1 -1
  297. package/dist/tools/registry/onchain.js +1 -1
  298. package/dist/tools/registry/query.js +1 -1
  299. package/dist/tools/retry.js +1 -1
  300. package/dist/tools/runtime-health.js +1 -1
  301. package/dist/tools/shared.js +1 -1
  302. package/dist/tools/upgrade-check.d.ts +1 -0
  303. package/dist/tools/upgrade-check.js +1 -1
  304. package/dist/tools/wip-verify-ledger.d.ts +2 -0
  305. package/dist/tools/wip-verify-ledger.js +1 -1
  306. package/dist/tools/wrap.d.ts +15 -1
  307. package/dist/tools/wrap.js +1 -1
  308. package/package.json +5 -3
@@ -1 +1 @@
1
- import{afterSalesRailRegex as a21a,afterSalesRailNodeMatches}from'../knowledge/template-scanner.js';import{TWO_TX_RENEW_RECIPE}from'../knowledge/protocol-facts.js';function emitAfterSalesGates(a,b){const c=[];if(a==='none')return c;const d=a21a(a),e=b['shape']['some'](f=>afterSalesRailNodeMatches(a,f['name']));return!e&&c['push']({'code':'AFTER_SALES_RAIL_MISSING','detail':'after_sales_mode\x20\x27'+a+'\x27\x20declares\x20a\x20buyer\x20after-sales\x20remedy,\x20but\x20machine_shape\x20has\x20no\x20'+('backing\x20rail\x20(no\x20node\x20matching\x20'+d+').\x20Add\x20the\x20'+a+'\x20node\x20family\x20')+'(e.g.\x20return_requested\x20->\x20returned\x20for\x20\x27return\x27)\x20as\x20a\x20node-gated\x20fund\x20rail\x20(decision\x2011:\x20NEVER\x20a\x20'+'claimed_by\x20leg\x20—\x20RAIL_CLAIMED_BY_LEG\x20critical)\x20anchored\x20on\x20the\x20delivered\x20ENTRY\x20time\x20'+'(INV-C2,\x20TIME-ANCHOR-01);\x20refund\x20and\x20award\x20are\x20independent\x20tracks\x20and\x20any\x20overlap\x20is\x20disclosed\x20'+'at\x20the\x20dual-payout\x20gate\x20(DUAL-RAIL-01).\x20Or\x20set\x20after_sales_mode\x20\x27none\x27\x20if\x20this\x20shop\x20ships\x20no\x20such\x20remedy.'}),c;}function emitAcceptanceGates(a,b){const c=[],d=[];if(a==='none')return{'blockers':c,'disclosures':d};const e=a==='contest'||a==='bounty'||a==='agent';e&&b['arbitrationMode']!=='third_party'&&c['push']({'code':'ACCEPTANCE_JUDGE_NOT_INDEPENDENT','detail':'acceptance_mode\x20\x27'+a+'\x27\x20is\x20a\x20judge-decided\x20acceptance\x20(a\x20third\x20party\x20rules\x20on\x20'+('release),\x20but\x20arbitration_mode\x20is\x20\x27'+(b['arbitrationMode']??'none')+'\x27,\x20not\x20\x27third_party\x27.\x20')+'The\x20party\x20owing\x20the\x20payout\x20must\x20not\x20also\x20decide\x20whether\x20it\x20is\x20owed\x20(merchant\x20self-adjudication,\x20'+'INV-A3).\x20Set\x20arbitration_mode\x20\x27third_party\x27\x20so\x20an\x20independent\x20venue/judge\x20Permission\x20rules\x20'+'(R2;\x20enforced\x20at\x20publish\x20by\x20controller-disjointness),\x20or\x20use\x20acceptance_mode\x20\x27milestone\x27\x20if\x20the\x20'+'buyer\x20genuinely\x20self-adjudicates.'});const f=b['feeParams']['revision_rounds_max'],g=typeof f==='number'||typeof f==='string'&&f['trim']()!==''&&/^\d+$/['test'](f['trim']());if(g){const h=b['guardSpecs']['some'](i=>i['host']==='repository'||/repository/i['test'](i['template_id']));!h&&c['push']({'code':'ACCEPTANCE_REVISION_UNBOUNDED','detail':'acceptance_mode\x20\x27'+a+'\x27\x20declares\x20a\x20bounded\x20revision\x20loop\x20'+('(fee_params.revision_rounds_max\x20=\x20'+String(f)+'),\x20but\x20no\x20counter-backed\x20Repository\x20')+'guard\x20exists.\x20The\x20chain\x20caps\x20EDGE\x20count\x20(MAX_FORWARD\x20/\x20MAX_NODE_PAIR),\x20never\x20VISIT\x20count,\x20'+'so\x20a\x20finite\x20cap\x20in\x20fee_params\x20alone\x20is\x20a\x20promise\x20the\x20chain\x20cannot\x20keep\x20(INV-A1).\x20Either\x20declare\x20'+'revision_rounds_max\x20\x27unlimited\x27\x20(the\x20honest\x20form\x20—\x20the\x20revision\x20loop\x20is\x20then\x20genuinely\x20'+'unbounded)\x20or\x20mount\x20a\x20counter-backed\x20Repository\x20guard\x20(pattern.repository_data_check\x20reading\x20a\x20'+'per-order\x20revision\x20tally\x20written\x20via\x20pattern.repository_write_authorization)\x20that\x20gates\x20the\x20'+'redelivery\x20forward\x20once\x20the\x20tally\x20reaches\x20the\x20cap.'});}if(a==='contest')d['push']('Winner\x20rule\x20(first-to-node):\x20the\x20winner\x20is\x20the\x20first\x20account\x20whose\x20forward\x20completes\x20entry\x20into\x20'+'the\x20adjudication\x20node\x20—\x20computable\x20from\x20the\x20order\x27s\x20Progress\x20history\x20(first\x20matching\x20entry,\x20earliest\x20'+'time);\x20ties\x20resolve\x20by\x20chain\x20timestamp.\x20This\x20rule\x20is\x20disclosed\x20for\x20judge/merchant\x20reference;\x20the\x20'+'chain\x20stores\x20no\x20winner\x20field\x20(F-RQD2-05).');else a==='bounty'&&d['push']('Winner\x20rule\x20(judge-accepted\x20triage):\x20winners\x20are\x20the\x20submitters\x20whose\x20reports\x20the\x20independent\x20judge\x20'+'accepts\x20(severity-ranked);\x20the\x20Progress\x20history\x20proves\x20who\x20delivered,\x20the\x20judge\x20permission\x20decides\x20'+'which\x20delivery\x20wins.');return{'blockers':c,'disclosures':d};}function emitInstallmentGates(a,b){const c=[];if(a==='none')return c;const d=/(due|owed|owing|unpaid|awaiting|pending)/i,f=/(paid|captured|funded|settled)/i,g=/(deposit|down_?pay|balance_due|balance_owed|awaiting|installment|milestone)/i,h=/(refund|cancel|exit|forfeit|kill|void|abandon|release|expire|lapse)/i,i=[];for(const l of b['shape']){const m=l['name'];for(const o of l['from']??[]){typeof o==='string'?i['push']({'prev':o,'target':m}):i['push']({'prev':o['prev'],'target':m,'guardKey':o['guard_key']});}}const j=i['filter'](p=>d['test'](p['prev'])&&f['test'](p['target'])&&(p['guardKey']===undefined||p['guardKey']['trim']()===''));j['length']>0x0&&c['push']({'code':'INSTALLMENT_FUNDING_UNGATED','detail':'installment_mode\x20\x27'+a+'\x27\x20captures\x20a\x20later\x20payment,\x20but\x20the\x20funding\x20forward(s)\x20'+j['map'](p=>'\x27'+p['prev']+'\x27\x20→\x20\x27'+p['target']+'\x27')['join'](',\x20')+'\x20carry\x20NO\x20guard_key.\x20A\x20bare\x20advance\x20records\x20the\x20balance\x20as\x20paid\x20WITHOUT\x20the\x20capture\x20landing\x20in\x20the\x20'+'Allocation\x20—\x20a\x20zero-value\x20advance\x20(INV-B1,\x20H4).\x20Bind\x20a\x20fund-gate\x20Guard\x20on\x20each\x20capture\x20forward\x20'+'(constant\x20=\x20order\x20address,\x20convert_witness\x20OrderAllocation(109),\x20allocation.balance\x20query\x201051\x20>=\x20the\x20'+'capture\x20amount).\x20PRE-STATE\x20CONSTRAINT\x20(esound-mn-261021\x20B-1,\x20mainnet-verified):\x20guards\x20read\x20the\x20'+'COMMITTED\x20pre-transaction\x20balance\x20—\x20funding\x20that\x20lands\x20in\x20the\x20SAME\x20PTB\x20(the\x20one-PTB\x20order_renew\x20'+'payment\x20half)\x20is\x20INVISIBLE\x20to\x20the\x20forward\x27s\x20guard,\x20so\x20a\x20balance-gated\x20capture\x20advanced\x20by\x20'+('order_renew\x20ALWAYS\x20aborts.\x20'+TWO_TX_RENEW_RECIPE+'\x20Pair\x20the\x20balance\x20gate\x20with\x20the\x20once\x20slot\x20')+'(H5\x20—\x20the\x20fund\x20gate\x20is\x20a\x20STATE\x20READ,\x20not\x20a\x20once)\x20so\x20a\x20replay\x20cannot\x20re-capture.'});const k=[];for(const p of b['shape']){if(!g['test'](p['name']))continue;const q=i['filter'](s=>s['prev']===p['name']),r=q['some'](s=>h['test'](s['target']));if(!r)k['push'](p['name']);}return k['length']>0x0&&c['push']({'code':'INSTALLMENT_DEPOSIT_STRANDED','detail':'installment_mode\x20\x27'+a+'\x27\x20holds\x20a\x20buyer\x20payment\x20at\x20state(s)\x20'+k['map'](t=>'\x27'+t+'\x27')['join'](',\x20')+'\x20with\x20NO\x20deposit-exit\x20rail\x20(no\x20outgoing\x20refund\x20/\x20cancel\x20/\x20forfeit\x20/\x20expire\x20edge).\x20There\x20is\x20no\x20on-chain\x20'+'obligation\x20to\x20pay\x20the\x20balance\x20(INV-B2,\x20H1),\x20so\x20a\x20buyer\x20who\x20walks\x20away\x20strands\x20the\x20already-paid\x20portion\x20'+'at\x20that\x20node\x20permanently\x20(Machine\x20+\x20Allocator\x20immutable,\x20IMMUT-001).\x20Add\x20a\x20deposit-exit\x20rail\x20from\x20each\x20'+'held\x20state\x20—\x20a\x20refund/cancel\x20forward\x20into\x20an\x20exit\x20node\x20whose\x20allocator\x20returns\x20the\x20held\x20funds\x20to\x20the\x20'+'order\x20payer\x20(GuardIdentifier(0))\x20or\x20applies\x20the\x20declared\x20deposit_exit_policy\x20(full\x20refund\x20vs\x20a\x20kill\x20fee\x20'+'compensating\x20the\x20merchant\x20for\x20the\x20reserved\x20capacity).'}),c;}function emitAffiliateGates(a,b){const c=[];if(a==='none')return c;const d=/(commission|affiliate|referr|attribut|partner_?payout)/i,e=b['shape']['some'](i=>d['test'](i['name'])),f=b['rows']['some'](i=>d['test'](i['value_from']??'')||d['test'](i['recipient_key']??''));!e&&!f&&c['push']({'code':'AFFILIATE_RAIL_MISSING','detail':'affiliate_mode\x20\x27'+a+'\x27\x20declares\x20a\x20referral/affiliate\x20commission\x20overlay,\x20but\x20machine_shape\x20has\x20no\x20'+'commission-family\x20node\x20and\x20the\x20allocator\x20has\x20no\x20commission\x20row\x20—\x20a\x20declared\x20partner\x20payout\x20with\x20no\x20rail\x20to\x20'+'walk\x20it\x20is\x20a\x20false\x20promise\x20at\x20quote\x20time\x20(INV-D3).\x20Add\x20an\x20INDEPENDENT\x20commission\x20leg:\x20a\x20Rate\x20row\x20off\x20a\x20'+'dedicated\x20commission\x20pool\x20(never\x20a\x20Surplus/Rate\x20drain\x20of\x20the\x20buyer\x27s\x20goods\x20escrow\x20—\x20anti-grab-pool)\x20to\x20an\x20explicit\x20'+'non-empty\x20partner\x20Entity,\x20gated\x20by\x20a\x20window-anchored\x20claim\x20guard\x20(INV-D1\x20rides\x20TIME-ANCHOR-01)\x20so\x20the\x20'+'commission\x20is\x20claimable\x20only\x20after\x20the\x20attribution/refund\x20window\x20closes.'});const g=/(post-?lock|clawback|unrecoverable|irrevocab|no\s*(?:revers|recov|clawback)|cannot be reversed|once released|released commission)/i,h=b['buildNotes']['some'](i=>g['test'](i));return!h&&c['push']({'code':'AFFILIATE_CLAWBACK_UNDISCLOSED','detail':'affiliate_mode\x20\x27'+a+'\x27\x20declares\x20a\x20commission\x20but\x20no\x20build_note\x20discloses\x20the\x20post-lock\x20no-clawback\x20'+'truth\x20(INV-D2).\x20SOLE\x20TRUTH:\x20Allocation\x20distribute\x20is\x20a\x20ONE-WAY\x20outflow\x20(no\x20debit/clawback\x20primitive,\x20§11.0\x20G2),\x20'+'so\x20once\x20a\x20commission\x20is\x20RELEASED\x20it\x20CANNOT\x20be\x20reversed\x20on\x20chain\x20—\x20a\x20refund/chargeback\x20after\x20release\x20leaves\x20the\x20'+'affiliate\x20commission\x20unrecoverable.\x20Add\x20a\x20build_note\x20stating\x20this\x20honestly\x20(e.g.\x20\x22post-lock:\x20a\x20released\x20'+'affiliate\x20commission\x20is\x20unrecoverable\x20—\x20refunds\x20after\x20the\x20attribution\x20window\x20do\x20NOT\x20claw\x20back\x20the\x20'+'partner\x20payout\x22).\x20L-04/D-5:\x20never\x20imply\x20a\x20recovery\x20capability\x20the\x20chain\x20does\x20not\x20have.'}),c;}function emitCrowdfundingGates(a,b){const c=[];if(a==='none')return c;const d=/(releas|settle|funded|disburs|project)/i,e=/(refund|missed|unmet|return|reimburse)/i,f=b['shape']['some'](s=>d['test'](s['name'])),g=b['rows']['some'](s=>s['track']==='settlement'&&(d['test'](s['guard_key']??'')||d['test'](s['recipient_key']??''))),h=b['shape']['some'](s=>e['test'](s['name'])),i=b['rows']['some'](s=>s['track']==='refund'||e['test'](s['guard_key']??''));!f&&!g&&c['push']({'code':'CROWDFUNDING_THRESHOLD_GATE_MISSING','detail':'crowdfunding_mode\x20\x27'+a+'\x27\x20declares\x20a\x20campaign\x20but\x20machine_shape\x20has\x20no\x20release/settlement\x20'+'node\x20and\x20the\x20allocator\x20has\x20no\x20settlement\x20row\x20to\x20the\x20project\x20Entity\x20—\x20the\x20escrowed\x20contributions\x20would\x20'+'strand\x20at\x20the\x20deadline\x20with\x20no\x20exit\x20rail\x20(INV-E1).\x20Add\x20a\x20release\x20leg\x20(Rate\x2010000\x20to\x20a\x20NON-EMPTY\x20project\x20'+'Entity,\x20gated\x20at\x20the\x20campaign-deadline\x20settlement\x20terminal)\x20and,\x20for\x20a\x20threshold\x20campaign,\x20its\x20D-BUG-2\x20'+'refund\x20twin.'});a==='threshold'&&!h&&!i&&c['push']({'code':'CROWDFUNDING_THRESHOLD_GATE_MISSING','detail':'crowdfunding_mode\x20\x27threshold\x27\x20declares\x20an\x20all-or-nothing\x20campaign\x20but\x20there\x20is\x20NO\x20refund-family\x20node/row\x20—\x20'+'a\x20missed\x20goal\x20would\x20strand\x20every\x20contribution\x20instead\x20of\x20returning\x20it\x20(INV-E1\x20/\x20D-BUG-2).\x20Add\x20the\x20refund\x20'+'leg\x20(per-contributor,\x20order-anchored\x20user\x20slot\x200\x20—\x20the\x20submitted\x20Order,\x20never\x20slot\x20254;\x20node-gated\x20at\x20the\x20'+'refund\x20terminal,\x20decision\x2011\x20—\x20never\x20a\x20claimed_by\x20leg)\x20as\x20the\x20mutually-exclusive\x20twin\x20of\x20the\x20'+'release\x20leg:\x20aggregate\x20>=\x20goal\x20→\x20release;\x20aggregate\x20<\x20goal\x20→\x20refund.'});if(a==='threshold'){const s=b['guardSpecs']['filter'](x=>x['host']==='repository'||/repository_write/i['test'](x['template_id'])),t=s['length']>0x0,u=s['some'](x=>{const y=(x['policy']?.['id_from']??'')['toLowerCase']();return y==='signer'||y==='clock';});if(!t)c['push']({'code':'CROWDFUNDING_AGGREGATE_UNBOUND','detail':'crowdfunding_mode\x20\x27threshold\x27\x20gates\x20release\x20on\x20an\x20aggregate\x20funding\x20total,\x20but\x20no\x20host:\x22repository\x22\x20'+'write\x20policy\x20declares\x20the\x20contribution\x20rows\x20—\x20with\x20no\x20write-bound\x20policy\x20the\x20total\x20is\x20forgeable,\x20so\x20'+'anyone\x20could\x20inflate\x20the\x20aggregate\x20and\x20fake\x20a\x20\x27goal\x20met\x27\x20(INV-E2\x20/\x20R-X1-17:\x20existence-is-not-trust).\x20'+'Mount\x20pattern.repository_write_authorization\x20(identity\x20leaf\x20order.owner==Signer\x20/\x20order.agent\x20has\x20Signer)\x20'+'and\x20key\x20the\x20contribution\x20rows\x20by\x20the\x20funder\x27s\x20ORDER\x20(policy\x20id_from\x20unset;\x20row\x20id\x20=\x20the\x20Order\x20address).'});else{if(u){const x=s['filter'](y=>{const z=(y['policy']?.['id_from']??'')['toLowerCase']();return z==='signer'||z==='clock';})['map'](y=>'\x27'+y['key']+'\x27');c['push']({'code':'CROWDFUNDING_SIGNER_KEYED_ROWS','detail':'crowdfunding_mode\x20\x27threshold\x27\x20gates\x20release\x20on\x20an\x20aggregate\x20funding\x20total,\x20but\x20the\x20contribution\x20'+('policy\x20'+x['join'](',\x20')+'\x20keys\x20rows\x20by\x20the\x20WALLET\x20(id_from\x20signer/clock)\x20—\x20the\x20OLD\x20pre-migration\x20')+'shape\x20(ksc-tn-261024\x20F-01/F-05).\x20Wallet-keyed\x20rows\x20feed\x20the\x20escrow-bound\x20sum\x20(query\x201179,\x20per-row\x20'+'min(row,\x20order.amount,\x20LIVE\x20allocation.balance))\x20ZERO\x20—\x20the\x20goal\x20gate\x20silently\x20bricks\x20—\x20and\x20the\x20free-form\x20sum-where\x20(1174)\x20stays\x20'+'self-reported,\x20so\x20a\x20backer\x20can\x20still\x20record\x201.0\x20for\x20a\x200.1\x20pledge.\x20Key\x20the\x20rows\x20by\x20the\x20funder\x27s\x20ORDER\x20'+'instead\x20(policy\x20id_from\x20unset;\x20the\x20backer\x27s\x20tooling\x20submits\x20the\x20row\x20id\x20=\x20their\x20Order\x20address\x20through\x20'+'the\x20passport-bearing\x20data\x20write),\x20pass\x20those\x20ORDER\x20addresses\x20as\x20the\x20aggregate\x27s\x20candidate\x20ids,\x20and\x20pair\x20the\x20gate\x20'+'with\x20the\x20live-escrow\x20leg\x20(allocation.balance\x20query\x201051\x20via\x20convert_witness\x20OrderAllocation\x20109,\x20'+'>=\x20order.amount)\x20so\x20a\x20refunded/never-funded\x20order\x20can\x20neither\x20count\x20toward\x20the\x20goal\x20nor\x20be\x20settled.'});}}const v=b['inputs']['campaign_deadline_ms']??b['feeParams']?.['campaign_deadline_ms'],w=typeof v==='number'?v:Number(v);if(b['buildTimeMs']!==undefined){if(!Number['isFinite'](w)||w<=0x0)c['push']({'code':'CROWDFUNDING_DEADLINE_UNSET','detail':'crowdfunding_mode\x20\x27threshold\x27\x20gates\x20release/refund/withdrawal\x20on\x20the\x20ABSOLUTE\x20shared\x20deadline\x20'+('(campaign_deadline_ms),\x20but\x20it\x20resolved\x20to\x20'+String(v)+'\x20even\x20though\x20this\x20build\x20knows\x20its\x20')+'instant\x20—\x20an\x20unresolved\x20zero\x20opens\x20the\x20deadline\x20gate\x20at\x20genesis:\x20the\x20pre-deadline\x20withdrawal\x20exit\x20is\x20'+'dead\x20on\x20arrival\x20and\x20the\x20threshold/refund\x20polarity\x20is\x20resolvable\x20at\x20block\x20one\x20(ktt5\x20T-20).\x20Pass\x20a\x20real\x20'+'future\x20epoch-ms\x20timestamp\x20via\x20inputs.campaign_deadline_ms,\x20or\x20a\x20length\x20via\x20'+'inputs.campaign_duration_days\x20for\x20the\x20generation-time\x20conversion.'});else{if(w<=b['buildTimeMs'])c['push']({'code':'CROWDFUNDING_DEADLINE_PAST','detail':'campaign_deadline_ms\x20('+w+')\x20is\x20not\x20after\x20this\x20build\x27s\x20instant\x20('+b['buildTimeMs']+')\x20—\x20'+'the\x20shared\x20deadline\x20is\x20ALREADY\x20EXPIRED\x20at\x20publish:\x20the\x20pre-deadline\x20WithdrawPledge\x20exit\x20is\x20dead\x20on\x20'+'arrival\x20and\x20the\x20threshold/refund\x20polarity\x20is\x20resolvable\x20at\x20block\x20one\x20(the\x20live\x20ktt5\x20run\x20set\x20the\x20'+'deadline\x20before\x20the\x20first\x20order\x20and\x20could\x20never\x20test\x20a\x20mid-round\x20withdrawal,\x20T-20).\x20Pass\x20a\x20future\x20'+'epoch-ms\x20timestamp\x20(build\x20instant\x20+\x20campaign_duration_days\x20is\x20the\x20sanctioned\x20conversion).'});else b['buildTimeMs']+0xa*0xea60-w>0x0&&c['push']({'code':'CROWDFUNDING_DEADLINE_IMMINENT','detail':'campaign_deadline_ms\x20('+w+')\x20is\x20less\x20than\x2010\x20minutes\x20after\x20this\x20build\x27s\x20instant\x20'+('('+b['buildTimeMs']+')\x20—\x20the\x20round\x20is\x20effectively\x20expired\x20by\x20the\x20time\x20ANY\x20buyer\x20sees\x20the\x20')+'listing\x20(pdd\x20F-09\x20min-lead).\x20Give\x20the\x20campaign\x20a\x20real\x20lead\x20window:\x20build\x20instant\x20+\x20'+'campaign_duration_days\x20/\x20campaign_duration_hours\x20(hours\x20for\x20short\x20pop-up\x20rounds,\x20minimum\x20'+'sanctioned\x20length\x2010\x20minutes)\x20or\x20a\x20further-out\x20absolute\x20timestamp.'});}}}const j=b['buildNotes'],k=/(attest|keeper|aggregate trust|read-?only sum|not a chain-?verified|independent recomputation)/i,l=/(not investment|non-?investment|no (?:investment )?return|never promise)/i,m=/(kyc|aml|securities|money-?transmission|regulatory|cross-border|compliance)/i,n=/(no-?refund|non-?refundable|keep-?it-?all)/i,o=j['some'](y=>l['test'](y)),p=j['some'](y=>m['test'](y)),q=a==='threshold'?j['some'](y=>k['test'](y)):!![],r=a==='flexible'?j['some'](y=>n['test'](y)):!![];if(!q||!o||!p||!r){const y=[!q?'the\x20aggregate-trust\x20boundary\x20(the\x20funding\x20total\x20is\x20a\x20keeper-attested\x20Repository\x20sum,\x20NOT\x20a\x20chain-verified\x20money\x20oracle)':null,!o?'the\x20L-01\x20non-investment\x20statement\x20(never\x20promise\x20returns\x20/\x20promote\x20coin\x20price;\x20not\x20investment\x20advice\x20or\x20a\x20return\x20promise)':null,!p?'the\x20L-05\x20KYC/AML\x20+\x20cross-border\x20regulatory\x20caution\x20(HIGH\x20intensity)':null,!r?'the\x20flexible\x20keep-it-all\x20NO-REFUND\x20posture\x20(contributions\x20non-refundable\x20once\x20the\x20deadline\x20passes;\x20no\x20refunds)':null]['filter'](Boolean);c['push']({'code':'CROWDFUNDING_DISCLOSURE_MISSING','detail':'crowdfunding_mode\x20\x27'+a+'\x27\x20declares\x20a\x20campaign\x20but\x20no\x20build_note\x20carries:\x20'+y['join'](';\x20')+'\x20'+'(INV-E3\x20/\x20L-04\x20/\x20L-01\x20/\x20L-05).\x20Add\x20these\x20as\x20honest\x20build_notes\x20—\x20never\x20present\x20an\x20attested\x20aggregate\x20as\x20a\x20'+'chain-verified\x20custody\x20proof,\x20never\x20imply\x20investment\x20returns,\x20and\x20flag\x20the\x20compliance\x20surface.'});}return c;}function emitLogisticsGates(a,b){const c=[];if(a==='none')return c;const d=b['shape'],e=d['some'](g=>g['named_operator']!==undefined||(g['from']??[])['some'](h=>h['named_operator']!==undefined));a==='courier'&&!e&&c['push']({'code':'LOGISTICS_COURIER_RAIL_MISSING','detail':'logistics_mode\x20\x27courier\x27\x20declares\x20per-order\x20dispatched\x20riders,\x20but\x20machine_shape\x20carries\x20NO\x20named_operator\x20'+'rail.\x20A\x20dispatched\x20rider\x20is\x20NEITHER\x20a\x20permission\x20entity\x20NOR\x20the\x20buyer\x20—\x20the\x20ONLY\x20forward\x20they\x20can\x20ever\x20'+'pass\x20is\x20a\x20namedOperator\x20roster\x20rail\x20(the\x20rider\x20namespace\x27s\x20per-order\x20roster,\x20written\x20by\x20the\x20dispatch\x20'+'keeper\x20via\x20permission\x20index\x20221;\x20K-1\x20batch\x20B).\x20Bind\x20the\x20handover\x20forwards\x20(merchant→courier\x20pickup,\x20'+'courier→buyer\x20drop-off)\x20with\x20named_operator\x20\x27<namespace>\x27\x20—\x20and\x20disclose\x20the\x20roster\x20duty\x20in\x20a\x20build_note\x20'+'(the\x20NAMED_OPERATOR_ROSTER_UNDISCLOSED\x20gate\x20and\x20the\x20G6\x20dispatch\x20disclosure\x20below\x20enforce\x20the\x20rest).'});const f=/(deliver|courier|shipping|freight|ride|dispatch|logistic)/i;if(a==='courier'){const g=b['rows']['find'](h=>h['mode']==='surplus'&&f['test']((h['value_from']??'')+'\x20'+(h['recipient_key']??'')));g!==undefined&&c['push']({'code':'LOGISTICS_COURIER_FEE_POOLED','detail':'logistics_mode\x20\x27courier\x27\x20has\x20a\x20delivery-fee\x20allocator\x20row\x20in\x20SURPLUS\x20mode\x20'+('(value_from/recipient_key\x20\x27'+(g['value_from']??g['recipient_key']??'')+'\x27)\x20—\x20a\x20surplus\x20leg\x20')+'drains\x20the\x20remainder\x20of\x20the\x20pool\x20it\x20hangs\x20on,\x20which\x20for\x20a\x20courier\x20build\x20IS\x20the\x20buyer\x27s\x20goods\x20escrow\x20'+'(the\x20grab-pool\x20shape\x20the\x20affiliate\x20INV-D3\x20family\x20bans).\x20The\x20delivery\x20fee\x20is\x20KNOWN\x20at\x20order\x20time\x20—\x20the\x20'+'buyer\x20sees\x20and\x20pays\x20it\x20before\x20dispatch\x20—\x20so\x20make\x20it\x20an\x20INDEPENDENT\x20leg:\x20a\x20fixed\x20Amount\x20row\x20(or\x20a\x20Rate\x20'+'row\x20off\x20a\x20dedicated\x20delivery-fee\x20pool\x20funded\x20separately),\x20never\x20a\x20Surplus/Rate\x20drain\x20of\x20the\x20goods\x20pool.'});}if(a==='pickup_point'){const h=b['guardSpecs']['some'](j=>j['template_id']==='pattern.time_lock_absolute'||j['template_id']==='tpl_time_lock_absolute_ms'),i=b['guardSpecs']['some'](j=>j['template_id']==='pattern.time_window_upper_bound'||j['template_id']==='tpl_time_window_upper'||j['template_id']==='tpl_time_window_upper_absolute_ms');(!h||!i)&&c['push']({'code':'LOGISTICS_PICKUP_CUTOFF_MISSING','detail':'logistics_mode\x20\x27pickup_point\x27\x20declares\x20batch\x20consolidation,\x20but\x20the\x20shape\x20is\x20missing\x20'+(''+(!h?'the\x20ABSOLUTE\x20batch-cutoff\x20release\x20gate\x20(pattern.time_lock_absolute\x20—\x20every\x20funder\x27s/leader\x27s\x20release\x20anchors\x20on\x20the\x20SAME\x20shared\x20cutoff\x20clock,\x20not\x20per-order\x20entry+duration)':''))+(''+(!h&&!i?'\x20and\x20':''))+(''+(!i?'the\x20unclaimed-goods\x20exit\x20window\x20(pattern.time_window_upper_bound\x20—\x20goods\x20never\x20picked\x20up\x20must\x20refund/return\x20at\x20a\x20bounded\x20deadline,\x20never\x20hold\x20open-ended)':''))+'.\x20Both\x20are\x20mandatory:\x20without\x20the\x20shared\x20cutoff\x20the\x20batch\x20is\x20not\x20a\x20batch\x20(each\x20order\x20releases\x20on\x20its\x20own\x20clock),\x20and\x20without\x20the\x20exit\x20window\x20an\x20unclaimed\x20parcel\x20strands\x20in\x20the\x20pickup\x20point\x20forever.'});}if(a==='carrier'){const j=/(track|shipping evidence|waybill|airbill|carrier record|parcel evidence)/i,k=b['guardSpecs']['some'](l=>l['host']==='machine'&&j['test'](l['key']+'\x20'+l['purpose']));!k&&c['push']({'code':'LOGISTICS_CARRIER_EVIDENCE_MISSING','detail':'logistics_mode\x20\x27carrier\x27\x20declares\x20third-party\x20carrier\x20shipment,\x20but\x20NO\x20machine\x20guard\x20binds\x20'+'shipping/tracking\x20evidence.\x20Add\x20a\x20repository_data_check\x20guard\x20on\x20the\x20ship\x20forward\x20keyed\x20to\x20a\x20'+'tracking-hash\x20row\x20(the\x20retail\x20idiom:\x20the\x20evidence\x20Repository\x20row\x20is\x20written\x20by\x20an\x20authorized\x20'+'writer\x20—\x20pattern.repository_write_authorization\x20—\x20and\x20the\x20ship\x20guard\x20reads\x20it),\x20so\x20a\x20dispute\x20has\x20a\x20'+'dispute-ready\x20record\x20of\x20what\x20was\x20shipped\x20and\x20when.'});}{const l=/(lost|loss|damag|theft)/i,m=q=>q['replace'](/permanently lost/gi,''),n=/(transit loss|lost (?:parcel|package|goods|in transit)|in[- ]transit loss|carrier lost|loss (?:is |)remed|loss route|lost shipment)/i,o=d['some'](q=>l['test'](q['name'])||l['test'](q['role']??''))||b['guardSpecs']['some'](q=>q['host']==='machine'&&l['test'](m(q['key']+'\x20'+q['purpose']))),p=b['buildNotes']['some'](q=>n['test'](q));!o&&!p&&c['push']({'code':'LOGISTICS_TRANSIT_LOSS_UNCOVERED','detail':'logistics_mode\x20\x27'+a+'\x27\x20moves\x20a\x20physical\x20good,\x20but\x20the\x20shape\x20has\x20NO\x20in-transit\x20loss\x20rail\x20'+'(no\x20loss/damage\x20node\x20or\x20machine-guard\x20family)\x20and\x20NO\x20build_note\x20disclosing\x20the\x20loss\x20remedy.\x20Goods\x20can\x20'+'be\x20lost\x20or\x20damaged\x20between\x20handover\x20and\x20acceptance\x20in\x20EVERY\x20physical\x20mode\x20—\x20silence\x20means\x20the\x20buyer\x27s\x20'+'funds\x20strand\x20behind\x20an\x20undeliverable\x20order\x20with\x20no\x20taught\x20route.\x20Either\x20express\x20the\x20loss\x20waypoint\x20(a\x20'+'node\x20like\x20the\x20retail\x20lost-parcel\x20record,\x20or\x20a\x20loss-evidence\x20machine\x20guard)\x20or\x20add\x20a\x20build_note\x20'+'disclosing\x20the\x20remedy\x20route\x20(e.g.\x20\x22transit\x20loss\x20is\x20remedied\x20by\x20the\x20buyer\x27s\x20arbitration\x20route\x20into\x20the\x20'+'refund\x20rail\x20—\x20the\x20ruling\x20pays\x20the\x20buyer;\x20the\x20carrier\x20claim\x20is\x20an\x20off-chain\x20recovery,\x20disclosed\x20as\x20such\x22).'});}if(a==='courier'||a==='pickup_point'){const q=/(dispatch|schedul|no.{0,24}oracle|no on-chain.{0,24}(dispatch|scheduler)|off-chain keeper|keeper.{0,40}dispatch|roster|named.?operator|permission.{0,12}221)/i,r=b['buildNotes']['some'](s=>q['test'](s));!r&&c['push']({'code':'LOGISTICS_DISPATCH_UNDISCLOSED','detail':'logistics_mode\x20\x27'+a+'\x27\x20is\x20a\x20dynamically\x20dispatched\x20fulfillment\x20topology,\x20but\x20no\x20build_note\x20'+'discloses\x20the\x20two\x20🔴\x20SOLE-TRUTH\x20boundaries.\x20①\x20The\x20chain\x20has\x20NO\x20dispatch/scheduling\x20primitive\x20—\x20'+'assignment\x20of\x20riders/pickup\x20batches\x20is\x20an\x20OFF-CHAIN\x20keeper\x20duty\x20(K-4);\x20its\x20only\x20chain\x20footprint\x20is\x20the\x20'+'namedOperator\x20roster\x20written\x20via\x20permission\x20index\x20221.\x20②\x20There\x20is\x20NO\x20distance/weight/weather\x20oracle\x20—\x20'+'ETA,\x20route,\x20and\x20dynamic\x20pricing\x20are\x20NOT\x20chain-verifiable.\x20Add\x20a\x20build_note\x20stating\x20WHO\x20dispatches\x20(the\x20'+'keeper),\x20WHAT\x20the\x20keeper\x20writes\x20(the\x20roster,\x20per\x20order/shift),\x20and\x20that\x20ETA/pricing\x20live\x20off-chain.'});}return c;}export function emitModeGates(a,b){const c=emitAfterSalesGates(a['afterSalesMode'],b),d=emitAcceptanceGates(a['acceptanceMode'],b);return{'blockers':[...c,...d['blockers'],...emitInstallmentGates(a['installmentMode'],b),...emitAffiliateGates(a['affiliateMode'],b),...emitCrowdfundingGates(a['crowdfundingMode'],b),...emitLogisticsGates(a['logisticsMode'],b)],'disclosures':[...d['disclosures']]};}export function deriveCapabilityModes({template:a,inputs:b}){const c=b['after_sales_mode'],d=c==='return'||c==='exchange'||c==='warranty'||c==='none'?c:undefined,e=d??a['after_sales_mode']??'none',f=b['acceptance_mode'],g=f==='milestone'||f==='contest'||f==='bounty'||f==='agent'||f==='none'?f:undefined,h=g??a['acceptance_mode']??'none',i=b['installment_mode'],j=i==='deposit_balance'||i==='milestone_n'||i==='none'?i:undefined,k=j??a['installment_mode']??'none',l=b['affiliate_mode'],m=l==='commission'||l==='none'?l:undefined,n=m??a['affiliate_mode']??'none',o=b['crowdfunding_mode'],p=o==='threshold'||o==='flexible'||o==='none'?o:undefined,q=p??a['crowdfunding_mode']??'none',r=b['logistics_mode'],s=r==='carrier'||r==='merchant_managed'||r==='courier'||r==='pickup_point'||r==='none'?r:undefined,t=s??a['logistics_mode']??'none';return{'afterSalesMode':e,'acceptanceMode':h,'installmentMode':k,'affiliateMode':n,'crowdfundingMode':q,'logisticsMode':t};}
1
+ import{afterSalesRailRegex as a21a,afterSalesRailNodeMatches}from'../knowledge/template-scanner.js';import{TWO_TX_RENEW_RECIPE}from'../knowledge/protocol-facts.js';function emitAfterSalesGates(a,b){const c=[];if(a==='none')return c;const d=a21a(a),e=b['shape']['some'](f=>afterSalesRailNodeMatches(a,f['name']));return!e&&c['push']({'code':'AFTER_SALES_RAIL_MISSING','detail':'after_sales_mode\x20\x27'+a+'\x27\x20declares\x20a\x20buyer\x20after-sales\x20remedy,\x20but\x20machine_shape\x20has\x20no\x20'+('backing\x20rail\x20(no\x20node\x20matching\x20'+d+').\x20Add\x20the\x20'+a+'\x20node\x20family\x20')+'(e.g.\x20return_requested\x20->\x20returned\x20for\x20\x27return\x27)\x20as\x20a\x20node-gated\x20fund\x20rail\x20(decision\x2011:\x20NEVER\x20a\x20'+'claimed_by\x20leg\x20—\x20RAIL_CLAIMED_BY_LEG\x20critical)\x20anchored\x20on\x20the\x20delivered\x20ENTRY\x20time\x20'+'(INV-C2,\x20TIME-ANCHOR-01);\x20refund\x20and\x20award\x20are\x20independent\x20tracks\x20and\x20any\x20overlap\x20is\x20disclosed\x20'+'at\x20the\x20dual-payout\x20gate\x20(DUAL-RAIL-01).\x20Or\x20set\x20after_sales_mode\x20\x27none\x27\x20if\x20this\x20shop\x20ships\x20no\x20such\x20remedy.'}),c;}function emitAcceptanceGates(a,b){const c=[],d=[];if(a==='none')return{'blockers':c,'disclosures':d};const e=a==='contest'||a==='bounty'||a==='agent';e&&b['arbitrationMode']!=='third_party'&&c['push']({'code':'ACCEPTANCE_JUDGE_NOT_INDEPENDENT','detail':'acceptance_mode\x20\x27'+a+'\x27\x20is\x20a\x20judge-decided\x20acceptance\x20(a\x20third\x20party\x20rules\x20on\x20'+('release),\x20but\x20arbitration_mode\x20is\x20\x27'+(b['arbitrationMode']??'none')+'\x27,\x20not\x20\x27third_party\x27.\x20')+'The\x20party\x20owing\x20the\x20payout\x20must\x20not\x20also\x20decide\x20whether\x20it\x20is\x20owed\x20(merchant\x20self-adjudication,\x20'+'INV-A3).\x20Set\x20arbitration_mode\x20\x27third_party\x27\x20so\x20an\x20independent\x20venue/judge\x20Permission\x20rules\x20'+'(R2;\x20enforced\x20at\x20publish\x20by\x20controller-disjointness),\x20or\x20use\x20acceptance_mode\x20\x27milestone\x27\x20if\x20the\x20'+'buyer\x20genuinely\x20self-adjudicates.'});const f=b['feeParams']['revision_rounds_max'],g=typeof f==='number'||typeof f==='string'&&f['trim']()!==''&&/^\d+$/['test'](f['trim']());if(g){const h=b['guardSpecs']['some'](i=>i['host']==='repository'||/repository/i['test'](i['template_id']));!h&&c['push']({'code':'ACCEPTANCE_REVISION_UNBOUNDED','detail':'acceptance_mode\x20\x27'+a+'\x27\x20declares\x20a\x20bounded\x20revision\x20loop\x20'+('(fee_params.revision_rounds_max\x20=\x20'+String(f)+'),\x20but\x20no\x20counter-backed\x20Repository\x20')+'guard\x20exists.\x20The\x20chain\x20caps\x20EDGE\x20count\x20(MAX_FORWARD\x20/\x20MAX_NODE_PAIR),\x20never\x20VISIT\x20count,\x20'+'so\x20a\x20finite\x20cap\x20in\x20fee_params\x20alone\x20is\x20a\x20promise\x20the\x20chain\x20cannot\x20keep\x20(INV-A1).\x20Either\x20declare\x20'+'revision_rounds_max\x20\x27unlimited\x27\x20(the\x20honest\x20form\x20—\x20the\x20revision\x20loop\x20is\x20then\x20genuinely\x20'+'unbounded)\x20or\x20mount\x20a\x20counter-backed\x20Repository\x20guard\x20(pattern.repository_data_check\x20reading\x20a\x20'+'per-order\x20revision\x20tally\x20written\x20via\x20pattern.repository_write_authorization)\x20that\x20gates\x20the\x20'+'redelivery\x20forward\x20once\x20the\x20tally\x20reaches\x20the\x20cap.'});}if(a==='contest')d['push']('Winner\x20rule\x20(first-to-node):\x20the\x20winner\x20is\x20the\x20first\x20account\x20whose\x20forward\x20completes\x20entry\x20into\x20'+'the\x20adjudication\x20node\x20—\x20computable\x20from\x20the\x20order\x27s\x20Progress\x20history\x20(first\x20matching\x20entry,\x20earliest\x20'+'time);\x20ties\x20resolve\x20by\x20chain\x20timestamp.\x20This\x20rule\x20is\x20disclosed\x20for\x20judge/merchant\x20reference;\x20the\x20'+'chain\x20stores\x20no\x20winner\x20field\x20(F-RQD2-05).');else a==='bounty'&&d['push']('Winner\x20rule\x20(judge-accepted\x20triage):\x20winners\x20are\x20the\x20submitters\x20whose\x20reports\x20the\x20independent\x20judge\x20'+'accepts\x20(severity-ranked);\x20the\x20Progress\x20history\x20proves\x20who\x20delivered,\x20the\x20judge\x20permission\x20decides\x20'+'which\x20delivery\x20wins.');return{'blockers':c,'disclosures':d};}function emitInstallmentGates(a,b){const c=[];if(a==='none')return c;const d=/(due|owed|owing|unpaid|awaiting|pending)/i,f=/(paid|captured|funded|settled)/i,g=/(deposit|down_?pay|balance_due|balance_owed|awaiting|installment|milestone)/i,h=/(refund|cancel|exit|forfeit|kill|void|abandon|release|expire|lapse)/i,i=[];for(const s of b['shape']){const t=s['name'];for(const u of s['from']??[]){typeof u==='string'?i['push']({'prev':u,'target':t}):i['push']({'prev':u['prev'],'target':t,'guardKey':u['guard_key']});}}const j=i['filter'](w=>d['test'](w['prev'])&&f['test'](w['target'])&&(w['guardKey']===undefined||w['guardKey']['trim']()===''));j['length']>0x0&&c['push']({'code':'INSTALLMENT_FUNDING_UNGATED','detail':'installment_mode\x20\x27'+a+'\x27\x20captures\x20a\x20later\x20payment,\x20but\x20the\x20funding\x20forward(s)\x20'+j['map'](w=>'\x27'+w['prev']+'\x27\x20→\x20\x27'+w['target']+'\x27')['join'](',\x20')+'\x20carry\x20NO\x20guard_key.\x20A\x20bare\x20advance\x20records\x20the\x20balance\x20as\x20paid\x20WITHOUT\x20the\x20capture\x20landing\x20in\x20the\x20'+'Allocation\x20—\x20a\x20zero-value\x20advance\x20(INV-B1,\x20H4).\x20Bind\x20a\x20fund-gate\x20Guard\x20on\x20each\x20capture\x20forward\x20'+'(constant\x20=\x20order\x20address,\x20convert_witness\x20OrderAllocation(109),\x20allocation.balance\x20query\x201051\x20>=\x20the\x20'+'capture\x20amount).\x20PRE-STATE\x20CONSTRAINT\x20(esound-mn-261021\x20B-1,\x20mainnet-verified):\x20guards\x20read\x20the\x20'+'COMMITTED\x20pre-transaction\x20balance\x20—\x20funding\x20that\x20lands\x20in\x20the\x20SAME\x20PTB\x20(the\x20one-PTB\x20order_renew\x20'+'payment\x20half)\x20is\x20INVISIBLE\x20to\x20the\x20forward\x27s\x20guard,\x20so\x20a\x20balance-gated\x20capture\x20advanced\x20by\x20'+('order_renew\x20ALWAYS\x20aborts.\x20'+TWO_TX_RENEW_RECIPE+'\x20Pair\x20the\x20balance\x20gate\x20with\x20the\x20once\x20slot\x20')+'(H5\x20—\x20the\x20fund\x20gate\x20is\x20a\x20STATE\x20READ,\x20not\x20a\x20once)\x20so\x20a\x20replay\x20cannot\x20re-capture.'});const k=new Set(b['rows']['filter'](w=>w['track']==='refund'||w['track']==='settlement')['map'](w=>w['guard_key'])['filter'](w=>typeof w==='string'&&w['trim']()!=='')),l=new Set(b['shape']['map'](w=>w['name'])),m=new Map(b['shape']['map'](w=>[w['name'],w['semantic_role']])),o=new Set();for(const w of b['guardSpecs']){if(w['host']!=='machine'||!/allocator_node_gate|progress_state_check/['test'](w['template_id']))continue;if(!k['has'](w['key']))continue;for(const x of Object['values'](w['params']??{})){if(typeof x==='string'&&l['has'](x))o['add'](x);}}const p=new Map();for(const y of i){const z=p['get'](y['prev'])??[];z['push'](y['target']),p['set'](y['prev'],z);}const q=A=>{const B=new Set([A]),C=[...p['get'](A)??[]];while(C['length']>0x0){const D=C['pop']();if(o['has'](D))return!![];const E=m['get'](D);if(E==='final'||E==='cancelled')return!![];if(B['has'](D))continue;B['add'](D);for(const F of p['get'](D)??[])if(!B['has'](F))C['push'](F);}return![];},r=[];for(const A of b['shape']){if(!g['test'](A['name']))continue;const B=i['filter'](D=>D['prev']===A['name']),C=q(A['name']);if(!C){const D=B['filter'](E=>h['test'](E['target']))['map'](E=>'\x27'+E['target']+'\x27');r['push'](D['length']>0x0?A['name']+'\x20(keyword-named\x20target(s)\x20'+D['join'](',\x20')+'\x20reach\x20no\x20refund/settlement\x20rail\x20and\x20no\x20final/cancelled\x20state\x20—\x20the\x20NAME\x20alone\x20is\x20not\x20an\x20exit)':A['name']);}}return r['length']>0x0&&c['push']({'code':'INSTALLMENT_DEPOSIT_STRANDED','detail':'installment_mode\x20\x27'+a+'\x27\x20holds\x20a\x20buyer\x20payment\x20at\x20state(s)\x20'+r['map'](E=>'\x27'+E+'\x27')['join'](',\x20')+'\x20with\x20NO\x20deposit-exit\x20rail\x20(no\x20outgoing\x20refund\x20/\x20cancel\x20/\x20forfeit\x20/\x20expire\x20edge).\x20There\x20is\x20no\x20on-chain\x20'+'obligation\x20to\x20pay\x20the\x20balance\x20(INV-B2,\x20H1),\x20so\x20a\x20buyer\x20who\x20walks\x20away\x20strands\x20the\x20already-paid\x20portion\x20'+'at\x20that\x20node\x20permanently\x20(Machine\x20+\x20Allocator\x20immutable,\x20IMMUT-001).\x20Add\x20a\x20deposit-exit\x20rail\x20from\x20each\x20'+'held\x20state\x20—\x20a\x20refund/cancel\x20forward\x20into\x20an\x20exit\x20node\x20whose\x20allocator\x20returns\x20the\x20held\x20funds\x20to\x20the\x20'+'order\x20payer\x20(GuardIdentifier(0))\x20or\x20applies\x20the\x20declared\x20deposit_exit_policy\x20(full\x20refund\x20vs\x20a\x20kill\x20fee\x20'+'compensating\x20the\x20merchant\x20for\x20the\x20reserved\x20capacity).'}),c;}function emitAffiliateGates(a,b){const c=[];if(a==='none')return c;const d=/(commission|affiliate|referr|attribut|partner_?payout)/i,e=b['shape']['some'](i=>d['test'](i['name'])),f=b['rows']['some'](i=>d['test'](i['value_from']??'')||d['test'](i['recipient_key']??''));!e&&!f&&c['push']({'code':'AFFILIATE_RAIL_MISSING','detail':'affiliate_mode\x20\x27'+a+'\x27\x20declares\x20a\x20referral/affiliate\x20commission\x20overlay,\x20but\x20machine_shape\x20has\x20no\x20'+'commission-family\x20node\x20and\x20the\x20allocator\x20has\x20no\x20commission\x20row\x20—\x20a\x20declared\x20partner\x20payout\x20with\x20no\x20rail\x20to\x20'+'walk\x20it\x20is\x20a\x20false\x20promise\x20at\x20quote\x20time\x20(INV-D3).\x20Add\x20an\x20INDEPENDENT\x20commission\x20leg:\x20a\x20Rate\x20row\x20off\x20a\x20'+'dedicated\x20commission\x20pool\x20(never\x20a\x20Surplus/Rate\x20drain\x20of\x20the\x20buyer\x27s\x20goods\x20escrow\x20—\x20anti-grab-pool)\x20to\x20an\x20explicit\x20'+'non-empty\x20partner\x20Entity,\x20gated\x20by\x20a\x20window-anchored\x20claim\x20guard\x20(INV-D1\x20rides\x20TIME-ANCHOR-01)\x20so\x20the\x20'+'commission\x20is\x20claimable\x20only\x20after\x20the\x20attribution/refund\x20window\x20closes.'});const g=/(post-?lock|clawback|unrecoverable|irrevocab|no\s*(?:revers|recov|clawback)|cannot be reversed|once released|released commission)/i,h=b['buildNotes']['some'](i=>g['test'](i));return!h&&c['push']({'code':'AFFILIATE_CLAWBACK_UNDISCLOSED','detail':'affiliate_mode\x20\x27'+a+'\x27\x20declares\x20a\x20commission\x20but\x20no\x20build_note\x20discloses\x20the\x20post-lock\x20no-clawback\x20'+'truth\x20(INV-D2).\x20SOLE\x20TRUTH:\x20Allocation\x20distribute\x20is\x20a\x20ONE-WAY\x20outflow\x20(no\x20debit/clawback\x20primitive,\x20§11.0\x20G2),\x20'+'so\x20once\x20a\x20commission\x20is\x20RELEASED\x20it\x20CANNOT\x20be\x20reversed\x20on\x20chain\x20—\x20a\x20refund/chargeback\x20after\x20release\x20leaves\x20the\x20'+'affiliate\x20commission\x20unrecoverable.\x20Add\x20a\x20build_note\x20stating\x20this\x20honestly\x20(e.g.\x20\x22post-lock:\x20a\x20released\x20'+'affiliate\x20commission\x20is\x20unrecoverable\x20—\x20refunds\x20after\x20the\x20attribution\x20window\x20do\x20NOT\x20claw\x20back\x20the\x20'+'partner\x20payout\x22).\x20L-04/D-5:\x20never\x20imply\x20a\x20recovery\x20capability\x20the\x20chain\x20does\x20not\x20have.'}),c;}function emitCrowdfundingGates(a,b){const c=[];if(a==='none')return c;const d=/(releas|settle|funded|disburs|project)/i,e=/(refund|missed|unmet|return|reimburse)/i,f=b['shape']['some'](s=>d['test'](s['name'])),g=b['rows']['some'](s=>s['track']==='settlement'&&(d['test'](s['guard_key']??'')||d['test'](s['recipient_key']??''))),h=b['shape']['some'](s=>e['test'](s['name'])),i=b['rows']['some'](s=>s['track']==='refund'||e['test'](s['guard_key']??''));!f&&!g&&c['push']({'code':'CROWDFUNDING_THRESHOLD_GATE_MISSING','detail':'crowdfunding_mode\x20\x27'+a+'\x27\x20declares\x20a\x20campaign\x20but\x20machine_shape\x20has\x20no\x20release/settlement\x20'+'node\x20and\x20the\x20allocator\x20has\x20no\x20settlement\x20row\x20to\x20the\x20project\x20Entity\x20—\x20the\x20escrowed\x20contributions\x20would\x20'+'strand\x20at\x20the\x20deadline\x20with\x20no\x20exit\x20rail\x20(INV-E1).\x20Add\x20a\x20release\x20leg\x20(Rate\x2010000\x20to\x20a\x20NON-EMPTY\x20project\x20'+'Entity,\x20gated\x20at\x20the\x20campaign-deadline\x20settlement\x20terminal)\x20and,\x20for\x20a\x20threshold\x20campaign,\x20its\x20D-BUG-2\x20'+'refund\x20twin.'});a==='threshold'&&!h&&!i&&c['push']({'code':'CROWDFUNDING_THRESHOLD_GATE_MISSING','detail':'crowdfunding_mode\x20\x27threshold\x27\x20declares\x20an\x20all-or-nothing\x20campaign\x20but\x20there\x20is\x20NO\x20refund-family\x20node/row\x20—\x20'+'a\x20missed\x20goal\x20would\x20strand\x20every\x20contribution\x20instead\x20of\x20returning\x20it\x20(INV-E1\x20/\x20D-BUG-2).\x20Add\x20the\x20refund\x20'+'leg\x20(per-contributor,\x20order-anchored\x20user\x20slot\x200\x20—\x20the\x20submitted\x20Order,\x20never\x20slot\x20254;\x20node-gated\x20at\x20the\x20'+'refund\x20terminal,\x20decision\x2011\x20—\x20never\x20a\x20claimed_by\x20leg)\x20as\x20the\x20mutually-exclusive\x20twin\x20of\x20the\x20'+'release\x20leg:\x20aggregate\x20>=\x20goal\x20→\x20release;\x20aggregate\x20<\x20goal\x20→\x20refund.'});if(a==='threshold'){const s=b['guardSpecs']['filter'](x=>x['host']==='repository'||/repository_write/i['test'](x['template_id'])),t=s['length']>0x0,u=s['some'](x=>{const y=(x['policy']?.['id_from']??'')['toLowerCase']();return y==='signer'||y==='clock';});if(!t)c['push']({'code':'CROWDFUNDING_AGGREGATE_UNBOUND','detail':'crowdfunding_mode\x20\x27threshold\x27\x20gates\x20release\x20on\x20an\x20aggregate\x20funding\x20total,\x20but\x20no\x20host:\x22repository\x22\x20'+'write\x20policy\x20declares\x20the\x20contribution\x20rows\x20—\x20with\x20no\x20write-bound\x20policy\x20the\x20total\x20is\x20forgeable,\x20so\x20'+'anyone\x20could\x20inflate\x20the\x20aggregate\x20and\x20fake\x20a\x20\x27goal\x20met\x27\x20(INV-E2\x20/\x20R-X1-17:\x20existence-is-not-trust).\x20'+'Mount\x20pattern.repository_write_authorization\x20(identity\x20leaf\x20order.owner==Signer\x20/\x20order.agent\x20has\x20Signer)\x20'+'and\x20key\x20the\x20contribution\x20rows\x20by\x20the\x20funder\x27s\x20ORDER\x20(policy\x20id_from\x20unset;\x20row\x20id\x20=\x20the\x20Order\x20address).'});else{if(u){const x=s['filter'](y=>{const z=(y['policy']?.['id_from']??'')['toLowerCase']();return z==='signer'||z==='clock';})['map'](y=>'\x27'+y['key']+'\x27');c['push']({'code':'CROWDFUNDING_SIGNER_KEYED_ROWS','detail':'crowdfunding_mode\x20\x27threshold\x27\x20gates\x20release\x20on\x20an\x20aggregate\x20funding\x20total,\x20but\x20the\x20contribution\x20'+('policy\x20'+x['join'](',\x20')+'\x20keys\x20rows\x20by\x20the\x20WALLET\x20(id_from\x20signer/clock)\x20—\x20the\x20OLD\x20pre-migration\x20')+'shape\x20(ksc-tn-261024\x20F-01/F-05).\x20Wallet-keyed\x20rows\x20feed\x20the\x20escrow-bound\x20sum\x20(query\x201179,\x20per-row\x20'+'min(row,\x20order.amount,\x20LIVE\x20allocation.balance))\x20ZERO\x20—\x20the\x20goal\x20gate\x20silently\x20bricks\x20—\x20and\x20the\x20free-form\x20sum-where\x20(1174)\x20stays\x20'+'self-reported,\x20so\x20a\x20backer\x20can\x20still\x20record\x201.0\x20for\x20a\x200.1\x20pledge.\x20Key\x20the\x20rows\x20by\x20the\x20funder\x27s\x20ORDER\x20'+'instead\x20(policy\x20id_from\x20unset;\x20the\x20backer\x27s\x20tooling\x20submits\x20the\x20row\x20id\x20=\x20their\x20Order\x20address\x20through\x20'+'the\x20passport-bearing\x20data\x20write),\x20pass\x20those\x20ORDER\x20addresses\x20as\x20the\x20aggregate\x27s\x20candidate\x20ids,\x20and\x20pair\x20the\x20gate\x20'+'with\x20the\x20live-escrow\x20leg\x20(allocation.balance\x20query\x201051\x20via\x20convert_witness\x20OrderAllocation\x20109,\x20'+'>=\x20order.amount)\x20so\x20a\x20refunded/never-funded\x20order\x20can\x20neither\x20count\x20toward\x20the\x20goal\x20nor\x20be\x20settled.'});}}const v=b['inputs']['campaign_deadline_ms']??b['feeParams']?.['campaign_deadline_ms'],w=typeof v==='number'?v:Number(v);if(b['buildTimeMs']!==undefined){if(!Number['isFinite'](w)||w<=0x0)c['push']({'code':'CROWDFUNDING_DEADLINE_UNSET','detail':'crowdfunding_mode\x20\x27threshold\x27\x20gates\x20release/refund/withdrawal\x20on\x20the\x20ABSOLUTE\x20shared\x20deadline\x20'+('(campaign_deadline_ms),\x20but\x20it\x20resolved\x20to\x20'+String(v)+'\x20even\x20though\x20this\x20build\x20knows\x20its\x20')+'instant\x20—\x20an\x20unresolved\x20zero\x20opens\x20the\x20deadline\x20gate\x20at\x20genesis:\x20the\x20pre-deadline\x20withdrawal\x20exit\x20is\x20'+'dead\x20on\x20arrival\x20and\x20the\x20threshold/refund\x20polarity\x20is\x20resolvable\x20at\x20block\x20one\x20(ktt5\x20T-20).\x20Pass\x20a\x20real\x20'+'future\x20epoch-ms\x20timestamp\x20via\x20inputs.campaign_deadline_ms,\x20or\x20a\x20length\x20via\x20'+'inputs.campaign_duration_days\x20for\x20the\x20generation-time\x20conversion.'});else{if(w<=b['buildTimeMs'])c['push']({'code':'CROWDFUNDING_DEADLINE_PAST','detail':'campaign_deadline_ms\x20('+w+')\x20is\x20not\x20after\x20this\x20build\x27s\x20instant\x20('+b['buildTimeMs']+')\x20—\x20'+'the\x20shared\x20deadline\x20is\x20ALREADY\x20EXPIRED\x20at\x20publish:\x20the\x20pre-deadline\x20WithdrawPledge\x20exit\x20is\x20dead\x20on\x20'+'arrival\x20and\x20the\x20threshold/refund\x20polarity\x20is\x20resolvable\x20at\x20block\x20one\x20(the\x20live\x20ktt5\x20run\x20set\x20the\x20'+'deadline\x20before\x20the\x20first\x20order\x20and\x20could\x20never\x20test\x20a\x20mid-round\x20withdrawal,\x20T-20).\x20Pass\x20a\x20future\x20'+'epoch-ms\x20timestamp\x20(build\x20instant\x20+\x20campaign_duration_days\x20is\x20the\x20sanctioned\x20conversion).'});else b['buildTimeMs']+0xa*0xea60-w>0x0&&c['push']({'code':'CROWDFUNDING_DEADLINE_IMMINENT','detail':'campaign_deadline_ms\x20('+w+')\x20is\x20less\x20than\x2010\x20minutes\x20after\x20this\x20build\x27s\x20instant\x20'+('('+b['buildTimeMs']+')\x20—\x20the\x20round\x20is\x20effectively\x20expired\x20by\x20the\x20time\x20ANY\x20buyer\x20sees\x20the\x20')+'listing\x20(pdd\x20F-09\x20min-lead).\x20Give\x20the\x20campaign\x20a\x20real\x20lead\x20window:\x20build\x20instant\x20+\x20'+'campaign_duration_days\x20/\x20campaign_duration_hours\x20(hours\x20for\x20short\x20pop-up\x20rounds,\x20minimum\x20'+'sanctioned\x20length\x2010\x20minutes)\x20or\x20a\x20further-out\x20absolute\x20timestamp.'});}}}const j=b['buildNotes'],k=/(attest|keeper|aggregate trust|read-?only sum|not a chain-?verified|independent recomputation)/i,l=/(not investment|non-?investment|no (?:investment )?return|never promise)/i,m=/(kyc|aml|securities|money-?transmission|regulatory|cross-border|compliance)/i,n=/(no-?refund|non-?refundable|keep-?it-?all)/i,o=j['some'](y=>l['test'](y)),p=j['some'](y=>m['test'](y)),q=a==='threshold'?j['some'](y=>k['test'](y)):!![],r=a==='flexible'?j['some'](y=>n['test'](y)):!![];if(!q||!o||!p||!r){const y=[!q?'the\x20aggregate-trust\x20boundary\x20(the\x20funding\x20total\x20is\x20a\x20keeper-attested\x20Repository\x20sum,\x20NOT\x20a\x20chain-verified\x20money\x20oracle)':null,!o?'the\x20L-01\x20non-investment\x20statement\x20(never\x20promise\x20returns\x20/\x20promote\x20coin\x20price;\x20not\x20investment\x20advice\x20or\x20a\x20return\x20promise)':null,!p?'the\x20L-05\x20KYC/AML\x20+\x20cross-border\x20regulatory\x20caution\x20(HIGH\x20intensity)':null,!r?'the\x20flexible\x20keep-it-all\x20NO-REFUND\x20posture\x20(contributions\x20non-refundable\x20once\x20the\x20deadline\x20passes;\x20no\x20refunds)':null]['filter'](Boolean);c['push']({'code':'CROWDFUNDING_DISCLOSURE_MISSING','detail':'crowdfunding_mode\x20\x27'+a+'\x27\x20declares\x20a\x20campaign\x20but\x20no\x20build_note\x20carries:\x20'+y['join'](';\x20')+'\x20'+'(INV-E3\x20/\x20L-04\x20/\x20L-01\x20/\x20L-05).\x20Add\x20these\x20as\x20honest\x20build_notes\x20—\x20never\x20present\x20an\x20attested\x20aggregate\x20as\x20a\x20'+'chain-verified\x20custody\x20proof,\x20never\x20imply\x20investment\x20returns,\x20and\x20flag\x20the\x20compliance\x20surface.'});}return c;}function emitLogisticsGates(a,b){const c=[];if(a==='none')return c;const d=b['shape'],e=d['some'](g=>g['named_operator']!==undefined||(g['from']??[])['some'](h=>h['named_operator']!==undefined));a==='courier'&&!e&&c['push']({'code':'LOGISTICS_COURIER_RAIL_MISSING','detail':'logistics_mode\x20\x27courier\x27\x20declares\x20per-order\x20dispatched\x20riders,\x20but\x20machine_shape\x20carries\x20NO\x20named_operator\x20'+'rail.\x20A\x20dispatched\x20rider\x20is\x20NEITHER\x20a\x20permission\x20entity\x20NOR\x20the\x20buyer\x20—\x20the\x20ONLY\x20forward\x20they\x20can\x20ever\x20'+'pass\x20is\x20a\x20namedOperator\x20roster\x20rail\x20(the\x20rider\x20namespace\x27s\x20per-order\x20roster,\x20written\x20by\x20the\x20dispatch\x20'+'keeper\x20via\x20permission\x20index\x20221;\x20K-1\x20batch\x20B).\x20Bind\x20the\x20handover\x20forwards\x20(merchant→courier\x20pickup,\x20'+'courier→buyer\x20drop-off)\x20with\x20named_operator\x20\x27<namespace>\x27\x20—\x20and\x20disclose\x20the\x20roster\x20duty\x20in\x20a\x20build_note\x20'+'(the\x20NAMED_OPERATOR_ROSTER_UNDISCLOSED\x20gate\x20and\x20the\x20G6\x20dispatch\x20disclosure\x20below\x20enforce\x20the\x20rest).'});const f=/(deliver|courier|shipping|freight|ride|dispatch|logistic)/i;if(a==='courier'){const g=b['rows']['find'](h=>h['mode']==='surplus'&&f['test']((h['value_from']??'')+'\x20'+(h['recipient_key']??'')));g!==undefined&&c['push']({'code':'LOGISTICS_COURIER_FEE_POOLED','detail':'logistics_mode\x20\x27courier\x27\x20has\x20a\x20delivery-fee\x20allocator\x20row\x20in\x20SURPLUS\x20mode\x20'+('(value_from/recipient_key\x20\x27'+(g['value_from']??g['recipient_key']??'')+'\x27)\x20—\x20a\x20surplus\x20leg\x20')+'drains\x20the\x20remainder\x20of\x20the\x20pool\x20it\x20hangs\x20on,\x20which\x20for\x20a\x20courier\x20build\x20IS\x20the\x20buyer\x27s\x20goods\x20escrow\x20'+'(the\x20grab-pool\x20shape\x20the\x20affiliate\x20INV-D3\x20family\x20bans).\x20The\x20delivery\x20fee\x20is\x20KNOWN\x20at\x20order\x20time\x20—\x20the\x20'+'buyer\x20sees\x20and\x20pays\x20it\x20before\x20dispatch\x20—\x20so\x20make\x20it\x20an\x20INDEPENDENT\x20leg:\x20a\x20fixed\x20Amount\x20row\x20(or\x20a\x20Rate\x20'+'row\x20off\x20a\x20dedicated\x20delivery-fee\x20pool\x20funded\x20separately),\x20never\x20a\x20Surplus/Rate\x20drain\x20of\x20the\x20goods\x20pool.'});}if(a==='pickup_point'){const h=b['guardSpecs']['some'](j=>j['template_id']==='pattern.time_lock_absolute'||j['template_id']==='tpl_time_lock_absolute_ms'),i=b['guardSpecs']['some'](j=>j['template_id']==='pattern.time_window_upper_bound'||j['template_id']==='tpl_time_window_upper'||j['template_id']==='tpl_time_window_upper_absolute_ms');(!h||!i)&&c['push']({'code':'LOGISTICS_PICKUP_CUTOFF_MISSING','detail':'logistics_mode\x20\x27pickup_point\x27\x20declares\x20batch\x20consolidation,\x20but\x20the\x20shape\x20is\x20missing\x20'+(''+(!h?'the\x20ABSOLUTE\x20batch-cutoff\x20release\x20gate\x20(pattern.time_lock_absolute\x20—\x20every\x20funder\x27s/leader\x27s\x20release\x20anchors\x20on\x20the\x20SAME\x20shared\x20cutoff\x20clock,\x20not\x20per-order\x20entry+duration)':''))+(''+(!h&&!i?'\x20and\x20':''))+(''+(!i?'the\x20unclaimed-goods\x20exit\x20window\x20(pattern.time_window_upper_bound\x20—\x20goods\x20never\x20picked\x20up\x20must\x20refund/return\x20at\x20a\x20bounded\x20deadline,\x20never\x20hold\x20open-ended)':''))+'.\x20Both\x20are\x20mandatory:\x20without\x20the\x20shared\x20cutoff\x20the\x20batch\x20is\x20not\x20a\x20batch\x20(each\x20order\x20releases\x20on\x20its\x20own\x20clock),\x20and\x20without\x20the\x20exit\x20window\x20an\x20unclaimed\x20parcel\x20strands\x20in\x20the\x20pickup\x20point\x20forever.'});}if(a==='carrier'){const j=/(track|shipping evidence|waybill|airbill|carrier record|parcel evidence)/i,k=b['guardSpecs']['some'](l=>l['host']==='machine'&&j['test'](l['key']+'\x20'+l['purpose']));!k&&c['push']({'code':'LOGISTICS_CARRIER_EVIDENCE_MISSING','detail':'logistics_mode\x20\x27carrier\x27\x20declares\x20third-party\x20carrier\x20shipment,\x20but\x20NO\x20machine\x20guard\x20binds\x20'+'shipping/tracking\x20evidence.\x20Add\x20a\x20repository_data_check\x20guard\x20on\x20the\x20ship\x20forward\x20keyed\x20to\x20a\x20'+'tracking-hash\x20row\x20(the\x20retail\x20idiom:\x20the\x20evidence\x20Repository\x20row\x20is\x20written\x20by\x20an\x20authorized\x20'+'writer\x20—\x20pattern.repository_write_authorization\x20—\x20and\x20the\x20ship\x20guard\x20reads\x20it),\x20so\x20a\x20dispute\x20has\x20a\x20'+'dispute-ready\x20record\x20of\x20what\x20was\x20shipped\x20and\x20when.'});}{const l=/(lost|loss|damag|theft)/i,m=q=>q['replace'](/permanently lost/gi,''),n=/(transit loss|lost (?:parcel|package|goods|in transit)|in[- ]transit loss|carrier lost|loss (?:is |)remed|loss route|lost shipment)/i,o=d['some'](q=>l['test'](q['name'])||l['test'](q['role']??''))||b['guardSpecs']['some'](q=>q['host']==='machine'&&l['test'](m(q['key']+'\x20'+q['purpose']))),p=b['buildNotes']['some'](q=>n['test'](q));!o&&!p&&c['push']({'code':'LOGISTICS_TRANSIT_LOSS_UNCOVERED','detail':'logistics_mode\x20\x27'+a+'\x27\x20moves\x20a\x20physical\x20good,\x20but\x20the\x20shape\x20has\x20NO\x20in-transit\x20loss\x20rail\x20'+'(no\x20loss/damage\x20node\x20or\x20machine-guard\x20family)\x20and\x20NO\x20build_note\x20disclosing\x20the\x20loss\x20remedy.\x20Goods\x20can\x20'+'be\x20lost\x20or\x20damaged\x20between\x20handover\x20and\x20acceptance\x20in\x20EVERY\x20physical\x20mode\x20—\x20silence\x20means\x20the\x20buyer\x27s\x20'+'funds\x20strand\x20behind\x20an\x20undeliverable\x20order\x20with\x20no\x20taught\x20route.\x20Either\x20express\x20the\x20loss\x20waypoint\x20(a\x20'+'node\x20like\x20the\x20retail\x20lost-parcel\x20record,\x20or\x20a\x20loss-evidence\x20machine\x20guard)\x20or\x20add\x20a\x20build_note\x20'+'disclosing\x20the\x20remedy\x20route\x20(e.g.\x20\x22transit\x20loss\x20is\x20remedied\x20by\x20the\x20buyer\x27s\x20arbitration\x20route\x20into\x20the\x20'+'refund\x20rail\x20—\x20the\x20ruling\x20pays\x20the\x20buyer;\x20the\x20carrier\x20claim\x20is\x20an\x20off-chain\x20recovery,\x20disclosed\x20as\x20such\x22).'});}if(a==='courier'||a==='pickup_point'){const q=/(dispatch|schedul|no.{0,24}oracle|no on-chain.{0,24}(dispatch|scheduler)|off-chain keeper|keeper.{0,40}dispatch|roster|named.?operator|permission.{0,12}221)/i,r=b['buildNotes']['some'](s=>q['test'](s));!r&&c['push']({'code':'LOGISTICS_DISPATCH_UNDISCLOSED','detail':'logistics_mode\x20\x27'+a+'\x27\x20is\x20a\x20dynamically\x20dispatched\x20fulfillment\x20topology,\x20but\x20no\x20build_note\x20'+'discloses\x20the\x20two\x20🔴\x20SOLE-TRUTH\x20boundaries.\x20①\x20The\x20chain\x20has\x20NO\x20dispatch/scheduling\x20primitive\x20—\x20'+'assignment\x20of\x20riders/pickup\x20batches\x20is\x20an\x20OFF-CHAIN\x20keeper\x20duty\x20(K-4);\x20its\x20only\x20chain\x20footprint\x20is\x20the\x20'+'namedOperator\x20roster\x20written\x20via\x20permission\x20index\x20221.\x20②\x20There\x20is\x20NO\x20distance/weight/weather\x20oracle\x20—\x20'+'ETA,\x20route,\x20and\x20dynamic\x20pricing\x20are\x20NOT\x20chain-verifiable.\x20Add\x20a\x20build_note\x20stating\x20WHO\x20dispatches\x20(the\x20'+'keeper),\x20WHAT\x20the\x20keeper\x20writes\x20(the\x20roster,\x20per\x20order/shift),\x20and\x20that\x20ETA/pricing\x20live\x20off-chain.'});}return c;}function emitFormulaGates(a){const b=[];for(const c of a['rows']){if(c['mode']!=='formula')continue;const d='allocator\x20row\x20('+c['track']+'/'+(c['recipient_key']??c['recipient'])+')';c['formula']?.['selector']!==0x2&&b['push']({'code':'FORMULA_SELECTOR_NOT_SUM_BOUND','detail':d+'\x20declares\x20a\x20Formula\x20leg\x20with\x20selector\x20'+JSON['stringify'](c['formula']?.['selector'])+'\x20—\x20only\x202\x20'+'(SUM_BOUND)\x20is\x20allowed.\x20A\x20bare\x20SUM\x20(1)\x20can\x20be\x20inflated\x20by\x20forged\x20rows:\x20any\x20Repository\x20writer\x20who\x20'+'can\x20add\x20a\x20large\x20row\x20inflates\x20the\x20scalar,\x20and\x20the\x20leg\x20pays\x20coefficient\x20×\x20scalar\x20/\x2010000\x20—\x20forged\x20'+'row,\x20forged\x20money\x20(ksc-tn-261024\x20F-01);\x20COUNT\x20(0)\x20is\x20likewise\x20escrow-unbound.\x20SUM_BOUND\x20clamps\x20'+'every\x20candidate\x20row\x20to\x20min(row_value,\x20the\x20amount\x20of\x20the\x20Order\x20its\x20id\x20names),\x20so\x20a\x20dynamic-pricing\x20'+'scalar\x20can\x20never\x20credit\x20a\x20contribution\x20beyond\x20the\x20escrow\x20actually\x20bound\x20to\x20it.\x20TWO\x20clamp\x20'+'guarantees,\x20keep\x20them\x20separate\x20—\x20never\x20blur\x20them\x20into\x20an\x20unconditional\x20\x22three-term\x20clamp\x22:\x20'+'(a)\x20UNCONDITIONAL\x20on\x20every\x20protocol\x20version:\x20min(row_value,\x20that\x20Order\x20amount),\x20with\x20a\x20candidate\x20'+'id\x20that\x20is\x20not\x20a\x20framework\x20Order\x20contributing\x200\x20fail-closed;\x20(b)\x20FLAG-GATED:\x20the\x20third\x20clamp\x20'+'term\x20against\x20the\x20row\x27s\x20LIVE\x20allocation\x20balance\x20ships\x20behind\x20the\x20v140\x20live-cap\x20protocol\x20flag\x20'+'(FLAG_ENABLE_REPOSITORY_ESCROW_LIVE_CAP)\x20—\x20on\x20a\x20protocol\x20version\x20without\x20it,\x20a\x20refunded\x20order\x27s\x20'+'frozen\x20amount\x20still\x20contributes\x20to\x20the\x20scalar.\x20Never\x20promise\x20the\x20live-balance\x20clamp\x20without\x20'+'naming\x20its\x20flag.\x20Declare\x20'+'formula:\x20{\x20selector:\x202,\x20repo,\x20key,\x20ids,\x20...\x20}\x20on\x20the\x20row\x20(the\x20runtime\x20spec\x20is\x20then\x20bound\x20via\x20'+'allocation\x20formula_spec_set).'});const e=c['formula']?.['ids'],f=e!==undefined&&e['length']>0x0?JSON['stringify'](e):'';!f['includes']('order')&&b['push']({'code':'FORMULA_ROW_KEY_NOT_ORDER','detail':d+'\x20declares\x20a\x20Formula\x20leg\x20whose\x20candidate\x20ids\x20'+(e===undefined||e['length']===0x0?'are\x20empty\x20or\x20missing':'('+f+')')+'\x20do\x20not\x20bind\x20an\x20Order\x20id.\x20'+'Under\x20SUM_BOUND\x20every\x20row\x20is\x20clamped\x20to\x20min(row_value,\x20order.amount\x20of\x20the\x20row\x20id);\x20a\x20row\x20keyed\x20by\x20'+'anything\x20that\x20is\x20not\x20a\x20real\x20framework\x20Order\x20contributes\x200\x20—\x20the\x20leg\x20silently\x20prices\x20at\x200\x20(fail-closed\x20'+'native\x20behavior,\x20a\x20silent\x20error\x20source),\x20and\x20an\x20empty\x20list\x20matches\x20NO\x20records.\x20Bind\x20ids\x20to\x20the\x20plan\x27s\x20'+'Order(s)\x20(e.g.\x20[{\x20\x22$ref\x22:\x20\x22<order\x20step\x20id>\x22\x20}])\x20so\x20the\x20clamp\x20reads\x20the\x20real\x20escrow.'});}return b;}export function emitModeGates(a,b){const c=emitAfterSalesGates(a['afterSalesMode'],b),d=emitAcceptanceGates(a['acceptanceMode'],b);return{'blockers':[...c,...d['blockers'],...emitInstallmentGates(a['installmentMode'],b),...emitAffiliateGates(a['affiliateMode'],b),...emitCrowdfundingGates(a['crowdfundingMode'],b),...emitLogisticsGates(a['logisticsMode'],b),...emitFormulaGates(b)],'disclosures':[...d['disclosures']]};}export function deriveCapabilityModes({template:a,inputs:b}){const c=b['after_sales_mode'],d=c==='return'||c==='exchange'||c==='warranty'||c==='none'?c:undefined,e=d??a['after_sales_mode']??'none',f=b['acceptance_mode'],g=f==='milestone'||f==='contest'||f==='bounty'||f==='agent'||f==='none'?f:undefined,h=g??a['acceptance_mode']??'none',i=b['installment_mode'],j=i==='deposit_balance'||i==='milestone_n'||i==='none'?i:undefined,k=j??a['installment_mode']??'none',l=b['affiliate_mode'],m=l==='commission'||l==='none'?l:undefined,n=m??a['affiliate_mode']??'none',o=b['crowdfunding_mode'],p=o==='threshold'||o==='flexible'||o==='none'?o:undefined,q=p??a['crowdfunding_mode']??'none',r=b['logistics_mode'],s=r==='carrier'||r==='merchant_managed'||r==='courier'||r==='pickup_point'||r==='none'?r:undefined,t=s??a['logistics_mode']??'none';return{'afterSalesMode':e,'acceptanceMode':h,'installmentMode':k,'affiliateMode':n,'crowdfundingMode':q,'logisticsMode':t};}
@@ -1 +1 @@
1
- import{landPlatformCommission}from'../knowledge/commission-landing.js';import{collectFeeParamLandings}from'../knowledge/template-scanner.js';import{describeFeeParams}from'../knowledge/param-tiers.js';import{paramSchema}from'../knowledge/param-schema.js';import{PLATFORM_TAKE_KEY}from'../knowledge/template-loader.js';import{compileTemplate}from'./compile.js';const DISCLOSURE_BUILD_MS=Date['UTC'](0x7ea,0x0,0x1);function probeValue(a){const b=typeof a==='number'?a:Number(a);if(!Number['isFinite'](b))return undefined;if(b===0x0)return 0x1;if(b===0x1)return 0x2;return Math['max'](0x1,Math['floor'](b/0x2));}function landedEffect(a,b,c){if(!PLATFORM_TAKE_KEY['test'](b))return{'effect':[]};const d=a['fee_params'],e=landPlatformCommission(a,d),f=landPlatformCommission(a,{...d,[b]:c});if(f['error']!==undefined)return{'effect':[],'blocked':f['error']['split']('.\x20')[0x0]};if(f['rows']===undefined||f['landing']?.['fee_key']!==b)return{'effect':[]};const g=e['rows']??(a['allocator']['rows']??[]);if(JSON['stringify'](g)===JSON['stringify'](f['rows']))return{'effect':[]};return{'effect':['allocator_rows:'+b]};}function changedSteps(c,d){if(d['blockers']['length']>c['blockers']['length'])return[];const e=movedSteps(c,d);if(e['length']===0x0&&d['blockers']['length']<c['blockers']['length']){const f=new Set(d['blockers']['map'](g=>g['code']));for(const g of new Set(c['blockers']['filter'](h=>!f['has'](h['code']))['map'](h=>h['code']))){e['push']('unblocks:'+g);}}return e;}function movedSteps(c,d){const e=[],f=Math['max'](c['plan']['steps']['length'],d['plan']['steps']['length']);for(let g=0x0;g<f;g++){const h=JSON['stringify'](c['plan']['steps'][g]??null),j=JSON['stringify'](d['plan']['steps'][g]??null);if(h!==j)e['push'](c['plan']['steps'][g]?.['id']??d['plan']['steps'][g]?.['id']??'#'+g);}return e;}function pairedKeys(a){const b=new Map();for(const d of a['allocator']['rows']??[]){const e=d['value_from'];if(e===undefined)continue;const f=d['guard_key']??'\x00unkeyed',h=b['get'](f)??new Set();h['add'](e),b['set'](f,h);}const c=new Map();for(const i of b['values']()){if(i['size']<0x2)continue;const j=[...i];for(const k of j)c['set'](k,j['find'](l=>l!==k));}return c;}export function discloseParams(a){const b=collectFeeParamLandings(a),c=compileTemplate(a,{},{'buildTimeMs':DISCLOSURE_BUILD_MS}),d=pairedKeys(a);return describeFeeParams(a)['map'](e=>{const f=(b['get'](e['key'])??[])['map'](o=>({'surface':o['surface'],'site':o['site']})),g=e['selector']&&typeof e['value']==='string'?(a['conditional_guards']??[])['filter'](o=>o['param']===e['key'])['flatMap'](o=>o['values']??[])['find'](o=>o!==e['value']):undefined;let h=g??probeValue(e['value']);const i=c['plan']['inputs'][e['key']];typeof h==='number'&&typeof i==='number'&&i>=DISCLOSURE_BUILD_MS&&h<=i&&(h=i+0x5265c00);if(h===undefined)return{...e,'status':'not-flippable','effect':[],'landing':f,'editable':![]};const j=compileTemplate(a,{[e['key']]:h},{'buildTimeMs':DISCLOSURE_BUILD_MS}),k=typeof h==='number'?landedEffect(a,e['key'],h):{'effect':[]};k['effect']['length']>0x0&&!f['some'](o=>o['surface']==='allocator_row')&&f['push']({'surface':'allocator_row','site':e['key']});const l=[...changedSteps(c,j),...k['effect']],m=d['get'](e['key']);let n=l['length']>0x0?'live':'inert';return n==='inert'&&m!==undefined&&movedSteps(c,j)['length']>0x0&&(n='live'),{...e,'status':n,'effect':l['length']>0x0?l:n==='live'?['allocator_rows:'+e['key']]:l,'landing':f,'editable':n==='live'&&e['disclosure']!=='hidden',...m!==undefined&&n==='live'?{'paired_with':m}:{},...k['blocked']!==undefined?{'blocked_by':k['blocked']}:{}};});}export function disclosureSummary(a){const b=discloseParams(a);return{'total':b['length'],'knobs':b['filter'](c=>c['disclosure']==='knob')['length'],'editable':b['filter'](c=>c['editable'])['length'],'inertKnobs':b['filter'](c=>c['disclosure']==='knob'&&c['status']==='inert')['map'](c=>c['key']),'benchmark':b['filter'](c=>c['disclosure']==='card')['length'],'hidden':b['filter'](c=>c['disclosure']==='hidden')['length'],'liveKnobs':b['filter'](c=>c['disclosure']==='knob'&&c['status']==='live')['map'](c=>c['key'])};}const EXTERNAL_CARRIER={'arbitration_fee_usd':'the\x20Service\x27s\x20bound\x20Arbitration\x20object\x20(a\x20case-level\x20fee\x20configured\x20there,\x20never\x20a\x20template\x20parameter)','courier_tip_bps':'the\x20rider\x20payroll\x20settled\x20outside\x20the\x20order\x20escrow\x20(tips\x20are\x20not\x20a\x20claim\x20on\x20this\x20pool)','max_discount_bps':'the\x20Service-side\x20Discount\x20(coupon)\x20object;\x20this\x20value\x20only\x20bounds\x20what\x20that\x20object\x20may\x20charge\x20(build-time\x20scale\x20check)','merchant_service_fee_bps':'the\x20INCUMBENT\x20platform\x27s\x20merchant-side\x20fee\x20(benchmark\x20only);\x20this\x20store\x20is\x20WoWok\x20direct\x20sales\x20and\x20takes\x20no\x20platform\x20commission,\x20so\x20no\x20money\x20rail\x20reads\x20this\x20value'};export function inertReason(a){if(a['disclosure']==='hidden')return{'code':'hidden','detail':'Plumbing/directive\x20row:\x20not\x20offered\x20and\x20not\x20meant\x20to\x20be\x20set.'};if(a['status']==='live')return undefined;const b=EXTERNAL_CARRIER[a['key']];if(b!==undefined)return{'code':'external_object','detail':'Carried\x20by\x20'+b+'.\x20Setting\x20it\x20on\x20this\x20template\x20changes\x20nothing\x20on\x20chain\x20—\x20configure\x20it\x20on\x20that\x20object\x20instead.'};if(a['blocked_by']!==undefined)return{'code':'external_object','detail':a['blocked_by']+'.\x20This\x20value\x20is\x20carried\x20by\x20a\x20different\x20object\x20or\x20money\x20shape,\x20not\x20by\x20this\x20template\x27s\x20guards.'};if(a['status']==='not-flippable')return{'code':'not_settable','detail':'The\x20value\x20is\x20not\x20a\x20number\x20a\x20control\x20can\x20offer\x20(no\x20sibling\x20value\x20to\x20probe).'};if(a['landing']['length']===0x0)return{'code':'no_consumer','detail':'No\x20guard,\x20allocator\x20row\x20or\x20time\x20anchor\x20names\x20this\x20key\x20—\x20setting\x20it\x20changes\x20nothing\x20on\x20chain.'};if(a['landing']['every'](e=>e['surface']==='directive'))return{'code':'prose_only','detail':'Named\x20only\x20in\x20the\x20template\x27s\x20prose\x20(build\x20notes\x20/\x20user\x20inputs);\x20no\x20machine\x20object\x20reads\x20it.'};const c=[...new Set(a['landing']['map'](e=>e['surface']+'\x20\x27'+e['site']+'\x27'))]['join'](',\x20'),d=a['landing']['some'](e=>e['surface']==='allocator_row')?'\x20—\x20the\x20allocator\x20rows\x20compile\x20with\x20a\x20literal\x20value,\x20not\x20this\x20key':a['landing']['some'](e=>e['surface']==='guard')?'\x20—\x20the\x20guard\x27s\x20constant\x20is\x20frozen\x20into\x20the\x20Guard\x20at\x20publish':a['landing']['some'](e=>e['surface']==='time_anchor')?'\x20—\x20the\x20time\x20anchor\x20compiles\x20its\x20duration\x20as\x20a\x20constant':'';return{'code':'seat_not_built','detail':'A\x20seat\x20is\x20declared\x20('+c+')\x20but\x20overriding\x20the\x20value\x20does\x20not\x20change\x20the\x20compiled\x20plan'+d+'.\x20It\x20is\x20a\x20published\x20price/capacity\x20figure,\x20not\x20an\x20enforced\x20constant:\x20a\x20Machine\x20rebuild\x20is\x20what\x20changes\x20it.'};}const SURFACE_WORDING={'guard':'enforced\x20by\x20guard','allocator_row':'allocator\x20row','time_anchor':'time\x20anchor','kernel':'compile\x20kernel','directive':'prose\x20only\x20(no\x20chain\x20effect)'};export function landingLine(a){if(a['length']===0x0)return'no\x20declared\x20landing';const b=new Set(),c=[];for(const d of a){const e=SURFACE_WORDING[d['surface']]??d['surface'],f=d['surface']==='directive'?e:e+'\x20\x27'+d['site']+'\x27';if(b['has'](f))continue;b['add'](f),c['push'](f);}return c['join'](';\x20');}export function paramPlane(a){const b=new Map(paramSchema(a)['map'](c=>[c['key'],c]));return discloseParams(a)['map'](c=>{const d=b['get'](c['key']);if(d===undefined)throw new Error('paramPlane:\x20\x27'+c['key']+'\x27\x20has\x20no\x20schema\x20row\x20(classification\x20is\x20not\x20total)');const e=inertReason(c);return{...d,'status':c['status'],'effect':c['effect'],'landing':c['landing'],'landing_line':c['status']!=='live'&&EXTERNAL_CARRIER[c['key']]!==undefined?'carried\x20by\x20'+EXTERNAL_CARRIER[c['key']]:landingLine(c['landing']),'editable':c['editable'],...e!==undefined?{'inert_reason':e}:{},...c['blocked_by']!==undefined?{'blocked_by':c['blocked_by']}:{},...c['paired_with']!==undefined?{'pair_note':'Shares\x20ONE\x2010000\x20basis-point\x20split\x20with\x20\x27'+c['paired_with']+'\x27\x20—\x20set\x20both\x20together;\x20moving\x20either\x20alone\x20exceeds\x2010000\x20and\x20the\x20build\x20refuses.'}:{}};});}
1
+ import{landPlatformCommission}from'../knowledge/commission-landing.js';import{collectFeeParamLandings}from'../knowledge/template-scanner.js';import{describeFeeParams}from'../knowledge/param-tiers.js';import{paramSchema}from'../knowledge/param-schema.js';import{PLATFORM_TAKE_KEY}from'../knowledge/template-loader.js';import{compileTemplate}from'./compile.js';const DISCLOSURE_BUILD_MS=Date['UTC'](0x7ea,0x0,0x1);function probeValue(a){const b=typeof a==='number'?a:Number(a);if(!Number['isFinite'](b))return undefined;if(b===0x0)return 0x1;if(b===0x1)return 0x2;return Math['max'](0x1,Math['floor'](b/0x2));}function landedEffect(a,b,c){if(!PLATFORM_TAKE_KEY['test'](b))return{'effect':[]};const d=a['fee_params'],e=landPlatformCommission(a,d),f=landPlatformCommission(a,{...d,[b]:c});if(f['error']!==undefined)return{'effect':[],'blocked':f['error']['split']('.\x20')[0x0]};if(f['rows']===undefined||f['landing']?.['fee_key']!==b)return{'effect':[]};const g=e['rows']??(a['allocator']['rows']??[]);if(JSON['stringify'](g)===JSON['stringify'](f['rows']))return{'effect':[]};return{'effect':['allocator_rows:'+b]};}function changedSteps(c,d){if(d['blockers']['length']>c['blockers']['length'])return[];const e=movedSteps(c,d);if(e['length']===0x0&&d['blockers']['length']<c['blockers']['length']){const f=new Set(d['blockers']['map'](g=>g['code']));for(const g of new Set(c['blockers']['filter'](h=>!f['has'](h['code']))['map'](h=>h['code']))){e['push']('unblocks:'+g);}}return e;}function movedSteps(c,d){const e=[],f=Math['max'](c['plan']['steps']['length'],d['plan']['steps']['length']);for(let g=0x0;g<f;g++){const h=JSON['stringify'](c['plan']['steps'][g]??null),j=JSON['stringify'](d['plan']['steps'][g]??null);if(h!==j)e['push'](c['plan']['steps'][g]?.['id']??d['plan']['steps'][g]?.['id']??'#'+g);}return e;}function pairedKeys(a){const b=new Map();for(const d of a['allocator']['rows']??[]){const e=d['value_from'];if(e===undefined)continue;const f=d['guard_key']??'\x00unkeyed',h=b['get'](f)??new Set();h['add'](e),b['set'](f,h);}const c=new Map();for(const i of b['values']()){if(i['size']<0x2)continue;const j=[...i];for(const k of j)c['set'](k,j['find'](l=>l!==k));}return c;}export function discloseParams(a){const b=collectFeeParamLandings(a),c=compileTemplate(a,{},{'buildTimeMs':DISCLOSURE_BUILD_MS}),d=pairedKeys(a);return describeFeeParams(a)['map'](e=>{const f=(b['get'](e['key'])??[])['map'](o=>({'surface':o['surface'],'site':o['site']})),g=e['selector']&&typeof e['value']==='string'?(a['conditional_guards']??[])['filter'](o=>o['param']===e['key'])['flatMap'](o=>o['values']??[])['find'](o=>o!==e['value']):undefined;let h=g??probeValue(e['value']);const i=c['plan']['inputs'][e['key']];typeof h==='number'&&typeof i==='number'&&i>=DISCLOSURE_BUILD_MS&&h<=i&&(h=i+0x5265c00);if(h===undefined)return{...e,'status':'not-flippable','effect':[],'landing':f,'editable':![]};const j=compileTemplate(a,{[e['key']]:h},{'buildTimeMs':DISCLOSURE_BUILD_MS}),k=typeof h==='number'?landedEffect(a,e['key'],h):{'effect':[]};k['effect']['length']>0x0&&!f['some'](o=>o['surface']==='allocator_row')&&f['push']({'surface':'allocator_row','site':e['key']});const l=[...changedSteps(c,j),...k['effect']],m=d['get'](e['key']);let n=l['length']>0x0?'live':'inert';return n==='inert'&&m!==undefined&&movedSteps(c,j)['length']>0x0&&(n='live'),{...e,'status':n,'effect':l['length']>0x0?l:n==='live'?['allocator_rows:'+e['key']]:l,'landing':f,'editable':n==='live'&&e['disclosure']!=='hidden',...m!==undefined&&n==='live'?{'paired_with':m}:{},...k['blocked']!==undefined?{'blocked_by':k['blocked']}:{}};});}export function disclosureSummary(a){const b=discloseParams(a);return{'total':b['length'],'knobs':b['filter'](c=>c['disclosure']==='knob')['length'],'editable':b['filter'](c=>c['editable'])['length'],'inertKnobs':b['filter'](c=>c['disclosure']==='knob'&&c['status']==='inert')['map'](c=>c['key']),'benchmark':b['filter'](c=>c['disclosure']==='card')['length'],'hidden':b['filter'](c=>c['disclosure']==='hidden')['length'],'liveKnobs':b['filter'](c=>c['disclosure']==='knob'&&c['status']==='live')['map'](c=>c['key'])};}const EXTERNAL_CARRIER={'arbitration_fee_usd':'the\x20Service\x27s\x20bound\x20Arbitration\x20object\x20(a\x20case-level\x20fee\x20configured\x20there,\x20never\x20a\x20template\x20parameter)','courier_tip_bps':'the\x20rider\x20payroll\x20settled\x20outside\x20the\x20order\x20escrow\x20(tips\x20are\x20not\x20a\x20claim\x20on\x20this\x20pool)','max_discount_bps':'the\x20Service-side\x20Discount\x20(coupon)\x20object;\x20this\x20value\x20only\x20bounds\x20what\x20that\x20object\x20may\x20charge\x20(build-time\x20scale\x20check)','merchant_service_fee_bps':'the\x20INCUMBENT\x20platform\x27s\x20merchant-side\x20fee\x20(benchmark\x20only);\x20this\x20store\x20is\x20WoWok\x20direct\x20sales\x20and\x20takes\x20no\x20platform\x20commission,\x20so\x20no\x20money\x20rail\x20reads\x20this\x20value','dispute_window_days':'the\x20keeper-enforced\x20OFF-Machine\x20arbitration\x20filing\x20window\x20(the\x20Arb\x20case\x20lives\x20outside\x20this\x20Machine;\x20the\x20rail\x20dispute-freeze\x20is\x20state-based,\x20never\x20time-based)','protection_cap_usd':'the\x20compensation-fund\x20policy\x20cap\x20(the\x20fund\x20pays\x20as\x20an\x20off-escrow\x20Entity\x20transfer\x20—\x20merchant\x20indemnity;\x20no\x20allocator\x20row\x20reads\x20it)','deposit_refund_days':'a\x20keeper\x20deadline\x20computed\x20off\x20the\x20completed-edge\x20progress-history\x20time\x20(R9\x20keeper\x20scheduling,\x20keeper_dependencies\x20carry\x20the\x20query)','inspection_deadline_hours':'a\x20keeper\x20deadline\x20computed\x20off\x20the\x20returned-edge\x20progress-history\x20time\x20(R9\x20keeper\x20scheduling)','objection_window_hours':'a\x20keeper\x20deadline\x20computed\x20off\x20the\x20inspected-edge\x20progress-history\x20time\x20(R9\x20keeper\x20scheduling)','prepay_cap':'the\x20Service\x20buy-gate\x20config\x20recommendation\x20(merchant-configurable\x20at\x20runtime,\x20not\x20a\x20plan\x20parameter)','max_sessions':'the\x20Service\x20buy-gate\x20coverage\x20bound\x20(merchant-configurable\x20at\x20runtime,\x20not\x20a\x20plan\x20parameter)'};export function inertReason(a){if(a['disclosure']==='hidden')return{'code':'hidden','detail':'Plumbing/directive\x20row:\x20not\x20offered\x20and\x20not\x20meant\x20to\x20be\x20set.'};if(a['status']==='live')return undefined;const b=EXTERNAL_CARRIER[a['key']];if(b!==undefined)return{'code':'external_object','detail':'Carried\x20by\x20'+b+'.\x20Setting\x20it\x20on\x20this\x20template\x20changes\x20nothing\x20on\x20chain\x20—\x20configure\x20it\x20on\x20that\x20object\x20instead.'};if(a['blocked_by']!==undefined)return{'code':'external_object','detail':a['blocked_by']+'.\x20This\x20value\x20is\x20carried\x20by\x20a\x20different\x20object\x20or\x20money\x20shape,\x20not\x20by\x20this\x20template\x27s\x20guards.'};if(a['status']==='not-flippable')return{'code':'not_settable','detail':'The\x20value\x20is\x20not\x20a\x20number\x20a\x20control\x20can\x20offer\x20(no\x20sibling\x20value\x20to\x20probe).'};if(a['landing']['length']===0x0)return{'code':'no_consumer','detail':'No\x20guard,\x20allocator\x20row\x20or\x20time\x20anchor\x20names\x20this\x20key\x20—\x20setting\x20it\x20changes\x20nothing\x20on\x20chain.'};if(a['landing']['every'](e=>e['surface']==='directive'))return{'code':'prose_only','detail':'Named\x20only\x20in\x20the\x20template\x27s\x20prose\x20(build\x20notes\x20/\x20user\x20inputs);\x20no\x20machine\x20object\x20reads\x20it.'};const c=[...new Set(a['landing']['map'](e=>e['surface']+'\x20\x27'+e['site']+'\x27'))]['join'](',\x20'),d=a['landing']['some'](e=>e['surface']==='allocator_row')?'\x20—\x20the\x20allocator\x20rows\x20compile\x20with\x20a\x20literal\x20value,\x20not\x20this\x20key':a['landing']['some'](e=>e['surface']==='guard')?'\x20—\x20the\x20guard\x27s\x20constant\x20is\x20frozen\x20into\x20the\x20Guard\x20at\x20publish':a['landing']['some'](e=>e['surface']==='time_anchor')?'\x20—\x20the\x20time\x20anchor\x20compiles\x20its\x20duration\x20as\x20a\x20constant':'';return{'code':'seat_not_built','detail':'A\x20seat\x20is\x20declared\x20('+c+')\x20but\x20overriding\x20the\x20value\x20does\x20not\x20change\x20the\x20compiled\x20plan'+d+'.\x20It\x20is\x20a\x20published\x20price/capacity\x20figure,\x20not\x20an\x20enforced\x20constant:\x20a\x20Machine\x20rebuild\x20is\x20what\x20changes\x20it.'};}const SURFACE_WORDING={'guard':'enforced\x20by\x20guard','allocator_row':'allocator\x20row','time_anchor':'time\x20anchor','kernel':'compile\x20kernel','directive':'prose\x20only\x20(no\x20chain\x20effect)'};export function landingLine(a){if(a['length']===0x0)return'no\x20declared\x20landing';const b=new Set(),c=[];for(const d of a){const e=SURFACE_WORDING[d['surface']]??d['surface'],f=d['surface']==='directive'?e:e+'\x20\x27'+d['site']+'\x27';if(b['has'](f))continue;b['add'](f),c['push'](f);}return c['join'](';\x20');}export function paramPlane(a){const b=new Map(paramSchema(a)['map'](c=>[c['key'],c]));return discloseParams(a)['map'](c=>{const d=b['get'](c['key']);if(d===undefined)throw new Error('paramPlane:\x20\x27'+c['key']+'\x27\x20has\x20no\x20schema\x20row\x20(classification\x20is\x20not\x20total)');const e=inertReason(c);return{...d,'status':c['status'],'effect':c['effect'],'landing':c['landing'],'landing_line':c['status']!=='live'&&EXTERNAL_CARRIER[c['key']]!==undefined?'carried\x20by\x20'+EXTERNAL_CARRIER[c['key']]:landingLine(c['landing']),'editable':c['editable'],...e!==undefined?{'inert_reason':e}:{},...c['blocked_by']!==undefined?{'blocked_by':c['blocked_by']}:{},...c['paired_with']!==undefined?{'pair_note':'Shares\x20ONE\x2010000\x20basis-point\x20split\x20with\x20\x27'+c['paired_with']+'\x27\x20—\x20set\x20both\x20together;\x20moving\x20either\x20alone\x20exceeds\x2010000\x20and\x20the\x20build\x20refuses.'}:{}};});}
@@ -19,3 +19,19 @@ export declare function recordPlanRound(planKey: string, steps: readonly PlanSte
19
19
  export declare function repeatedPlanFailures(planKey: string): RepeatedFailure[];
20
20
  export declare function lockedFreshStep(planKey: string, planStepIds: readonly string[], adopted: ReadonlySet<string>): LockedStep | undefined;
21
21
  export declare function clearPlanStep(planKey: string, stepId: string): void;
22
+ export interface PlanReceipt {
23
+ plan_key: string;
24
+ recorded_at: number;
25
+ completed: boolean;
26
+ steps: {
27
+ stepId: string;
28
+ status: string;
29
+ digest?: string;
30
+ address?: string;
31
+ error?: string;
32
+ }[];
33
+ outputs: Record<string, string>;
34
+ late_mark_bindings?: Record<string, string>;
35
+ }
36
+ export declare function writePlanReceipt(planKey: string, receipt: Omit<PlanReceipt, "plan_key" | "recorded_at">): void;
37
+ export declare function readPlanReceipt(planKey: string): PlanReceipt | undefined;
@@ -1 +1 @@
1
- const LEDGER_PLAN_CAP=0x14,ledger=new Map();export function planLedgerKey(a){let b;try{b=JSON['stringify'](a)??'';}catch{b=String(typeof a);}let c=0x811c9dc5;for(let d=0x0;d<b['length'];d++){c^=b['charCodeAt'](d),c=Math['imul'](c,0x1000193);}return(c>>>0x0)['toString'](0x10);}function entriesFor(a){let b=ledger['get'](a);if(b===undefined){b=new Map(),ledger['set'](a,b);while(ledger['size']>LEDGER_PLAN_CAP){const c=ledger['keys']()['next']()['value'];if(c===undefined)break;ledger['delete'](c);}}return b;}export function recordPlanRound(a,b){const c=entriesFor(a);for(const d of b){if(d['status']==='executed'){if(d['error']===undefined||d['error']['startsWith']('resumed\x20from\x20a\x20prior\x20run'))c['delete'](d['stepId']);continue;}if(d['status']==='failed'&&typeof d['error']==='string'&&d['error']['length']>0x0){const e=c['get'](d['stepId']);if(e!==undefined&&e['lastError']===d['error'])e['count']+=0x1;else c['set'](d['stepId'],{'lastError':d['error'],'count':0x1});}}}export function repeatedPlanFailures(a){const b=ledger['get'](a);if(b===undefined)return[];return[...b['entries']()]['filter'](([,c])=>c['count']>=0x2)['map'](([c,d])=>({'step_id':c,'consecutive_rounds':d['count'],'error':d['lastError']}));}export function lockedFreshStep(a,b,c){const d=new Map(repeatedPlanFailures(a)['map'](e=>[e['step_id'],e]));for(const e of b){if(c['has'](e))continue;const f=d['get'](e);if(f!==undefined)return{'stepId':e,'count':f['consecutive_rounds'],'lastError':f['error']};}return undefined;}export function clearPlanStep(a,b){ledger['get'](a)?.['delete'](b);}
1
+ import{existsSync,mkdirSync,readFileSync,renameSync,writeFileSync}from'node:fs';import{join}from'node:path';import{getWowMcpDir}from'@wowok/wowok';const LEDGER_PLAN_CAP=0x14,ledger=new Map();export function planLedgerKey(a){let b;try{b=JSON['stringify'](a)??'';}catch{b=String(typeof a);}let c=0x811c9dc5;for(let d=0x0;d<b['length'];d++){c^=b['charCodeAt'](d),c=Math['imul'](c,0x1000193);}return(c>>>0x0)['toString'](0x10);}function entriesFor(a){let b=ledger['get'](a);if(b===undefined){b=new Map(),ledger['set'](a,b);while(ledger['size']>LEDGER_PLAN_CAP){const c=ledger['keys']()['next']()['value'];if(c===undefined)break;ledger['delete'](c);}}return b;}export function recordPlanRound(a,b){const c=entriesFor(a);for(const d of b){if(d['status']==='executed'){if(d['error']===undefined||d['error']['startsWith']('resumed\x20from\x20a\x20prior\x20run'))c['delete'](d['stepId']);continue;}if(d['status']==='failed'&&typeof d['error']==='string'&&d['error']['length']>0x0){const e=c['get'](d['stepId']);if(e!==undefined&&e['lastError']===d['error'])e['count']+=0x1;else c['set'](d['stepId'],{'lastError':d['error'],'count':0x1});}}}export function repeatedPlanFailures(a){const b=ledger['get'](a);if(b===undefined)return[];return[...b['entries']()]['filter'](([,c])=>c['count']>=0x2)['map'](([c,d])=>({'step_id':c,'consecutive_rounds':d['count'],'error':d['lastError']}));}export function lockedFreshStep(a,b,c){const d=new Map(repeatedPlanFailures(a)['map'](e=>[e['step_id'],e]));for(const e of b){if(c['has'](e))continue;const f=d['get'](e);if(f!==undefined)return{'stepId':e,'count':f['consecutive_rounds'],'lastError':f['error']};}return undefined;}export function clearPlanStep(a,b){ledger['get'](a)?.['delete'](b);}function receiptsDir(){const a=process['env']['WOWOK_CONFIG_DIR']!==undefined&&process['env']['WOWOK_CONFIG_DIR']['length']>0x0?process['env']['WOWOK_CONFIG_DIR']:getWowMcpDir();return join(a,'plan-receipts');}function receiptPath(a){return join(receiptsDir(),a+'.json');}export function writePlanReceipt(a,b){try{const c=receiptsDir();if(!existsSync(c))mkdirSync(c,{'recursive':!![]});const d={...b,'plan_key':a,'recorded_at':Date['now']()},e=receiptPath(a)+'.tmp';writeFileSync(e,JSON['stringify'](d,null,0x2),'utf8'),renameSync(e,receiptPath(a));}catch{}}export function readPlanReceipt(a){try{const b=receiptPath(a);if(!existsSync(b))return undefined;const c=JSON['parse'](readFileSync(b,'utf8'));if(typeof c!=='object'||c===null||!Array['isArray'](c['steps']))return undefined;return c;}catch{return undefined;}}
@@ -12,6 +12,8 @@ export type LateQuery = {
12
12
  } | {
13
13
  by: "address";
14
14
  address: string;
15
+ } | {
16
+ by: "env_signer";
15
17
  };
16
18
  export interface LateExpr {
17
19
  $late: LateQuery;
@@ -23,6 +25,7 @@ export declare function isLate(v: ResolvedValue): v is LateExpr;
23
25
  export declare const P: (o: Record<string, unknown>) => ResolvedParams;
24
26
  export declare function ref(stepId: string): RefExpr;
25
27
  export declare function collectLateMarks(node: unknown, out?: Set<string>): Set<string>;
28
+ export declare function collectRecipientLateMarks(plan: Plan, out?: Set<string>): Set<string>;
26
29
  export declare function collectAddressSlotBareNames(plan: Plan, out?: Set<string>): Set<string>;
27
30
  export declare const CREATABLE_OBJECTS: {
28
31
  readonly permission: "Permission";
@@ -85,6 +88,17 @@ export interface Plan {
85
88
  external_refs?: string[];
86
89
  pending_guards?: PendingGuard[];
87
90
  derived_params?: DerivedParam[];
91
+ runtime_writes?: RuntimeWriteStep[];
92
+ }
93
+ export interface RuntimeWriteStep {
94
+ repository: RefExpr;
95
+ policy: string;
96
+ id_from: "none" | "signer" | "clock";
97
+ shape: "single_value" | "items";
98
+ call: {
99
+ data_add: Record<string, unknown>;
100
+ };
101
+ notes: string;
88
102
  }
89
103
  export interface DerivedParam {
90
104
  param: string;
@@ -99,7 +113,7 @@ export declare function stepById(plan: Plan, id: StepId): PlanStep | undefined;
99
113
  export declare function createsOf(plan: Plan, kind: CreatableKind): CreateStep[];
100
114
  export declare function resolveValue(value: ResolvedValue, outputs: ReadonlyMap<StepId, string>, resolveLate: (q: LateQuery) => string): JsonValue | string;
101
115
  export interface PlanIssue {
102
- code: "PLAN_DUP_STEP" | "PLAN_UNKNOWN_KIND" | "PLAN_REF_UNKNOWN" | "PLAN_REF_FORWARD" | "PLAN_PUBLISH_TARGET" | "PLAN_PROSE_GUARD" | "PLAN_MACHINE_NODES" | "PLAN_REQUIRES_UNKNOWN" | "PLAN_GUARD_PLACEHOLDER" | "PLAN_GUARD_EMPTY_VEC" | "PLAN_GUARD_ZERO_ADDR" | "PLAN_LOGIC_ARITY" | "PLAN_NAME_COLLISION";
116
+ code: "PLAN_DUP_STEP" | "PLAN_UNKNOWN_KIND" | "PLAN_REF_UNKNOWN" | "PLAN_REF_FORWARD" | "PLAN_PUBLISH_TARGET" | "PLAN_PROSE_GUARD" | "PLAN_MACHINE_NODES" | "PLAN_REQUIRES_UNKNOWN" | "PLAN_GUARD_PLACEHOLDER" | "PLAN_GUARD_EMPTY_VEC" | "PLAN_GUARD_ZERO_ADDR" | "PLAN_LOGIC_ARITY" | "PLAN_NAME_COLLISION" | "PLAN_LATE_EMPTY_MARK" | "PLAN_NAME_REF_ORPHAN";
103
117
  step?: StepId;
104
118
  detail: string;
105
119
  }
@@ -1 +1 @@
1
- import{OBJECT_GRAPH}from'../chain-semantics/index.js';export function isRef(a){return typeof a==='object'&&a!==null&&!Array['isArray'](a)&&typeof a['$ref']==='string'&&Object['keys'](a)['every'](b=>b==='$ref'||b==='path');}export function isLate(a){return typeof a==='object'&&a!==null&&!Array['isArray'](a)&&typeof a['$late']==='object'&&a['$late']!==null&&Object['keys'](a)['every'](b=>b==='$late');}export const P=a=>a;export function ref(a){return{'$ref':a};}export function collectLateMarks(a,b=new Set()){if(Array['isArray'](a)){for(const c of a)collectLateMarks(c,b);return b;}if(a&&typeof a==='object'){const d=a,e=d['$late'];if(e&&typeof e==='object'){const f=e;if(f['by']==='local_name'&&typeof f['mark']==='string')b['add'](f['mark']);}for(const g of Object['values'](d))collectLateMarks(g,b);}return b;}export function collectAddressSlotBareNames(a,b=new Set()){const c=d=>/^0x[0-9a-fA-F]{1,64}$/['test'](d['trim']());for(const d of a['steps']){if(d['op']!=='create'||d['object']!=='guard')continue;const e=d['params']['table'];if(!Array['isArray'](e))continue;for(const f of e){if(f===null||typeof f!=='object')continue;const g=f,h=g['value_type'],i=h==='Address',j=h==='VecAddress';if(!i&&!j)continue;const k=g['value'];i&&typeof k==='string'&&k['length']>0x0&&!c(k)&&b['add'](k);if(j&&Array['isArray'](k))for(const l of k){if(typeof l==='string'&&l['length']>0x0&&!c(l))b['add'](l);}}}return b;}export const CREATABLE_OBJECTS={'permission':'Permission','guard':'Guard','repository':'Repository','machine':'Machine','service':'Service<T>','arbitration':'Arbitration<T>','treasury':'Treasury<T>','reward':'Reward<T>','demand':'Demand','contact':'Contact','proof':'Proof','resource':'Resource'};export const PUBLISHABLE_KINDS=['service','machine'];export function refsOf(a,b=new Set()){if(isRef(a))b['add'](a['$ref']);else{if(Array['isArray'](a)){for(const c of a)refsOf(c,b);}else{if(typeof a==='object'&&a!==null&&!isLate(a)){for(const d of Object['values'](a))refsOf(d,b);}}}return b;}export function stepById(a,b){return a['steps']['find'](c=>c['id']===b);}export function createsOf(a,b){return a['steps']['filter'](c=>c['op']==='create'&&c['object']===b);}export function resolveValue(a,b,c){if(isRef(a)){const d=b['get'](a['$ref']);if(d===undefined)throw new Error('unresolved\x20ref:\x20'+a['$ref']);return a['path']?''+d+a['path']:d;}if(isLate(a))return c(a['$late']);if(Array['isArray'](a))return a['map'](e=>resolveValue(e,b,c));if(typeof a==='object'&&a!==null)return Object['fromEntries'](Object['entries'](a)['map'](([e,f])=>[e,resolveValue(f,b,c)]));return a;}function guardStructuralIssues(a,b){const c=[],d=g=>{typeof g==='string'&&g['includes']('${')&&c['push']({'code':'PLAN_GUARD_PLACEHOLDER','step':a,'detail':'unfilled\x20template\x20placeholder\x20\x27'+g['slice'](0x0,0x30)+'\x27\x20—\x20resolve\x20every\x20guard\x20param\x20before\x20execution'});},e=b['table'];if(Array['isArray'](e))for(const g of e){if(g===null||typeof g!=='object')continue;const h=g,i=h['value'];i===''&&c['push']({'code':'PLAN_GUARD_EMPTY_VEC','step':a,'detail':'table\x20row\x20'+String(h['identifier'])+'\x20carries\x20an\x20EMPTY\x20value\x20—\x20the\x20serialized\x20bytes\x20are\x20empty\x20and\x20the\x20chain\x20aborts\x20the\x20create\x20(E_TABLE_ITEM_VALUE_EMPTY=14)'}),(h['value_type']==='VecAddress'||h['value_type']===0xa)&&Array['isArray'](i)&&i['some'](j=>typeof j==='string'&&/^0x0+$/i['test'](j))&&c['push']({'code':'PLAN_GUARD_ZERO_ADDR','step':a,'detail':'table\x20row\x20'+String(h['identifier'])+'\x20(VecAddress)\x20carries\x20a\x20ZERO-ADDRESS\x20placeholder\x20—\x20'+'the\x20retired\x20ddmc4\x20B-04\x20workaround;\x20a\x20zero\x20address\x20is\x20NOT\x20\x22no\x20list\x22\x20(the\x20guard\x20table\x20would\x20claim\x20'+'address\x200\x20is\x20allowed).\x20Legal\x20exits:\x20arm\x20the\x20list\x20with\x20real\x20addresses,\x20or\x20omit\x20the\x20guard\x20via\x20'+'guard_resolutions\x20{kind:\x22omit\x22}\x20when\x20\x27no\x20list\x27\x20is\x20the\x20intended\x20polarity.'}),d(i);}const f=j=>{if(Array['isArray'](j)){for(const m of j)f(m);return;}if(j===null||typeof j!=='object')return;const l=j;(l['type']==='logic_and'||l['type']==='logic_or')&&Array['isArray'](l['nodes'])&&l['nodes']['length']===0x1&&c['push']({'code':'PLAN_LOGIC_ARITY','step':a,'detail':String(l['type'])+'\x20with\x20a\x20single\x20child\x20—\x20the\x20kernel\x20rejects\x20the\x20shape;\x20unwrap\x20the\x20operand\x20(the\x20compile\x20kernel\x20normalizes\x20this\x20automatically)'});for(const [o,p]of Object['entries'](l)){if(o==='type')continue;d(p),f(p);}};return f(b['root']),c;}export function validatePlan(a){const b=[],c=new Set(a['steps']['map'](e=>e['id'])),d=new Map();return a['steps']['forEach']((e,f)=>{d['has'](e['id'])&&b['push']({'code':'PLAN_DUP_STEP','step':e['id'],'detail':'duplicate\x20step\x20id\x20at\x20index\x20'+f});d['set'](e['id'],f);if(e['op']==='create'){if(!(e['object']in CREATABLE_OBJECTS))b['push']({'code':'PLAN_UNKNOWN_KIND','step':e['id'],'detail':'unknown\x20object\x20kind:\x20'+e['object']});else!(CREATABLE_OBJECTS[e['object']]in OBJECT_GRAPH)&&b['push']({'code':'PLAN_UNKNOWN_KIND','step':e['id'],'detail':'kind\x20'+e['object']+'\x20not\x20in\x20chain\x20OBJECT_GRAPH'});if(e['object']==='guard'){const h=e['params']['table'];(!Array['isArray'](h)||h['length']===0x0)&&b['push']({'code':'PLAN_PROSE_GUARD','step':e['id'],'detail':'guard\x20requires\x20a\x20non-empty\x20structured\x20`table`\x20param\x20(no\x20prose\x20logic\x20slots)'}),b['push'](...guardStructuralIssues(e['id'],e['params']));}if(e['object']==='machine'){const j=e['params']['nodes'];(!Array['isArray'](j)||j['length']===0x0)&&b['push']({'code':'PLAN_MACHINE_NODES','step':e['id'],'detail':'machine\x20requires\x20a\x20non-empty\x20`nodes`\x20param'});}}if(e['op']==='configure'){for(const k of e['requires']??[]){(!d['has'](k)||d['get'](k)===f)&&b['push']({'code':'PLAN_REQUIRES_UNKNOWN','step':e['id'],'detail':'requires\x20unknown/prior-less\x20step:\x20'+k});}typeof e['target']==='string'&&c['has'](e['target'])&&b['push']({'code':'PLAN_NAME_COLLISION','step':e['id'],'detail':'target\x20\x27'+e['target']+'\x27\x20names\x20a\x20create\x20step\x20in\x20THIS\x20plan\x20—\x20pass\x20{\x22$ref\x22:\x20\x22'+e['target']+'\x22}\x20so\x20it\x20binds\x20to\x20this\x20run\x27s\x20output.\x20'+'A\x20bare\x20name\x20resolves\x20through\x20the\x20global\x20mark\x20namespace\x20and\x20silently\x20binds\x20a\x20previous\x20run\x27s\x20object\x20(frozen,\x20unrepairable)'});}if(e['op']==='publish'){const l=d['get'](e['target']['$ref']),m=l===undefined?undefined:a['steps'][l];if(!c['has'](e['target']['$ref']))b['push']({'code':'PLAN_REF_UNKNOWN','step':e['id'],'detail':'publish\x20target\x20unknown:\x20'+e['target']['$ref']});else(m===undefined||m['op']!=='create'||!PUBLISHABLE_KINDS['includes'](m['object']))&&b['push']({'code':'PLAN_PUBLISH_TARGET','step':e['id'],'detail':'publish\x20target\x20must\x20be\x20a\x20created\x20service|machine,\x20got:\x20'+(m?.['op']==='create'?m['object']:m?.['op'])});}const g=e['op']==='create'||e['op']==='configure'?refsOf(e['params']):new Set();if(e['op']==='configure'&&isRef(e['target']))g['add'](e['target']['$ref']);if(e['op']==='publish')g['add'](e['target']['$ref']);for(const n of g){const o=d['get'](n);if(!c['has'](n))b['push']({'code':'PLAN_REF_UNKNOWN','step':e['id'],'detail':'ref\x20to\x20unknown\x20step:\x20'+n});else(o===undefined||o>=f)&&b['push']({'code':'PLAN_REF_FORWARD','step':e['id'],'detail':'ref\x20to\x20non-prior\x20step:\x20'+n});}}),b;}
1
+ import{OBJECT_GRAPH}from'../chain-semantics/index.js';export function isRef(a){return typeof a==='object'&&a!==null&&!Array['isArray'](a)&&typeof a['$ref']==='string'&&Object['keys'](a)['every'](b=>b==='$ref'||b==='path');}export function isLate(a){return typeof a==='object'&&a!==null&&!Array['isArray'](a)&&typeof a['$late']==='object'&&a['$late']!==null&&Object['keys'](a)['every'](b=>b==='$late');}export const P=a=>a;export function ref(a){return{'$ref':a};}export function collectLateMarks(a,b=new Set()){if(Array['isArray'](a)){for(const c of a)collectLateMarks(c,b);return b;}if(a&&typeof a==='object'){const d=a,e=d['$late'];if(e&&typeof e==='object'){const f=e;if(f['by']==='local_name'&&typeof f['mark']==='string')b['add'](f['mark']);}for(const g of Object['values'](d))collectLateMarks(g,b);}return b;}export function collectRecipientLateMarks(a,b=new Set()){const c=d=>{if(typeof d==='object'&&d!==null&&!Array['isArray'](d)){const e=d;if(Array['isArray'](e['allocators']))d=e['allocators'];}if(!Array['isArray'](d))return;for(const f of d){if(typeof f!=='object'||f===null)continue;const g=f,h=Array['isArray'](g['sharing'])?g['sharing']:[];for(const i of h){const j=i?.['who'],k=j?.['Entity'],m=k?.['name_or_address'],n=m!==null&&typeof m==='object'?m['$late']:undefined;if(n!==null&&typeof n==='object'){const o=n;if(o['by']==='local_name'&&typeof o['mark']==='string')b['add'](o['mark']);}}}};for(const d of a['steps']){if(d['op']==='create'&&d['object']==='service')c(d['params']['order_allocators']);if(d['op']==='configure'&&d['method']==='order_allocators')c(d['params']['allocators']);}return b;}export function collectAddressSlotBareNames(a,b=new Set()){const c=d=>/^0x[0-9a-fA-F]{1,64}$/['test'](d['trim']());for(const d of a['steps']){if(d['op']!=='create'||d['object']!=='guard')continue;const e=d['params']['table'];if(!Array['isArray'](e))continue;for(const f of e){if(f===null||typeof f!=='object')continue;const g=f,h=g['value_type'],i=h==='Address',j=h==='VecAddress';if(!i&&!j)continue;const k=g['value'];i&&typeof k==='string'&&k['length']>0x0&&!c(k)&&b['add'](k);if(j&&Array['isArray'](k))for(const l of k){if(typeof l==='string'&&l['length']>0x0&&!c(l))b['add'](l);}}}return b;}export const CREATABLE_OBJECTS={'permission':'Permission','guard':'Guard','repository':'Repository','machine':'Machine','service':'Service<T>','arbitration':'Arbitration<T>','treasury':'Treasury<T>','reward':'Reward<T>','demand':'Demand','contact':'Contact','proof':'Proof','resource':'Resource'};export const PUBLISHABLE_KINDS=['service','machine'];export function refsOf(a,b=new Set()){if(isRef(a))b['add'](a['$ref']);else{if(Array['isArray'](a)){for(const c of a)refsOf(c,b);}else{if(typeof a==='object'&&a!==null&&!isLate(a)){for(const d of Object['values'](a))refsOf(d,b);}}}return b;}export function stepById(a,b){return a['steps']['find'](c=>c['id']===b);}export function createsOf(a,b){return a['steps']['filter'](c=>c['op']==='create'&&c['object']===b);}export function resolveValue(a,b,c){if(isRef(a)){const d=b['get'](a['$ref']);if(d===undefined)throw new Error('unresolved\x20ref:\x20'+a['$ref']);return a['path']?''+d+a['path']:d;}if(isLate(a))return c(a['$late']);if(Array['isArray'](a))return a['map'](e=>resolveValue(e,b,c));if(typeof a==='object'&&a!==null)return Object['fromEntries'](Object['entries'](a)['map'](([e,f])=>[e,resolveValue(f,b,c)]));return a;}function guardStructuralIssues(a,b){const c=[],d=['WRITER_ACCOUNT_ADDRESS'],e=h=>{if(typeof h==='string'&&h['includes']('${')){c['push']({'code':'PLAN_GUARD_PLACEHOLDER','step':a,'detail':'unfilled\x20template\x20placeholder\x20\x27'+h['slice'](0x0,0x30)+'\x27\x20—\x20resolve\x20every\x20guard\x20param\x20before\x20execution'});return;}typeof h==='string'&&d['some'](i=>h['includes'](i))&&c['push']({'code':'PLAN_GUARD_PLACEHOLDER','step':a,'detail':'unfilled\x20template\x20placeholder\x20sentinel\x20\x27'+h['slice'](0x0,0x30)+'\x27\x20—\x20resolve\x20every\x20guard\x20param\x20before\x20execution\x20(algr12\x20P0-5:\x20this\x20literal\x20published\x20to\x20mainnet\x20and\x20blocked\x20every\x20evidence\x20write)'});},f=b['table'];if(Array['isArray'](f))for(const h of f){if(h===null||typeof h!=='object')continue;const i=h,j=i['value'];j===''&&c['push']({'code':'PLAN_GUARD_EMPTY_VEC','step':a,'detail':'table\x20row\x20'+String(i['identifier'])+'\x20carries\x20an\x20EMPTY\x20value\x20—\x20the\x20serialized\x20bytes\x20are\x20empty\x20and\x20the\x20chain\x20aborts\x20the\x20create\x20(E_TABLE_ITEM_VALUE_EMPTY=14)'}),(i['value_type']==='VecAddress'||i['value_type']===0xa)&&Array['isArray'](j)&&j['some'](k=>typeof k==='string'&&/^0x0+$/i['test'](k))&&c['push']({'code':'PLAN_GUARD_ZERO_ADDR','step':a,'detail':'table\x20row\x20'+String(i['identifier'])+'\x20(VecAddress)\x20carries\x20a\x20ZERO-ADDRESS\x20placeholder\x20—\x20'+'the\x20retired\x20ddmc4\x20B-04\x20workaround;\x20a\x20zero\x20address\x20is\x20NOT\x20\x22no\x20list\x22\x20(the\x20guard\x20table\x20would\x20claim\x20'+'address\x200\x20is\x20allowed).\x20Legal\x20exits:\x20arm\x20the\x20list\x20with\x20real\x20addresses,\x20or\x20omit\x20the\x20guard\x20via\x20'+'guard_resolutions\x20{kind:\x22omit\x22}\x20when\x20\x27no\x20list\x27\x20is\x20the\x20intended\x20polarity.'}),e(j);}const g=l=>{if(Array['isArray'](l)){for(const o of l)g(o);return;}if(l===null||typeof l!=='object')return;const m=l;(m['type']==='logic_and'||m['type']==='logic_or')&&Array['isArray'](m['nodes'])&&m['nodes']['length']===0x1&&c['push']({'code':'PLAN_LOGIC_ARITY','step':a,'detail':String(m['type'])+'\x20with\x20a\x20single\x20child\x20—\x20the\x20kernel\x20rejects\x20the\x20shape;\x20unwrap\x20the\x20operand\x20(the\x20compile\x20kernel\x20normalizes\x20this\x20automatically)'});for(const [p,q]of Object['entries'](m)){if(p==='type')continue;e(q),g(q);}};return g(b['root']),c;}function lateEmptyMarkIssues(a,b){const c=[],d=e=>{if(Array['isArray'](e)){for(const h of e)d(h);return;}if(e===null||typeof e!=='object')return;const f=e,g=f['$late'];if(g!==null&&typeof g==='object'){const i=g;i['by']==='local_name'&&typeof i['mark']==='string'&&i['mark']['length']===0x0&&c['push']({'code':'PLAN_LATE_EMPTY_MARK','step':a,'detail':'{$late:{by:\x27local_name\x27,\x20mark:\x27\x27}}\x20—\x20an\x20EMPTY\x20mark\x20makes\x20the\x20SDK\x20substitute\x20the\x20deployer\x27s\x20own\x20account\x20for\x20the\x20Entity/name\x20slot\x20(cour\x20ENTITY-LATENAME);\x20declare\x20the\x20LocalMark\x20name\x20and\x20register\x20it\x20before\x20running'}),i['by']==='address'&&typeof i['address']==='string'&&i['address']['length']===0x0&&c['push']({'code':'PLAN_LATE_EMPTY_MARK','step':a,'detail':'{$late:{by:\x27address\x27,\x20address:\x27\x27}}\x20—\x20an\x20EMPTY\x20address\x20makes\x20the\x20SDK\x20substitute\x20the\x20deployer\x27s\x20own\x20account\x20for\x20the\x20Entity/name\x20slot\x20(cour\x20ENTITY-LATENAME);\x20bind\x20a\x20real\x20address'});}for(const j of Object['values'](f))d(j);};return d(b),c;}function nameReferenceOrphanIssues(a){const b=new Set();for(const e of a['steps']){if(e['op']!=='create')continue;const f=e['params']['name'];if(typeof f==='string'&&f['length']>0x0)b['add'](f);}const c=new Set(a['external_refs']??[]),d=[];for(const g of a['steps']){if(g['op']!=='configure')continue;const h=i=>{if(Array['isArray'](i)){for(const l of i)h(l);return;}if(i===null||typeof i!=='object')return;const j=i,k=Object['keys'](j);if(k['length']===0x1&&k[0x0]==='name'&&typeof j['name']==='string'){const m=j['name'];!b['has'](m)&&!c['has'](m)&&d['push']({'code':'PLAN_NAME_REF_ORPHAN','step':g['id'],'detail':'configure\x20step\x20\x27{'+g['id']+'}\x27\x20references\x20an\x20object\x20by\x20bare\x20name\x20form\x20{name:\x20\x22'+m+'\x22}\x20with\x20NO\x20create\x20step\x20in\x20this\x20plan\x20and\x20no\x20external_refs\x20declaration\x20—\x20'+'the\x20SDK\x27s\x20name-resolution\x20semantics\x20are\x20CREATE-IF-MISSING,\x20so\x20this\x20write\x20would\x20mint\x20a\x20fresh\x20orphan\x20object\x20instead\x20of\x20binding\x20the\x20intended\x20one\x20(cour\x20ORPHAN-REPO,\x20mainnet:\x202\x20permanent\x20orphans,\x200.0123\x20WOW;\x20guards\x20freeze\x20at\x20publish).\x20'+('Fix:\x20create\x20the\x20object\x20explicitly\x20in\x20this\x20plan\x20and\x20pass\x20{\x22$ref\x22:\x20\x22<step-id>\x22},\x20or\x20declare\x20\x22'+m+'\x22\x20in\x20plan.external_refs\x20AFTER\x20registering\x20the\x20LocalMark\x20—\x20')+('or,\x20if\x20minting\x20is\x20truly\x20intended,\x20make\x20it\x20explicit\x20with\x20{name:\x20\x22'+m+'\x22,\x20create_if_missing:\x20true}')});}else{for(const o of Object['values'](j))h(o);}};h(g['params']);}return d;}export function validatePlan(a){const b=[],c=new Set(a['steps']['map'](e=>e['id'])),d=new Map();return a['steps']['forEach']((e,f)=>{d['has'](e['id'])&&b['push']({'code':'PLAN_DUP_STEP','step':e['id'],'detail':'duplicate\x20step\x20id\x20at\x20index\x20'+f});d['set'](e['id'],f);if(e['op']==='create'){if(!(e['object']in CREATABLE_OBJECTS))b['push']({'code':'PLAN_UNKNOWN_KIND','step':e['id'],'detail':'unknown\x20object\x20kind:\x20'+e['object']});else!(CREATABLE_OBJECTS[e['object']]in OBJECT_GRAPH)&&b['push']({'code':'PLAN_UNKNOWN_KIND','step':e['id'],'detail':'kind\x20'+e['object']+'\x20not\x20in\x20chain\x20OBJECT_GRAPH'});if(e['object']==='guard'){const h=e['params']['table'];(!Array['isArray'](h)||h['length']===0x0)&&b['push']({'code':'PLAN_PROSE_GUARD','step':e['id'],'detail':'guard\x20requires\x20a\x20non-empty\x20structured\x20`table`\x20param\x20(no\x20prose\x20logic\x20slots)'}),b['push'](...guardStructuralIssues(e['id'],e['params']));}if(e['object']==='machine'){const j=e['params']['nodes'];(!Array['isArray'](j)||j['length']===0x0)&&b['push']({'code':'PLAN_MACHINE_NODES','step':e['id'],'detail':'machine\x20requires\x20a\x20non-empty\x20`nodes`\x20param'});}}if(e['op']==='configure'){for(const k of e['requires']??[]){(!d['has'](k)||d['get'](k)===f)&&b['push']({'code':'PLAN_REQUIRES_UNKNOWN','step':e['id'],'detail':'requires\x20unknown/prior-less\x20step:\x20'+k});}typeof e['target']==='string'&&c['has'](e['target'])&&b['push']({'code':'PLAN_NAME_COLLISION','step':e['id'],'detail':'target\x20\x27'+e['target']+'\x27\x20names\x20a\x20create\x20step\x20in\x20THIS\x20plan\x20—\x20pass\x20{\x22$ref\x22:\x20\x22'+e['target']+'\x22}\x20so\x20it\x20binds\x20to\x20this\x20run\x27s\x20output.\x20'+'A\x20bare\x20name\x20resolves\x20through\x20the\x20global\x20mark\x20namespace\x20and\x20silently\x20binds\x20a\x20previous\x20run\x27s\x20object\x20(frozen,\x20unrepairable)'});}if(e['op']==='publish'){const l=d['get'](e['target']['$ref']),m=l===undefined?undefined:a['steps'][l];if(!c['has'](e['target']['$ref']))b['push']({'code':'PLAN_REF_UNKNOWN','step':e['id'],'detail':'publish\x20target\x20unknown:\x20'+e['target']['$ref']});else(m===undefined||m['op']!=='create'||!PUBLISHABLE_KINDS['includes'](m['object']))&&b['push']({'code':'PLAN_PUBLISH_TARGET','step':e['id'],'detail':'publish\x20target\x20must\x20be\x20a\x20created\x20service|machine,\x20got:\x20'+(m?.['op']==='create'?m['object']:m?.['op'])});}e['op']!=='publish'&&e['params']!==undefined&&b['push'](...lateEmptyMarkIssues(e['id'],e['params']));const g=e['op']==='create'||e['op']==='configure'?refsOf(e['params']):new Set();if(e['op']==='configure'&&isRef(e['target']))g['add'](e['target']['$ref']);if(e['op']==='publish')g['add'](e['target']['$ref']);for(const n of g){const o=d['get'](n);if(!c['has'](n))b['push']({'code':'PLAN_REF_UNKNOWN','step':e['id'],'detail':'ref\x20to\x20unknown\x20step:\x20'+n});else(o===undefined||o>=f)&&b['push']({'code':'PLAN_REF_FORWARD','step':e['id'],'detail':'ref\x20to\x20non-prior\x20step:\x20'+n});}}),b['push'](...nameReferenceOrphanIssues(a)),b;}
@@ -1 +1 @@
1
- import{afterEach,beforeEach,describe,expect,it}from'vitest';import{existsSync,mkdtempSync,rmSync,writeFileSync}from'node:fs';import{tmpdir}from'node:os';import{join}from'node:path';import{ENTRYPOINT}from'@wowok/wowok';import{clearJudgmentLayers,clearJudgmentOverride,clearJudgmentOverrides,getJudgmentDoc,judgmentDisableTrace,judgmentLayerError,judgmentStatus,patchUserJudgmentDoc,setJudgmentIndustryOverlay,setJudgmentOverride,setJudgmentPersonaFragment}from'./judgment.js';import{checkUtilRisks}from'../knowledge/util-risk.js';import{appetiteMultiplier,evaluateOutcome,resolveInterests}from'../evaluation/game-strategy.js';import{evaluateArbGame}from'../evaluation/arbitration-game.js';import{registerDemandMatchEvaluation,matchDemandToServices}from'../evaluation/builtins/demand-match.js';import{extractDemandCapability}from'../evaluation/extract.js';import{monitorOrder}from'../customer/order-monitor.js';import{ModeEvaluator}from'../extensions/mode-evaluator.js';import{mergedBaselinesOverlay,registerIndustryBaselines}from'../extensions/industry-layers.js';import{scoreScorecard}from'../strategy/scorecard.js';import{FakeDataPlane}from'../graph/onchain/dataplane.js';import{expandTopology}from'../graph/onchain/expand.js';import{FULL,fullServiceState}from'../graph/onchain/fixtures.js';import{buildViewport}from'../graph/onchain/viewport.js';import{runAnalyzers}from'../graph/onchain/analyze.js';import{EVALUATION_SERVICE_INTENTS,resolveExpansionStrategy,withEvaluationBundle}from'../graph/onchain/strategy.js';import{projectEvaluationFacts}from'../graph/onchain/facts.js';import{evaluateGraphServiceFacts,registerGraphServiceEvaluations}from'../evaluation/builtins/graph-service.js';let configDir;function writeUserDoc(a){writeFileSync(join(configDir,'judgment.json'),JSON['stringify'](a,null,0x2),'utf-8');}beforeEach(()=>{configDir=mkdtempSync(join(tmpdir(),'wowok-config-audit-')),process['env']['WOWOK_CONFIG_DIR']=configDir,registerDemandMatchEvaluation();}),afterEach(()=>{delete process['env']['WOWOK_CONFIG_DIR'];if(existsSync(configDir))rmSync(configDir,{'recursive':!![],'force':!![]});clearJudgmentOverrides(),clearJudgmentLayers();});async function projectFixture(){registerGraphServiceEvaluations();const a=withEvaluationBundle(resolveExpansionStrategy({'intents':[...EVALUATION_SERVICE_INTENTS]})),b=await expandTopology(new FakeDataPlane(fullServiceState()),{'network':ENTRYPOINT['Mainnet'],'seed':FULL['svc'],'edges':a['edges'],'budget':a['budget']}),c=buildViewport(b,FULL['svc'],'neutral');return projectEvaluationFacts(c,FULL['svc'],runAnalyzers(c));}const demandCap=extractDemandCapability({'object':'0xdemand','location':'Shanghai','description':'need\x20a\x20freelance\x20designer'},{'industry':'freelance','price_max':0x96n,'keywords':['design','logo'],'capabilities':{'has_arbitration':!![],'has_refund_path':!![],'has_milestone_nodes':![],'has_compensation_fund':![],'has_wip_verification':!![],'has_messenger':![],'has_buy_guard':![],'has_dynamic_pricing':![],'is_published':!![],'is_paused':![]}}),inRegionService={'object':'0xgood','location':'Shanghai','description':'freelance\x20logo\x20design','sales':[{'price':'100','wip_hash':'abc'}],'arbitrations':['0xarb'],'compensation_fund':'500','bPublished':!![],'bPaused':![]},breakdownOf=(a,b)=>a['breakdown']['find'](c=>c['rule_id']===b);describe('config\x20audit\x20—\x20evaluation\x20section',()=>{it('1.\x20weights.trust_reviews\x20flows\x20into\x20the\x20aggregated\x20trust\x20total\x20(user\x20doc\x20channel)',async()=>{const a=await projectFixture(),b=await evaluateGraphServiceFacts(a);expect(b['trust']['breakdown']['find'](d=>d['rule_id']==='trust_reviews')['weight'])['toBe'](0x23),writeUserDoc({'version':0x1,'evaluation':{'weights':{'trust_reviews':0x46}}});const c=await evaluateGraphServiceFacts(a);expect(c['trust']['breakdown']['find'](d=>d['rule_id']==='trust_reviews')['weight'])['toBe'](0x46),expect(c['trust']['total'])['toBe'](0x2f);}),it('2.\x20severity_deduction.critical\x2050→5\x20lifts\x20the\x20risk-side\x20rule\x20score\x20(session\x20override)',async()=>{const a=await projectFixture(),b=await evaluateGraphServiceFacts(a);expect(b['risk']['breakdown']['find'](d=>d['rule_id']==='risk_fund')['score'])['toBe'](0x19),expect(setJudgmentOverride('evaluation.severity_deduction.critical',0x5))['toEqual']({'ok':!![]});const c=await evaluateGraphServiceFacts(a);expect(c['risk']['breakdown']['find'](d=>d['rule_id']==='risk_fund')['score'])['toBe'](0x46),expect(c['risk']['breakdown']['find'](d=>d['rule_id']==='risk_trust')['score'])['toBe'](0x41),expect(c['risk']['total'])['toBe'](0x56);}),it('3.\x20level_bands\x20first\x20band\x20min\x2085→30\x20flips\x20the\x20level\x20of\x20an\x20unchanged\x20score\x20(session\x20override)',async()=>{const a=await projectFixture(),b=await evaluateGraphServiceFacts(a);expect(b['trust']['total'])['toBe'](0x31),expect(b['trust']['level'])['toBe']('high'),setJudgmentOverride('evaluation.level_bands',[{'min':0x1e,'level':'low'},{'min':0x46,'level':'medium_low'},{'min':0x32,'level':'medium_high'},{'min':0x0,'level':'high'}]);const c=await evaluateGraphServiceFacts(a);expect(c['trust']['total'])['toBe'](0x31),expect(c['trust']['level'])['toBe']('low');}),it('4.\x20grade_words.trust\x20first\x20band\x20min\x2070→20\x20flips\x20the\x20rendered\x20grade\x20word\x20(session\x20override)',async()=>{const a=await projectFixture(),b=await evaluateGraphServiceFacts(a);expect(b['trust']['summary'])['toContain']('grade:\x20weak'),setJudgmentOverride('evaluation.grade_words.trust',[{'min':0x14,'word':'strong'},{'min':0x32,'word':'fair'},{'min':0x0,'word':'weak'}]);const c=await evaluateGraphServiceFacts(a);expect(c['trust']['summary'])['toContain']('grade:\x20strong');}),it('5.\x20dimensions.<id>.label\x20retune\x20reaches\x20the\x20live\x20summary\x20rendering\x20(industry\x20overlay\x20channel)',async()=>{const a=await projectFixture(),b=await evaluateGraphServiceFacts(a);expect(b['trust']['summary'])['toContain']('weakest\x20Fund\x20safety'),setJudgmentIndustryOverlay({'evaluation':{'dimensions':{'trust_fund_safety':{'label':'Fund\x20Cushion','description':'audit\x20retune'}}}},'pack:audit');const c=await evaluateGraphServiceFacts(a);expect(c['trust']['summary'])['toContain']('weakest\x20Fund\x20Cushion'),expect(c['trust']['breakdown']['find'](d=>d['rule_id']==='trust_fund_safety')['dimension'])['toBe']('Fund\x20Cushion');});}),describe('config\x20audit\x20—\x20game\x20section',()=>{it('6.\x20scoring.base\x2060→80\x20lifts\x20every\x20net\x20score\x20(judgment_doc_patch\x20channel)',()=>{expect(evaluateOutcome('refund','customer')['net_score'])['toBe'](0x50);const a=patchUserJudgmentDoc({'game':{'scoring':{'base':0x50}}});expect(a['applied'])['toBe'](!![]),expect(evaluateOutcome('refund','customer')['net_score'])['toBe'](0x64);}),it('7.\x20appetite_multipliers.conservative\x201.5→0.6\x20changes\x20the\x20conservative\x20sensitivity\x20result\x20(session\x20override)',()=>{const a=evaluateOutcome('refund','merchant',{'risk_appetite':'conservative'});expect(a['risk_score'])['toBe'](0x4b),expect(a['net_score'])['toBe'](0x0),setJudgmentOverride('game.appetite_multipliers.conservative',0.6);const b=evaluateOutcome('refund','merchant',{'risk_appetite':'conservative'});expect(b['risk_score'])['toBe'](0x1e),expect(b['net_score'])['toBe'](0x1e),expect(appetiteMultiplier('conservative'))['toBe'](0.6);}),it('8.\x20role_interests.customer.prefer\x20+\x20node_advanced\x20adds\x20a\x20gain\x20(industry\x20overlay\x20channel)',()=>{const a=evaluateOutcome('advance','customer');expect(a['gains'])['toEqual']([]),expect(a['net_score'])['toBe'](0x3c),setJudgmentIndustryOverlay({'game':{'role_interests':{'customer':{'prefer':['fund_returned_to_buyer','node_advanced'],'avoid':[],'sensitivity':0x1}}}},'pack:audit');const b=evaluateOutcome('advance','customer');expect(b['gains'])['toEqual'](['node_advanced']),expect(b['net_score'])['toBe'](0x50);}),it('9.\x20a\x20new\x20keyword_rules\x20entry\x20re-anchors\x20prefer\x20on\x20a\x20matching\x20requirement\x20(user\x20doc\x20channel)',()=>{const a=resolveInterests('system',{'requirements':['please\x20test\x20it']});expect(a['prefer'])['toEqual']([]),writeUserDoc({'version':0x1,'game':{'keyword_rules':[{'id':'kw_audit_testing','keywords':['test'],'effect':'node_advanced','anchor':'prefer','when_forbidden':![]}]}});const b=resolveInterests('system',{'requirements':['please\x20test\x20it']});expect(b['prefer'])['toEqual'](['node_advanced']);}),it('10.\x20forbid_pattern\x20rewritten\x20to\x20a\x20non-matching\x20pattern\x20disarms\x20when_forbidden\x20rules\x20(user\x20doc\x20channel)',()=>{const a=resolveInterests('neutral',{'requirements':['never\x20arbitration']});expect(a['avoid'])['toContain']('arbitration_review_triggered'),writeUserDoc({'version':0x1,'game':{'forbid_pattern':'zzz_never_matches'}});const b=resolveInterests('neutral',{'requirements':['never\x20arbitration']});expect(b['avoid'])['toEqual']([]);});}),describe('config\x20audit\x20—\x20game.arb\x20section\x20(7-state\x20game)',()=>{it('11.\x20arb.scoring.per_gain\x2020→40\x20moves\x20the\x20favorability\x20of\x20a\x201-gain\x20move\x20(session\x20override)',()=>{const a=evaluateArbGame('Voting','arbitrator');expect(a['actions'][0x0]?.['gain_score'])['toBe'](0x14),expect(a['actions'][0x0]?.['favorability'])['toBe'](0x50),setJudgmentOverride('game.arb.scoring.per_gain',0x28);const b=evaluateArbGame('Voting','arbitrator');expect(b['actions'][0x0]?.['gain_score'])['toBe'](0x28),expect(b['actions'][0x0]?.['favorability'])['toBe'](0x64);}),it('12.\x20a\x20new\x20arb\x20keyword_rules\x20entry\x20re-anchors\x20a\x20perspective\x27s\x20prefer\x20(user\x20doc\x20channel)',()=>{const a=evaluateArbGame('Principal_confirming','customer',{'requirements':['expedite\x20please']});expect(a['actions'][0x0]?.['gain_score'])['toBe'](0x0),expect(a['actions'][0x0]?.['favorability'])['toBe'](0x3c),writeUserDoc({'version':0x1,'game':{'arb':{'keyword_rules':[{'id':'arb_kw_audit_expedite','keywords':['expedite'],'effect':'case_advanced','anchor':'prefer','when_forbidden':![]}]}}});const b=evaluateArbGame('Principal_confirming','customer',{'requirements':['expedite\x20please']});expect(b['actions'][0x0]?.['gain_score'])['toBe'](0x14),expect(b['actions'][0x0]?.['favorability'])['toBe'](0x50);});}),describe('config\x20audit\x20—\x20match\x20section',()=>{it('13.\x20region_scores.exact\x20100→50\x20halves\x20the\x20region\x20rule\x20score\x20(session\x20override)',async()=>{const [a]=await matchDemandToServices(demandCap,[inRegionService]);expect(breakdownOf(a['result'],'region')['score'])['toBe'](0x64),setJudgmentOverride('match.region_scores.exact',0x32);const [b]=await matchDemandToServices(demandCap,[inRegionService]);expect(breakdownOf(b['result'],'region')['score'])['toBe'](0x32),expect(b['result']['total'])['toBeLessThan'](a['result']['total']);}),it('14.\x20weights.capabilities\x2030→60\x20raises\x20its\x20renormalized\x20share\x20(session\x20override)',async()=>{const [a]=await matchDemandToServices(demandCap,[inRegionService]);expect(breakdownOf(a['result'],'capabilities')['weight'])['toBe'](0x1e),expect(a['result']['total'])['toBe'](0x49),setJudgmentOverride('match.weights.capabilities',0x3c);const [b]=await matchDemandToServices(demandCap,[inRegionService]);expect(breakdownOf(b['result'],'capabilities')['weight'])['toBe'](0x3c),expect(breakdownOf(b['result'],'region')['weight'])['toBe'](0xf),expect(b['result']['total'])['toBe'](0x4e);}),it('15.\x20trust_bands\x20second\x20band\x20score\x2060→10\x20(extracted\x20trust_score\x20is\x2050\x20→\x20band\x20#2)\x20(session\x20override)',async()=>{const [a]=await matchDemandToServices(demandCap,[inRegionService]);expect(breakdownOf(a['result'],'trust')['score'])['toBe'](0x3c),setJudgmentOverride('match.trust_bands',[{'min':0x4b,'score':0x64},{'min':0x32,'score':0xa},{'min':0x19,'score':0x1e},{'min':0x0,'score':0x0}]);const [b]=await matchDemandToServices(demandCap,[inRegionService]);expect(breakdownOf(b['result'],'trust')['score'])['toBe'](0xa);}),it('16.\x20neutral_score\x2050→10\x20changes\x20unknown-signal\x20scoring\x20(user\x20doc\x20channel)',async()=>{const a=extractDemandCapability({'object':'0xdemand','location':'Shanghai','description':'anything'},{'industry':'freelance','price_max':0x96n,'keywords':[],'capabilities':{'has_arbitration':![],'has_refund_path':![],'has_milestone_nodes':![],'has_compensation_fund':![],'has_wip_verification':![],'has_messenger':![],'has_buy_guard':![],'has_dynamic_pricing':![],'is_published':![],'is_paused':![]}}),[b]=await matchDemandToServices(a,[inRegionService]);expect(breakdownOf(b['result'],'tags')['score'])['toBe'](0x32),writeUserDoc({'version':0x1,'match':{'neutral_score':0xa}});const [c]=await matchDemandToServices(a,[inRegionService]);expect(breakdownOf(c['result'],'tags')['score'])['toBe'](0xa);}),it('17.\x20price_over_budget_tolerance_pct\x2010→100\x20turns\x20a\x20rejection\x20into\x20a\x20partial\x20score\x20(session\x20override)',async()=>{const a={...inRegionService,'object':'0xpricey','sales':[{'price':'200','wip_hash':'x'}]},[b]=await matchDemandToServices(demandCap,[a]);expect(breakdownOf(b['result'],'price')['score'])['toBe'](0x0),setJudgmentOverride('match.price_over_budget_tolerance_pct',0x64);const [c]=await matchDemandToServices(demandCap,[a]);expect(breakdownOf(c['result'],'price')['score'])['toBe'](0x32);}),it('18.\x20top_n\x205→2\x20caps\x20the\x20returned\x20candidate\x20count\x20(session\x20override)',async()=>{const a=[inRegionService,{...inRegionService,'object':'0xb'},{...inRegionService,'object':'0xc'}];expect((await matchDemandToServices(demandCap,a))['length'])['toBe'](0x3),setJudgmentOverride('match.top_n',0x2),expect((await matchDemandToServices(demandCap,a))['length'])['toBe'](0x2);});}),describe('config\x20audit\x20—\x20monitor\x20section',()=>{const a=0x36ee80,b=c=>({'order_id':'0xorder','service_id':'0xservice','created_at':0x64*a,'now':0x64*a,...c});it('19.\x20messenger_timeout_hours\x2024→1\x20surfaces\x20the\x20timeout\x20finding\x20(user\x20doc\x20hot\x20reload)',()=>{const c=b({'last_user_message_at':0x62*a,'has_messenger':!![]});expect(monitorOrder({'current':c})['map'](f=>f['id']))['not']['toContain']('messenger_unanswered'),writeUserDoc({'version':0x1,'monitor':{'thresholds':{'messenger_timeout_hours':0x1}}});const d=monitorOrder({'current':c}),e=d['find'](f=>f['id']==='messenger_unanswered');expect(e?.['severity'])['toBe']('high');}),it('20.\x20escalation.stall_escalation_multiplier\x202→1\x20moves\x20the\x20critical\x20escalation\x20point\x20(session\x20override)',()=>{const c=b({'current_node':'Pay','last_progress_at':0x14*a}),d=monitorOrder({'current':c})['find'](f=>f['id']==='progress_stall');expect(d?.['severity'])['toBe']('high'),setJudgmentOverride('monitor.escalation.stall_escalation_multiplier',0x1);const e=monitorOrder({'current':c})['find'](f=>f['id']==='progress_stall');expect(e?.['severity'])['toBe']('critical');}),it('21.\x20compensation_coverage_min\x201.0→5\x20surfaces\x20the\x20insufficient-coverage\x20finding\x20(session\x20override)',()=>{const c=b({'compensation_balance':0x12cn,'order_amount':0x64n});expect(monitorOrder({'current':c})['map'](e=>e['id']))['not']['toContain']('compensation_insufficient'),setJudgmentOverride('monitor.thresholds.compensation_coverage_min',0x5);const d=monitorOrder({'current':c})['find'](e=>e['id']==='compensation_insufficient');expect(d?.['severity'])['toBe']('high');}),it('22.\x20explicit\x20MonitorThresholds\x20argument\x20wins\x20over\x20the\x20document\x20(caller\x20precedence)',()=>{const c=b({'last_user_message_at':0x62*a,'has_messenger':!![]});setJudgmentOverride('monitor.thresholds.messenger_timeout_hours',0x1),expect(monitorOrder({'current':c})['map'](d=>d['id']))['toContain']('messenger_unanswered'),expect(monitorOrder({'current':c,'thresholds':{'messenger_timeout_hours':0x48}})['map'](d=>d['id']))['not']['toContain']('messenger_unanswered'),clearJudgmentOverride('monitor.thresholds.messenger_timeout_hours');});}),describe('config\x20audit\x20—\x20mode\x20section',()=>{it('23.\x20appetite_thresholds.conservative.max_risk\x2030→99\x20flips\x20the\x20risk\x20recommendation\x20(session\x20override)',()=>{const a={'getCard':f=>({'constraints':{},'risk_profile':{'funds_risk':'medium'}})},b=new ModeEvaluator(a),c={'name':'audit_mode','traits':[],'machine_shape':{},'capabilities_used':['cap_audit'],'risk_appetite':'conservative','risk_constraints':{}},d=b['evaluateMode'](c);expect(d['risk_score'])['toBe'](0x3c),expect(d['recommendations']['join']('\x0a'))['toContain']('exceeds\x20conservative\x20mode\x20threshold\x2030'),setJudgmentOverride('mode.appetite_thresholds.conservative.max_risk',0x63);const e=b['evaluateMode'](c);expect(e['risk_score'])['toBe'](0x3c),expect(e['recommendations']['join']('\x0a'))['not']['toContain']('exceeds');});}),describe('config\x20audit\x20—\x20scorecard\x20section',()=>{function a(c){return{'account':'0xshop','industry':'education','network':'testnet','collected_at':0x0,'metrics':c,'unavailable':[],'errors':[]};}const b=(c,d)=>({'id':c,'source':'market_operations','status':'ok','value':d,'collected_at':0x0});it('24.\x20metrics.order_count.good_threshold\x2020→1\x20drives\x20the\x20metric\x20to\x20full\x20score\x20(session\x20override)',()=>{const d=a([b('order_count',0x1)]),e=scoreScorecard(d,'balanced');expect(e['metric_scores'][0x0]?.['score'])['toBe'](0x0),expect(e['overall'])['toBe'](0x0),setJudgmentOverride('scorecard.metrics.order_count.good_threshold',0x1);const f=scoreScorecard(d,'balanced');expect(f['metric_scores'][0x0]?.['score'])['toBe'](0x64),expect(f['overall'])['toBe'](0x64);}),it('25.\x20metrics.completion_rate.weight\x20posture\x20retune\x20changes\x20the\x20normalized\x20overall\x20(session\x20override)',()=>{const d=a([b('order_count',0x5),b('completion_rate',0.75)]),e=scoreScorecard(d,'margin');expect(e['metric_scores'][0x1]?.['weight'])['toBe'](0.15),expect(e['overall'])['toBe'](0x26),setJudgmentOverride('scorecard.metrics.completion_rate.weight',{'volume':0.15,'balanced':0.2,'margin':0.9});const f=scoreScorecard(d,'margin');expect(f['metric_scores'][0x1]?.['weight'])['toBe'](0.9),expect(f['overall'])['toBe'](0x2f);}),it('26.\x20shop_evidence_metrics\x20cleared\x20→\x20market-only\x20evidence\x20yields\x20a\x20null\x20overall\x20(session\x20override)',()=>{const d=a([b('order_count',0x14),b('supply_demand_ratio',0x2)]),e=scoreScorecard(d,'balanced');expect(e['overall'])['toBe'](0x5e),setJudgmentOverride('scorecard.shop_evidence_metrics',[]);const f=scoreScorecard(d,'balanced');expect(f['overall'])['toBeNull']();});}),describe('config\x20audit\x20—\x20rules\x20section\x20(declarative\x20rule\x20book)',()=>{it('27.\x20a\x20retuned\x20case\x20level\x20low→high\x20changes\x20the\x20finding\x20severity\x20(user\x20doc\x20channel)',()=>{const a=checkUtilRisks({'large_util_import':!![]})['find'](c=>c['id']==='R-UTIL-03');expect(a?.['level'])['toBe']('low'),writeUserDoc({'version':0x1,'rules':{'domains':{'util':{'rules':[{'rule_id':'R-UTIL-03','cases':[{'when':{'field':'large_util_import','op':'eq','value':!![]},'level':'high','title':'AUDIT:\x20util\x20import\x20retuned\x20to\x20high','description':'Audit-rewritten\x20description\x20for\x20R-UTIL-03.'}]}]}}}});const b=checkUtilRisks({'large_util_import':!![]})['find'](c=>c['id']==='R-UTIL-03');expect(b?.['level'])['toBe']('high'),expect(b?.['title'])['toContain']('AUDIT');}),it('28.\x20enabled:false\x20via\x20the\x20industry\x20layer\x20silences\x20the\x20finding\x20AND\x20leaves\x20a\x20disable\x20trace',()=>{expect(checkUtilRisks({'large_util_import':!![],'expects_util_events':!![]})['map'](a=>a['id']))['toEqual'](['R-UTIL-03','R-UTIL-04']),expect(setJudgmentIndustryOverlay({'rules':{'domains':{'util':{'rules':[{'rule_id':'R-UTIL-03','enabled':![]}]}}}},'pack:audit')['ok'])['toBe'](!![]),expect(checkUtilRisks({'large_util_import':!![],'expects_util_events':!![]})['map'](a=>a['id']))['toEqual'](['R-UTIL-04']),expect(judgmentDisableTrace())['toEqual']([{'layer':'pack:audit','domain':'util','rule_id':'R-UTIL-03'}]);}),it('29.\x20case.title/description\x20rewording\x20is\x20visible\x20in\x20the\x20finding\x20text\x20(user\x20doc\x20channel)',()=>{const a=checkUtilRisks({'bcs_manually_synced':!![]})['find'](c=>c['id']==='R-UTIL-05');expect(a?.['title'])['toContain']('SDK\x20BCS\x20structures\x20must\x20stay\x20in\x20sync'),writeUserDoc({'version':0x1,'rules':{'domains':{'util':{'rules':[{'rule_id':'R-UTIL-05','cases':[{'when':{'field':'bcs_manually_synced','op':'eq','value':!![]},'level':'medium','title':'AUDIT:\x20hand-maintained\x20BCS\x20layouts\x20drift\x20from\x20Move\x20structs','description':'Audit-rewritten\x20description\x20for\x20R-UTIL-05.'}]}]}}}});const b=checkUtilRisks({'bcs_manually_synced':!![]})['find'](c=>c['id']==='R-UTIL-05');expect(b?.['title'])['toContain']('AUDIT:\x20hand-maintained\x20BCS'),expect(b?.['description'])['toContain']('Audit-rewritten\x20description\x20for\x20R-UTIL-05.');});}),describe('config\x20audit\x20—\x20layer\x20chain\x20and\x20composition',()=>{it('30.\x20precedence\x20chain:\x20industry\x20X=61\x20<\x20user\x20doc\x20X=63\x20<\x20persona\x20X=62,\x20unwinding\x20in\x20reverse',()=>{expect(getJudgmentDoc()['game']['scoring']['base'])['toBe'](0x3c),setJudgmentIndustryOverlay({'game':{'scoring':{'base':0x3d}}},'pack:x'),expect(getJudgmentDoc()['game']['scoring']['base'])['toBe'](0x3d),writeUserDoc({'version':0x1,'game':{'scoring':{'base':0x3f}}}),expect(getJudgmentDoc()['game']['scoring']['base'])['toBe'](0x3f),setJudgmentPersonaFragment({'game':{'scoring':{'base':0x3e}}},'persona:y'),expect(getJudgmentDoc()['game']['scoring']['base'])['toBe'](0x3e),expect(evaluateOutcome('refund','customer')['net_score'])['toBe'](0x52),rmSync(join(configDir,'judgment.json')),expect(getJudgmentDoc()['game']['scoring']['base'])['toBe'](0x3e),setJudgmentPersonaFragment(null),expect(getJudgmentDoc()['game']['scoring']['base'])['toBe'](0x3d),setJudgmentIndustryOverlay(null),expect(getJudgmentDoc()['game']['scoring']['base'])['toBe'](0x3c);}),it('31.\x20mergedBaselinesOverlay:\x20the\x20later\x20industry\x20in\x20the\x20list\x20wins,\x20and\x20the\x20merged\x20overlay\x20drives\x20the\x20engine',()=>{registerIndustryBaselines({'category':'audit-a','fragment':{'monitor':{'thresholds':{'messenger_timeout_hours':0x1}}}}),registerIndustryBaselines({'category':'audit-b','fragment':{'monitor':{'thresholds':{'messenger_timeout_hours':0x2}}}});const a=mergedBaselinesOverlay(['audit-a','audit-b']);expect(a['monitor']?.['thresholds']?.['messenger_timeout_hours'])['toBe'](0x2),expect(setJudgmentIndustryOverlay(mergedBaselinesOverlay(['audit-a','audit-b']),'merged:audit')['ok'])['toBe'](!![]),expect(getJudgmentDoc()['monitor']['thresholds']['messenger_timeout_hours'])['toBe'](0x2);const b=0x36ee80,c={'order_id':'0xorder','service_id':'0xs','created_at':0x64*b,'now':0x64*b,'last_user_message_at':98.5*b,'has_messenger':!![]};expect(monitorOrder({'current':c})['map'](d=>d['id']))['not']['toContain']('messenger_unanswered');}),it('32.\x20an\x20invalid\x20persona\x20fragment\x20is\x20rejected,\x20the\x20layer\x20error\x20is\x20visible,\x20the\x20last\x20good\x20stays\x20in\x20force',()=>{expect(setJudgmentPersonaFragment({'game':{'scoring':{'base':0x46}}},'persona:audit')['ok'])['toBe'](!![]),expect(getJudgmentDoc()['game']['scoring']['base'])['toBe'](0x46);const a=setJudgmentPersonaFragment({'game':{'scoring':{'bse':0x1}}},'persona:audit');expect(a['ok'])['toBe'](![]),expect(judgmentLayerError('persona'))['toContain']('bse'),expect(judgmentStatus()['layer_errors']['persona'])['toContain']('bse'),expect(getJudgmentDoc()['game']['scoring']['base'])['toBe'](0x46);}),it('33.\x20severity_deduction\x20×\x20level_bands\x20combo:\x20a\x20big\x20deduction\x20pushes\x20the\x20score\x20across\x20a\x20band\x20boundary',async()=>{const a=await projectFixture(),b=await evaluateGraphServiceFacts(a);expect(b['risk']['total'])['toBe'](0x4a),expect(b['risk']['level'])['toBe']('medium_low'),setJudgmentOverride('evaluation.severity_deduction.high',0x50);const c=await evaluateGraphServiceFacts(a);expect(c['risk']['total'])['toBe'](0x39),expect(c['risk']['level'])['toBe']('medium_high');});}),describe('config\x20audit\x20—\x20rejection\x20semantics',()=>{it('34a.\x20user-document\x20guardrails:\x20typoed\x20weight,\x20invented\x20rule\x20id,\x20non-enum\x20severity\x20word',()=>{writeUserDoc({'version':0x1,'evaluation':{'weights':{'trust_revews':0x32}}}),getJudgmentDoc(),expect(judgmentStatus()['last_reload_error'])['toContain']('unknown\x20dimension\x20\x27trust_revews\x27'),expect(getJudgmentDoc()['evaluation']['weights']['trust_reviews'])['toBe'](0x23),writeUserDoc({'version':0x1,'rules':{'domains':{'service':{'rules':[{'rule_id':'R-S-9-99','enabled':![]}]}}}}),getJudgmentDoc(),expect(judgmentStatus()['last_reload_error'])['toContain']('unknown\x20rule\x20\x27R-S-9-99\x27'),writeUserDoc({'version':0x1,'evaluation':{'severity_deduction':{'warning':0x19}}}),getJudgmentDoc(),expect(judgmentStatus()['last_reload_error'])['toMatch'](/warning/i),expect(getJudgmentDoc()['evaluation']['severity_deduction']['critical'])['toBe'](0x32);}),it('34b.\x20judgment_set\x20guardrails:\x20type\x20mismatch\x20and\x20unknown\x20path\x20are\x20rejected',()=>{expect(setJudgmentOverride('evaluation.weights.trust_reviews','high')['ok'])['toBe'](![]),expect(setJudgmentOverride('evaluation.weights.does_not_exist',0x1)['ok'])['toBe'](![]),expect(getJudgmentDoc()['evaluation']['weights']['trust_reviews'])['toBe'](0x23);});});
1
+ import{afterEach,beforeEach,describe,expect,it}from'vitest';import{existsSync,mkdtempSync,rmSync,writeFileSync}from'node:fs';import{tmpdir}from'node:os';import{join}from'node:path';import{ENTRYPOINT}from'@wowok/wowok';import{clearJudgmentLayers,clearJudgmentOverride,clearJudgmentOverrides,getJudgmentDoc,judgmentDisableTrace,judgmentLayerError,judgmentStatus,patchUserJudgmentDoc,setJudgmentIndustryOverlay,setJudgmentOverride,setJudgmentPersonaFragment}from'./judgment.js';import{checkUtilRisks}from'../knowledge/util-risk.js';import{appetiteMultiplier,evaluateOutcome,resolveInterests}from'../evaluation/game-strategy.js';import{evaluateArbGame}from'../evaluation/arbitration-game.js';import{registerDemandMatchEvaluation,matchDemandToServices}from'../evaluation/builtins/demand-match.js';import{extractDemandCapability}from'../evaluation/extract.js';import{monitorOrder}from'../customer/order-monitor.js';import{ModeEvaluator}from'../extensions/mode-evaluator.js';import{mergedBaselinesOverlay,registerIndustryBaselines}from'../extensions/industry-layers.js';import{scoreScorecard}from'../strategy/scorecard.js';import{FakeDataPlane}from'../graph/onchain/dataplane.js';import{expandTopology}from'../graph/onchain/expand.js';import{FULL,fullServiceState}from'../graph/onchain/fixtures.js';import{buildViewport}from'../graph/onchain/viewport.js';import{runAnalyzers}from'../graph/onchain/analyze.js';import{EVALUATION_SERVICE_INTENTS,resolveExpansionStrategy,withEvaluationBundle}from'../graph/onchain/strategy.js';import{projectEvaluationFacts}from'../graph/onchain/facts.js';import{evaluateGraphServiceFacts,registerGraphServiceEvaluations}from'../evaluation/builtins/graph-service.js';let configDir;function writeUserDoc(a){writeFileSync(join(configDir,'judgment.json'),JSON['stringify'](a,null,0x2),'utf-8');}beforeEach(()=>{configDir=mkdtempSync(join(tmpdir(),'wowok-config-audit-')),process['env']['WOWOK_CONFIG_DIR']=configDir,registerDemandMatchEvaluation();}),afterEach(()=>{delete process['env']['WOWOK_CONFIG_DIR'];if(existsSync(configDir))rmSync(configDir,{'recursive':!![],'force':!![]});clearJudgmentOverrides(),clearJudgmentLayers();});async function projectFixture(){registerGraphServiceEvaluations();const a=withEvaluationBundle(resolveExpansionStrategy({'intents':[...EVALUATION_SERVICE_INTENTS]})),b=await expandTopology(new FakeDataPlane(fullServiceState()),{'network':ENTRYPOINT['Mainnet'],'seed':FULL['svc'],'edges':a['edges'],'budget':a['budget']}),c=buildViewport(b,FULL['svc'],'neutral');return projectEvaluationFacts(c,FULL['svc'],runAnalyzers(c));}const demandCap=extractDemandCapability({'object':'0xdemand','location':'Shanghai','description':'need\x20a\x20freelance\x20designer'},{'industry':'freelance','price_max':0x96n,'keywords':['design','logo'],'capabilities':{'has_arbitration':!![],'has_refund_path':!![],'has_milestone_nodes':![],'has_compensation_fund':![],'has_wip_verification':!![],'has_messenger':![],'has_buy_guard':![],'has_dynamic_pricing':![],'is_published':!![],'is_paused':![]}}),inRegionService={'object':'0xgood','location':'Shanghai','description':'freelance\x20logo\x20design','sales':[{'price':'100','wip_hash':'abc'}],'arbitrations':['0xarb'],'compensation_fund':'500','bPublished':!![],'bPaused':![]},breakdownOf=(a,b)=>a['breakdown']['find'](c=>c['rule_id']===b);describe('config\x20audit\x20—\x20evaluation\x20section',()=>{it('1.\x20weights.trust_reviews\x20flows\x20into\x20the\x20aggregated\x20trust\x20total\x20(user\x20doc\x20channel)',async()=>{const a=await projectFixture(),b=await evaluateGraphServiceFacts(a);expect(b['trust']['breakdown']['find'](d=>d['rule_id']==='trust_reviews')['weight'])['toBe'](0x23),writeUserDoc({'version':0x1,'evaluation':{'weights':{'trust_reviews':0x46}}});const c=await evaluateGraphServiceFacts(a);expect(c['trust']['breakdown']['find'](d=>d['rule_id']==='trust_reviews')['weight'])['toBe'](0x46),expect(c['trust']['total'])['toBe'](0x2f);}),it('2.\x20severity_deduction.critical\x2050→5\x20lifts\x20the\x20risk-side\x20rule\x20score\x20(session\x20override)',async()=>{const a=await projectFixture(),b=await evaluateGraphServiceFacts(a);expect(b['risk']['breakdown']['find'](d=>d['rule_id']==='risk_fund')['score'])['toBe'](0x19),expect(setJudgmentOverride('evaluation.severity_deduction.critical',0x5))['toEqual']({'ok':!![]});const c=await evaluateGraphServiceFacts(a);expect(c['risk']['breakdown']['find'](d=>d['rule_id']==='risk_fund')['score'])['toBe'](0x46),expect(c['risk']['breakdown']['find'](d=>d['rule_id']==='risk_trust')['score'])['toBe'](0x41),expect(c['risk']['total'])['toBe'](0x56);}),it('3.\x20level_bands\x20first\x20band\x20min\x2085→30\x20flips\x20the\x20level\x20of\x20an\x20unchanged\x20score\x20(session\x20override)',async()=>{const a=await projectFixture(),b=await evaluateGraphServiceFacts(a);expect(b['trust']['total'])['toBe'](0x31),expect(b['trust']['level'])['toBe']('high'),setJudgmentOverride('evaluation.level_bands',[{'min':0x1e,'level':'low'},{'min':0x46,'level':'medium_low'},{'min':0x32,'level':'medium_high'},{'min':0x0,'level':'high'}]);const c=await evaluateGraphServiceFacts(a);expect(c['trust']['total'])['toBe'](0x31),expect(c['trust']['level'])['toBe']('low');}),it('4.\x20grade_words.trust\x20first\x20band\x20min\x2070→20\x20flips\x20the\x20rendered\x20grade\x20word\x20(session\x20override)',async()=>{const a=await projectFixture(),b=await evaluateGraphServiceFacts(a);expect(b['trust']['summary'])['toContain']('grade:\x20weak'),setJudgmentOverride('evaluation.grade_words.trust',[{'min':0x14,'word':'strong'},{'min':0x32,'word':'fair'},{'min':0x0,'word':'weak'}]);const c=await evaluateGraphServiceFacts(a);expect(c['trust']['summary'])['toContain']('grade:\x20strong');}),it('5.\x20dimensions.<id>.label\x20retune\x20reaches\x20the\x20live\x20summary\x20rendering\x20(industry\x20overlay\x20channel)',async()=>{const a=await projectFixture(),b=await evaluateGraphServiceFacts(a);expect(b['trust']['summary'])['toContain']('weakest\x20Fund\x20safety'),setJudgmentIndustryOverlay({'evaluation':{'dimensions':{'trust_fund_safety':{'label':'Fund\x20Cushion','description':'audit\x20retune'}}}},'pack:audit');const c=await evaluateGraphServiceFacts(a);expect(c['trust']['summary'])['toContain']('weakest\x20Fund\x20Cushion'),expect(c['trust']['breakdown']['find'](d=>d['rule_id']==='trust_fund_safety')['dimension'])['toBe']('Fund\x20Cushion');});}),describe('config\x20audit\x20—\x20game\x20section',()=>{it('6.\x20scoring.base\x2060→80\x20lifts\x20every\x20net\x20score\x20(judgment_doc_patch\x20channel)',()=>{expect(evaluateOutcome('refund','customer')['net_score'])['toBe'](0x50);const a=patchUserJudgmentDoc({'game':{'scoring':{'base':0x50}}});expect(a['applied'])['toBe'](!![]),expect(evaluateOutcome('refund','customer')['net_score'])['toBe'](0x64);}),it('7.\x20appetite_multipliers.conservative\x201.5→0.6\x20changes\x20the\x20conservative\x20sensitivity\x20result\x20(session\x20override)',()=>{const a=evaluateOutcome('refund','merchant',{'risk_appetite':'conservative'});expect(a['risk_score'])['toBe'](0x4b),expect(a['net_score'])['toBe'](0x0),setJudgmentOverride('game.appetite_multipliers.conservative',0.6);const b=evaluateOutcome('refund','merchant',{'risk_appetite':'conservative'});expect(b['risk_score'])['toBe'](0x1e),expect(b['net_score'])['toBe'](0x1e),expect(appetiteMultiplier('conservative'))['toBe'](0.6);}),it('8.\x20role_interests.customer.prefer\x20+\x20node_advanced\x20adds\x20a\x20gain\x20(industry\x20overlay\x20channel)',()=>{const a=evaluateOutcome('advance','customer');expect(a['gains'])['toEqual']([]),expect(a['net_score'])['toBe'](0x3c),setJudgmentIndustryOverlay({'game':{'role_interests':{'customer':{'prefer':['fund_returned_to_buyer','node_advanced'],'avoid':[],'sensitivity':0x1}}}},'pack:audit');const b=evaluateOutcome('advance','customer');expect(b['gains'])['toEqual'](['node_advanced']),expect(b['net_score'])['toBe'](0x50);}),it('9.\x20a\x20new\x20keyword_rules\x20entry\x20re-anchors\x20prefer\x20on\x20a\x20matching\x20requirement\x20(user\x20doc\x20channel)',()=>{const a=resolveInterests('system',{'requirements':['please\x20test\x20it']});expect(a['prefer'])['toEqual']([]),writeUserDoc({'version':0x1,'game':{'keyword_rules':[{'id':'kw_audit_testing','keywords':['test'],'effect':'node_advanced','anchor':'prefer','when_forbidden':![]}]}});const b=resolveInterests('system',{'requirements':['please\x20test\x20it']});expect(b['prefer'])['toEqual'](['node_advanced']);}),it('10.\x20forbid_pattern\x20rewritten\x20to\x20a\x20non-matching\x20pattern\x20disarms\x20when_forbidden\x20rules\x20(user\x20doc\x20channel)',()=>{const a=resolveInterests('neutral',{'requirements':['never\x20arbitration']});expect(a['avoid'])['toContain']('arbitration_review_triggered'),writeUserDoc({'version':0x1,'game':{'forbid_pattern':'zzz_never_matches'}});const b=resolveInterests('neutral',{'requirements':['never\x20arbitration']});expect(b['avoid'])['toEqual']([]);});}),describe('config\x20audit\x20—\x20game.arb\x20section\x20(7-state\x20game)',()=>{it('11.\x20arb.scoring.per_gain\x2020→40\x20moves\x20the\x20favorability\x20of\x20a\x201-gain\x20move\x20(session\x20override)',()=>{const a=evaluateArbGame('Voting','arbitrator');expect(a['actions'][0x0]?.['gain_score'])['toBe'](0x14),expect(a['actions'][0x0]?.['favorability'])['toBe'](0x50),setJudgmentOverride('game.arb.scoring.per_gain',0x28);const b=evaluateArbGame('Voting','arbitrator');expect(b['actions'][0x0]?.['gain_score'])['toBe'](0x28),expect(b['actions'][0x0]?.['favorability'])['toBe'](0x64);}),it('12.\x20a\x20new\x20arb\x20keyword_rules\x20entry\x20re-anchors\x20a\x20perspective\x27s\x20prefer\x20(user\x20doc\x20channel)',()=>{const a=evaluateArbGame('Principal_confirming','customer',{'requirements':['expedite\x20please']});expect(a['actions'][0x0]?.['gain_score'])['toBe'](0x0),expect(a['actions'][0x0]?.['favorability'])['toBe'](0x3c),writeUserDoc({'version':0x1,'game':{'arb':{'keyword_rules':[{'id':'arb_kw_audit_expedite','keywords':['expedite'],'effect':'case_advanced','anchor':'prefer','when_forbidden':![]}]}}});const b=evaluateArbGame('Principal_confirming','customer',{'requirements':['expedite\x20please']});expect(b['actions'][0x0]?.['gain_score'])['toBe'](0x14),expect(b['actions'][0x0]?.['favorability'])['toBe'](0x50);});}),describe('config\x20audit\x20—\x20match\x20section',()=>{it('13.\x20region_scores.exact\x20100→50\x20halves\x20the\x20region\x20rule\x20score\x20(session\x20override)',async()=>{const [a]=await matchDemandToServices(demandCap,[inRegionService]);expect(breakdownOf(a['result'],'region')['score'])['toBe'](0x64),setJudgmentOverride('match.region_scores.exact',0x32);const [b]=await matchDemandToServices(demandCap,[inRegionService]);expect(breakdownOf(b['result'],'region')['score'])['toBe'](0x32),expect(b['result']['total'])['toBeLessThan'](a['result']['total']);}),it('14.\x20weights.capabilities\x2030→60\x20raises\x20its\x20renormalized\x20share\x20(session\x20override)',async()=>{const [a]=await matchDemandToServices(demandCap,[inRegionService]);expect(breakdownOf(a['result'],'capabilities')['weight'])['toBe'](0x1e),expect(a['result']['total'])['toBe'](0x47),setJudgmentOverride('match.weights.capabilities',0x3c);const [b]=await matchDemandToServices(demandCap,[inRegionService]);expect(breakdownOf(b['result'],'capabilities')['weight'])['toBe'](0x3c),expect(breakdownOf(b['result'],'region')['weight'])['toBe'](0xf),expect(b['result']['total'])['toBe'](0x4d);}),it('15.\x20trust_bands\x20second\x20band\x20score\x2060→10\x20(extracted\x20trust_score\x20is\x2050\x20→\x20band\x20#2)\x20(session\x20override)',async()=>{const [a]=await matchDemandToServices(demandCap,[inRegionService]);expect(breakdownOf(a['result'],'trust')['score'])['toBe'](0x3c),setJudgmentOverride('match.trust_bands',[{'min':0x4b,'score':0x64},{'min':0x32,'score':0xa},{'min':0x19,'score':0x1e},{'min':0x0,'score':0x0}]);const [b]=await matchDemandToServices(demandCap,[inRegionService]);expect(breakdownOf(b['result'],'trust')['score'])['toBe'](0xa);}),it('16.\x20neutral_score\x2050→10\x20changes\x20unknown-signal\x20scoring\x20(user\x20doc\x20channel)',async()=>{const a=extractDemandCapability({'object':'0xdemand','location':'Shanghai','description':'anything'},{'industry':'freelance','price_max':0x96n,'keywords':[],'capabilities':{'has_arbitration':![],'has_refund_path':![],'has_milestone_nodes':![],'has_compensation_fund':![],'has_wip_verification':![],'has_messenger':![],'has_buy_guard':![],'has_dynamic_pricing':![],'is_published':![],'is_paused':![]}}),[b]=await matchDemandToServices(a,[inRegionService]);expect(breakdownOf(b['result'],'tags')['score'])['toBe'](0x32),writeUserDoc({'version':0x1,'match':{'neutral_score':0xa}});const [c]=await matchDemandToServices(a,[inRegionService]);expect(breakdownOf(c['result'],'tags')['score'])['toBe'](0xa);}),it('17.\x20price_over_budget_tolerance_pct\x2010→100\x20turns\x20a\x20rejection\x20into\x20a\x20partial\x20score\x20(session\x20override)',async()=>{const a={...inRegionService,'object':'0xpricey','sales':[{'price':'200','wip_hash':'x'}]},[b]=await matchDemandToServices(demandCap,[a]);expect(breakdownOf(b['result'],'price')['score'])['toBe'](0x0),setJudgmentOverride('match.price_over_budget_tolerance_pct',0x64);const [c]=await matchDemandToServices(demandCap,[a]);expect(breakdownOf(c['result'],'price')['score'])['toBe'](0x32);}),it('18.\x20top_n\x205→2\x20caps\x20the\x20returned\x20candidate\x20count\x20(session\x20override)',async()=>{const a=[inRegionService,{...inRegionService,'object':'0xb'},{...inRegionService,'object':'0xc'}];expect((await matchDemandToServices(demandCap,a))['length'])['toBe'](0x3),setJudgmentOverride('match.top_n',0x2),expect((await matchDemandToServices(demandCap,a))['length'])['toBe'](0x2);});}),describe('config\x20audit\x20—\x20monitor\x20section',()=>{const a=0x36ee80,b=c=>({'order_id':'0xorder','service_id':'0xservice','created_at':0x64*a,'now':0x64*a,...c});it('19.\x20messenger_timeout_hours\x2024→1\x20surfaces\x20the\x20timeout\x20finding\x20(user\x20doc\x20hot\x20reload)',()=>{const c=b({'last_user_message_at':0x62*a,'has_messenger':!![]});expect(monitorOrder({'current':c})['map'](f=>f['id']))['not']['toContain']('messenger_unanswered'),writeUserDoc({'version':0x1,'monitor':{'thresholds':{'messenger_timeout_hours':0x1}}});const d=monitorOrder({'current':c}),e=d['find'](f=>f['id']==='messenger_unanswered');expect(e?.['severity'])['toBe']('high');}),it('20.\x20escalation.stall_escalation_multiplier\x202→1\x20moves\x20the\x20critical\x20escalation\x20point\x20(session\x20override)',()=>{const c=b({'current_node':'Pay','last_progress_at':0x14*a}),d=monitorOrder({'current':c})['find'](f=>f['id']==='progress_stall');expect(d?.['severity'])['toBe']('high'),setJudgmentOverride('monitor.escalation.stall_escalation_multiplier',0x1);const e=monitorOrder({'current':c})['find'](f=>f['id']==='progress_stall');expect(e?.['severity'])['toBe']('critical');}),it('21.\x20compensation_coverage_min\x201.0→5\x20surfaces\x20the\x20insufficient-coverage\x20finding\x20(session\x20override)',()=>{const c=b({'compensation_balance':0x12cn,'order_amount':0x64n});expect(monitorOrder({'current':c})['map'](e=>e['id']))['not']['toContain']('compensation_insufficient'),setJudgmentOverride('monitor.thresholds.compensation_coverage_min',0x5);const d=monitorOrder({'current':c})['find'](e=>e['id']==='compensation_insufficient');expect(d?.['severity'])['toBe']('high');}),it('22.\x20explicit\x20MonitorThresholds\x20argument\x20wins\x20over\x20the\x20document\x20(caller\x20precedence)',()=>{const c=b({'last_user_message_at':0x62*a,'has_messenger':!![]});setJudgmentOverride('monitor.thresholds.messenger_timeout_hours',0x1),expect(monitorOrder({'current':c})['map'](d=>d['id']))['toContain']('messenger_unanswered'),expect(monitorOrder({'current':c,'thresholds':{'messenger_timeout_hours':0x48}})['map'](d=>d['id']))['not']['toContain']('messenger_unanswered'),clearJudgmentOverride('monitor.thresholds.messenger_timeout_hours');});}),describe('config\x20audit\x20—\x20mode\x20section',()=>{it('23.\x20appetite_thresholds.conservative.max_risk\x2030→99\x20flips\x20the\x20risk\x20recommendation\x20(session\x20override)',()=>{const a={'getCard':f=>({'constraints':{},'risk_profile':{'funds_risk':'medium'}})},b=new ModeEvaluator(a),c={'name':'audit_mode','traits':[],'machine_shape':{},'capabilities_used':['cap_audit'],'risk_appetite':'conservative','risk_constraints':{}},d=b['evaluateMode'](c);expect(d['risk_score'])['toBe'](0x3c),expect(d['recommendations']['join']('\x0a'))['toContain']('exceeds\x20conservative\x20mode\x20threshold\x2030'),setJudgmentOverride('mode.appetite_thresholds.conservative.max_risk',0x63);const e=b['evaluateMode'](c);expect(e['risk_score'])['toBe'](0x3c),expect(e['recommendations']['join']('\x0a'))['not']['toContain']('exceeds');});}),describe('config\x20audit\x20—\x20scorecard\x20section',()=>{function a(c){return{'account':'0xshop','industry':'education','network':'testnet','collected_at':0x0,'metrics':c,'unavailable':[],'errors':[]};}const b=(c,d)=>({'id':c,'source':'market_operations','status':'ok','value':d,'collected_at':0x0});it('24.\x20metrics.order_count.good_threshold\x2020→1\x20drives\x20the\x20metric\x20to\x20full\x20score\x20(session\x20override)',()=>{const d=a([b('order_count',0x1)]),e=scoreScorecard(d,'balanced');expect(e['metric_scores'][0x0]?.['score'])['toBe'](0x0),expect(e['overall'])['toBe'](0x0),setJudgmentOverride('scorecard.metrics.order_count.good_threshold',0x1);const f=scoreScorecard(d,'balanced');expect(f['metric_scores'][0x0]?.['score'])['toBe'](0x64),expect(f['overall'])['toBe'](0x64);}),it('25.\x20metrics.completion_rate.weight\x20posture\x20retune\x20changes\x20the\x20normalized\x20overall\x20(session\x20override)',()=>{const d=a([b('order_count',0x5),b('completion_rate',0.75)]),e=scoreScorecard(d,'margin');expect(e['metric_scores'][0x1]?.['weight'])['toBe'](0.15),expect(e['overall'])['toBe'](0x26),setJudgmentOverride('scorecard.metrics.completion_rate.weight',{'volume':0.15,'balanced':0.2,'margin':0.9});const f=scoreScorecard(d,'margin');expect(f['metric_scores'][0x1]?.['weight'])['toBe'](0.9),expect(f['overall'])['toBe'](0x2f);}),it('26.\x20shop_evidence_metrics\x20cleared\x20→\x20market-only\x20evidence\x20yields\x20a\x20null\x20overall\x20(session\x20override)',()=>{const d=a([b('order_count',0x14),b('supply_demand_ratio',0x2)]),e=scoreScorecard(d,'balanced');expect(e['overall'])['toBe'](0x5e),setJudgmentOverride('scorecard.shop_evidence_metrics',[]);const f=scoreScorecard(d,'balanced');expect(f['overall'])['toBeNull']();});}),describe('config\x20audit\x20—\x20rules\x20section\x20(declarative\x20rule\x20book)',()=>{it('27.\x20a\x20retuned\x20case\x20level\x20low→high\x20changes\x20the\x20finding\x20severity\x20(user\x20doc\x20channel)',()=>{const a=checkUtilRisks({'large_util_import':!![]})['find'](c=>c['id']==='R-UTIL-03');expect(a?.['level'])['toBe']('low'),writeUserDoc({'version':0x1,'rules':{'domains':{'util':{'rules':[{'rule_id':'R-UTIL-03','cases':[{'when':{'field':'large_util_import','op':'eq','value':!![]},'level':'high','title':'AUDIT:\x20util\x20import\x20retuned\x20to\x20high','description':'Audit-rewritten\x20description\x20for\x20R-UTIL-03.'}]}]}}}});const b=checkUtilRisks({'large_util_import':!![]})['find'](c=>c['id']==='R-UTIL-03');expect(b?.['level'])['toBe']('high'),expect(b?.['title'])['toContain']('AUDIT');}),it('28.\x20enabled:false\x20via\x20the\x20industry\x20layer\x20silences\x20the\x20finding\x20AND\x20leaves\x20a\x20disable\x20trace',()=>{expect(checkUtilRisks({'large_util_import':!![],'expects_util_events':!![]})['map'](a=>a['id']))['toEqual'](['R-UTIL-03','R-UTIL-04']),expect(setJudgmentIndustryOverlay({'rules':{'domains':{'util':{'rules':[{'rule_id':'R-UTIL-03','enabled':![]}]}}}},'pack:audit')['ok'])['toBe'](!![]),expect(checkUtilRisks({'large_util_import':!![],'expects_util_events':!![]})['map'](a=>a['id']))['toEqual'](['R-UTIL-04']),expect(judgmentDisableTrace())['toEqual']([{'layer':'pack:audit','domain':'util','rule_id':'R-UTIL-03'}]);}),it('29.\x20case.title/description\x20rewording\x20is\x20visible\x20in\x20the\x20finding\x20text\x20(user\x20doc\x20channel)',()=>{const a=checkUtilRisks({'bcs_manually_synced':!![]})['find'](c=>c['id']==='R-UTIL-05');expect(a?.['title'])['toContain']('SDK\x20BCS\x20structures\x20must\x20stay\x20in\x20sync'),writeUserDoc({'version':0x1,'rules':{'domains':{'util':{'rules':[{'rule_id':'R-UTIL-05','cases':[{'when':{'field':'bcs_manually_synced','op':'eq','value':!![]},'level':'medium','title':'AUDIT:\x20hand-maintained\x20BCS\x20layouts\x20drift\x20from\x20Move\x20structs','description':'Audit-rewritten\x20description\x20for\x20R-UTIL-05.'}]}]}}}});const b=checkUtilRisks({'bcs_manually_synced':!![]})['find'](c=>c['id']==='R-UTIL-05');expect(b?.['title'])['toContain']('AUDIT:\x20hand-maintained\x20BCS'),expect(b?.['description'])['toContain']('Audit-rewritten\x20description\x20for\x20R-UTIL-05.');});}),describe('config\x20audit\x20—\x20layer\x20chain\x20and\x20composition',()=>{it('30.\x20precedence\x20chain:\x20industry\x20X=61\x20<\x20user\x20doc\x20X=63\x20<\x20persona\x20X=62,\x20unwinding\x20in\x20reverse',()=>{expect(getJudgmentDoc()['game']['scoring']['base'])['toBe'](0x3c),setJudgmentIndustryOverlay({'game':{'scoring':{'base':0x3d}}},'pack:x'),expect(getJudgmentDoc()['game']['scoring']['base'])['toBe'](0x3d),writeUserDoc({'version':0x1,'game':{'scoring':{'base':0x3f}}}),expect(getJudgmentDoc()['game']['scoring']['base'])['toBe'](0x3f),setJudgmentPersonaFragment({'game':{'scoring':{'base':0x3e}}},'persona:y'),expect(getJudgmentDoc()['game']['scoring']['base'])['toBe'](0x3e),expect(evaluateOutcome('refund','customer')['net_score'])['toBe'](0x52),rmSync(join(configDir,'judgment.json')),expect(getJudgmentDoc()['game']['scoring']['base'])['toBe'](0x3e),setJudgmentPersonaFragment(null),expect(getJudgmentDoc()['game']['scoring']['base'])['toBe'](0x3d),setJudgmentIndustryOverlay(null),expect(getJudgmentDoc()['game']['scoring']['base'])['toBe'](0x3c);}),it('31.\x20mergedBaselinesOverlay:\x20the\x20later\x20industry\x20in\x20the\x20list\x20wins,\x20and\x20the\x20merged\x20overlay\x20drives\x20the\x20engine',()=>{registerIndustryBaselines({'category':'audit-a','fragment':{'monitor':{'thresholds':{'messenger_timeout_hours':0x1}}}}),registerIndustryBaselines({'category':'audit-b','fragment':{'monitor':{'thresholds':{'messenger_timeout_hours':0x2}}}});const a=mergedBaselinesOverlay(['audit-a','audit-b']);expect(a['monitor']?.['thresholds']?.['messenger_timeout_hours'])['toBe'](0x2),expect(setJudgmentIndustryOverlay(mergedBaselinesOverlay(['audit-a','audit-b']),'merged:audit')['ok'])['toBe'](!![]),expect(getJudgmentDoc()['monitor']['thresholds']['messenger_timeout_hours'])['toBe'](0x2);const b=0x36ee80,c={'order_id':'0xorder','service_id':'0xs','created_at':0x64*b,'now':0x64*b,'last_user_message_at':98.5*b,'has_messenger':!![]};expect(monitorOrder({'current':c})['map'](d=>d['id']))['not']['toContain']('messenger_unanswered');}),it('32.\x20an\x20invalid\x20persona\x20fragment\x20is\x20rejected,\x20the\x20layer\x20error\x20is\x20visible,\x20the\x20last\x20good\x20stays\x20in\x20force',()=>{expect(setJudgmentPersonaFragment({'game':{'scoring':{'base':0x46}}},'persona:audit')['ok'])['toBe'](!![]),expect(getJudgmentDoc()['game']['scoring']['base'])['toBe'](0x46);const a=setJudgmentPersonaFragment({'game':{'scoring':{'bse':0x1}}},'persona:audit');expect(a['ok'])['toBe'](![]),expect(judgmentLayerError('persona'))['toContain']('bse'),expect(judgmentStatus()['layer_errors']['persona'])['toContain']('bse'),expect(getJudgmentDoc()['game']['scoring']['base'])['toBe'](0x46);}),it('33.\x20severity_deduction\x20×\x20level_bands\x20combo:\x20a\x20big\x20deduction\x20pushes\x20the\x20score\x20across\x20a\x20band\x20boundary',async()=>{const a=await projectFixture(),b=await evaluateGraphServiceFacts(a);expect(b['risk']['total'])['toBe'](0x4a),expect(b['risk']['level'])['toBe']('medium_low'),setJudgmentOverride('evaluation.severity_deduction.high',0x50);const c=await evaluateGraphServiceFacts(a);expect(c['risk']['total'])['toBe'](0x39),expect(c['risk']['level'])['toBe']('medium_high');});}),describe('config\x20audit\x20—\x20rejection\x20semantics',()=>{it('34a.\x20user-document\x20guardrails:\x20typoed\x20weight,\x20invented\x20rule\x20id,\x20non-enum\x20severity\x20word',()=>{writeUserDoc({'version':0x1,'evaluation':{'weights':{'trust_revews':0x32}}}),getJudgmentDoc(),expect(judgmentStatus()['last_reload_error'])['toContain']('unknown\x20dimension\x20\x27trust_revews\x27'),expect(getJudgmentDoc()['evaluation']['weights']['trust_reviews'])['toBe'](0x23),writeUserDoc({'version':0x1,'rules':{'domains':{'service':{'rules':[{'rule_id':'R-S-9-99','enabled':![]}]}}}}),getJudgmentDoc(),expect(judgmentStatus()['last_reload_error'])['toContain']('unknown\x20rule\x20\x27R-S-9-99\x27'),writeUserDoc({'version':0x1,'evaluation':{'severity_deduction':{'warning':0x19}}}),getJudgmentDoc(),expect(judgmentStatus()['last_reload_error'])['toMatch'](/warning/i),expect(getJudgmentDoc()['evaluation']['severity_deduction']['critical'])['toBe'](0x32);}),it('34b.\x20judgment_set\x20guardrails:\x20type\x20mismatch\x20and\x20unknown\x20path\x20are\x20rejected',()=>{expect(setJudgmentOverride('evaluation.weights.trust_reviews','high')['ok'])['toBe'](![]),expect(setJudgmentOverride('evaluation.weights.does_not_exist',0x1)['ok'])['toBe'](![]),expect(getJudgmentDoc()['evaluation']['weights']['trust_reviews'])['toBe'](0x23);});});
@@ -245,6 +245,7 @@ export declare const MatchSectionSchema: z.ZodObject<{
245
245
  trust: z.ZodNumber;
246
246
  capabilities: z.ZodNumber;
247
247
  buyable: z.ZodNumber;
248
+ reward_commitment: z.ZodNumber;
248
249
  tags: z.ZodNumber;
249
250
  acceptance: z.ZodNumber;
250
251
  }, z.core.$strict>;
@@ -272,6 +273,7 @@ export declare const MatchSectionInputSchema: z.ZodObject<{
272
273
  trust: z.ZodOptional<z.ZodNumber>;
273
274
  capabilities: z.ZodOptional<z.ZodNumber>;
274
275
  buyable: z.ZodOptional<z.ZodNumber>;
276
+ reward_commitment: z.ZodOptional<z.ZodNumber>;
275
277
  tags: z.ZodOptional<z.ZodNumber>;
276
278
  acceptance: z.ZodOptional<z.ZodNumber>;
277
279
  }, z.core.$strict>>;
@@ -655,6 +657,7 @@ export declare const JudgmentDocSchema: z.ZodObject<{
655
657
  trust: z.ZodNumber;
656
658
  capabilities: z.ZodNumber;
657
659
  buyable: z.ZodNumber;
660
+ reward_commitment: z.ZodNumber;
658
661
  tags: z.ZodNumber;
659
662
  acceptance: z.ZodNumber;
660
663
  }, z.core.$strict>;
@@ -901,6 +904,7 @@ export declare const JudgmentDocInputSchema: z.ZodObject<{
901
904
  trust: z.ZodOptional<z.ZodNumber>;
902
905
  capabilities: z.ZodOptional<z.ZodNumber>;
903
906
  buyable: z.ZodOptional<z.ZodNumber>;
907
+ reward_commitment: z.ZodOptional<z.ZodNumber>;
904
908
  tags: z.ZodOptional<z.ZodNumber>;
905
909
  acceptance: z.ZodOptional<z.ZodNumber>;
906
910
  }, z.core.$strict>>;
@@ -1072,6 +1076,7 @@ export declare const JudgmentFragmentSchema: z.ZodObject<{
1072
1076
  trust: z.ZodOptional<z.ZodNumber>;
1073
1077
  capabilities: z.ZodOptional<z.ZodNumber>;
1074
1078
  buyable: z.ZodOptional<z.ZodNumber>;
1079
+ reward_commitment: z.ZodOptional<z.ZodNumber>;
1075
1080
  tags: z.ZodOptional<z.ZodNumber>;
1076
1081
  acceptance: z.ZodOptional<z.ZodNumber>;
1077
1082
  }, z.core.$strict>>;