@wowok/agent-mcp 3.3.9 → 3.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (480) hide show
  1. package/README.md +8 -0
  2. package/dist/chain-semantics/composition-truth.d.ts +102 -0
  3. package/dist/chain-semantics/composition-truth.js +1 -0
  4. package/dist/chain-semantics/eval-order.js +1 -1
  5. package/dist/chain-semantics/field-capability.js +1 -1
  6. package/dist/chain-semantics/freeze-map.js +1 -1
  7. package/dist/chain-semantics/fund-flow.js +1 -1
  8. package/dist/chain-semantics/guard-verbs.js +1 -1
  9. package/dist/chain-semantics/index.d.ts +1 -0
  10. package/dist/chain-semantics/index.js +1 -1
  11. package/dist/chain-semantics/object-graph.js +1 -1
  12. package/dist/composition/audit.js +1 -1
  13. package/dist/composition/blueprint-view.d.ts +3 -3
  14. package/dist/composition/blueprint-view.js +1 -1
  15. package/dist/composition/compile.d.ts +26 -4
  16. package/dist/composition/compile.js +1 -1
  17. package/dist/composition/emit-phases.d.ts +206 -0
  18. package/dist/composition/emit-phases.js +1 -0
  19. package/dist/composition/generate.d.ts +40 -0
  20. package/dist/composition/generate.js +1 -0
  21. package/dist/composition/guard-fill.d.ts +44 -0
  22. package/dist/composition/guard-fill.js +1 -0
  23. package/dist/composition/inflight.d.ts +26 -2
  24. package/dist/composition/inflight.js +1 -1
  25. package/dist/composition/input-normalize.d.ts +15 -0
  26. package/dist/composition/input-normalize.js +1 -0
  27. package/dist/composition/materialize.d.ts +22 -13
  28. package/dist/composition/materialize.js +1 -1
  29. package/dist/composition/mode-gates.d.ts +35 -0
  30. package/dist/composition/mode-gates.js +1 -0
  31. package/dist/composition/param-disclosure.d.ts +61 -0
  32. package/dist/composition/param-disclosure.js +1 -0
  33. package/dist/composition/plan-retry-ledger.d.ts +21 -0
  34. package/dist/composition/plan-retry-ledger.js +1 -0
  35. package/dist/composition/plan.d.ts +17 -2
  36. package/dist/composition/plan.js +1 -1
  37. package/dist/composition/product-card.d.ts +94 -0
  38. package/dist/composition/product-card.js +1 -0
  39. package/dist/composition/supply-chain-emit.d.ts +46 -0
  40. package/dist/composition/supply-chain-emit.js +1 -0
  41. package/dist/config/config-audit.spec.js +1 -1
  42. package/dist/config/config-warnings.d.ts +2 -0
  43. package/dist/config/config-warnings.js +1 -0
  44. package/dist/config/exposure.d.ts +2 -2
  45. package/dist/config/judgment.d.ts +31 -5
  46. package/dist/config/judgment.js +1 -1
  47. package/dist/config/judgment.spec.js +1 -1
  48. package/dist/config/match-policy-file.d.ts +34 -0
  49. package/dist/config/match-policy-file.js +1 -0
  50. package/dist/config/match-policy-file.spec.d.ts +1 -0
  51. package/dist/config/match-policy-file.spec.js +1 -0
  52. package/dist/config/rule-engine.d.ts +5 -5
  53. package/dist/config/rule-engine.js +1 -1
  54. package/dist/config/runtime.d.ts +0 -1
  55. package/dist/config/runtime.js +1 -1
  56. package/dist/config/severity.d.ts +0 -2
  57. package/dist/config/severity.js +1 -1
  58. package/dist/config/store-policy.spec.js +1 -1
  59. package/dist/config/template-params.d.ts +42 -0
  60. package/dist/config/template-params.js +1 -0
  61. package/dist/config/template-params.spec.d.ts +1 -0
  62. package/dist/config/template-params.spec.js +1 -0
  63. package/dist/customer/account-events.js +1 -1
  64. package/dist/data/api/api.spec.js +1 -1
  65. package/dist/data/api/cli.js +1 -1
  66. package/dist/data/api/server.d.ts +1 -0
  67. package/dist/data/api/server.js +1 -1
  68. package/dist/data/projection/store.d.ts +3 -1
  69. package/dist/data/projection/store.js +1 -1
  70. package/dist/data/projection/types.d.ts +32 -0
  71. package/dist/data/sync/cdc.d.ts +1 -2
  72. package/dist/data/sync/cdc.js +1 -1
  73. package/dist/data/sync/cdc.spec.js +1 -1
  74. package/dist/data/sync/store.d.ts +5 -0
  75. package/dist/data/sync/store.js +1 -1
  76. package/dist/data/sync/types.d.ts +2 -0
  77. package/dist/evaluation/acceptance.d.ts +8 -0
  78. package/dist/evaluation/acceptance.js +1 -1
  79. package/dist/evaluation/builtins/demand-match.js +1 -1
  80. package/dist/evaluation/builtins/graph-service.spec.js +1 -1
  81. package/dist/evaluation/capability.d.ts +2 -0
  82. package/dist/evaluation/category-match-rules.d.ts +0 -1
  83. package/dist/evaluation/category-match-rules.js +1 -1
  84. package/dist/evaluation/composer.d.ts +25 -0
  85. package/dist/evaluation/composer.js +1 -1
  86. package/dist/evaluation/engine.js +1 -1
  87. package/dist/evaluation/extract.d.ts +7 -0
  88. package/dist/evaluation/extract.js +1 -1
  89. package/dist/evaluation/game-strategy.d.ts +0 -3
  90. package/dist/evaluation/game-strategy.js +1 -1
  91. package/dist/evaluation/guard-scan.js +1 -1
  92. package/dist/evaluation/match-operation.d.ts +9 -0
  93. package/dist/evaluation/match-operation.js +1 -1
  94. package/dist/evaluation/match-policy-resolver.d.ts +9 -0
  95. package/dist/evaluation/match-policy-resolver.js +1 -0
  96. package/dist/evaluation/match-policy.d.ts +3 -1
  97. package/dist/evaluation/match-policy.js +1 -1
  98. package/dist/evaluation/region.d.ts +0 -6
  99. package/dist/evaluation/region.js +1 -1
  100. package/dist/evaluation/standards.d.ts +2 -1
  101. package/dist/evaluation/standards.js +1 -1
  102. package/dist/evaluation/structured-lines.d.ts +8 -0
  103. package/dist/evaluation/structured-lines.js +1 -0
  104. package/dist/evaluation/types.d.ts +6 -0
  105. package/dist/experience/realtime-feedback.js +1 -1
  106. package/dist/extensions/capability-manifest.d.ts +1 -0
  107. package/dist/extensions/capability-manifest.js +1 -1
  108. package/dist/extensions/capability.d.ts +91 -0
  109. package/dist/extensions/capability.js +1 -0
  110. package/dist/extensions/industry-audit.spec.js +1 -1
  111. package/dist/extensions/industry-pack.d.ts +13 -0
  112. package/dist/extensions/industry-pack.js +1 -1
  113. package/dist/extensions/modes.js +1 -1
  114. package/dist/extensions/registry.d.ts +0 -2
  115. package/dist/extensions/registry.js +1 -1
  116. package/dist/goal/GoalEngine.js +1 -1
  117. package/dist/graph/onchain/analyze.js +1 -1
  118. package/dist/graph/onchain/expand.js +1 -1
  119. package/dist/graph/onchain/exposure.js +1 -1
  120. package/dist/graph/onchain/facts.js +1 -1
  121. package/dist/graph/onchain/order-status.d.ts +0 -1
  122. package/dist/graph/onchain/order-status.js +1 -1
  123. package/dist/harness/recover.js +1 -1
  124. package/dist/harness/verify.d.ts +0 -3
  125. package/dist/harness/verify.js +1 -1
  126. package/dist/index.js +1 -1
  127. package/dist/intent/types.d.ts +0 -1
  128. package/dist/intent/types.js +1 -1
  129. package/dist/keeper/detectors.js +1 -1
  130. package/dist/keeper/types.d.ts +0 -1
  131. package/dist/keeper/types.js +1 -1
  132. package/dist/knowledge/allocation-risk.d.ts +1 -0
  133. package/dist/knowledge/allocation-risk.js +1 -1
  134. package/dist/knowledge/allocation-templates.js +1 -1
  135. package/dist/knowledge/allocator-rail-verifier.d.ts +6 -1
  136. package/dist/knowledge/allocator-rail-verifier.js +1 -1
  137. package/dist/knowledge/arb-fund-facts.d.ts +1 -0
  138. package/dist/knowledge/arb-fund-facts.js +1 -1
  139. package/dist/knowledge/arbitration-ledger.js +1 -1
  140. package/dist/knowledge/arbitration-puzzle.js +1 -1
  141. package/dist/knowledge/arbitration-risk.d.ts +1 -0
  142. package/dist/knowledge/arbitration-risk.js +1 -1
  143. package/dist/knowledge/audit-rules.d.ts +2 -2
  144. package/dist/knowledge/audit-rules.js +1 -1
  145. package/dist/knowledge/baselines/judgment-baselines.json +21 -2
  146. package/dist/knowledge/baselines/rules/allocation.json +6 -6
  147. package/dist/knowledge/baselines/rules/arb.json +2 -2
  148. package/dist/knowledge/baselines/rules/guard.json +11 -11
  149. package/dist/knowledge/baselines/rules/oracle.json +120 -0
  150. package/dist/knowledge/baselines/rules/order.json +1 -1
  151. package/dist/knowledge/baselines/rules/plan.json +385 -18
  152. package/dist/knowledge/baselines/rules/progress.json +20 -2
  153. package/dist/knowledge/baselines/semantic-facts.js +1 -1
  154. package/dist/knowledge/builtin-templates.d.ts +25 -1
  155. package/dist/knowledge/builtin-templates.js +1 -1
  156. package/dist/knowledge/catalog-facts.d.ts +4 -0
  157. package/dist/knowledge/catalog-facts.js +1 -0
  158. package/dist/knowledge/commission-landing.js +1 -1
  159. package/dist/knowledge/component-schema.d.ts +64 -0
  160. package/dist/knowledge/component-schema.js +1 -0
  161. package/dist/knowledge/contact-templates.d.ts +0 -1
  162. package/dist/knowledge/contact-templates.js +1 -1
  163. package/dist/knowledge/dynamic-pricing.js +1 -1
  164. package/dist/knowledge/entity-recipient-guard.js +1 -1
  165. package/dist/knowledge/event-semantics.js +1 -1
  166. package/dist/knowledge/fee-param-bindings.d.ts +26 -0
  167. package/dist/knowledge/fee-param-bindings.js +1 -0
  168. package/dist/knowledge/fund-layer.d.ts +1 -0
  169. package/dist/knowledge/fund-layer.js +1 -1
  170. package/dist/knowledge/game-scenarios.js +1 -1
  171. package/dist/knowledge/getting-started.d.ts +2 -2
  172. package/dist/knowledge/getting-started.js +1 -1
  173. package/dist/knowledge/guard-anchor-reach.js +1 -1
  174. package/dist/knowledge/guard-binding-table.d.ts +52 -0
  175. package/dist/knowledge/guard-binding-table.js +1 -0
  176. package/dist/knowledge/guard-binding-verifier.d.ts +30 -0
  177. package/dist/knowledge/guard-binding-verifier.js +1 -0
  178. package/dist/knowledge/guard-bindings.js +1 -1
  179. package/dist/knowledge/guard-blueprint.d.ts +68 -0
  180. package/dist/knowledge/guard-blueprint.js +1 -0
  181. package/dist/knowledge/guard-design-patterns.d.ts +1 -1
  182. package/dist/knowledge/guard-design-patterns.js +1 -1
  183. package/dist/knowledge/guard-field-cognition.js +1 -1
  184. package/dist/knowledge/guard-host-context.d.ts +24 -0
  185. package/dist/knowledge/guard-host-context.js +1 -0
  186. package/dist/knowledge/guard-ledger.js +1 -1
  187. package/dist/knowledge/guard-lint.d.ts +1 -0
  188. package/dist/knowledge/guard-lint.js +1 -1
  189. package/dist/knowledge/guard-node-gates.d.ts +3 -0
  190. package/dist/knowledge/guard-node-gates.js +1 -1
  191. package/dist/knowledge/guard-puzzle.js +1 -1
  192. package/dist/knowledge/guard-render.js +1 -1
  193. package/dist/knowledge/guard-risk.js +1 -1
  194. package/dist/knowledge/guard-submission-prompt.d.ts +11 -0
  195. package/dist/knowledge/guard-submission-prompt.js +1 -1
  196. package/dist/knowledge/guard-templates.d.ts +1 -1
  197. package/dist/knowledge/guard-templates.js +1 -1
  198. package/dist/knowledge/guard-translation.js +1 -1
  199. package/dist/knowledge/index.d.ts +1 -1
  200. package/dist/knowledge/index.js +1 -1
  201. package/dist/knowledge/industry-generalizer.d.ts +6 -1
  202. package/dist/knowledge/industry-generalizer.js +1 -1
  203. package/dist/knowledge/industry-registry.js +1 -1
  204. package/dist/knowledge/industry-strategy.js +1 -1
  205. package/dist/knowledge/jsonrpc-enum.d.ts +52 -3
  206. package/dist/knowledge/jsonrpc-enum.js +1 -1
  207. package/dist/knowledge/knob-docs.d.ts +5 -0
  208. package/dist/knowledge/knob-docs.js +1 -0
  209. package/dist/knowledge/machine-templates.js +1 -1
  210. package/dist/knowledge/machine-topology.js +1 -1
  211. package/dist/knowledge/machine-translation.js +1 -1
  212. package/dist/knowledge/object-dependency.d.ts +31 -0
  213. package/dist/knowledge/object-dependency.js +1 -0
  214. package/dist/knowledge/onchain-constants.d.ts +4 -0
  215. package/dist/knowledge/onchain-constants.js +1 -1
  216. package/dist/knowledge/order-ledger.js +1 -1
  217. package/dist/knowledge/param-schema.d.ts +93 -0
  218. package/dist/knowledge/param-schema.js +1 -0
  219. package/dist/knowledge/param-tiers.d.ts +25 -0
  220. package/dist/knowledge/param-tiers.js +1 -0
  221. package/dist/knowledge/passport-ledger.d.ts +1 -1
  222. package/dist/knowledge/passport-ledger.js +1 -1
  223. package/dist/knowledge/path-oracle/coverage.d.ts +16 -0
  224. package/dist/knowledge/path-oracle/coverage.js +1 -0
  225. package/dist/knowledge/path-oracle/index.d.ts +5 -0
  226. package/dist/knowledge/path-oracle/index.js +1 -0
  227. package/dist/knowledge/path-oracle/products/food-delivery.d.ts +2 -0
  228. package/dist/knowledge/path-oracle/products/food-delivery.js +1 -0
  229. package/dist/knowledge/path-oracle/schema.d.ts +188 -0
  230. package/dist/knowledge/path-oracle/schema.js +1 -0
  231. package/dist/knowledge/pattern-resolutions.d.ts +108 -0
  232. package/dist/knowledge/pattern-resolutions.js +1 -0
  233. package/dist/knowledge/progress-ledger.js +1 -1
  234. package/dist/knowledge/progress-risk.js +1 -1
  235. package/dist/knowledge/projection.spec.js +1 -1
  236. package/dist/knowledge/protocol-facts.js +1 -1
  237. package/dist/knowledge/requirement-families.d.ts +13 -0
  238. package/dist/knowledge/requirement-families.js +1 -0
  239. package/dist/knowledge/reward-ledger.js +1 -1
  240. package/dist/knowledge/safety-rules.js +1 -1
  241. package/dist/knowledge/scenario-modes.d.ts +2 -0
  242. package/dist/knowledge/scenario-modes.js +1 -1
  243. package/dist/knowledge/scenario-topology.js +1 -1
  244. package/dist/knowledge/semantic-ir.d.ts +4 -0
  245. package/dist/knowledge/semantic-ir.js +1 -1
  246. package/dist/knowledge/service-allocation-semantics.js +1 -1
  247. package/dist/knowledge/service-ledger.d.ts +1 -1
  248. package/dist/knowledge/service-ledger.js +1 -1
  249. package/dist/knowledge/service-templates.js +1 -1
  250. package/dist/knowledge/sku-name-gate.d.ts +17 -0
  251. package/dist/knowledge/sku-name-gate.js +1 -0
  252. package/dist/knowledge/strategy-manuals.d.ts +1 -1
  253. package/dist/knowledge/strategy-manuals.js +1 -1
  254. package/dist/knowledge/supply-chain.d.ts +9 -0
  255. package/dist/knowledge/supply-chain.js +1 -1
  256. package/dist/knowledge/template-loader.d.ts +114 -6
  257. package/dist/knowledge/template-loader.js +1 -1
  258. package/dist/knowledge/template-nav.d.ts +9 -0
  259. package/dist/knowledge/template-nav.js +1 -0
  260. package/dist/knowledge/template-prose.d.ts +1 -1
  261. package/dist/knowledge/template-registry.js +1 -1
  262. package/dist/knowledge/template-scanner.d.ts +95 -0
  263. package/dist/knowledge/template-scanner.js +1 -1
  264. package/dist/knowledge/template-test-profiles.d.ts +17 -0
  265. package/dist/knowledge/template-test-profiles.js +1 -0
  266. package/dist/knowledge/template-validation.d.ts +1 -0
  267. package/dist/knowledge/template-validation.js +1 -1
  268. package/dist/knowledge/tools-reference.js +1 -1
  269. package/dist/knowledge/treasury-templates.js +1 -1
  270. package/dist/knowledge/workflow-guidance.d.ts +5 -0
  271. package/dist/knowledge/workflow-guidance.js +1 -1
  272. package/dist/monitor/MonitorLoop.js +1 -1
  273. package/dist/participation/radar-core.js +1 -1
  274. package/dist/participation/time-window.d.ts +37 -0
  275. package/dist/participation/time-window.js +1 -0
  276. package/dist/persona/address-format.d.ts +0 -1
  277. package/dist/persona/address-format.js +1 -1
  278. package/dist/persona/bridge.js +1 -1
  279. package/dist/persona/index.d.ts +0 -2
  280. package/dist/persona/index.js +1 -1
  281. package/dist/persona/model.js +1 -1
  282. package/dist/persona/persona-audit.spec.js +1 -1
  283. package/dist/persona/types.d.ts +6 -0
  284. package/dist/playbooks/service-build/business-puzzle.js +1 -1
  285. package/dist/playbooks/service-build/game-theory.d.ts +2 -2
  286. package/dist/playbooks/service-build/intent-analyzer.js +1 -1
  287. package/dist/playbooks/service-build/machine-panorama.d.ts +1 -0
  288. package/dist/playbooks/service-build/machine-panorama.js +1 -1
  289. package/dist/playbooks/service-build/merchant-guide.d.ts +52 -22
  290. package/dist/playbooks/service-build/merchant-guide.js +1 -1
  291. package/dist/playbooks/service-build/migration-planner.d.ts +2 -0
  292. package/dist/playbooks/service-build/migration-planner.js +1 -1
  293. package/dist/playbooks/service-build/mode-actions.js +1 -1
  294. package/dist/playbooks/service-build/object-panorama.d.ts +8 -0
  295. package/dist/playbooks/service-build/object-panorama.js +1 -1
  296. package/dist/playbooks/service-build/participation-radar.d.ts +1 -0
  297. package/dist/playbooks/service-build/participation-radar.js +1 -1
  298. package/dist/playbooks/service-build/relationship-profile.js +1 -1
  299. package/dist/playbooks/service-build/reverse-mapping.d.ts +6 -0
  300. package/dist/playbooks/service-build/reverse-mapping.js +1 -1
  301. package/dist/playbooks/service-build/service-panorama.d.ts +2 -0
  302. package/dist/playbooks/service-build/service-panorama.js +1 -1
  303. package/dist/playbooks/service-build/service-quote.js +1 -1
  304. package/dist/playbooks/service-build/service-quote.spec.js +1 -1
  305. package/dist/playbooks/service-build/workflow-design-assessment.d.ts +10 -1
  306. package/dist/playbooks/service-build/workflow-design-assessment.js +1 -1
  307. package/dist/relationship/registry.js +1 -1
  308. package/dist/review/index.js +1 -1
  309. package/dist/review/repository.js +1 -1
  310. package/dist/runtime/instance-registry.d.ts +7 -1
  311. package/dist/runtime/instance-registry.js +1 -1
  312. package/dist/safety/confirm-gate.js +1 -1
  313. package/dist/schema/benchmark-migration/index.d.ts +106 -0
  314. package/dist/schema/benchmark-migration/index.js +1 -1
  315. package/dist/schema/call/allocation.d.ts +15 -6
  316. package/dist/schema/call/allocation.js +1 -1
  317. package/dist/schema/call/arbitration.js +1 -1
  318. package/dist/schema/call/base.d.ts +264 -0
  319. package/dist/schema/call/base.js +1 -1
  320. package/dist/schema/call/bridge.d.ts +34 -6
  321. package/dist/schema/call/demand.d.ts +15 -6
  322. package/dist/schema/call/demand.js +1 -1
  323. package/dist/schema/call/error-codes.d.ts +1 -1
  324. package/dist/schema/call/error-codes.js +1 -1
  325. package/dist/schema/call/guard.d.ts +8 -8
  326. package/dist/schema/call/guard.js +1 -1
  327. package/dist/schema/call/handler.d.ts +3 -0
  328. package/dist/schema/call/handler.js +1 -1
  329. package/dist/schema/call/machine.d.ts +32 -8
  330. package/dist/schema/call/machine.js +1 -1
  331. package/dist/schema/call/order.d.ts +26 -8
  332. package/dist/schema/call/order.js +1 -1
  333. package/dist/schema/call/payment.d.ts +20 -8
  334. package/dist/schema/call/payment.js +1 -1
  335. package/dist/schema/call/permission-handler.js +1 -1
  336. package/dist/schema/call/permission.d.ts +330 -114
  337. package/dist/schema/call/permission.js +1 -1
  338. package/dist/schema/call/personal.d.ts +10 -4
  339. package/dist/schema/call/personal.js +1 -1
  340. package/dist/schema/call/progress.d.ts +16 -4
  341. package/dist/schema/call/reward.d.ts +10 -4
  342. package/dist/schema/call/reward.js +1 -1
  343. package/dist/schema/call/semantic.d.ts +1 -0
  344. package/dist/schema/call/semantic.js +1 -1
  345. package/dist/schema/call/service.d.ts +131 -43
  346. package/dist/schema/call/service.js +1 -1
  347. package/dist/schema/call/treasury.d.ts +15 -6
  348. package/dist/schema/call/treasury.js +1 -1
  349. package/dist/schema/common/index.js +1 -1
  350. package/dist/schema/config/index.d.ts +61 -0
  351. package/dist/schema/config/index.js +1 -1
  352. package/dist/schema/envelope-unify.d.ts +4 -0
  353. package/dist/schema/envelope-unify.js +1 -0
  354. package/dist/schema/evaluation/index.d.ts +224 -19
  355. package/dist/schema/evaluation/index.js +1 -1
  356. package/dist/schema/goal/index.d.ts +47 -0
  357. package/dist/schema/goal/planning.d.ts +116 -1
  358. package/dist/schema/goal/planning.js +1 -1
  359. package/dist/schema/industry-pack/index.d.ts +166 -6
  360. package/dist/schema/industry-pack/index.js +1 -1
  361. package/dist/schema/industry-pack/modes.d.ts +6 -6
  362. package/dist/schema/keeper/index.d.ts +26 -0
  363. package/dist/schema/local/index.d.ts +157 -0
  364. package/dist/schema/local/index.js +1 -1
  365. package/dist/schema/local/wip.d.ts +6 -0
  366. package/dist/schema/local/wip.js +1 -1
  367. package/dist/schema/messenger/index.d.ts +28 -0
  368. package/dist/schema/messenger/index.js +1 -1
  369. package/dist/schema/operations.d.ts +343 -84
  370. package/dist/schema/operations.js +1 -1
  371. package/dist/schema/persona/index.d.ts +2907 -640
  372. package/dist/schema/persona/index.js +1 -1
  373. package/dist/schema/query/bi.d.ts +251 -4
  374. package/dist/schema/query/bi.js +1 -1
  375. package/dist/schema/query/index.d.ts +271 -78
  376. package/dist/schema/query/index.js +1 -1
  377. package/dist/schema/schema-query/index.d.ts +1 -1
  378. package/dist/schema/schema-query/index.js +1 -1
  379. package/dist/schema/schema-version.js +1 -1
  380. package/dist/schema/utils/permission-machine-check.d.ts +2 -0
  381. package/dist/schema/utils/permission-machine-check.js +1 -1
  382. package/dist/schema/watch/index.d.ts +16 -0
  383. package/dist/schema/watch/index.js +1 -1
  384. package/dist/schema/workflow/index.d.ts +2 -2
  385. package/dist/schema/workflow/index.js +1 -1
  386. package/dist/schema-query-impl/index.d.ts +1 -1
  387. package/dist/schema-query-impl/index.js +1 -1
  388. package/dist/schemas/account_operation.output.json +98 -2
  389. package/dist/schemas/benchmark_migration_operation.output.json +341 -12
  390. package/dist/schemas/benchmark_migration_operation.schema.json +42 -3
  391. package/dist/schemas/bridge_operation.output.json +98 -2
  392. package/dist/schemas/bridge_operation.schema.json +5 -5
  393. package/dist/schemas/config_operation.output.json +352 -0
  394. package/dist/schemas/config_operation.schema.json +20 -2
  395. package/dist/schemas/evaluation_operation.output.json +586 -4
  396. package/dist/schemas/evaluation_operation.schema.json +194 -3
  397. package/dist/schemas/goal_operation.schema.json +183 -0
  398. package/dist/schemas/guard2file.schema.json +1 -1
  399. package/dist/schemas/index.json +1 -1
  400. package/dist/schemas/industry_pack_operation.output.json +771 -1
  401. package/dist/schemas/industry_pack_operation.schema.json +28 -4
  402. package/dist/schemas/keeper_operation.output.json +96 -2
  403. package/dist/schemas/local_cache_operation.output.json +98 -2
  404. package/dist/schemas/local_history_operation.output.json +98 -2
  405. package/dist/schemas/local_info_operation.output.json +98 -2
  406. package/dist/schemas/local_mark_operation.output.json +98 -2
  407. package/dist/schemas/machineNode2file.schema.json +1 -1
  408. package/dist/schemas/messenger_operation.output.json +107 -2
  409. package/dist/schemas/messenger_operation.schema.json +41 -34
  410. package/dist/schemas/monitor_events.output.json +96 -2
  411. package/dist/schemas/monitor_subscription.output.json +96 -2
  412. package/dist/schemas/onchain_events.output.json +108 -14
  413. package/dist/schemas/onchain_operations.output.json +326 -11
  414. package/dist/schemas/onchain_operations.schema.json +1343 -734
  415. package/dist/schemas/onchain_operations_allocation.schema.json +35 -19
  416. package/dist/schemas/onchain_operations_arbitration.schema.json +16 -8
  417. package/dist/schemas/onchain_operations_contact.schema.json +12 -4
  418. package/dist/schemas/onchain_operations_demand.schema.json +33 -17
  419. package/dist/schemas/onchain_operations_gen_passport.schema.json +12 -4
  420. package/dist/schemas/onchain_operations_gen_proof.schema.json +1 -1
  421. package/dist/schemas/onchain_operations_guard.schema.json +297 -111
  422. package/dist/schemas/onchain_operations_machine.schema.json +56 -39
  423. package/dist/schemas/onchain_operations_order.schema.json +67 -42
  424. package/dist/schemas/onchain_operations_payment.schema.json +27 -12
  425. package/dist/schemas/onchain_operations_permission.schema.json +363 -232
  426. package/dist/schemas/onchain_operations_personal.schema.json +43 -28
  427. package/dist/schemas/onchain_operations_progress.schema.json +49 -32
  428. package/dist/schemas/onchain_operations_proof.schema.json +12 -4
  429. package/dist/schemas/onchain_operations_repository.schema.json +17 -8
  430. package/dist/schemas/onchain_operations_reward.schema.json +36 -20
  431. package/dist/schemas/onchain_operations_service.schema.json +230 -130
  432. package/dist/schemas/onchain_operations_treasury.schema.json +36 -20
  433. package/dist/schemas/onchain_table_data.output.json +276 -19
  434. package/dist/schemas/onchain_table_data.schema.json +104 -64
  435. package/dist/schemas/persona_operation.output.json +7752 -0
  436. package/dist/schemas/persona_operation.schema.json +1232 -4
  437. package/dist/schemas/query_toolkit.output.json +1054 -146
  438. package/dist/schemas/query_toolkit.schema.json +144 -13
  439. package/dist/schemas/schema_query.schema.json +1 -1
  440. package/dist/schemas/watch_operation.output.json +86 -3
  441. package/dist/schemas/wip_file.output.json +8 -0
  442. package/dist/schemas/workflow_operation.schema.json +5 -4
  443. package/dist/schemas/wowok_buildin_info.schema.json +1 -1
  444. package/dist/task/playbook.js +1 -1
  445. package/dist/tools/handlers/benchmark-migration.d.ts +12 -3
  446. package/dist/tools/handlers/benchmark-migration.js +1 -1
  447. package/dist/tools/handlers/config.js +1 -1
  448. package/dist/tools/handlers/evaluation.js +1 -1
  449. package/dist/tools/handlers/evaluation.spec.js +1 -1
  450. package/dist/tools/handlers/industry-pack.js +1 -1
  451. package/dist/tools/handlers/messenger.js +1 -1
  452. package/dist/tools/handlers/onchain.d.ts +24 -0
  453. package/dist/tools/handlers/onchain.js +1 -1
  454. package/dist/tools/handlers/persona.js +1 -1
  455. package/dist/tools/handlers/query.d.ts +8 -0
  456. package/dist/tools/handlers/query.js +1 -1
  457. package/dist/tools/handlers/winner-derivation.d.ts +20 -0
  458. package/dist/tools/handlers/winner-derivation.js +1 -0
  459. package/dist/tools/handlers/wip-upload.js +1 -1
  460. package/dist/tools/index.d.ts +1 -0
  461. package/dist/tools/index.js +1 -1
  462. package/dist/tools/registry/business.js +1 -1
  463. package/dist/tools/registry/config.js +1 -1
  464. package/dist/tools/registry/evaluation.js +1 -1
  465. package/dist/tools/registry/identity.js +1 -1
  466. package/dist/tools/registry/onchain.js +1 -1
  467. package/dist/tools/registry/query.js +1 -1
  468. package/dist/tools/sanitize-output.js +1 -1
  469. package/dist/tools/sanitize-output.spec.js +1 -1
  470. package/dist/tools/transport-integrity.d.ts +7 -0
  471. package/dist/tools/transport-integrity.js +1 -0
  472. package/dist/tools/types.d.ts +1 -0
  473. package/dist/tools/upgrade-check.d.ts +22 -0
  474. package/dist/tools/upgrade-check.js +1 -1
  475. package/dist/tools/wrap.d.ts +6 -1
  476. package/dist/tools/wrap.js +1 -1
  477. package/package.json +7 -6
  478. package/dist/extensions/business-modules.d.ts +0 -54
  479. package/dist/extensions/business-modules.js +0 -1
  480. package/dist/schemas/guard-templates.json +0 -379
@@ -0,0 +1 @@
1
+ export function normalizeCompileInputs(a,b,c){const d=[],e=[];b['review_reward_pool']!==undefined&&b['reward_funding']===undefined&&(b={...b,'reward_funding':b['review_reward_pool']});{const f=a['fee_params'],g=f['campaign_deadline_ms']!==undefined,h=f['campaign_duration_days']!==undefined,i=b['campaign_duration_hours']!==undefined;if(g&&(h||i)){const j=w=>{if(w===undefined||w===null||w==='')return undefined;const x=typeof w==='number'?w:Number(w);return Number['isFinite'](x)?x:undefined;},l=j(b['campaign_deadline_ms']),m=j(b['campaign_duration_days']),o=j(b['campaign_duration_hours']),p=j(f['campaign_deadline_ms']),q=j(f['campaign_duration_days']),r=m!==undefined?m*0x5265c00:o!==undefined?o*0x36ee80:q!==undefined?q*0x5265c00:undefined,s=m!==undefined?'campaign_duration_days':o!==undefined?'campaign_duration_hours':'campaign_duration_days',t=m??o??q??0x0,u=l!==undefined&&l>0x0?l:p,v=m!==undefined||o!==undefined||u===undefined||u===0x0;if(c!==undefined&&r!==undefined&&r>0x0&&v){const w=Math['round'](c+r),x=m!==undefined?Math['round'](c+m*0x5265c00):undefined,y=o!==undefined?Math['round'](c+o*0x36ee80):undefined,z=[u!==undefined&&u>0x0?u:undefined,x,y]['filter'](A=>A!==undefined);new Set(z)['size']>0x1?d['push']({'code':'CAMPAIGN_DEADLINE_CONFLICT','detail':'the\x20campaign\x20answers\x20name\x20different\x20instants:\x20'+[m!==undefined?'campaign_duration_days\x20('+m+'\x20d\x20→\x20'+x+'\x20at\x20this\x20build\x20instant)':undefined,o!==undefined?'campaign_duration_hours\x20('+o+'\x20h\x20→\x20'+y+'\x20at\x20this\x20build\x20instant)':undefined,u!==undefined&&u>0x0?'campaign_deadline_ms\x20('+u+')':undefined]['filter'](Boolean)['join'](',\x20')+'.\x20ONE\x20campaign\x20has\x20ONE\x20deadline:\x20pass\x20ONE\x20length\x20(days\x20OR\x20hours)\x20or\x20the\x20absolute\x20timestamp,\x20and\x20drop\x20the\x20others\x20(0\x20=\x20unset\x20is\x20not\x20a\x20deadline).'}):(b={...b,'campaign_deadline_ms':w},e['push']({'param':'campaign_deadline_ms','from':s,'input':t,'value':w,'at_ms':c,'note':'converted\x20at\x20generation:\x20'+t+'\x20'+(s==='campaign_duration_hours'?'hour(s)':'day(s)')+'\x20after\x20the\x20build\x20instant\x20'+('('+new Date(c)['toISOString']()+')\x20became\x20the\x20ABSOLUTE\x20campaign\x20')+('deadline\x20epoch-ms\x20'+w+'\x20—\x20the\x20value\x20every\x20deadline\x20gate\x20and\x20the\x20pre-deadline\x20')+'withdrawal\x20window\x20now\x20read\x20on\x20chain'}));}}}{const A=a['fee_params'];for(const [B,C]of Object['entries'](b)){if(!/_days$/['test'](B)||B==='campaign_duration_days'||!(B in A))continue;const D=typeof C==='number'?C:typeof C==='string'&&C['trim']()!==''?Number(C):NaN;Number['isFinite'](D)&&!Number['isInteger'](D)&&d['push']({'code':'WINDOW_TRUNCATION_ZERO','detail':'input\x20\x27'+B+'\x27\x20=\x20'+String(C)+'\x20is\x20a\x20FRACTIONAL\x20day\x20count\x20—\x20the\x20knob\x20lands\x20in\x20a\x20guard-table\x20'+('U64\x20slot\x20as\x20a\x20DAY\x20COUNT,\x20which\x20BCS\x20truncates\x20to\x20'+String(Math['trunc'](D))+':\x20any\x20`<=`\x20closing\x20window\x20')+'it\x20feeds\x20computes\x20anchor\x20+\x200\x20and\x20welds\x20shut\x20the\x20instant\x20its\x20anchor\x20entry\x20lands\x20(Guards\x20are\x20'+'immutable\x20—\x20the\x20live\x20run\x20compiled\x20a\x200.002-day\x20test\x20window\x20into\x20a\x20permanently\x20closed\x20review\x20rail).\x20'+'Pass\x20whole\x20days,\x20or\x20express\x20sub-day\x20precision\x20as\x20a\x20millisecond\x20duration\x20in\x20a\x20'+'ms-denominated\x20slot\x20pair\x20(duration\x20in\x20ms\x20beside\x20ms_per_day\x20=\x201).'});}}return{'inputs':b,'derivedParams':e,'blockers':d};}export function applyConditionalSelectors(a,b){const d=[],e=new Set();for(const k of a['conditional_guards']??[]){const l=b[k['param']]??a['fee_params'][k['param']];if(l!==k['emit_value'])e['add'](k['guard_key']);}{const m=new Map();for(const n of a['conditional_guards']??[]){const o=m['get'](n['param']);if(o===undefined)m['set'](n['param'],new Set(n['values']??[]));else{for(const p of n['values']??[])o['add'](p);}}for(const [q,r]of m){if(r['size']===0x0)continue;const s=b[q];if(s===undefined||s===null||s==='')continue;const t=String(s);if(r['has'](t))continue;d['push']({'code':'SELECTOR_VALUE_UNKNOWN','detail':'build\x20input\x20\x27'+q+'\x27\x20=\x20\x27'+t+'\x27\x20is\x20outside\x20the\x20value\x20set\x20this\x20template\x20accepts\x20'+('('+[...r]['join']('\x20|\x20')+').\x20The\x20param\x20drives\x20a\x20conditional\x20guard\x20emission,\x20so\x20an\x20out-of-set\x20answer\x20')+'used\x20to\x20compile\x20the\x20DEFAULT\x20business\x20model\x20silently\x20instead\x20of\x20the\x20one\x20asked\x20for\x20—\x20on\x20the\x20'+'storefront_mode\x20/\x20deposit_exit_policy\x20families\x20that\x20means\x20a\x20public\x20storefront\x20or\x20a\x20refunded\x20deposit\x20'+'with\x20no\x20warning\x20at\x20all.\x20Answer\x20one\x20of\x20the\x20accepted\x20values,\x20or\x20drop\x20the\x20input\x20to\x20take\x20the\x20declared\x20'+('default\x20(\x27'+String(a['fee_params'][q]??'none')+'\x27).')});}}const f=new Map();for(const u of a['conditional_guards']??[]){f['set'](u['param'],(f['get'](u['param'])??0x0)+0x1);}const g=new Set((a['conditional_guards']??[])['filter'](w=>(f['get'](w['param'])??0x0)>0x1)['map'](w=>w['guard_key'])),h=new Set([...e]['filter'](w=>g['has'](w))),i=h['size']>0x0?a['machine_shape']['map'](w=>({...w,'from':(w['from']??[])['filter'](x=>typeof x==='string'||x['guard_key']===undefined||!h['has'](x['guard_key']))})):a['machine_shape'],j=h['size']>0x0?(a['allocator']['rows']??[])['filter'](w=>w['guard_key']===undefined||!h['has'](w['guard_key'])):a['allocator']['rows']??[];return{'dropKeys':e,'selectorDroppedKeys':h,'shape':i,'rows':j,'blockers':d};}
@@ -1,4 +1,4 @@
1
- import { type CreateStep, type LateQuery, type Plan } from "./plan.js";
1
+ import { type CreateStep, type LateQuery, type Plan, type StepId } from "./plan.js";
2
2
  import { type PlanAuditResult } from "./audit.js";
3
3
  export interface ExecOutcome {
4
4
  outcome: "executed" | "failed" | "pending_input";
@@ -17,13 +17,33 @@ export interface MaterializeIO {
17
17
  resolveLate?: LateResolver;
18
18
  read?: ObjectReader;
19
19
  env?: unknown;
20
+ envByAccount?: Record<string, unknown>;
21
+ timeoutMs?: number;
20
22
  }
21
23
  export declare function handlerExecutor(env?: unknown): Executor;
24
+ export declare function adaptConfigureParams(method: string, params: unknown): unknown;
22
25
  export declare function adaptCreateData(step: CreateStep, resolved: Record<string, unknown>): Record<string, unknown>;
23
26
  export declare function preflightPlan(plan: Plan): {
24
27
  plan: Plan;
25
28
  audit: PlanAuditResult;
26
29
  };
30
+ export interface BindAuditOffense {
31
+ step: StepId;
32
+ slot: string;
33
+ kind: "intra_plan_bare_name" | "undeclared_external";
34
+ value: string;
35
+ }
36
+ export declare function bindAuditPlan(plan: Plan): BindAuditOffense[];
37
+ export interface BindRecoveryEntry {
38
+ step: string;
39
+ kind?: string;
40
+ object?: string;
41
+ address?: string;
42
+ funded?: string;
43
+ retrieval?: string;
44
+ }
45
+ export declare function bindRecoveryList(plan: Plan, executed?: Record<string, string>): BindRecoveryEntry[];
46
+ export declare function bindAuditReport(offenses: BindAuditOffense[], recovery: BindRecoveryEntry[]): string;
27
47
  export type StepStatus = "executed" | "failed" | "blocked";
28
48
  export interface StepResult {
29
49
  stepId: string;
@@ -36,6 +56,7 @@ export interface MaterializeResult {
36
56
  steps: StepResult[];
37
57
  outputs: Record<string, string>;
38
58
  completed: boolean;
59
+ budgetExhausted: boolean;
39
60
  preflight: PlanAuditResult;
40
61
  readback: ReadbackReport;
41
62
  }
@@ -52,16 +73,4 @@ export interface ReadbackReport {
52
73
  ok: boolean;
53
74
  checks: ReadbackCheck[];
54
75
  }
55
- interface SharingRow {
56
- mode?: string;
57
- sharing?: string | number;
58
- }
59
- interface AllocatorRowLike {
60
- track?: string;
61
- guard?: unknown;
62
- sharing?: SharingRow[];
63
- }
64
- export declare function planAllocatorRows(plan: Plan): AllocatorRowLike[];
65
76
  export declare function conservationCheck(plan: Plan): ReadbackCheck[];
66
- export declare function verifyMaterialization(plan: Plan, outputs: ReadonlyMap<string, string>, io: Pick<MaterializeIO, "read" | "env">): Promise<ReadbackReport>;
67
- export {};
@@ -1 +1 @@
1
- import{CREATABLE_OBJECTS,createsOf,isRef,resolveValue}from'./plan.js';import{auditPlan}from'./audit.js';export function handlerExecutor(a){return async(b,c)=>{const {handleOnchainOperations:d}=await import('../tools/handlers/onchain.js'),e=await d({'operation_type':b,'data':c,'env':a}),f=e['structuredContent'],g=f?.['result'];return{'outcome':f?.['outcome']==='executed'?'executed':f?.['outcome']==='pending_input'?'pending_input':'failed','digest':g?.['digest'],'created':Array['isArray'](g?.['created'])?g['created']:[],'error':g?.['error']};};}export function adaptCreateData(a,b){const {name:c,permission:d,type_parameter:e,nodes:f,...g}=b;switch(a['object']){case'service':case'arbitration':return{'object':{'name':c,'type_parameter':e,'permission':d},...g};case'machine':return{'object':{'name':c,...d!==undefined?{'permission':d}:{}},...g['description']!==undefined?{'description':g['description']}:{},'node':{'op':'add','nodes':f,'bReplace':!![]}};case'guard':return b;case'permission':case'contact':case'repository':default:return{'object':{'name':c,...d!==undefined?{'permission':d}:{}},...g};}}export function preflightPlan(a){const b=auditPlan(a),c=new Set(b['findings']['map'](g=>g['rule_id'])),d=c['has']('ARB-KEY-PLANE-01'),e=b['issues']['length']===0x0&&!b['findings']['some'](g=>g['level']==='critical')&&!d,f=a['steps']['map'](g=>{if(g['op']!=='publish')return g;const h=g['preflight']['map'](i=>{const j=i['check']['endsWith']('_publish')?e:!c['has'](i['check']);return{...i,'status':j?'pass':'fail'};});return{...g,'preflight':h};});return{'plan':{...a,'steps':f},'audit':b};}function stripGenerics(a){return a['replace'](/<.*>$/,'');}function matchCreated(a,b){const c=stripGenerics(b);return a['created']['find'](d=>{if(typeof d['type_raw']!=='string'||typeof d['object']!=='string')return![];return stripGenerics(d['type_raw'])['endsWith']('::'+c);})?.['object'];}const DEFAULT_LATE=a=>{if(a['by']==='address')return a['address'];throw new Error('unresolved\x20late\x20binding\x20(no\x20resolver\x20injected):\x20local_name\x20\x27'+a['mark']+'\x27');};export async function materializePlan(a,b,c){const {plan:d,audit:f}=preflightPlan(a),g=new Map(Object['entries'](c?.['outputs']??{})),h=new Set(c?.['completedSteps']??[]),i=[],j=b['resolveLate']??DEFAULT_LATE,k=new Map(d['steps']['filter'](o=>o['op']==='create')['map'](o=>[o['id'],o['object']])),l=o=>resolveValue(o,g,j);let m=![];for(const o of d['steps']){if(m){i['push']({'stepId':o['id'],'status':'blocked','error':'halted\x20by\x20earlier\x20failure/blocked\x20publish'});continue;}if(h['has'](o['id'])){const p=g['get'](o['id']);if(p===undefined){i['push']({'stepId':o['id'],'status':'failed','error':'resumed\x20step\x20has\x20no\x20recorded\x20output\x20—\x20pass\x20it\x20in\x20previous_outputs'}),m=!![];continue;}i['push']({'stepId':o['id'],'status':'executed','address':p,'error':'resumed\x20from\x20a\x20prior\x20run\x20(adopted,\x20not\x20re-executed)'});continue;}try{if(o['op']==='publish'){const t=o['preflight']['filter'](w=>w['status']==='fail');if(t['length']>0x0){i['push']({'stepId':o['id'],'status':'blocked','error':'preflight\x20failed:\x20'+t['map'](w=>w['check'])['join'](',\x20')+'\x20(refusing\x20to\x20publish\x20—\x20A-2)'});continue;}const u=l(o['target']),v=await b['execute'](k['get'](o['target']['$ref'])??'',{'object':u,'publish':!![]},b['env']);if(v['outcome']!=='executed'){i['push']({'stepId':o['id'],'status':'failed','error':v['error']??v['outcome']}),m=!![];continue;}i['push']({'stepId':o['id'],'status':'executed','digest':v['digest'],'address':u});continue;}const q=Object['fromEntries'](Object['entries'](o['params'])['map'](([w,x])=>[w,l(x)]));if(o['op']==='create'){const w=adaptCreateData(o,q),x=await b['execute'](o['object'],w,b['env']);if(x['outcome']!=='executed'){i['push']({'stepId':o['id'],'status':'failed','error':x['error']??x['outcome']}),m=!![];continue;}const y=matchCreated(x,CREATABLE_OBJECTS[o['object']]);if(y===undefined){i['push']({'stepId':o['id'],'status':'failed','error':'created\x20'+o['object']+'\x20not\x20found\x20in\x20transaction\x20result'}),m=!![];continue;}g['set'](o['id'],y),i['push']({'stepId':o['id'],'status':'executed','digest':x['digest'],'address':y});continue;}const r=l(o['target']),s=await b['execute'](k['get'](isRef(o['target'])?o['target']['$ref']:'')??'',{'object':r,[o['method']]:q},b['env']);if(s['outcome']!=='executed'){i['push']({'stepId':o['id'],'status':'failed','error':s['error']??s['outcome']}),m=!![];continue;}i['push']({'stepId':o['id'],'status':'executed','digest':s['digest'],'address':r});}catch(z){i['push']({'stepId':o['id'],'status':'failed','error':z instanceof Error?z['message']:String(z)}),m=!![];}}const n=await verifyMaterialization(d,g,b);return{'steps':i,'outputs':Object['fromEntries'](g),'completed':i['every'](A=>A['status']==='executed'),'preflight':f,'readback':n};}export function planAllocatorRows(a){const b=[],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)b['push'](f);}};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 conservationCheck(a){const b=planAllocatorRows(a);if(b['length']===0x0)return[{'name':'allocator_conservation','ok':![],'detail':'no\x20allocator\x20rows\x20(PLAN-ALLOC-01)'}];const c=new Map();for(const e of b){const f=e['track']??'settlement';c['set'](f,[...c['get'](f)??[],e]);}const d=[];for(const [g,h]of c){const i=h['flatMap'](l=>(l['sharing']??[])['map'](m=>m['mode']));if(i['some'](l=>l==='Amount')){d['push']({'name':'conservation:'+g,'ok':!![],'detail':'contains\x20Amount-mode\x20row(s)\x20—\x20fixed\x20payouts\x20are\x20not\x20statically\x20verifiable\x20against\x20the\x20escrow\x20total'});continue;}let j=0x0;for(const l of h){for(const m of l['sharing']??[]){if(m['mode']==='Rate'||m['mode']==='RateGross')j+=Number(m['sharing']??0x0);}}const k=i['some'](n=>n==='Surplus');if(j>0x2710)d['push']({'name':'conservation:'+g,'ok':![],'detail':'rate\x20sum\x20'+j+'\x20>\x2010000\x20—\x20track\x20pays\x20out\x20MORE\x20than\x20it\x20holds'});else j<0x2710&&!k?d['push']({'name':'conservation:'+g,'ok':![],'detail':'rate\x20sum\x20'+j+'\x20<\x2010000\x20and\x20no\x20Surplus\x20row\x20—\x20the\x20remainder\x20has\x20no\x20fund\x20exit'}):d['push']({'name':'conservation:'+g,'ok':!![],'detail':k?'rate\x20sum\x20'+j+'\x20+\x20Surplus\x20row\x20absorbs\x20the\x20remainder':'rate\x20sum\x20'+j+'\x20==\x2010000'});}return d;}export async function verifyMaterialization(a,b,c){const d=[...conservationCheck(a)];if(c['read']!==undefined)for(const f of createsOf(a,'service')){const g=b['get'](f['id']);if(g===undefined)continue;try{const h=await c['read'](g,'service',c['env']);if(h===undefined||h===null){d['push']({'name':'readback:'+f['id'],'ok':![],'detail':'service\x20'+g+'\x20not\x20readable\x20after\x20creation'});continue;}const i=planAllocatorRows(a)['length'],j=h['order_allocators']?.['allocators']?.['length']??(Array['isArray'](h['order_allocators'])?h['order_allocators']['length']:undefined);j!==undefined&&d['push']({'name':'readback:'+f['id']+':allocators','ok':j>=i,'detail':'on-chain\x20allocator\x20rows\x20'+j+'\x20vs\x20plan\x20'+i});}catch(k){d['push']({'name':'readback:'+f['id'],'ok':![],'detail':k instanceof Error?k['message']:String(k)});}}return{'ok':d['every'](l=>l['ok']),'checks':d};}
1
+ import{CREATABLE_OBJECTS,createsOf,isLate,isRef,resolveValue}from'./plan.js';import{auditPlan}from'./audit.js';import{normalizeGuardRowNames}from'./guard-fill.js';function deriveCreated(a){if(Array['isArray'](a['created']))return a['created'];const b=Array['isArray'](a['objectChanges'])?a['objectChanges']:[];return b['filter'](d=>d?.['type']==='created'&&typeof d?.['objectId']==='string')['map'](d=>({'object':d['objectId'],'type_raw':d['objectType']}));}export function handlerExecutor(a){return async(b,c)=>{const {handleOnchainOperations:d}=await import('../tools/handlers/onchain.js'),e=await d({'operation_type':b,'data':c,'env':a}),f=e['structuredContent']??{},g=f['result']!==undefined&&f['result']['data']!==undefined?f['result']:f,h=g['data']?.['result']??g['result']??g,i=g['outcome']??g['data']?.['outcome']??f['outcome']??f['status'];return{'outcome':i==='executed'||i==='success'?'executed':i==='pending_input'?'pending_input':'failed','digest':h['digest']??g['digest'],'created':deriveCreated(h),'error':h['error']??g['error']};};}function normalizeGuardTable(a,b){if(!Array['isArray'](a))return{'table':a,'description':b};return normalizeGuardRowNames(a,b,MAX_DESCRIPTION_CONTENT);}const MAX_DESCRIPTION_CONTENT=0xf9e,MAX_POLICY_DESCRIPTION_BYTES=0x1f4;function truncateToBytes(a,b){if(Buffer['byteLength'](a,'utf8')<=b)return a;let c=a;while(c['length']>0x0&&Buffer['byteLength'](c,'utf8')>b)c=c['slice'](0x0,-0x1);return c;}function truncateDescription(a){if(typeof a!=='string')return a;if(Buffer['byteLength'](a,'utf8')>MAX_DESCRIPTION_CONTENT)return truncateToBytes(a,MAX_DESCRIPTION_CONTENT-0x3)+'...';return a;}export function adaptConfigureParams(a,b){if(a==='pause'&&b!==null&&typeof b==='object'&&!Array['isArray'](b))return b['pause'];if(a==='guard_add'&&b!==null&&typeof b==='object'&&!Array['isArray'](b))return[b];if(a==='coin_add'&&b!==null&&typeof b==='object'&&!Array['isArray'](b)){const c=b,d=c['coin'];if(c['balance']===undefined&&(typeof d==='number'||typeof d==='string'&&/^[0-9]+$/['test'](d)))return{'balance':d};}if(a==='order_allocators'&&b!==null&&typeof b==='object'){const e=b,f=e['allocators'];if(Array['isArray'](f)){const g=f['map'](h=>{const i=h,j=i['sharing'];if(!Array['isArray'](j))return h;return{...i,'sharing':j['map'](k=>{const m=k,n=m['who'];if(n&&typeof n['Entity']==='string')return{...m,'who':{'Entity':{'name_or_address':n['Entity']}}};return k;})};});return{...e,'allocators':g};}}if(a==='sales'&&b!==null&&typeof b==='object'){const h=b,i=h['sales'];if(Array['isArray'](i)){const j=i['map'](k=>{if(!k||typeof k!=='object')return k;const l=k,m=l['stock']??l['quantity']??0x0;return{'suspension':![],'wip':'',...l,'stock':m};});return{...h,'sales':j};}}if(a==='policies'&&b!==null&&typeof b==='object'&&!Array['isArray'](b)){const k=b,l=k['policy'];if(Array['isArray'](l))return{...k,'policy':l['map'](m=>{if(!m||typeof m!=='object')return m;const n=m;return{...Array['isArray'](n['write_guard'])?null:{'write_guard':[]},...n,...typeof n['description']==='string'?{'description':truncateToBytes(n['description'],MAX_POLICY_DESCRIPTION_BYTES)}:{}};})};}return b;}export function adaptCreateData(a,b){const {name:c,permission:d,type_parameter:e,nodes:f,...g}=b;if(g['description']!==undefined)g['description']=truncateDescription(g['description']);switch(a['object']){case'service':case'arbitration':return{'object':{'name':c,'type_parameter':e,'permission':d},...g};case'machine':return{'object':{'name':c,...d!==undefined?{'permission':d}:{}},...g['description']!==undefined?{'description':g['description']}:{},'node':{'op':'add','nodes':f,'bReplace':!![]}};case'guard':{const h=normalizeGuardTable(b['table'],b['description']);return{...b,'description':truncateDescription(h['description']),'table':h['table']};}case'permission':case'contact':case'repository':default:{const i=g['policies'];return{'object':{'name':c,...d!==undefined?{'permission':d}:{}},...g,...a['object']==='repository'&&Array['isArray'](i)?{'policies':{'op':'set','policy':i['map'](j=>{if(!j||typeof j!=='object')return j;const k=j;return{...Array['isArray'](k['write_guard'])?null:{'write_guard':[]},...k,...typeof k['description']==='string'?{'description':truncateToBytes(k['description'],MAX_POLICY_DESCRIPTION_BYTES)}:{}};})}}:{}};}}}export function preflightPlan(a){const b=auditPlan(a),c=new Set(b['findings']['map'](g=>g['rule_id'])),d=c['has']('ARB-KEY-PLANE-01'),e=b['issues']['length']===0x0&&!b['findings']['some'](g=>g['level']==='critical')&&!d,f=a['steps']['map'](g=>{if(g['op']!=='publish')return g;const h=g['preflight']['map'](i=>{const j=i['check']['endsWith']('_publish')?e:!c['has'](i['check']);return{...i,'status':j?'pass':'fail'};});return{...g,'preflight':h};});return{'plan':{...a,'steps':f},'audit':b};}export function bindAuditPlan(a){const b=new Map();for(const h of a['steps']){if(h['op']!=='create')continue;const i=h['params']['name'];if(typeof i==='string'&&i['length']>0x0)b['set'](i,h['id']);}const c=new Set(a['external_refs']??[]),d=[],e=new Set(['value','Entity','name_or_address','objects','coin']),f=(j,k,l,m)=>{if(!e['has'](l))return;b['has'](m)&&d['push']({'step':j,'slot':k,'kind':'intra_plan_bare_name','value':m});},g=(j,k,l)=>{if(b['has'](l))d['push']({'step':j,'slot':k,'kind':'intra_plan_bare_name','value':l});else!c['has'](l)&&d['push']({'step':j,'slot':k,'kind':'undeclared_external','value':l});};for(const j of a['steps']){if(j['op']==='configure'){const m=j['target'];if(typeof m==='string')f(j['id'],'target','value',m);else{if(isLate(m)){const n=m['$late'];if(n['by']==='local_name')g(j['id'],'target',n['mark']);}}}if(j['op']==='publish')continue;const k=j['params'];if(typeof k==='string')f(j['id'],'params','value',k);const l=(o,p,r)=>{if(o===null||o===undefined)return;if(Array['isArray'](o)){o['forEach']((u,w)=>l(u,p,r+'['+String(w)+']'));return;}if(typeof o==='object'){if(isRef(o))return;if(isLate(o)){const u=o['$late'];if(u['by']==='local_name')g(j['id'],r,u['mark']);return;}for(const [w,x]of Object['entries'](o)){l(x,w,r==='params'?'params.'+w:r+'.'+w);}return;}if(typeof o==='string')f(j['id'],r,p,o);};l(k,'','params');}return d;}function retrievalFor(a){if(a==='service')return'stop\x20new\x20orders\x20first\x20(onchain_operations\x20data\x20key\x20\x27pause\x27),\x20then\x20take\x20the\x20fund\x20back\x20'+'(data\x20key\x20\x27compensation_fund_withdraw\x27,\x20owner\x20signer\x20—\x20the\x20pool\x20returns\x20to\x20the\x20owner)';if(a==='reward')return'drain\x20the\x20pool\x20(onchain_operations\x20data\x20key\x20\x27withdraw\x27,\x20owner\x20signer;\x20'+'confirm\x20the\x20pool\x20balance\x20first\x20—\x20a\x20short\x20pool\x20aborts\x20cleanly\x20without\x20paying)';return'holds\x20no\x20build-time\x20money;\x20create-frozen\x20—\x20it\x20cannot\x20be\x20deleted\x20or\x20unbound.\x20'+'Remove\x20its\x20LocalMark\x20name\x20(local_mark_operation)\x20so\x20later\x20runs\x20never\x20bind\x20it\x20by\x20name';}export function bindRecoveryList(a,b){const c=new Map(a['steps']['map'](g=>[g['id'],g])),d=new Map();for(const g of a['steps']){if(g['op']!=='configure')continue;if(g['method']!=='coin_add'&&g['method']!=='compensation_fund_add')continue;const h=g['target'],i=h!==null&&typeof h==='object'?h['$ref']:undefined,j=g['params']?.['balance'];typeof i==='string'&&(typeof j==='string'||typeof j==='number')&&d['set'](i,String(j));}const e=[],f=(k,l)=>{const m=c['get'](k),n=m?.['op']==='create'?m:undefined,o=n?.['object'],p=n?String(n['params']['name']??''):'',q=d['get'](k);e['push']({'step':k,...o!==undefined?{'kind':o}:{},...p?{'object':p}:{},...l?{'address':l}:{},...q!==undefined?{'funded':q}:{},...o!==undefined?{'retrieval':retrievalFor(o)}:{}});};if(b)for(const [k,l]of Object['entries'](b)){f(k,typeof l==='string'&&l['length']>0x0?l:undefined);}else{for(const m of a['steps'])if(m['op']==='create')f(m['id']);}return e;}function teardownPlan(a){if(a['length']===0x0)return'';const b=[],c=a['find'](d=>d['kind']==='service');c!==undefined&&b['push']('\x20\x201.\x20stop\x20new\x20orders:\x20onchain_operations\x20on\x20the\x20Service'+(c['address']?'\x20'+c['address']:'')+'\x20with\x20data\x20key\x20\x27pause\x27.','\x20\x202.\x20take\x20the\x20compensation\x20fund\x20back:\x20the\x20same\x20Service,\x20data\x20key\x20\x27compensation_fund_withdraw\x27\x20(owner\x20signer\x20—\x20the\x20pool\x20returns\x20to\x20the\x20owner;\x20real\x20money\x20only\x20if\x20the\x20money-in\x20step\x20ran\x20—\x20confirm\x20the\x20balance\x20first).');for(const d of a['filter'](e=>e['kind']==='reward')){b['push']('\x20\x20'+(b['length']+0x1)+'.\x20drain\x20the\x20reward\x20pool'+(d['address']?'\x20'+d['address']:'')+':\x20data\x20key\x20\x27withdraw\x27\x20(owner\x20signer;\x20confirm\x20the\x20pool\x20balance\x20first\x20—\x20a\x20short\x20pool\x20aborts\x20cleanly).');}return a['some'](e=>e['kind']!==undefined&&e['kind']!=='service'&&e['kind']!=='reward')&&b['push']('\x20\x20'+(b['length']+0x1)+'.\x20frozen\x20leftovers\x20(guards,\x20machine,\x20repositories)\x20cannot\x20be\x20deleted\x20or\x20unbound\x20—\x20they\x20stay\x20inert\x20on\x20chain;\x20remove\x20their\x20LocalMark\x20names\x20(local_mark_operation)\x20so\x20later\x20runs\x20never\x20bind\x20them\x20by\x20name.'),'\x0aTEARDOWN\x20PLAN\x20(abandon\x20this\x20run\x27s\x20store\x20—\x20execute\x20top\x20to\x20bottom):\x0a'+b['join']('\x0a');}export function bindAuditReport(a,b){const c=a['slice'](0x0,0xc)['map'](e=>'\x20\x20•\x20step\x20\x27'+e['step']+'\x27\x20'+e['slot']+'\x20->\x20\x27'+e['value']+'\x27\x20('+(e['kind']==='intra_plan_bare_name'?'names\x20an\x20object\x20THIS\x20plan\x20creates\x20—\x20must\x20be\x20{\x22$ref\x22:\x20\x22<create_step_id>\x22}':'undeclared\x20external\x20local_name\x20—\x20declare\x20it\x20in\x20plan.external_refs\x20or\x20bind\x20a\x20plan\x20ref')+')'),d=b['length']>0x0?b['map'](e=>{const f=e['object']!==undefined?(e['kind']??'object')+':\x20'+e['object']:e['kind']??'';return'\x20\x20•\x20'+e['step']+(f?'\x20('+f+')':'')+(e['address']!==undefined?'\x20@'+e['address']:'\x20—\x20no\x20address\x20recorded\x20—\x20find\x20the\x20object\x20by\x20its\x20name\x20(workspace/onchain_objects)\x20or\x20its\x20create\x20digest')+(e['funded']!==undefined?';\x20plan-funded\x20'+e['funded']+'\x20raw\x20(confirm\x20the\x20live\x20balance\x20before\x20relying\x20on\x20it)':'')+(e['retrieval']!==undefined?';\x20take\x20back:\x20'+e['retrieval']:'');})['join']('\x0a'):'\x20\x20•\x20(none\x20—\x20nothing\x20was\x20executed\x20in\x20this\x20run;\x20no\x20funds\x20or\x20objects\x20to\x20recover)';return'Offending\x20slots:\x0a'+c['join']('\x0a')+(a['length']>0xc?'\x0a\x20\x20…\x20+'+(a['length']-0xc)+'\x20more':'')+'\x0a'+('RECOVERY\x20LIST\x20(objects\x20already\x20created\x20by\x20this\x20run\x20—\x20id\x20+\x20digest/address\x20—\x20so\x20you\x20can\x20recover\x20funds/objects):\x0a'+d)+teardownPlan(b);}function stripGenerics(a){return a['replace'](/<.*>$/,'');}function matchCreated(a,b){const c=stripGenerics(b);return a['created']['find'](d=>{if(typeof d['type_raw']!=='string'||typeof d['object']!=='string')return![];return stripGenerics(d['type_raw'])['endsWith']('::'+c);})?.['object'];}const DEFAULT_LATE=a=>{if(a['by']==='address')return a['address'];throw new Error('unresolved\x20late\x20binding\x20(no\x20resolver\x20injected):\x20local_name\x20\x27'+a['mark']+'\x27');};export async function materializePlan(a,b,c){const {plan:d,audit:f}=preflightPlan(a),g=new Map(Object['entries'](c?.['outputs']??{})),h=new Set(c?.['completedSteps']??[]),i=[],j=b['resolveLate']??DEFAULT_LATE,k=new Map(d['steps']['filter'](t=>t['op']==='create')['map'](t=>[t['id'],t['object']])),l=s=>resolveValue(s,g,j),m=s=>{if(s['account']===undefined)return b['env'];const t=b['envByAccount']?.[s['account']];if(t===undefined)throw new Error('step\x20\x27'+s['id']+'\x27\x20declares\x20account\x20\x27'+s['account']+'\x27\x20but\x20no\x20env\x20was\x20provided\x20for\x20it\x20—\x20'+('re-run\x20plan_execute\x20with\x20accounts[\x22'+s['account']+'\x22]\x20(a\x20declared\x20account\x20never\x20falls\x20back\x20')+'to\x20the\x20default\x20signer:\x20the\x20controller\x20identity\x20is\x20the\x20point)');return t;};let n=![],o='halted\x20by\x20earlier\x20failure/blocked\x20publish';const p=b['timeoutMs']!==undefined&&b['timeoutMs']>0x0?Date['now']()+b['timeoutMs']:undefined;let q=![];for(const s of d['steps']){if(n){i['push']({'stepId':s['id'],'status':'blocked','error':o});continue;}if(h['has'](s['id'])){if(k['has'](s['id'])){const t=g['get'](s['id']);if(t===undefined){i['push']({'stepId':s['id'],'status':'failed','error':'resumed\x20create\x20step\x20has\x20no\x20recorded\x20output\x20—\x20pass\x20its\x20created\x20address\x20in\x20previous_outputs'}),n=!![];continue;}i['push']({'stepId':s['id'],'status':'executed','address':t,'error':'resumed\x20from\x20a\x20prior\x20run\x20(adopted,\x20not\x20re-executed)'});continue;}i['push']({'stepId':s['id'],'status':'executed','error':'resumed\x20from\x20a\x20prior\x20run\x20(adopted,\x20not\x20re-executed)'});continue;}if(p!==undefined&&Date['now']()>=p){q=!![],n=!![],o='time\x20budget\x20('+b['timeoutMs']+'ms)\x20exhausted\x20before\x20this\x20step\x20—\x20RESUME,\x20not\x20re-run:\x20send\x20plan_execute\x20again\x20with\x20completed_steps\x20=\x20every\x20stepId\x20whose\x20status\x20is\x20\x27executed\x27,\x20previous_outputs\x20=\x20outputs',i['push']({'stepId':s['id'],'status':'blocked','error':o});continue;}try{if(s['op']==='publish'){const y=s['preflight']['filter'](B=>B['status']==='fail');if(y['length']>0x0){i['push']({'stepId':s['id'],'status':'blocked','error':'preflight\x20failed:\x20'+y['map'](B=>B['check'])['join'](',\x20')+'\x20(refusing\x20to\x20publish\x20—\x20A-2)'});continue;}const z=l(s['target']),A=await b['execute'](k['get'](s['target']['$ref'])??'',{'object':z,'publish':!![]},m(s));if(A['outcome']!=='executed'){i['push']({'stepId':s['id'],'status':'failed',...A['digest']!==undefined?{'digest':A['digest']}:{},'error':A['error']??A['outcome']}),n=!![];continue;}i['push']({'stepId':s['id'],'status':'executed','digest':A['digest'],'address':z});continue;}const u=isRef(s['params'])?l(s['params']):Object['fromEntries'](Object['entries'](s['params'])['map'](([B,C])=>[B,l(C)]));if(s['op']==='create'){const B=adaptCreateData(s,u),C=await b['execute'](s['object'],B,m(s));if(C['outcome']!=='executed'){i['push']({'stepId':s['id'],'status':'failed',...C['digest']!==undefined?{'digest':C['digest']}:{},'error':C['error']??C['outcome']}),n=!![];continue;}const D=matchCreated(C,CREATABLE_OBJECTS[s['object']]);if(D===undefined){i['push']({'stepId':s['id'],'status':'failed',...C['digest']!==undefined?{'digest':C['digest']}:{},'error':'created\x20'+s['object']+'\x20not\x20found\x20in\x20transaction\x20result'}),n=!![];continue;}g['set'](s['id'],D),i['push']({'stepId':s['id'],'status':'executed','digest':C['digest'],'address':D});continue;}const v=l(s['target']),w=k['get'](isRef(s['target'])?s['target']['$ref']:'')??'';if(w===''){i['push']({'stepId':s['id'],'status':'failed','error':'PLAN_TARGET_REF_REQUIRED:\x20step\x20\x27'+s['id']+'\x27\x20target\x20does\x20not\x20trace\x20to\x20a\x20create\x20step\x20in\x20this\x20plan\x20—\x20'+'configure\x20targets\x20must\x20be\x20{\x22$ref\x22:\x20\x22<create_step_id>\x22}\x20(a\x20bare\x20name\x20binds\x20the\x20global\x20mark\x20namespace\x20across\x20runs,\x20W5-05)'}),n=!![];continue;}const x=await b['execute'](w,{'object':v,[s['method']]:adaptConfigureParams(s['method'],u)},m(s));if(x['outcome']!=='executed'){i['push']({'stepId':s['id'],'status':'failed',...x['digest']!==undefined?{'digest':x['digest']}:{},'error':x['error']??x['outcome']}),n=!![];continue;}i['push']({'stepId':s['id'],'status':'executed','digest':x['digest'],'address':v});}catch(E){const F=E?.['digest'];i['push']({'stepId':s['id'],'status':'failed',...typeof F==='string'&&F?{'digest':F}:{},'error':E instanceof Error?E['message']:String(E)}),n=!![];}}const r=await verifyMaterialization(d,g,b);return{'steps':i,'outputs':Object['fromEntries'](g),'completed':i['every'](G=>G['status']==='executed'),'budgetExhausted':q,'preflight':f,'readback':r};}function planAllocatorRows(a){const b=[],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)b['push'](f);}};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 conservationCheck(a){const b=planAllocatorRows(a);if(b['length']===0x0)return[{'name':'allocator_conservation','ok':![],'detail':'no\x20allocator\x20rows\x20(PLAN-ALLOC-01)'}];const c=[];return b['forEach']((d,e)=>{const f=d['track']??'settlement',g=typeof d['guard']==='object'&&d['guard']!==null?String(d['guard']['$ref']??JSON['stringify'](d['guard'])['slice'](0x0,0x28)):String(d['guard']??'?'),h='conservation:'+f+'['+e+']'+(g!=='?'?'('+g+')':''),i=(d['sharing']??[])['map'](l=>l['mode']);if(i['some'](l=>l==='Amount')){c['push']({'name':h,'ok':!![],'detail':'contains\x20Amount-mode\x20row(s)\x20—\x20fixed\x20payouts\x20are\x20not\x20statically\x20verifiable\x20against\x20the\x20escrow\x20total'});return;}let j=0x0;for(const l of d['sharing']??[]){if(l['mode']==='Rate'||l['mode']==='RateGross')j+=Number(l['sharing']??0x0);}const k=i['some'](n=>n==='Surplus');if(j>0x2710)c['push']({'name':h,'ok':![],'detail':'rate\x20sum\x20'+j+'\x20>\x2010000\x20—\x20row\x20pays\x20out\x20MORE\x20than\x20it\x20holds'});else j<0x2710&&!k?c['push']({'name':h,'ok':![],'detail':'rate\x20sum\x20'+j+'\x20<\x2010000\x20and\x20no\x20Surplus\x20row\x20—\x20the\x20remainder\x20has\x20no\x20fund\x20exit'}):c['push']({'name':h,'ok':!![],'detail':k?'rate\x20sum\x20'+j+'\x20+\x20Surplus\x20row\x20absorbs\x20the\x20remainder':'rate\x20sum\x20'+j+'\x20==\x2010000'});}),c;}async function verifyMaterialization(a,b,c){const d=[...conservationCheck(a)];if(c['read']!==undefined)for(const f of createsOf(a,'service')){const g=b['get'](f['id']);if(g===undefined)continue;try{const h=await c['read'](g,'service',c['env']);if(h===undefined||h===null){d['push']({'name':'readback:'+f['id'],'ok':![],'detail':'service\x20'+g+'\x20not\x20readable\x20after\x20creation'});continue;}const i=planAllocatorRows(a)['length'],j=h['order_allocators']?.['allocators']?.['length']??(Array['isArray'](h['order_allocators'])?h['order_allocators']['length']:undefined);j!==undefined&&d['push']({'name':'readback:'+f['id']+':allocators','ok':j>=i,'detail':'on-chain\x20allocator\x20rows\x20'+j+'\x20vs\x20plan\x20'+i});}catch(k){d['push']({'name':'readback:'+f['id'],'ok':![],'detail':k instanceof Error?k['message']:String(k)});}}return{'ok':d['every'](l=>l['ok']),'checks':d};}
@@ -0,0 +1,35 @@
1
+ import type { JsonValue } from "./plan.js";
2
+ import type { AllocatorRowData, CompilableTemplate, CompileBlocker, GuardSpec } from "./compile.js";
3
+ type AfterSalesMode = NonNullable<CompilableTemplate["after_sales_mode"]>;
4
+ type AcceptanceMode = NonNullable<CompilableTemplate["acceptance_mode"]>;
5
+ type InstallmentMode = NonNullable<CompilableTemplate["installment_mode"]>;
6
+ type AffiliateMode = NonNullable<CompilableTemplate["affiliate_mode"]>;
7
+ type CrowdfundingMode = NonNullable<CompilableTemplate["crowdfunding_mode"]>;
8
+ type LogisticsMode = NonNullable<CompilableTemplate["logistics_mode"]>;
9
+ export interface ModeGateContext {
10
+ shape: CompilableTemplate["machine_shape"];
11
+ rows: AllocatorRowData[];
12
+ guardSpecs: GuardSpec[];
13
+ buildNotes: string[];
14
+ feeParams: CompilableTemplate["fee_params"];
15
+ arbitrationMode: CompilableTemplate["arbitration_mode"];
16
+ inputs: Record<string, JsonValue>;
17
+ buildTimeMs?: number;
18
+ }
19
+ export interface ModeGateAxes {
20
+ afterSalesMode: AfterSalesMode;
21
+ acceptanceMode: AcceptanceMode;
22
+ installmentMode: InstallmentMode;
23
+ affiliateMode: AffiliateMode;
24
+ crowdfundingMode: CrowdfundingMode;
25
+ logisticsMode: LogisticsMode;
26
+ }
27
+ export declare function emitModeGates(axes: ModeGateAxes, ctx: ModeGateContext): {
28
+ blockers: CompileBlocker[];
29
+ disclosures: string[];
30
+ };
31
+ export declare function deriveCapabilityModes({ template, inputs }: {
32
+ template: CompilableTemplate;
33
+ inputs: Record<string, JsonValue>;
34
+ }): ModeGateAxes;
35
+ export {};
@@ -0,0 +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};}
@@ -0,0 +1,61 @@
1
+ import { type ParamRow } from "../knowledge/param-tiers.js";
2
+ import { type ParamSchemaRow } from "../knowledge/param-schema.js";
3
+ import { type IndustryTemplate } from "../knowledge/template-loader.js";
4
+ export type ParamStatus = "live" | "inert" | "not-flippable";
5
+ export interface DisclosedParam extends ParamRow {
6
+ status: ParamStatus;
7
+ effect: string[];
8
+ landing: {
9
+ surface: string;
10
+ site: string;
11
+ }[];
12
+ editable: boolean;
13
+ paired_with?: string;
14
+ blocked_by?: string;
15
+ }
16
+ export declare function discloseParams(t: IndustryTemplate): DisclosedParam[];
17
+ export interface DisclosureSummary {
18
+ total: number;
19
+ knobs: number;
20
+ editable: number;
21
+ inertKnobs: string[];
22
+ benchmark: number;
23
+ hidden: number;
24
+ liveKnobs: string[];
25
+ }
26
+ export declare function disclosureSummary(t: IndustryTemplate): DisclosureSummary;
27
+ export type ParamPlaneRow = ParamSchemaRow & {
28
+ status: ParamStatus;
29
+ effect: string[];
30
+ landing: {
31
+ surface: string;
32
+ site: string;
33
+ }[];
34
+ landing_line: string;
35
+ editable: boolean;
36
+ inert_reason?: {
37
+ code: InertCode;
38
+ detail: string;
39
+ };
40
+ blocked_by?: string;
41
+ pair_note?: string;
42
+ };
43
+ export type InertCode = "external_object" | "no_consumer" | "prose_only" | "seat_not_built" | "not_settable" | "hidden";
44
+ export declare function inertReason(r: {
45
+ key: string;
46
+ status: ParamStatus;
47
+ disclosure: string;
48
+ landing: readonly {
49
+ surface: string;
50
+ site: string;
51
+ }[];
52
+ blocked_by?: string;
53
+ }): {
54
+ code: InertCode;
55
+ detail: string;
56
+ } | undefined;
57
+ export declare function landingLine(landing: readonly {
58
+ surface: string;
59
+ site: string;
60
+ }[]): string;
61
+ export declare function paramPlane(t: IndustryTemplate): ParamPlaneRow[];
@@ -0,0 +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.'}:{}};});}
@@ -0,0 +1,21 @@
1
+ export interface PlanStepOutcomeLike {
2
+ stepId: string;
3
+ status: string;
4
+ digest?: string;
5
+ error?: string;
6
+ }
7
+ export interface RepeatedFailure {
8
+ step_id: string;
9
+ consecutive_rounds: number;
10
+ error: string;
11
+ }
12
+ export interface LockedStep {
13
+ stepId: string;
14
+ count: number;
15
+ lastError: string;
16
+ }
17
+ export declare function planLedgerKey(plan: unknown): string;
18
+ export declare function recordPlanRound(planKey: string, steps: readonly PlanStepOutcomeLike[]): void;
19
+ export declare function repeatedPlanFailures(planKey: string): RepeatedFailure[];
20
+ export declare function lockedFreshStep(planKey: string, planStepIds: readonly string[], adopted: ReadonlySet<string>): LockedStep | undefined;
21
+ export declare function clearPlanStep(planKey: string, stepId: string): void;
@@ -0,0 +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);}
@@ -20,6 +20,10 @@ export type ResolvedValue = JsonValue | RefExpr | LateExpr;
20
20
  export type ResolvedParams = Record<string, ResolvedValue>;
21
21
  export declare function isRef(v: ResolvedValue): v is RefExpr;
22
22
  export declare function isLate(v: ResolvedValue): v is LateExpr;
23
+ export declare const P: (o: Record<string, unknown>) => ResolvedParams;
24
+ export declare function ref(stepId: string): RefExpr;
25
+ export declare function collectLateMarks(node: unknown, out?: Set<string>): Set<string>;
26
+ export declare function collectAddressSlotBareNames(plan: Plan, out?: Set<string>): Set<string>;
23
27
  export declare const CREATABLE_OBJECTS: {
24
28
  readonly permission: "Permission";
25
29
  readonly guard: "Guard";
@@ -36,10 +40,10 @@ export declare const CREATABLE_OBJECTS: {
36
40
  };
37
41
  export type CreatableKind = keyof typeof CREATABLE_OBJECTS;
38
42
  export declare const PUBLISHABLE_KINDS: readonly ["service", "machine"];
39
- export type PublishableKind = (typeof PUBLISHABLE_KINDS)[number];
40
43
  interface StepBase {
41
44
  id: StepId;
42
45
  notes?: string;
46
+ account?: string;
43
47
  }
44
48
  export interface CreateStep extends StepBase {
45
49
  op: "create";
@@ -75,16 +79,27 @@ export interface Plan {
75
79
  version: 1;
76
80
  intent: string;
77
81
  templateId?: string;
82
+ template_digest?: string;
78
83
  inputs: Record<string, JsonValue>;
79
84
  steps: PlanStep[];
85
+ external_refs?: string[];
80
86
  pending_guards?: PendingGuard[];
87
+ derived_params?: DerivedParam[];
88
+ }
89
+ export interface DerivedParam {
90
+ param: string;
91
+ from: string;
92
+ input: number;
93
+ value: number;
94
+ at_ms: number;
95
+ note: string;
81
96
  }
82
97
  export declare function refsOf(value: unknown, out?: Set<StepId>): Set<StepId>;
83
98
  export declare function stepById(plan: Plan, id: StepId): PlanStep | undefined;
84
99
  export declare function createsOf(plan: Plan, kind: CreatableKind): CreateStep[];
85
100
  export declare function resolveValue(value: ResolvedValue, outputs: ReadonlyMap<StepId, string>, resolveLate: (q: LateQuery) => string): JsonValue | string;
86
101
  export interface PlanIssue {
87
- 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";
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";
88
103
  step?: StepId;
89
104
  detail: string;
90
105
  }
@@ -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 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;}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)'});}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});}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 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;}
@@ -0,0 +1,94 @@
1
+ export interface CardEvidence {
2
+ source: string;
3
+ detail: string;
4
+ }
5
+ export interface CardAlignment {
6
+ template_id: string;
7
+ industry: string;
8
+ variant: string;
9
+ product_ref: string;
10
+ archetype: "leader" | "challenger";
11
+ phase: 1 | 2 | 3;
12
+ one_liner: string;
13
+ evidence: CardEvidence[];
14
+ }
15
+ export interface CardFundSpeed {
16
+ key: string;
17
+ value: number | string;
18
+ landing_line: string;
19
+ evidence: CardEvidence[];
20
+ }
21
+ export interface CardVsTraditional {
22
+ dimension: string;
23
+ wowok: string;
24
+ traditional: null;
25
+ wowok_evidence: string[];
26
+ }
27
+ export interface CardFeatures {
28
+ flow: string[];
29
+ fund_speed: CardFundSpeed | null;
30
+ model: string[];
31
+ vs_traditional: CardVsTraditional[];
32
+ }
33
+ export interface CardCost {
34
+ platform_fee: {
35
+ bps: number;
36
+ cap_bps: number | null;
37
+ self_platform: string;
38
+ evidence: CardEvidence[];
39
+ };
40
+ gas_objects_estimate: {
41
+ value: number;
42
+ basis: string;
43
+ };
44
+ compensation_fund: {
45
+ policy: "allowed" | "forbidden";
46
+ note: string;
47
+ };
48
+ keeper_dependencies: string[];
49
+ }
50
+ export interface CardParams {
51
+ total: number;
52
+ editable: number;
53
+ live: number;
54
+ groups: Array<{
55
+ group: string;
56
+ tier: number;
57
+ count: number;
58
+ }>;
59
+ full_rows_via: string;
60
+ }
61
+ export interface CardRisks {
62
+ key_risk: string;
63
+ differences: string[];
64
+ user_inputs: string[];
65
+ capability_risks: string[];
66
+ capability_risks_note: string;
67
+ }
68
+ export interface ProductCard {
69
+ alignment: CardAlignment;
70
+ features: CardFeatures;
71
+ cost: CardCost;
72
+ params: CardParams;
73
+ risks: CardRisks;
74
+ templates_version: number;
75
+ }
76
+ export interface ProductCardSummary {
77
+ template_id: string;
78
+ industry: string;
79
+ product_ref: string;
80
+ archetype: string;
81
+ one_liner: string;
82
+ cost_headline: {
83
+ platform_fee_bps: number;
84
+ gas_objects_estimate: number;
85
+ compensation_fund: "allowed" | "forbidden";
86
+ };
87
+ params: {
88
+ total: number;
89
+ editable: number;
90
+ };
91
+ templates_version: number;
92
+ }
93
+ export declare function productCard(templateId: string): ProductCard;
94
+ export declare function productCards(industry?: string): ProductCardSummary[];
@@ -0,0 +1 @@
1
+ import{listBuiltinTemplates,getBuiltinTemplate,BUILTIN_TEMPLATES_VERSION}from'../knowledge/builtin-templates.js';import{paramPlane}from'./param-disclosure.js';const COMPARE_KEYS=[{'key':'platform_commission_bps','dimension':'platform_take_rate','label':'platform\x20commission'},{'key':'merchant_service_fee_bps','dimension':'merchant_service_fee','label':'merchant\x20service\x20fee'},{'key':'incumbent_take_bps','dimension':'incumbent_take_rate_reference','label':'declared\x20incumbent\x20take-rate\x20reference'}],FUND_SPEED_KEYS=['settle_hours','auto_confirm_hours'],SELF_PLATFORM_NOTE='supported\x20—\x20set\x20platform_commission_bps\x20and\x20attach\x20a\x20dedicated\x20platform\x20Entity;\x20the\x20cap\x20(when\x20declared)\x20bounds\x20the\x20take';function bpsToPercent(a){const b=a/0x64;return(Number['isInteger'](b)?b:b['toFixed'](0x2))+'%';}function projectFundSpeed(a,b){const c=FUND_SPEED_KEYS['find'](e=>a['fee_params'][e]!==undefined);if(c===undefined)return null;const d=b['find'](e=>e['key']===c);return{'key':c,'value':a['fee_params'][c],'landing_line':d?.['landing_line']??'declared\x20in\x20fee_params\x20(no\x20landing\x20probe\x20row)','evidence':[{'source':'fee_params','detail':c+'\x20=\x20'+String(a['fee_params'][c])},...d?[{'source':'param_plane','detail':'status='+d['status']+',\x20landing='+d['landing_line']}]:[]]};}function projectVsTraditional(a){const b=[];for(const {key:c,dimension:d,label:e}of COMPARE_KEYS){const f=a['fee_params'][c];if(f===undefined||typeof f!=='number')continue;const g=a['fee_params']['platform_rate_cap_bps'],h=typeof g==='number'&&c==='platform_commission_bps'?'\x20(declared\x20cap\x20'+bpsToPercent(g)+')':'';b['push']({'dimension':d,'wowok':bpsToPercent(f)+'\x20'+e+h,'traditional':null,'wowok_evidence':[c,...typeof g==='number'&&c==='platform_commission_bps'?['platform_rate_cap_bps']:[]]});}return b;}export function productCard(a){const b=getBuiltinTemplate(a);if(!b)throw new Error('template\x20\x27'+a+'\x27\x20is\x20not\x20in\x20the\x20builtin\x20catalog\x20'+('(available:\x20'+listBuiltinTemplates()['map'](e=>e['id'])['join'](',\x20')+')'));const c=paramPlane(b),d=b['machine_shape']['map'](e=>{const f=e['semantic_role']??e['role'];return e['name']+'\x20—\x20'+f;});return{'alignment':{'template_id':b['id'],'industry':b['industry'],'variant':b['variant'],'product_ref':b['product_ref'],'archetype':b['archetype'],'phase':b['phase'],'one_liner':b['product_ref']+'-modeled\x20'+b['variant']+'\x20archetype\x20for\x20'+b['industry']+':\x20'+(b['trust_mechanisms']['length']+'\x20declared\x20trust\x20mechanisms,\x20'+b['guards']['length']+'\x20guard\x20refs,\x20')+(b['machine_shape']['length']+'\x20machine\x20nodes,\x20'+c['filter'](e=>e['editable'])['length']+'/'+c['length']+'\x20params\x20editable.'),'evidence':[{'source':'product_ref','detail':b['product_ref']},{'source':'trust_mechanisms','detail':b['trust_mechanisms']['length']+'\x20entries'},{'source':'guards','detail':b['guards']['length']+'\x20refs'},{'source':'machine_shape','detail':b['machine_shape']['length']+'\x20nodes'}]},'features':{'flow':d,'fund_speed':projectFundSpeed(b,c),'model':[...b['trust_mechanisms']],'vs_traditional':projectVsTraditional(b)},'cost':{'platform_fee':{'bps':typeof b['fee_params']['platform_commission_bps']==='number'?b['fee_params']['platform_commission_bps']:0x0,'cap_bps':typeof b['fee_params']['platform_rate_cap_bps']==='number'?b['fee_params']['platform_rate_cap_bps']:null,'self_platform':SELF_PLATFORM_NOTE,'evidence':[{'source':'fee_params','detail':'platform_commission_bps\x20=\x20'+String(b['fee_params']['platform_commission_bps']??0x0)},...typeof b['fee_params']['platform_rate_cap_bps']==='number'?[{'source':'fee_params','detail':'platform_rate_cap_bps\x20=\x20'+String(b['fee_params']['platform_rate_cap_bps'])}]:[]]},'gas_objects_estimate':{'value':b['machine_shape']['length']+b['guards']['length'],'basis':'template\x20shape\x20(machine\x20nodes\x20+\x20guard\x20refs),\x20pre-compile\x20—\x20the\x20compiled\x20object\x20count\x20is\x20the\x20MID\x20stage\x27s\x20compose_probe\x20verdict'},'compensation_fund':{'policy':b['compensation_fund_policy']==='forbidden'?'forbidden':'allowed','note':b['compensation_fund_policy']==='forbidden'?'DO-NOT-FUND\x20ruling\x20on\x20this\x20template\x27s\x20key_risk\x20—\x20the\x20build\x20guide\x20emits\x20neither\x20the\x20topup\x20step\x20nor\x20the\x20fund-sizing\x20check':'sized\x20at\x20deploy\x20time\x20against\x20the\x20key_risk\x20—\x20never\x20a\x20fixed\x20formula'},'keeper_dependencies':[...b['keeper_dependencies']]},'params':{'total':c['length'],'editable':c['filter'](e=>e['editable'])['length'],'live':c['filter'](e=>e['status']==='live')['length'],'groups':((()=>{const e=new Map();for(const f of c){const g=e['get'](f['group'])??{'tier':f['tier'],'count':0x0};e['set'](f['group'],{'tier':Math['min'](g['tier'],f['tier']),'count':g['count']+0x1});}return[...e['entries']()]['map'](([h,{tier:i,count:j}])=>({'group':h,'tier':i,'count':j}))['sort']((h,i)=>h['tier']-i['tier']||h['group']['localeCompare'](i['group']));})()),'full_rows_via':'industry_pack_operation\x20action=\x27get\x27\x20layer=\x27params\x27\x20template=\x27<id>\x27'},'risks':{'key_risk':b['key_risk'],'differences':[...b['differences']],'user_inputs':[...b['user_inputs']],'capability_risks':[],'capability_risks_note':'union\x20with\x20Lattice\x20Capability.risks\x20lands\x20with\x20the\x20Binding\x20Table\x20(M2+)\x20—\x20this\x20card\x20projects\x20the\x20template\x27s\x20own\x20declared\x20risks\x20only'},'templates_version':BUILTIN_TEMPLATES_VERSION};}export function productCards(a){const b=listBuiltinTemplates(),c=a?b['filter'](d=>d['industry']===a):b;return c['map'](d=>{const e=paramPlane(d);return{'template_id':d['id'],'industry':d['industry'],'product_ref':d['product_ref'],'archetype':d['archetype'],'one_liner':d['product_ref']+'-modeled\x20'+d['variant']+'\x20archetype\x20for\x20'+d['industry']+':\x20'+(d['trust_mechanisms']['length']+'\x20trust\x20mechanisms,\x20'+e['filter'](f=>f['editable'])['length']+'/'+e['length']+'\x20params\x20editable.'),'cost_headline':{'platform_fee_bps':typeof d['fee_params']['platform_commission_bps']==='number'?d['fee_params']['platform_commission_bps']:0x0,'gas_objects_estimate':d['machine_shape']['length']+d['guards']['length'],'compensation_fund':d['compensation_fund_policy']==='forbidden'?'forbidden':'allowed'},'params':{'total':e['length'],'editable':e['filter'](f=>f['editable'])['length']},'templates_version':BUILTIN_TEMPLATES_VERSION};});}