@wowok/agent-mcp 3.2.3 → 3.2.4
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.
- package/dist/chain-semantics/field-capability.js +1 -1
- package/dist/chain-semantics/freeze-map.js +1 -1
- package/dist/chain-semantics/fund-flow.js +1 -1
- package/dist/chain-semantics/guard-verbs.js +1 -1
- package/dist/communication/proof-reuse.d.ts +9 -0
- package/dist/communication/proof-reuse.js +1 -0
- package/dist/evaluation/builtins/graph-service.spec.js +1 -1
- package/dist/evaluation/engine.js +1 -1
- package/dist/experience/realtime-feedback.js +1 -1
- package/dist/graph/onchain/expand.js +1 -1
- package/dist/graph/onchain/exposure.js +1 -1
- package/dist/harness/recover.js +1 -1
- package/dist/knowledge/allocation-ledger.js +1 -1
- package/dist/knowledge/builtin-templates.d.ts +1 -1
- package/dist/knowledge/builtin-templates.js +1 -1
- package/dist/knowledge/getting-started.js +1 -1
- package/dist/knowledge/guard-bindings.js +1 -1
- package/dist/knowledge/guard-design-patterns.d.ts +1 -1
- package/dist/knowledge/guard-design-patterns.js +1 -1
- package/dist/knowledge/guard-ledger.js +1 -1
- package/dist/knowledge/guard-risk.js +1 -1
- package/dist/knowledge/guard-templates.js +1 -1
- package/dist/knowledge/index.js +1 -1
- package/dist/knowledge/industry-registry.js +1 -1
- package/dist/knowledge/jsonrpc-enum.js +1 -1
- package/dist/knowledge/machine-ledger.js +1 -1
- package/dist/knowledge/machine-templates.js +1 -1
- package/dist/knowledge/progress-ledger.js +1 -1
- package/dist/knowledge/scenario-modes.d.ts +1 -0
- package/dist/knowledge/template-loader.d.ts +1 -0
- package/dist/knowledge/template-loader.js +1 -1
- package/dist/knowledge/template-registry.js +1 -1
- package/dist/knowledge/template-scanner.js +1 -1
- package/dist/monitor/MonitorLoop.js +1 -1
- package/dist/participation/radar-core.js +1 -1
- package/dist/playbooks/service-build/business-puzzle.js +1 -1
- package/dist/playbooks/service-build/machine-panorama.js +1 -1
- package/dist/playbooks/service-build/object-panorama.js +1 -1
- package/dist/playbooks/service-build/participation-radar.js +1 -1
- package/dist/playbooks/service-build/relationship-profile.js +1 -1
- package/dist/playbooks/service-build/service-panorama.js +1 -1
- package/dist/playbooks/service-build/service-quote.js +1 -1
- package/dist/playbooks/service-build/service-quote.spec.d.ts +1 -0
- package/dist/playbooks/service-build/service-quote.spec.js +1 -0
- package/dist/review/index.js +1 -1
- package/dist/safety/confirm-gate.js +1 -1
- package/dist/schema/call/arbitration.js +1 -1
- package/dist/schema/call/base.d.ts +4 -0
- package/dist/schema/call/base.js +1 -1
- package/dist/schema/call/bridge.d.ts +1 -0
- package/dist/schema/call/error-codes.d.ts +1 -1
- package/dist/schema/call/error-codes.js +1 -1
- package/dist/schema/call/machine.js +1 -1
- package/dist/schema/call/semantic.js +1 -1
- package/dist/schema/call/service.js +1 -1
- package/dist/schema/common/index.js +1 -1
- package/dist/schema/interaction/index.d.ts +1 -1
- package/dist/schema/local/index.d.ts +10 -0
- package/dist/schema/local/index.js +1 -1
- package/dist/schema/query/bi.d.ts +26 -0
- package/dist/schema/query/bi.js +1 -1
- package/dist/schema/schema-version.js +1 -1
- package/dist/schema-query-impl/index.js +1 -1
- package/dist/schemas/account_operation.output.json +1 -0
- package/dist/schemas/bridge_operation.output.json +1 -0
- package/dist/schemas/index.json +1 -1
- package/dist/schemas/local_cache_operation.output.json +1 -0
- package/dist/schemas/local_history_operation.output.json +1 -0
- package/dist/schemas/local_info_operation.output.json +1 -0
- package/dist/schemas/local_mark_operation.output.json +1 -0
- package/dist/schemas/onchain_operations.output.json +1 -0
- package/dist/schemas/onchain_operations.schema.json +3 -3
- package/dist/schemas/onchain_operations_arbitration.schema.json +1 -1
- package/dist/schemas/onchain_operations_machine.schema.json +1 -1
- package/dist/schemas/onchain_operations_service.schema.json +1 -1
- package/dist/schemas/query_toolkit.output.json +91 -7
- package/dist/tools/handlers/config.js +1 -1
- package/dist/tools/handlers/messenger.js +1 -1
- package/dist/tools/handlers/onchain.js +1 -1
- package/dist/tools/move-fn-index.gen.js +1 -1
- package/dist/tools/wrap.js +1 -1
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
export const FIELD_CAPABILITY={'Order.dispute':{'writeBy':['order.dispute\x20(package,\x20via\
|
|
1
|
+
export const FIELD_CAPABILITY={'Order.dispute':{'writeBy':['order.dispute\x20(package,\x20via\x20the\x20Service-bound\x20dispute\x20filing\x20flow)'],'readBy':['order.dispute\x20count/contains\x20check\x20(MAX_DISPUTE_COUNT\x20gate,\x20order.move:101-102)','guard-query:\x20order.dispute\x20count\x20/\x20has'],'enforcedBy':['filing\x20is\x20allowlist-gated:\x20the\x20Service-bound\x20dispute\x20entry\x20points\x20enforce\x20the\x20arbitrator\x20allowlist\x20(39),\x20the\x20neutrality\x20rule\x20(33)\x20and\x20the\x20order\x20binding\x20(26)\x20BEFORE\x20the\x20case\x20is\x20minted;\x20the\x20Service-blind\x20arbitration-module\x20dispute\x20entries\x20abort\x20E_DISPUTE_DEPRECATED\x20(arbitration\x2010)'],'writeOnly':![],'notes':'A-11\x20CLOSED:\x20filing-time\x20enforcement\x20replaced\x20the\x20old\x20abort-only-at-compensation\x20surface;\x20an\x20off-allowlist\x20venue\x20can\x20no\x20longer\x20be\x20filed\x20against\x20at\x20all.','findings':['A-10','A-11'],'source':{'file':'order.move','line':0x45,'pattern':'dispute:\x20vector<address>'}},'Order.required_info':{'writeBy':['owner-only\x20order\x20field\x20update\x20(order.move:77-80)'],'readBy':['guard-query:\x20order.required_info\x20some\x20/\x20value'],'enforcedBy':[],'writeOnly':!![],'notes':'buy\x20path\x20never\x20reads\x20customer_required/required_info\x20(A-1).\x20Owner-write-only\x20field.','findings':['A-1','A-10'],'source':{'file':'order.move','line':0x49,'pattern':'required_info:\x20Option<address>'}},'Order.claimed_by':{'writeBy':['order.compensate\x20(package,\x20order.move:94-97)'],'readBy':['the\x20not-yet-claimed\x20assert\x20on\x20the\x20compensate/dispute\x20path','guard-query:\x20order.claimed_by\x20some\x20/\x20value'],'enforcedBy':['blocks\x20second\x20compensate/dispute'],'writeOnly':![],'notes':'NOT\x20read\x20by\x20allocation.alloc\x20—\x20refund\x20rail\x20must\x20self-check\x20via\x20refund\x20guard\x20(DUAL-RAIL-01).\x20Deliberate\x20design,\x20order.move:199-220.','findings':['A-3'],'source':{'file':'order.move','line':0x48,'pattern':'claimed_by:\x20Option<address>'}},'Order.time':{'writeBy':['order.new\x20(clock::timestamp_ms\x20at\x20creation)'],'readBy':['guard-query:\x20order.time'],'enforcedBy':['template-declared\x20time\x20anchors'],'writeOnly':![],'notes':'Stable\x20anchor\x20for\x20window\x20guards\x20—\x20unlike\x20Progress.current_time\x20it\x20is\x20path-INDEPENDENT.','source':{'file':'order.move','line':0x4a,'pattern':'time:\x20u64'}},'Service.customer_required':{'writeBy':['service\x20settings\x20(pre-publish)'],'readBy':['guard-query'],'enforcedBy':[],'writeOnly':!![],'notes':'A-1:\x20declared\x20but\x20never\x20enforced\x20on\x20buy.\x20Fix\x20=\x20body-level\x20assert\x20in\x20order\x20creation\x20(protocol\x20upgrade).','findings':['A-1'],'source':{'file':'service.move','line':0xcd,'pattern':'customer_required:\x20vector<String>'}},'Service.repositories':{'writeBy':['service\x20settings'],'readBy':['guard-query:\x20service.repository\x20count\x20/\x20has'],'enforcedBy':[],'writeOnly':!![],'findings':['A-10'],'source':{'file':'service.move','line':0xc8,'pattern':'repositories:\x20vector<address>'}},'Service.rewards':{'writeBy':['service\x20settings'],'readBy':['guard-query'],'enforcedBy':[],'writeOnly':!![],'findings':['A-10'],'source':{'file':'service.move','line':0xd3,'pattern':'rewards:\x20vector<address>'}},'Service.order_allocators':{'writeBy':['service\x20settings\x20(pre-publish\x20replace;\x20post-publish\x20append-only)'],'readBy':['buy\x20path\x20(order-bound\x20Allocation\x20creation)','guard-query'],'enforcedBy':['publish\x20requires\x20non-empty\x20(E_NO_ALLOCATOR,\x20service.move:689-700)'],'writeOnly':![],'notes':'Replacement\x20frozen\x20at\x20publish\x20(E_ALREADY_PUBLISHED\x20on\x20the\x20pre-publish\x20replacement\x20path).\x20Append-only\x20additions\x20remain\x20possible\x20via\x20the\x20allocator-append\x20mutation\x20—\x20prefix\x20allocators\x20+\x20threshold\x20frozen,\x20EALLOCATORS_NOT_EXTENSION=20\x20on\x20violation\x20(J1).\x20Zero\x20allocator\x20rows\x20=\x20no\x20settlement\x20and\x20no\x20refund\x20rail\x20(B-1).','findings':['B-1','A-2'],'source':{'file':'service.move','line':0xd2,'pattern':'order_allocators:\x20Option<Allocators>'}},'Sale.wip':{'writeBy':['service\x20sales\x20mutation'],'readBy':['guard-query'],'enforcedBy':[],'writeOnly':!![],'notes':'wip_hash\x20IS\x20enforced\x20at\x20quote\x20(E_WIP_HASH_NOT_MATCH);\x20wip\x20url\x20itself\x20is\x20not.\x20No\x20on-chain\x20escrow\x20of\x20wip\x20content\x20(A-15).','findings':['A-10','A-15'],'source':{'file':'service.move','line':0x6b,'pattern':'wip:\x20String'}},'Machine.consensus_repositories':{'writeBy':['machine\x20settings\x20(pre-publish)'],'readBy':['guard-query:\x20machine.consensus_repository\x20count\x20/\x20has'],'enforcedBy':[],'writeOnly':!![],'findings':['A-10'],'source':{'file':'machine.move','line':0x13f,'pattern':'consensus_repositories:\x20vector<address>'}},'Machine.nodes':{'writeBy':['machine\x20graph\x20mutation\x20(pre-publish)'],'readBy':['progress\x20node-advance','guard-query'],'enforcedBy':['publish\x20freeze\x20—\x20publishing\x20blocks\x20all\x20later\x20graph\x20changes'],'writeOnly':![],'notes':'Missing\x20edge\x20after\x20publish\x20=\x20permanent\x20brick\x20(A-2);\x20L1\x20must\x20dry-run\x20terminal\x20reachability\x20pre-publish.','findings':['A-2'],'source':{'file':'machine.move','line':0x13e,'pattern':'nodes:\x20ParentLinkedTable<String,\x20vector<NodePair>>'}},'Progress.current_time':{'writeBy':['progress\x20node\x20entry\x20(timestamp\x20refreshed\x20on\x20every\x20advance,\x20progress.move:458)'],'readBy':['guard-query:\x20progress.current_time'],'enforcedBy':['window\x20guards\x20anchored\x20on\x20it'],'writeOnly':![],'notes':'PATH-DEPENDENT:\x20=\x20time\x20of\x20entering\x20CURRENT\x20node.\x20Routing\x20through\x20extra\x20nodes\x20(e.g.\x20reviewed)\x20postpones\x20settlement\x20windows\x20(E-10).\x20TIME-ANCHOR-01\x20checks\x20anchor\x20invariance\x20across\x20paths.','findings':['E-10','D-14'],'source':{'file':'progress.move','line':0x55,'pattern':'current_time:\x20u64'}},'Discount.benchmark':{'writeBy':['service.discounts\x20(creation)'],'readBy':['quote\x20price\x20calc\x20(discount\x20application)'],'enforcedBy':[],'writeOnly':![],'notes':'A-4:\x20below-benchmark\x20coupon\x20does\x20NOT\x20change\x20price\x20but\x20IS\x20still\x20burned\x20(a\x20discounted\x20quote\x20sets\x20discount:some\x20and\x20the\x20buy\x20path\x20destroys\x20the\x20coupon\x20unconditionally).','findings':['A-4'],'source':{'file':'service.move','line':0x85,'pattern':'benchmark:\x20Option<u64>'}},'Allocation.payment_info.for_object':{'writeBy':['buy\x20path\x20(set\x20to\x20the\x20Order\x20anchor\x20at\x20Allocation\x20creation)'],'readBy':['allocation.alloc\x20(ENO_PAYMENT_INFO\x20assert)'],'enforcedBy':['alloc\x20aborts\x20when\x20absent'],'writeOnly':![],'notes':'None\x20+\x20GuardIdentifier\x20recipient\x20=\x20CRITICAL\x20(funds\x20unrouteable)\x20—\x20template_scan\x20R-RECIPIENT-03\x20territory.','source':{'file':'allocation.move','line':0x194,'pattern':'payment_info:\x20Option<PaymentInfo>'}},'Treasury.inflow':{'writeBy':['treasury\x20deposit\x20paths'],'readBy':['guard-query','direct\x20field\x20accessor\x20treasury.inflow'],'enforcedBy':[],'writeOnly':![],'notes':'owner_receive\x20moves\x20value\x20out\x20WITHOUT\x20touching\x20outflow\x20—\x20never\x20re-derive\x20inflow\x20from\x20events\x20(treasury.move:86-88).','source':{'file':'treasury.move','line':0x4f,'pattern':'inflow:\x20u128'}},'Contact.permission':{'writeBy':['contact\x20settings'],'readBy':[],'enforcedBy':[],'writeOnly':![],'notes':'Never\x20consulted\x20anywhere\x20—\x20the\x20contact\x20status-change\x20call\x20(contact.move:33-43)\x20ignores\x20it\x20(A-16).\x20Not\x20part\x20of\x20the\x20A-10\x20guard-query\x20cluster:\x20it\x20has\x20no\x20reader\x20at\x20all.','findings':['A-16'],'source':{'file':'contact.move','line':0x1e,'pattern':'permission:\x20address'}}};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export const FREEZE_MAP={'service_publish':{'object':'Service<T>','trigger':'service.publish','frozen':['order_allocators:\x20full\x20replacement\x20blocked\x20(E_ALREADY_PUBLISHED);\x20append-only\x20additions\x20remain\x20possible\x20(
|
|
1
|
+
export const FREEZE_MAP={'service_publish':{'object':'Service<T>','trigger':'service.publish','frozen':['order_allocators:\x20full\x20replacement\x20blocked\x20(E_ALREADY_PUBLISHED);\x20append-only\x20additions\x20remain\x20possible\x20via\x20the\x20allocator-append\x20mutation\x20(prefix/threshold\x20frozen\x20—\x20EALLOCATORS_NOT_EXTENSION=20)','all\x20settings\x20paths\x20(every\x20mutation\x20aborts\x20once\x20published)'],'preconditions':['order_allocators\x20must\x20be\x20non-empty\x20(E_NO_ALLOCATOR)','compensation_fund\x20>\x200\x20implies\x20arbitrations\x20non-empty'],'consequence':'Wrong/missing\x20allocator\x20or\x20unreachable\x20business-terminal\x20node\x20=\x20permanent\x20brick;\x20the\x20only\x20remedy\x20is\x20a\x20new\x20Service\x20(A-2).','findings':['A-2'],'sources':[{'file':'service.move','line':0x315,'pattern':'E_ALREADY_PUBLISHED'},{'file':'service.move','line':0x2f6,'pattern':'E_NO_ALLOCATOR'}]},'machine_publish':{'object':'Machine','trigger':'machine.publish','frozen':['entire\x20graph:\x20nodes/pairs/forwards\x20(publish\x20blocks\x20every\x20later\x20graph\x20mutation)'],'preconditions':['publishability\x20checks:\x20E_NO_ENTRY_EDGE(19)\x20E_EDGE_SOURCE_NOT_FOUND(20)\x20E_FORWARD_NO_IDENTITY(21)\x20E_UNREACHABLE_THRESHOLD(22)'],'consequence':'A\x20missing\x20paid->closed_cancel\x20edge\x20can\x20never\x20be\x20added\x20later\x20(A-2/F-2).','findings':['A-2'],'sources':[{'file':'machine.move','line':0x146,'pattern':'assert_not_published'},{'file':'machine.move','line':0x33,'pattern':'E_NO_ENTRY_EDGE'}]},'forward_construction':{'object':'machine.Forward','trigger':'machine\x20forward\x20construction,\x20guarded\x20or\x20plain\x20(pre-publish)','frozen':[],'preconditions':['permissionIndex\x20>=\x201000\x20(USER_DEFINED_PERM_INDEX,\x20machine.move:91,109)\x20—\x20template\x20perm\x202/3\x20aborts\x20on\x20chain\x20(B-8)','retained_submission\x20must\x20be\x20a\x20subset\x20of\x20the\x20guard\x27s\x20submissions\x20(E_RETAINED_SUBMISSION_ERROR,\x20machine.move:95)','one\x20of\x20namedOperator\x20|\x20permissionIndex\x20|\x20guard\x20must\x20be\x20set\x20(E_PERMISSION_NOT_DEFINED)'],'consequence':'Bad\x20forwards\x20fail\x20at\x20build\x20time\x20—\x20but\x20only\x20if\x20the\x20tool\x20layer\x20surfaces\x20the\x20abort\x20reason.','findings':['B-8'],'sources':[{'file':'machine.move','line':0x5b,'pattern':'USER_DEFINED_PERM_INDEX'},{'file':'machine.move','line':0x5f,'pattern':'E_RETAINED_SUBMISSION_ERROR'}]},'repository_no_freeze':{'object':'Repository','trigger':'(none\x20—\x20no\x20publish\x20concept)','frozen':[],'preconditions':['policies\x20mutable\x20post-share\x20via\x20the\x20permission-guarded\x20policy\x20add/set/remove/clear\x20calls\x20(repository.move:695-776)'],'consequence':'Write-policy\x20mistakes\x20are\x20repairable\x20—\x20unlike\x20Machine/Service\x20publish.','sources':[{'file':'repository.move','line':0x2b7,'pattern':'public\x20fun\x20policy_add'}]},'discount_creation':{'object':'Discount','trigger':'service.discounts\x20(creation)','frozen':['all\x20fields\x20including\x20transferable\x20and\x20benchmark'],'preconditions':['discount_type\x20in\x20{0\x20rates,\x201\x20minus};\x20rates\x20requires\x20off\x20<=\x2010000','time_end\x20>=\x20time_start\x20(default\x20now)'],'consequence':'Non-transferable\x20coupon\x20can\x20never\x20be\x20re-homed;\x20benchmark\x20errors\x20burn\x20buyer\x20coupons\x20(A-4).','findings':['A-4'],'sources':[{'file':'service.move','line':0x8d,'pattern':'fun\x20discounts'}]}};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export const FUND_FLOWS={'buy_entry':{'kind':'entry','summary':'Buyer\x20pays:\x20coin\x20split\x20->\x20Order\x20+\x20Allocation\x20escrow\x20anchored\x20to\x20the\x20order.','path':['service\x20buy\x20(creates\x20Order,\x20service.move:
|
|
1
|
+
export const FUND_FLOWS={'buy_entry':{'kind':'entry','summary':'Buyer\x20pays:\x20coin\x20split\x20->\x20Order\x20+\x20Allocation\x20escrow\x20anchored\x20to\x20the\x20order.','path':['service\x20buy\x20(creates\x20Order,\x20service.move:459)','order-bound\x20Allocation\x20creation\x20(splits\x20coin,\x20sets\x20payment_info.for_object=order,\x20service.move:408)'],'invariants':['Allocation.balance\x20==\x20order\x20amount\x20at\x20creation','quote.ctx\x20binds\x20quote\x20to\x20tx\x20digest;\x20stock\x20deducted\x20in\x20same\x20tx\x20as\x20buy'],'sources':[{'file':'service.move','line':0x1cb,'pattern':'buy2_imp'},{'file':'service.move','line':0x198,'pattern':'order_allocation'}]},'exit_alloc':{'kind':'exit','summary':'Escrow\x20exit\x201\x20(settlement\x20/\x20refund):\x20guard-matched\x20allocators\x20distribute\x20the\x20pool.','path':['allocation.alloc\x20(allocation.move:408)','per\x20matched\x20allocator:\x20once-slot\x20(OnceKey{guard,\x20allocator\x20index,\x20key})\x20consumed','Payment<T>\x20created;\x20CoinWrapper<T>\x20transferred\x20to\x20each\x20recipient','recipient\x20unwraps\x20via\x20payment.unwrap\x20/\x20order.owner_receive'],'invariants':['balance\x20>=\x20allocators.threshold\x20(EINSUFFICIENT_BALANCE)','balance\x20>\x200\x20(EZERO_DISTRIBUTION)\x20—\x20replay\x20on\x20drained\x20pool\x20aborts','payment_info\x20must\x20be\x20some\x20(ENO_PAYMENT_INFO)','every\x20allocator\x20with\x20matching\x20guard\x20RUNS,\x20in\x20vector\x20order,\x20against\x20the\x20shrinking\x20pool','once-slot\x20per\x20allocator\x20index\x20makes\x20replay\x20of\x20the\x20same\x20guard\x20abort'],'findings':['A-3'],'sources':[{'file':'allocation.move','line':0x198,'pattern':'public\x20fun\x20alloc<T>'},{'file':'allocation.move','line':0x19f,'pattern':'EZERO_DISTRIBUTION'}]},'exit_compensation':{'kind':'exit','summary':'Escrow\x20exit\x202\x20(arbitration\x20indemnity):\x20service\x20compensation_fund\x20pays\x20order\x20owner\x20directly.','path':['service\x20compensation\x20claim\x20(service.move:494;\x20arbitrations\x20whitelist\x20+\x20E33\x20conflict\x20check\x20at\x20:503-505)','arbitration.compensate\x20->\x20order.compensate\x20writes\x20claimed_by','compensation_fund\x20split\x20->\x20public_transfer\x20to\x20order.owner\x20(service.move:512)'],'invariants':['order\x20must\x20not\x20be\x20already\x20claimed\x20(E_ORDER_ALREADY_CLAIMED)','claiming\x20arbitration\x20must\x20be\x20in\x20service.arbitrations\x20whitelist'],'sources':[{'file':'service.move','line':0x1ee,'pattern':'compensation_claim'},{'file':'service.move','line':0x200,'pattern':'order::owner(order)'},{'file':'order.move','line':0x5e,'pattern':'public(package)\x20fun\x20compensate'}]},'dual_rail_fact':{'kind':'fact','summary':'A-3\x20dual\x20rail:\x20alloc\x20never\x20reads\x20claimed_by;\x20compensate\x20never\x20touches\x20the\x20escrow\x20balance.','path':['order.move:213-234\x20(deliberate:\x20refund-of-principal\x20+\x20damages\x20in\x20one\x20case\x20is\x20legal)'],'invariants':['Double-pay\x20prevention\x20is\x20delegated\x20to\x20template\x20convention:\x20refund\x20guard\x20MUST\x20assert\x20claimed_by\x20is\x20none','Tool\x20layer\x20MUST\x20enforce\x20this\x20convention\x20via\x20rule\x20DUAL-RAIL-01\x20—\x20the\x20chain\x20will\x20not'],'findings':['A-3'],'sources':[{'file':'order.move','line':0xd5,'pattern':'claimed_by'}]},'buyer_receive':{'kind':'exit','summary':'Buyer\x20claims\x20inbound\x20funds:\x20order.owner_receive\x20unwraps\x20Payment\x20and\x20transfers\x20coin\x20to\x20owner.','path':['order.owner_receive\x20(order.move:235-237,\x20public_transfer\x20to\x20self.owner)'],'invariants':['only\x20order.owner\x20receives'],'sources':[{'file':'order.move','line':0xeb,'pattern':'owner_receive'}]},'reward_claim':{'kind':'exit','summary':'Reward\x20pool\x20exit:\x20guard+passport\x20gated\x20claim\x20transfers\x20coin\x20to\x20recipient.','path':['reward.claim\x20(reward.move:139)\x20->\x20coin\x20to\x20recipient\x20(reward.move:202)'],'invariants':['passport\x20must\x20satisfy\x20the\x20matched\x20RewardGuard'],'sources':[{'file':'reward.move','line':0x8b,'pattern':'public\x20fun\x20claim<T>'}]},'treasury_flows':{'kind':'internal','summary':'Treasury:\x20deposit/withdraw/guard-driven\x20external\x20flows;\x20owner_receive\x20bypasses\x20outflow\x20counter.','path':['treasury.deposit\x20/\x20withdraw\x20(external_*_guard\x20driven\x20variants)','treasury.owner_receive\x20moves\x20value\x20out\x20WITHOUT\x20touching\x20outflow'],'invariants':['inflow\x20and\x20outflow\x20are\x20u128\x20accumulators;\x20conservation\x20audit\x20must\x20read\x20fields,\x20not\x20events'],'sources':[{'file':'treasury.move','line':0x48,'pattern':'public\x20struct\x20Treasury<phantom\x20T>\x20has\x20key'}]},'discount_burn':{'kind':'fact','summary':'A-4:\x20coupon\x20burned\x20unconditionally\x20at\x20buy,\x20even\x20when\x20benchmark\x20unmet\x20(price\x20unchanged).','path':['the\x20discounted\x20quote\x20sets\x20quote.discount=some\x20unconditionally\x20(service.move:351)','the\x20buy\x20path\x20destroys\x20the\x20coupon\x20unconditionally\x20(service.move:469)'],'invariants':['Fix\x20(protocol\x20upgrade,\x20body-level):\x20the\x20discounted\x20quote\x20returns\x20discount:none\x20below\x20benchmark'],'findings':['A-4'],'sources':[{'file':'service.move','line':0x15f,'pattern':'discount'},{'file':'service.move','line':0x1d5,'pattern':'discount_destroy'}]},'conservation_gap':{'kind':'fact','summary':'No\x20on-chain\x20conservation\x20check:\x20accumulator_*\x20are\x20private\x20and\x20sender==@0x0\x20is\x20unreachable.','path':[],'invariants':['Conservation\x20(sum\x20in\x20==\x20sum\x20out\x20+\x20balances)\x20MUST\x20be\x20audited\x20by\x20the\x20tool\x20layer\x20post-materialization\x20(A-14)'],'findings':['A-14'],'sources':[{'file':'service.move','line':0xcf,'pattern':'compensation_fund:\x20Balance<T>'}]}};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export const GUARD_QUERY_SOURCE='ts-sdk/packages/wowok/src/w/call/guard-ins.ts#GUARDQUERY';export const NATIVE_VALIDATION={'entry':'the\x20native\x20guard-data\x20validation\x20call\x20(guard.move:15),\x20invoked\x20at\x20guard.move:
|
|
1
|
+
export const GUARD_QUERY_SOURCE='ts-sdk/packages/wowok/src/w/call/guard-ins.ts#GUARDQUERY';export const NATIVE_VALIDATION={'entry':'the\x20native\x20guard-data\x20validation\x20call\x20(guard.move:15),\x20invoked\x20at\x20guard.move:271','semantics':['Query\x20on\x20absent\x20object\x20/\x20unset\x20Option\x20/\x20missing\x20collection\x20entry\x20aborts\x20with\x20VM\x20error\x20(e.g.\x20W_FIELD_NOT_FOUND)\x20—\x20the\x20Guard\x20does\x20NOT\x20silently\x20return\x200.\x20Safe\x20failure\x20mode,\x20NOT\x20a\x20null-bypass\x20risk.','Guard.rep\x20flag:\x20false\x20means\x20the\x20queried\x20object\x20or\x20first\x20parameter\x20failed\x20validation.','Empty-value\x20table\x20constant\x20crashes\x20with\x20MovePrimitiveRuntimeError\x20(A-5):\x20vector::borrow(&item.value,0)\x20without\x20length\x20check.'],'sources':[{'file':'guard.move','line':0xf,'pattern':'native\x20fun\x20validate_guard_data'},{'file':'guard.move','line':0x10f,'pattern':'validate_guard_data(&table_data,\x20input)'},{'file':'guard.move','line':0x76,'pattern':'rep:\x20bool'}]};export const PATH_DEPENDENT_TIME_QUERIES=[{'queryPrefix':'progress.current_time','semantics':'Time\x20of\x20ENTERING\x20the\x20current\x20node\x20(progress.move:458),\x20not\x20of\x20any\x20business\x20event.\x20A\x20buyer\x20leaving\x20a\x20review\x20(detour\x20via\x20reviewed\x20node)\x20postpones\x20merchant\x20settlement\x20windows.','findings':['E-10','D-14'],'sources':[{'file':'progress.move','line':0x55,'pattern':'current_time:\x20u64'}]},{'queryPrefix':'progress.session.forward.time','semantics':'Per-forward\x20last-op\x20time\x20inside\x20the\x20current\x20session;\x20also\x20path-local.','findings':['E-10'],'sources':[{'file':'progress.move','line':0x2d,'pattern':'time:\x20u64'}]}];export const STABLE_TIME_QUERIES=[{'queryPrefix':'order.time','semantics':'Order\x20creation\x20time\x20(order.move:112).\x20Never\x20moves.\x20Preferred\x20anchor\x20for\x20settlement/refund\x20windows.'}];export const WRITE_ONLY_QUERY_PREFIXES=[{'queryPrefix':'order.required_info','field':'Order.required_info','findings':['A-1','A-10']},{'queryPrefix':'order.claimed_by','field':'Order.claimed_by','findings':['A-3']},{'queryPrefix':'service.repository','field':'Service.repositories','findings':['A-10']},{'queryPrefix':'service.reward','field':'Service.rewards','findings':['A-10']},{'queryPrefix':'service.sale.wip','field':'Sale.wip','findings':['A-10','A-15']},{'queryPrefix':'machine.consensus_repository','field':'Machine.consensus_repositories','findings':['A-10']}];
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export interface ProofUseRecord {
|
|
2
|
+
kind: "issued" | "consumed";
|
|
3
|
+
service?: string;
|
|
4
|
+
at: number;
|
|
5
|
+
}
|
|
6
|
+
export declare function noteProofIssued(proofAddress: string): void;
|
|
7
|
+
export declare function priorProofConsumptions(proofAddress: string): ProofUseRecord[];
|
|
8
|
+
export declare function recordProofConsumption(proofAddress: string, service?: string): void;
|
|
9
|
+
export declare function resetProofLedger(): void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const ledger=new Map();function keyOf(a){return a['trim']()['toLowerCase']();}export function noteProofIssued(a){if(typeof a!=='string'||a['length']===0x0)return;const b=keyOf(a),c=ledger['get'](b)??[];c['push']({'kind':'issued','at':Date['now']()}),ledger['set'](b,c);}export function priorProofConsumptions(a){if(typeof a!=='string'||!/^0x[0-9a-fA-F]{1,64}$/['test'](a['trim']()))return[];return(ledger['get'](keyOf(a))??[])['filter'](b=>b['kind']==='consumed');}export function recordProofConsumption(a,b){if(typeof a!=='string'||!/^0x[0-9a-fA-F]{1,64}$/['test'](a['trim']()))return;const c=keyOf(a),d=ledger['get'](c)??[];d['push']({'kind':'consumed','service':b,'at':Date['now']()}),ledger['set'](c,d);}export function resetProofLedger(){ledger['clear']();}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{describe,expect,it}from'vitest';import{ENTRYPOINT}from'@wowok/wowok';import{FakeDataPlane}from'../../graph/onchain/dataplane.js';import{expandTopology}from'../../graph/onchain/expand.js';import{FULL,GAP,fullServiceState,gapServiceState,truncatedServiceState}from'../../graph/onchain/fixtures.js';import{buildViewport}from'../../graph/onchain/viewport.js';import{runAnalyzers}from'../../graph/onchain/analyze.js';import{EVALUATION_SERVICE_INTENTS,resolveExpansionStrategy,withEvaluationBundle}from'../../graph/onchain/strategy.js';import{projectEvaluationFacts as
|
|
1
|
+
import{describe,expect,it}from'vitest';import{ENTRYPOINT}from'@wowok/wowok';import{FakeDataPlane}from'../../graph/onchain/dataplane.js';import{expandTopology}from'../../graph/onchain/expand.js';import{FULL,GAP,fullServiceState,gapServiceState,truncatedServiceState}from'../../graph/onchain/fixtures.js';import{buildViewport}from'../../graph/onchain/viewport.js';import{runAnalyzers}from'../../graph/onchain/analyze.js';import{EVALUATION_SERVICE_INTENTS,resolveExpansionStrategy,withEvaluationBundle}from'../../graph/onchain/strategy.js';import{projectEvaluationFacts as a35a}from'../../graph/onchain/facts.js';import{evaluateGraphServiceFacts,GRAPH_RULE_INPUT_FACTS,registerGraphServiceEvaluations}from'./graph-service.js';async function evalState(a,b){registerGraphServiceEvaluations();const c=withEvaluationBundle(resolveExpansionStrategy({'intents':[...EVALUATION_SERVICE_INTENTS]})),d=await expandTopology(new FakeDataPlane(a),{'network':ENTRYPOINT['Mainnet'],'seed':b,'edges':c['edges'],'budget':c['budget']}),e=buildViewport(d,b,'neutral'),f=a35a(e,b,runAnalyzers(e));return{'projected':f,'r':await evaluateGraphServiceFacts(f)};}const scoreOf=(a,b,c)=>a[b]['breakdown']['find'](d=>d['rule_id']===c);describe('graph\x20service\x20evaluation\x20—\x20fully\x20hooked\x20shop\x20(TR-14.1)',()=>{it('scores\x20all\x20nine\x20dimensions\x20from\x20material\x20facts\x20with\x20no\x20default-low\x20deductions',async()=>{const {r:a}=await evalState(fullServiceState(),FULL['svc']);expect(a['unverified'])['toEqual']([]),expect(a['completeness'])['toBe'](0x64);const c=scoreOf(a,'trust','trust_arbitration');expect(c['score'])['toBe'](0x64),expect(c['matched'])['toEqual'](expect['arrayContaining'](['arbitrator\x20roster\x20configured','arbitration\x20fee\x20funded','arbitration\x20active'])),expect(c['reason'])['toContain']('Arbitration\x2020/20'),expect(scoreOf(a,'trust','trust_reviews')['score'])['toBe'](0x28),expect(scoreOf(a,'trust','trust_fulfillment')['score'])['toBe'](0x19);const d=scoreOf(a,'trust','trust_fund_safety');expect(d['score'])['toBe'](0x0),expect(d['mismatched'])['toContain']('compensation\x20fund\x20below\x20the\x20statutory\x203x\x20exposure\x20ceiling'),expect(scoreOf(a,'trust','trust_transparency')['score'])['toBe'](0x64),expect(a['trust']['total'])['toBe'](0x31);const e=scoreOf(a,'risk','risk_fund');expect(e['score'])['toBeLessThan'](0x64),expect(e['mismatched'])['toContain']('Payout\x20exposure:\x20compensation\x20fund\x20is\x20below\x20the\x203x\x20ceiling\x20of\x20windowed\x20order\x20amounts'),expect(e['mismatched']?.['some'](h=>h['startsWith']('R2:')))['toBe'](![]),expect(e['finding_refs']?.['map'](h=>h['id']))['toContain']('R2:'+FULL['svc']['toLowerCase']());const f=scoreOf(a,'risk','risk_trust');expect(f['score'])['toBeLessThan'](0x64),expect(f['mismatched']?.['some'](h=>h['startsWith']('R1:')))['toBe'](![]),expect(f['mismatched']?.['length'])['toBeGreaterThan'](0x0),expect(f['finding_refs']?.['some'](h=>h['id']['startsWith']('R1:')))['toBe'](!![]);for(const h of[...a['trust']['breakdown'],...a['risk']['breakdown']]){for(const i of h['mismatched']??[])expect(i)['not']['toContain']('::node::');}expect(scoreOf(a,'risk','risk_workflow')['score'])['toBe'](0x64),expect(scoreOf(a,'risk','risk_behavior')['score'])['toBe'](0x64);for(const j of[...a['trust']['breakdown'],...a['risk']['breakdown']]){const k=(j['reason']??'')['toLowerCase']();expect(k)['not']['toContain']('no\x20data'),expect(k)['not']['toContain']('default\x20low');}const g=a['trust']['trace']['filter'](l=>l['kind']==='rule'&&l['detail']['startsWith']('score='));expect(g['map'](l=>l['id']))['toEqual'](expect['arrayContaining'](Object['keys'](GRAPH_RULE_INPUT_FACTS)['filter'](l=>l['startsWith']('trust_'))));}),it('keeps\x20the\x20injection\x20+\x20requirement\x20mechanisms\x20working',async()=>{const {projected:a}=await evalState(fullServiceState(),FULL['svc']),b=await evaluateGraphServiceFacts(a,{'overrides':{'rules':{'trust_arbitration':{'weight':0x28}}}});expect(b['trust']['total'])['toBe'](0x3a);const c=await evaluateGraphServiceFacts(a,{'requirements':[{'rule_id':'trust_fund_safety','condition':'require'}]});expect(c['trust']['blocked'])['toBe'](!![]),expect(c['trust']['red_flags']['length'])['toBeGreaterThan'](0x0);});}),describe('graph\x20service\x20evaluation\x20—\x20configured-empty\x20shell\x20(TR-14.1)',()=>{it('scores\x20verified\x20absence\x20as\x20a\x20configured\x20fact\x20and\x20excludes\x20only\x20the\x20gap\x20dimension',async()=>{const {r:a}=await evalState(gapServiceState(),GAP['svc']),b=scoreOf(a,'trust','trust_arbitration');expect(b['score'])['toBe'](0x0),expect(b['reason'])['toContain']('verified\x20absence'),expect(scoreOf(a,'trust','trust_reviews')['score'])['toBe'](0x32),expect(a['unverified'])['toEqual'](['risk_workflow']),expect(scoreOf(a,'risk','risk_workflow'))['toBeUndefined'](),expect(a['risk']['unverified'])['toEqual'](['risk_workflow']),expect(a['trust']['unverified'])['toEqual'](['risk_workflow']);const c=a['risk']['trace']['find'](d=>d['kind']==='rule'&&d['id']==='risk_workflow');expect(c?.['detail'])['toContain']('not\x20applicable'),expect(scoreOf(a,'trust','trust_transparency')['score'])['toBe'](0x28),expect(scoreOf(a,'trust','trust_fund_safety')['score'])['toBe'](0x0);});}),describe('graph\x20service\x20evaluation\x20—\x20truncated\x20order\x20window\x20(TR-14.1)',()=>{it('excludes\x20the\x20unverifiable\x20dimensions\x20and\x20renormalizes\x20the\x20weighted\x20total',async()=>{const {r:a}=await evalState(truncatedServiceState(),FULL['svc']);expect(a['unverified'])['toEqual'](expect['arrayContaining'](['trust_fulfillment','trust_fund_safety','risk_fund','risk_behavior'])),expect(scoreOf(a,'trust','trust_fulfillment'))['toBeUndefined'](),expect(scoreOf(a,'trust','trust_fund_safety'))['toBeUndefined'](),expect(scoreOf(a,'risk','risk_fund'))['toBeUndefined'](),expect(scoreOf(a,'risk','risk_behavior'))['toBeUndefined'](),expect(a['trust']['total'])['toBe'](0x44);for(const b of['trust_fulfillment','trust_fund_safety']){expect(a['trust']['trace']['find'](c=>c['kind']==='rule'&&c['id']===b)?.['detail'])['toContain']('not\x20applicable');}for(const c of['risk_fund','risk_behavior']){expect(a['risk']['trace']['find'](d=>d['kind']==='rule'&&d['id']===c)?.['detail'])['toContain']('not\x20applicable');}});}),describe('graph\x20service\x20evaluation\x20—\x20scoring\x20report\x20(TR-14.2)',()=>{it('renders\x20a\x20per-dimension\x20report\x20with\x20score,\x20weight,\x20state,\x20confidence\x20and\x20evidence',async()=>{const {projected:a,r:c}=await evalState(fullServiceState(),FULL['svc']),d=new Map(a['facts']['map'](g=>[g['key'],g])),e=[];for(const g of['trust','risk']){const h=c[g];e['push'](g['toUpperCase']()+'\x20'+h['total']+'/100\x20('+h['level']+')\x20—\x20'+h['summary']);for(const i of h['breakdown']){const j=GRAPH_RULE_INPUT_FACTS[i['rule_id']]??[],k=j['map'](o=>o+':state='+(d['get'](o)?.['state']??'missing')),l=j['map'](o=>d['get'](o)?.['provenance']['confidence']??'missing'),n=j['map'](o=>d['get'](o)?.['evidence']??'missing')['join']('\x20');e['push'](i['rule_id']+':\x20score='+i['score']+'\x20weight='+i['weight']+'\x20'+k['join'](',')+'\x20confidence='+[...new Set(l)]['join']('+')+'\x20evidence=\x22'+n+'\x22');}}expect(e)['toHaveLength'](0xb);const f=e['filter'](o=>o['includes']('score='));expect(f)['toHaveLength'](0x9);for(const o of f){expect(o)['toMatch'](/weight=\d+/),expect(o)['toContain']('state=present'),expect(o)['toMatch'](/confidence=(exact|bounded|windowed|derived)/);const p=o['match'](/evidence="(.*)"/);expect(p,o)['not']['toBeNull'](),expect(p[0x1]['length'],o)['toBeGreaterThan'](0x0);}expect(c['trust']['summary'])['toContain']('weakest\x20Fund\x20safety'),expect(c['trust']['summary'])['not']['toContain']('trust_fund_safety'),expect(c['trust']['summary'])['toMatch'](/grade: (strong|fair|weak)/),expect(c['trust']['summary'])['toContain']('Compensation\x20fund');});});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{REQUIREMENT_PASS_THRESHOLD,effectiveWeight,isDataSourceEnabled,isRuleEnabled,normalizeInjection}from'./user-injection.js';import{levelFromScore as
|
|
1
|
+
import{REQUIREMENT_PASS_THRESHOLD,effectiveWeight,isDataSourceEnabled,isRuleEnabled,normalizeInjection}from'./user-injection.js';import{levelFromScore as a41a}from'./standards.js';export function levelFromScore(a){return a41a(a);}function appliesTo(a,b){if(!a||a['length']===0x0)return!![];return a['includes'](b);}export class EvaluationEngine{static ['instance']=null;['dataSources']=new Map();['rules']=new Map();static['Instance'](){return!EvaluationEngine['instance']&&(EvaluationEngine['instance']=new EvaluationEngine()),EvaluationEngine['instance'];}['registerDataSource'](a){if(!a['id']||this['dataSources']['has'](a['id']))return![];return this['dataSources']['set'](a['id'],a),!![];}['unregisterDataSource'](a){return this['dataSources']['delete'](a);}['registerRule'](a){if(!a['id']||this['rules']['has'](a['id']))return![];return this['rules']['set'](a['id'],a),!![];}['unregisterRule'](a){return this['rules']['delete'](a);}['getRule'](a){return this['rules']['get'](a);}['listRules'](){return Array['from'](this['rules']['values']());}['getDataSource'](a){return this['dataSources']['get'](a);}['listDataSources'](){return Array['from'](this['dataSources']['values']());}async['evaluate'](a,b,c){const d=normalizeInjection(c),e={'evaluation_id':a,'entities':b,'facts':{},'injection':d,'now':Date['now']()},f=[],g=Array['from'](this['dataSources']['values']())['filter'](m=>appliesTo(m['evaluation_ids'],a))['sort']((m,n)=>(m['priority']??0x0)-(n['priority']??0x0));for(const m of g){if(!isDataSourceEnabled(m['id'],d)){f['push']({'kind':'override','id':m['id'],'detail':'data\x20source\x20disabled\x20by\x20user\x20override'});continue;}if(m['isEnabled']&&!m['isEnabled'](e))continue;const n=await m['extract'](e);Object['assign'](e['facts'],n),f['push']({'kind':'data_source','id':m['id'],'detail':'extracted\x20'+Object['keys'](n)['length']+'\x20fact(s)'});}const h=[],i=[];for(const o of this['rules']['values']()){if(!appliesTo(o['evaluation_ids'],a))continue;if(!isRuleEnabled(o['id'],d)){f['push']({'kind':'override','id':o['id'],'detail':'rule\x20disabled\x20by\x20user\x20override'});continue;}if(o['isEnabled']&&!o['isEnabled'](e))continue;const p=o['evaluate'](e);if(!p){f['push']({'kind':'rule','id':o['id'],'detail':'not\x20applicable\x20—\x20excluded\x20from\x20weighted\x20aggregation'});continue;}const q=effectiveWeight(o,d);h['push']({'rule_id':o['id'],'dimension':o['dimension'],'score':p['score'],'weight':q,'weight_source':q!==o['weight']?'override':'default','reason':p['reason'],'matched':p['matched'],'mismatched':p['mismatched'],'finding_refs':p['finding_refs'],'red_flag':p['red_flag']}),p['red_flag']&&i['push'](p['reason']??o['id']+'\x20triggered\x20a\x20hard\x20block'),f['push']({'kind':'rule','id':o['id'],'detail':'score='+p['score']+'\x20weight='+q});}const j=aggregateScore(h);let k=i['length']>0x0;for(const r of d['requirements']??[]){const s=h['find'](t=>t['rule_id']===r['rule_id']);if(r['condition']==='require')(!s||s['score']<REQUIREMENT_PASS_THRESHOLD||s['red_flag'])&&(k=!![],i['push'](r['note']??'Requirement\x20requires\x20rule\x20\x27'+r['rule_id']+'\x27\x20to\x20pass'));else r['condition']==='forbid'&&(s&&s['red_flag']&&(k=!![],i['push'](r['note']??'Requirement\x20forbids\x20rule\x20\x27'+r['rule_id']+'\x27\x20from\x20triggering')));}const l=e['facts']['summary']??buildSummary(a,j,h,i,k);return{'evaluation_id':a,'total':j,'level':levelFromScore(j),'breakdown':h,'red_flags':i,'blocked':k,'trace':f,'summary':l,'criterionScores':e['facts']['criterionScores'],'findings':e['facts']['findings'],'strengths':e['facts']['strengths'],'needsLlm':e['facts']['needsLlm'],'llmPrompt':e['facts']['llmPrompt']};}}function aggregateScore(a){if(a['length']===0x0)return 0x0;let c=0x0,d=0x0;for(const e of a){c+=e['score']*e['weight'],d+=e['weight'];}if(d<=0x0)return 0x0;return clamp(Math['round'](c/d),0x0,0x64);}function clamp(a,b,c){return Math['max'](b,Math['min'](c,a));}function buildSummary(a,b,c,d,e){const f=['Evaluation\x20\x27'+a+'\x27:\x20score\x20'+b+'/100'];return e?f['push']('BLOCKED\x20('+d['length']+'\x20red\x20flag(s))'):f['push'](c['length']+'\x20rule(s)\x20evaluated'),f['join']('\x20—\x20');}export function getEvaluationEngine(){return EvaluationEngine['Instance']();}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{distillIntent,extractSignals}from'./intent-distill.js';import{getProfile,updateFromOperation}from'./user-profile.js';import{findMatches,recordSignature}from'./experience-reuse.js';import{EXPERIENCE_LAYER_VERSION}from'./types.js';import{isEnabled as
|
|
1
|
+
import{distillIntent,extractSignals}from'./intent-distill.js';import{getProfile,updateFromOperation}from'./user-profile.js';import{findMatches,recordSignature}from'./experience-reuse.js';import{EXPERIENCE_LAYER_VERSION}from'./types.js';import{isEnabled as a63a}from'../config/index.js';import{recordIndustrySignal}from'../knowledge/flywheel-loop.js';export{EXPERIENCE_LAYER_VERSION};export function getExperienceFeedback(a,b,c){try{const d=distillIntent(a,b,c),e=findMatches(d['primary_intent'],a,b,0x3);if(e['length']===0x0)return undefined;const f=e[0x0],g=getProfile();return formatFeedback(f,e,d['scenario'],g);}catch{return undefined;}}export function recordOperationOutcome(a,b,c,d,e,f=[]){try{const g=distillIntent(a,b,c),h=extractSignals(a,b);recordSignature({'intent':g['primary_intent'],'scenario':g['scenario'],'signals':h,'timestamp':Date['now'](),'outcome':d,'error_code':e}),updateFromOperation(g['primary_intent'],g['scenario'],d,e,f);try{if(a63a('industry_evolution')){const i=typeof b?.['industry']==='string'&&b['industry']['trim']()?b['industry']['trim']():undefined;if(i){const j=d==='success'?{'success':!![]}:{'success':![],'error_code':e};recordIndustrySignal(i,{'type':a,'data':b},j);}}}catch{}}catch{}}function formatFeedback(a,b,c,d){const e=buildAdviceText(a,b,d),f=collectAvoidList(b,d),g=a['relevance'],h=c??a['signature']['scenario'],i={};if(e)i['advice']=e;if(f['length']>0x0)i['avoid']=f;if(g>0x0)i['relevance']=Math['round'](g*0x64)/0x64;if(h)i['matched_scenario']=h;return i;}function buildAdviceText(a,b,c){const d=[];if(a['signature']['outcome']==='success')d['push']('Historically,\x20'+a['signature']['intent']+'\x20operation\x20succeeded');else a['signature']['outcome']==='failed'&&d['push']('Historically,\x20'+a['signature']['intent']+'\x20operation\x20failed\x20('+(a['signature']['error_code']??'unknown\x20error')+'),\x20pay\x20special\x20attention\x20to\x20parameters');return c['expertise_tier']==='novice'&&b['length']>0x0&&d['push']('It\x20is\x20recommended\x20to\x20carefully\x20check\x20parameters\x20before\x20executing'),d['join'](';\x20')||a['advice'];}function collectAvoidList(b,c){const d=new Set();for(const e of b){for(const f of e['avoid']){d['add'](f);}}for(const g of c['frequent_pitfalls']){d['add']('You\x20often\x20make\x20mistakes\x20at\x20the\x20'+g+'\x20step,\x20please\x20be\x20especially\x20careful');}return Array['from'](d)['slice'](0x0,0x5);}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{EDGE_SCHEMAS,EDGE_SCHEMA_BY_ID}from'./edge-schema.js';import{extractCoinType,extractEventRefs,extractObjectEdges,extractReverseRefs,extractTableRefs,inferObjectType,REVERSE_GROUP_WILDCARD}from'./extract.js';import{mergeBudget}from'./dataplane.js';import{deriveOrderCompletion,terminalNamesOfEdges}from'./order-status.js';import{LINKER_RING_LIMIT as a95a}from'./sdk-batch.js';import{wowAddressKind}from'@wowok/wowok';function readStats(a){const b=a;if(b['stats'])return{'batches':b['stats']['batches'],'byChannel':{...b['stats']['byChannel']},'dedupHits':b['stats']['dedupHits']};if(b['batches'])return{'batches':Object['values'](b['batches'])['reduce']((c,d)=>c+d,0x0),'byChannel':{...b['batches']},'dedupHits':b['dedupHits']??0x0};return{'batches':0x0,'byChannel':{'objects':0x0,'keyedFields':0x0,'tables':0x0,'events':0x0},'dedupHits':0x0};}function isEoa(a){return wowAddressKind(a)==='user';}function isWfNodeId(a){return a['includes']('::node::');}class Gate{['wl'];constructor(a){this['wl']=a;}['allows'](a,b){if(this['wl']['deny']?.['includes'](a['id']))return![];const c=this['wl']['familyDepths']?.[a['family']];if(c!==undefined&&b>=c)return![];if(this['wl']['schemas'])return this['wl']['schemas']['includes'](a['id']);if(this['wl']['families']&&!this['wl']['families']['includes'](a['family']))return![];return!![];}['allowsTable'](a,b){if(a['read']['kind']!=='table')return![];if(this['wl']['deny']?.['includes'](a['id']))return![];const c=this['wl']['familyDepths']?.[a['family']];if(c!==undefined&&b>=c)return![];if(this['wl']['families']&&!this['wl']['families']['includes'](a['family']))return![];return!!this['wl']['tableEdges']?.['includes'](a['id']);}['allowsEvent'](a,b){if(a['read']['kind']!=='event')return![];if(this['wl']['deny']?.['includes'](a['id']))return![];const c=this['wl']['familyDepths']?.[a['family']];if(c!==undefined&&b>=c)return![];if(this['wl']['families']&&!this['wl']['families']['includes'](a['family']))return![];return!!this['wl']['eventEdges']?.['includes'](a['id']);}['effectiveMaxHops'](a){const b=a['maxHops'],c=this['wl']['schemaHops']?.[a['id']];if(b===undefined)return c;if(c===undefined)return b;return Math['min'](b,c);}}class GraphBuilder{['graph'];['edgeIds']=new Set();['budget'];['exhausted']={};constructor(a,b,c){this['budget']=c,this['graph']={'network':a,'seed':b,'builtAt':Date['now'](),'nodes':new Map(),'edges':[],'out':new Map(),'inc':new Map(),'gaps':[],'truncations':[],'rpcReport':{'batches':0x0,'byChannel':{'objects':0x0,'keyedFields':0x0,'tables':0x0,'events':0x0},'dedupHits':0x0},'budgetExhausted':{}};}['addSeed'](a){const b=inferObjectType(a),c={'id':a,'kind':isWfNodeId(a)?'wfnode':isEoa(a)?'eoa':'object','objectType':b??undefined,'state':'seed','origins':[],'depth':0x0};return this['graph']['nodes']['set'](a,c),c;}['addNode'](a,b,c){const d=this['graph']['nodes']['get'](a);if(d){if(c)d['origins']['push']({'via':c['schema'],'from':c['from'],'depth':b});return d;}if(this['graph']['nodes']['size']>=this['budget']['maxNodes'])return this['exhausted']['nodes']=!![],undefined;const e=isWfNodeId(a),f=e?undefined:inferObjectType(a),g={'id':a,'kind':e?'wfnode':isEoa(a)?'eoa':'object','objectType':f??undefined,'state':e?'stub':'seed','origins':c?[{'via':c['schema'],'from':c['from'],'depth':b}]:[],'depth':b};return this['graph']['nodes']['set'](a,g),g;}['addEdge'](a,b,c,d,e){const f=c['to'],g=c['key']?'|'+c['key']:'',h=a['id']+'|'+b+'→'+f+g;if(this['edgeIds']['has'](h))return;this['edgeIds']['add'](h);const i={'id':h,'schema':a['id'],'family':a['family'],'from':b,'to':f,'retention':a['retention'],'observedAt':d,'payload':c['payload'],'truncated':e||a['retention']==='bounded_window','key':c['key']};this['graph']['edges']['push'](i),pushMap(this['graph']['out'],b,i),pushMap(this['graph']['inc'],f,i);}['markTruncation'](a){this['graph']['truncations']['push'](a);}['finalize'](a){return this['graph']['rpcReport']=readStats(a),this['graph']['budgetExhausted']=this['exhausted'],this['graph'];}}function pushMap(a,b,c){const d=a['get'](b);if(d)d['push'](c);else a['set'](b,[c]);}export async function expandTopology(a,c){const d=c['seed']['toLowerCase'](),e=mergeBudget(c['budget']),f=new Gate(c['edges']??{}),h=new GraphBuilder(c['network'],d,e);h['addSeed'](d);const i=new Set(),j=new Set(),l=new Set(),m=new Map(),n=new Set();let o=new Set([d]);for(let p=0x0;p<=e['maxDepth'];p++){if(o['size']===0x0)break;if(h['exhausted']['nodes'])break;const q=Date['now'](),r=new Map(),t=(D,E)=>{const F=r['get'](D);if(F)return F;const G=new Map();r['set'](D,G);const H=h['graph']['nodes']['get'](D);if(H&&H['origins']['length']>0x0&&!E['has'](D)){E['add'](D);for(const I of H['origins']){if(!I['via']||!I['from']||E['has'](I['from']))continue;const J=t(I['from'],E);for(const [L,M]of J){if(M<(G['get'](L)??Infinity))G['set'](L,M);}const K=(J['get'](I['via'])??0x0)+0x1;if(K<(G['get'](I['via'])??Infinity))G['set'](I['via'],K);}E['delete'](D);}return G;},u=[...o]['filter'](D=>{const E=h['graph']['nodes']['get'](D);return E['kind']==='object'&&(E['state']==='seed'||E['state']==='stub')&&!i['has'](D);}),v=new Set();if(u['length']>0x0){const D=await a['getObjects'](u);if(readStats(a)['batches']>=e['maxRpcs'])h['exhausted']['rpcs']=!![];for(const E of u){const F=h['graph']['nodes']['get'](E),G=lookupMapLower(D,E);i['add'](E);if(!G){F['state']='error',F['error']='not_found_or_failed',h['graph']['gaps']['push'](E);continue;}F['state']='fetched',F['raw']=G,F['objectType']=String(G['type']??F['objectType']??inferObjectType(E)??''),F['coinType']=extractCoinType(G['type_raw']),v['add'](E);}}const w=[];for(const H of v){const I=h['graph']['nodes']['get'](H);if(!I['objectType']||!I['raw'])continue;for(const J of extractObjectEdges(I['objectType'],I['raw'])){const K=EDGE_SCHEMA_BY_ID['get'](J['schemaId']);if(!K||!f['allows'](K,p))continue;w['push']({'schema':K,'sourceId':H,'refs':J['refs'],'observed':J['refs']['length']});}}const x=[...v]['filter'](L=>{const M=h['graph']['nodes']['get'](L);return EDGE_SCHEMAS['some'](N=>N['source']===M['objectType']&&N['read']['kind']==='table');});for(const L of x){const M=h['graph']['nodes']['get'](L),N=EDGE_SCHEMAS['filter'](P=>P['source']===M['objectType']&&P['read']['kind']==='table'&&f['allowsTable'](P,p)),O=new Map();for(const P of N){const Q=P['read']['rowType'],R=O['get'](Q)??[];R['push'](P),O['set'](Q,R);}for(const [S,T]of O){const U=L+'|'+S;if(l['has'](U))continue;l['add'](U);const V=Math['max'](...T['map'](a0=>e['perKindCaps'][a0['id']]??e['maxFanoutPerNode']));let W,X=![];try{const a0=await a['getTable'](L,{'maxItems':V});if(readStats(a)['batches']>=e['maxRpcs'])h['exhausted']['rpcs']=!![];W=a0['items'],X=a0['truncated'];}catch{h['graph']['gaps']['push'](L+'#'+S);continue;}const Y=new Set(T['map'](a1=>a1['id'])),Z=extractTableRefs(S,L,W)['filter'](a1=>{const a2=EDGE_SCHEMA_BY_ID['get'](a1['schemaId']);return a2['read']['kind']==='derived'||Y['has'](a1['schemaId']);});for(const a1 of Z){const a2=EDGE_SCHEMA_BY_ID['get'](a1['schemaId']);let a3=a1['refs'];a2['family']==='M'&&M['coinType']&&(a3=a3['map'](a4=>({...a4,'payload':{'coinType':M['coinType'],...a4['payload']}}))),w['push']({'schema':a2,'sourceId':L,'refs':a3,'observed':a3['length']});}X&&h['markTruncation']({'nodeId':L,'schema':T[0x0]['id'],'observed':W['length'],'limit':V,'reason':'table_page'});}}const y=[...o]['filter'](a4=>{const a5=h['graph']['nodes']['get'](a4);return a5['kind']!=='wfnode'&&(a5['kind']==='eoa'||a5['state']==='fetched');}),z=new Map(),A=new Map();for(const a4 of y){const a5=h['graph']['nodes']['get'](a4);for(const a6 of EDGE_SCHEMAS){if(a6['read']['kind']!=='reverse'||!f['allows'](a6,p))continue;if(!sourceMatches(a6['source'],a5))continue;const a7=a6['read']['parent'],a8=a4+'|'+a7;if(j['has'](a8))continue;if(!z['has'](a7))z['set'](a7,[]);z['get'](a7)['push'](a4);const a9=a4+'|'+a7+'|schema',aa=A['get'](a9)??[];aa['push'](a6),A['set'](a9,aa);}}for(const [ab,ac]of z){for(const ae of ac)j['add'](ae+'|'+ab);let ad=new Map();try{ad=await a['getKeyedFields'](ab,ac);if(readStats(a)['batches']>=e['maxRpcs'])h['exhausted']['rpcs']=!![];}catch{h['graph']['gaps']['push']('reverse:'+ab);continue;}for(const af of ac){const ag=A['get'](af+'|'+ab+'|schema')??[],ah=lookupMapLower(ad,af);if(!ah)continue;const ai=extractReverseRefs(ab,ah['data']??ah);for(const aj of ag){const ak=aj['read'];for(const al of ai){if(al['schemaId']!==REVERSE_GROUP_WILDCARD&&al['schemaId']!==aj['id'])continue;let am=al['refs']['map'](an=>an['to']?an:{...an,'to':af});ak['kind']==='reverse'&&ak['filterType']&&(am=am['filter'](an=>inferObjectType(an['to'])===ak['filterType']));if(am['length']===0x0)continue;w['push']({'schema':aj,'sourceId':af,'refs':am,'observed':am['length']});}}}}for(const an of EDGE_SCHEMAS){const ao=an['read'];if(ao['kind']!=='event'||!f['allowsEvent'](an,p))continue;const ap=[...o]['filter'](ar=>{if(n['has'](ar+'|'+an['id']))return![];return sourceMatches(an['source'],h['graph']['nodes']['get'](ar));});if(ap['length']===0x0)continue;let aq=m['get'](ao['eventType']);if(!aq){aq={'events':[],'truncated':![],'failed':![]};try{const ar=await a['getEvents'](ao['eventType'],{'maxPages':e['maxEventPages']});if(readStats(a)['batches']>=e['maxRpcs'])h['exhausted']['rpcs']=!![];aq['events']=ar['events'],aq['truncated']=ar['truncated'],ar['truncated']&&ar['events']['length']===0x0&&(aq['failed']=!![],h['graph']['gaps']['push']('events:'+ao['eventType']));}catch{aq['failed']=!![],h['graph']['gaps']['push']('events:'+ao['eventType']);}m['set'](ao['eventType'],aq);}if(aq['failed']){for(const as of ap)n['add'](as+'|'+an['id']);continue;}if(aq['truncated']){h['exhausted']['eventPages']=!![];for(const at of ap){h['markTruncation']({'nodeId':at,'schema':an['id'],'observed':aq['events']['length'],'limit':e['maxEventPages'],'reason':'event_pages'});}}for(const au of ap){n['add'](au+'|'+an['id']);const av=extractEventRefs(ao,au,aq['events']);if(av['length']===0x0)continue;w['push']({'schema':an,'sourceId':au,'refs':av,'observed':av['length'],'truncated':aq['truncated']});}}const B=new Set(),C=new Map();for(const aw of w){const ax=e['perKindCaps'][aw['schema']['id']]??e['maxFanoutPerNode'],ay=C['get'](aw['sourceId'])??0x0,az=Math['max'](0x0,e['maxFanoutPerNode']-ay),aA=Math['min'](ax,az),aB=aw['refs']['slice'](0x0,aA);aw['refs']['length']>aA&&h['markTruncation']({'nodeId':aw['sourceId'],'schema':aw['schema']['id'],'observed':aw['refs']['length'],'limit':a95a,'reason':'fanout'});const aC=new Map();for(const aD of aB){const aE=aD['from']??aw['sourceId'],aF=isWfNodeId(aD['to'])?p:p+0x1,aG=h['graph']['nodes']['has'](aD['to']),aH=f['effectiveMaxHops'](aw['schema']);if(aH!==undefined){const aJ=(t(aE,new Set())['get'](aw['schema']['id'])??0x0)+0x1;if(aJ>aH&&!aG){aC['set'](aE,(aC['get'](aE)??0x0)+0x1);continue;}}if(aF>e['maxDepth']&&!aG){h['exhausted']['depth']=!![];continue;}const aI=h['addNode'](aD['to'],Math['min'](aF,e['maxDepth']),{'schema':aw['schema']['id'],'from':aE});if(!aI)break;h['addEdge'](aw['schema'],aE,aD,q,aw['truncated']===!![]||aw['refs']['length']>aA),C['set'](aw['sourceId'],ay+0x1);if(!isWfNodeId(aD['to'])&&aF<=e['maxDepth'])B['add'](aD['to']);}for(const [aK,aL]of aC){h['markTruncation']({'nodeId':aK,'schema':aw['schema']['id'],'observed':aL,'limit':f['effectiveMaxHops'](aw['schema'])??0x0,'reason':'schema_hops'});}}if(h['exhausted']['rpcs']){h['graph']['gaps']['push']('budget:maxRpcs');break;}o=B;}return h['finalize'](a);}function sourceMatches(a,b){if(a==='ANY')return!![];if(a==='EOA')return b['kind']==='eoa';return b['objectType']===a;}function lookupMapLower(a,b){const c=a['get'](b);if(c!==undefined)return c;for(const [d,e]of a)if(d['toLowerCase']()===b)return e;return undefined;}export function orderCompletionInGraph(a,b){const c=a['nodes']['get'](b['toLowerCase']()),d=c?.['raw']?.['data']??c?.['raw']??{},e=String(d['machine']??''),f=String(d['progress']??''),g=a['nodes']['get'](f['toLowerCase']()),h=String((g?.['raw']?.['data']??g?.['raw']??{})['current']??'');let i=null;if(e){const j=e['toLowerCase']()+'::node::',k=a['edges']['filter'](l=>l['schema']==='wf.transition'&&l['from']['startsWith'](j))['map'](l=>({'node':l['payload']?.['node'],'prev_node':l['payload']?.['prevNode']}));if(k['length']>0x0)i=terminalNamesOfEdges(k);}return deriveOrderCompletion({'machine':e||null,'progress':f||null,'currentNode':h||null,'terminalNames':i});}
|
|
1
|
+
import{EDGE_SCHEMAS,EDGE_SCHEMA_BY_ID}from'./edge-schema.js';import{extractCoinType,extractEventRefs,extractObjectEdges,extractReverseRefs,extractTableRefs,inferObjectType,REVERSE_GROUP_WILDCARD}from'./extract.js';import{mergeBudget}from'./dataplane.js';import{deriveOrderCompletion,terminalNamesOfEdges}from'./order-status.js';import{LINKER_RING_LIMIT as a96a}from'./sdk-batch.js';import{wowAddressKind}from'@wowok/wowok';function readStats(a){const b=a;if(b['stats'])return{'batches':b['stats']['batches'],'byChannel':{...b['stats']['byChannel']},'dedupHits':b['stats']['dedupHits']};if(b['batches'])return{'batches':Object['values'](b['batches'])['reduce']((c,d)=>c+d,0x0),'byChannel':{...b['batches']},'dedupHits':b['dedupHits']??0x0};return{'batches':0x0,'byChannel':{'objects':0x0,'keyedFields':0x0,'tables':0x0,'events':0x0},'dedupHits':0x0};}function isEoa(a){return wowAddressKind(a)==='user';}function isWfNodeId(a){return a['includes']('::node::');}class Gate{['wl'];constructor(a){this['wl']=a;}['allows'](a,b){if(this['wl']['deny']?.['includes'](a['id']))return![];const c=this['wl']['familyDepths']?.[a['family']];if(c!==undefined&&b>=c)return![];if(this['wl']['schemas'])return this['wl']['schemas']['includes'](a['id']);if(this['wl']['families']&&!this['wl']['families']['includes'](a['family']))return![];return!![];}['allowsTable'](a,b){if(a['read']['kind']!=='table')return![];if(this['wl']['deny']?.['includes'](a['id']))return![];const c=this['wl']['familyDepths']?.[a['family']];if(c!==undefined&&b>=c)return![];if(this['wl']['families']&&!this['wl']['families']['includes'](a['family']))return![];return!!this['wl']['tableEdges']?.['includes'](a['id']);}['allowsEvent'](a,b){if(a['read']['kind']!=='event')return![];if(this['wl']['deny']?.['includes'](a['id']))return![];const c=this['wl']['familyDepths']?.[a['family']];if(c!==undefined&&b>=c)return![];if(this['wl']['families']&&!this['wl']['families']['includes'](a['family']))return![];return!!this['wl']['eventEdges']?.['includes'](a['id']);}['effectiveMaxHops'](a){const b=a['maxHops'],c=this['wl']['schemaHops']?.[a['id']];if(b===undefined)return c;if(c===undefined)return b;return Math['min'](b,c);}}class GraphBuilder{['graph'];['edgeIds']=new Set();['budget'];['exhausted']={};constructor(a,b,c){this['budget']=c,this['graph']={'network':a,'seed':b,'builtAt':Date['now'](),'nodes':new Map(),'edges':[],'out':new Map(),'inc':new Map(),'gaps':[],'truncations':[],'rpcReport':{'batches':0x0,'byChannel':{'objects':0x0,'keyedFields':0x0,'tables':0x0,'events':0x0},'dedupHits':0x0},'budgetExhausted':{}};}['addSeed'](a){const b=inferObjectType(a),c={'id':a,'kind':isWfNodeId(a)?'wfnode':isEoa(a)?'eoa':'object','objectType':b??undefined,'state':'seed','origins':[],'depth':0x0};return this['graph']['nodes']['set'](a,c),c;}['addNode'](a,b,c){const d=this['graph']['nodes']['get'](a);if(d){if(c)d['origins']['push']({'via':c['schema'],'from':c['from'],'depth':b});return d;}if(this['graph']['nodes']['size']>=this['budget']['maxNodes'])return this['exhausted']['nodes']=!![],undefined;const e=isWfNodeId(a),f=e?undefined:inferObjectType(a),g={'id':a,'kind':e?'wfnode':isEoa(a)?'eoa':'object','objectType':f??undefined,'state':e?'stub':'seed','origins':c?[{'via':c['schema'],'from':c['from'],'depth':b}]:[],'depth':b};return this['graph']['nodes']['set'](a,g),g;}['addEdge'](a,b,c,d,e){const f=c['to'],g=c['key']?'|'+c['key']:'',h=a['id']+'|'+b+'→'+f+g;if(this['edgeIds']['has'](h))return;this['edgeIds']['add'](h);const i={'id':h,'schema':a['id'],'family':a['family'],'from':b,'to':f,'retention':a['retention'],'observedAt':d,'payload':c['payload'],'truncated':e||a['retention']==='bounded_window','key':c['key']};this['graph']['edges']['push'](i),pushMap(this['graph']['out'],b,i),pushMap(this['graph']['inc'],f,i);}['markTruncation'](a){this['graph']['truncations']['push'](a);}['finalize'](a){return this['graph']['rpcReport']=readStats(a),this['graph']['budgetExhausted']=this['exhausted'],this['graph'];}}function pushMap(a,b,c){const d=a['get'](b);if(d)d['push'](c);else a['set'](b,[c]);}export async function expandTopology(a,c){const d=c['seed']['toLowerCase'](),e=mergeBudget(c['budget']),f=new Gate(c['edges']??{}),h=new GraphBuilder(c['network'],d,e);h['addSeed'](d);const i=new Set(),j=new Set(),l=new Set(),m=new Map(),n=new Set();let o=new Set([d]);for(let p=0x0;p<=e['maxDepth'];p++){if(o['size']===0x0)break;if(h['exhausted']['nodes'])break;const q=Date['now'](),r=new Map(),t=(D,E)=>{const F=r['get'](D);if(F)return F;const G=new Map();r['set'](D,G);const H=h['graph']['nodes']['get'](D);if(H&&H['origins']['length']>0x0&&!E['has'](D)){E['add'](D);for(const I of H['origins']){if(!I['via']||!I['from']||E['has'](I['from']))continue;const J=t(I['from'],E);for(const [L,M]of J){if(M<(G['get'](L)??Infinity))G['set'](L,M);}const K=(J['get'](I['via'])??0x0)+0x1;if(K<(G['get'](I['via'])??Infinity))G['set'](I['via'],K);}E['delete'](D);}return G;},u=[...o]['filter'](D=>{const E=h['graph']['nodes']['get'](D);return E['kind']==='object'&&(E['state']==='seed'||E['state']==='stub')&&!i['has'](D);}),v=new Set();if(u['length']>0x0){const D=await a['getObjects'](u);if(readStats(a)['batches']>=e['maxRpcs'])h['exhausted']['rpcs']=!![];for(const E of u){const F=h['graph']['nodes']['get'](E),G=lookupMapLower(D,E);i['add'](E);if(!G){F['state']='error',F['error']='not_found_or_failed',h['graph']['gaps']['push'](E);continue;}F['state']='fetched',F['raw']=G,F['objectType']=String(G['type']??F['objectType']??inferObjectType(E)??''),F['coinType']=extractCoinType(G['type_raw']),v['add'](E);}}const w=[];for(const H of v){const I=h['graph']['nodes']['get'](H);if(!I['objectType']||!I['raw'])continue;for(const J of extractObjectEdges(I['objectType'],I['raw'])){const K=EDGE_SCHEMA_BY_ID['get'](J['schemaId']);if(!K||!f['allows'](K,p))continue;w['push']({'schema':K,'sourceId':H,'refs':J['refs'],'observed':J['refs']['length']});}}const x=[...v]['filter'](L=>{const M=h['graph']['nodes']['get'](L);return EDGE_SCHEMAS['some'](N=>N['source']===M['objectType']&&N['read']['kind']==='table');});for(const L of x){const M=h['graph']['nodes']['get'](L),N=EDGE_SCHEMAS['filter'](P=>P['source']===M['objectType']&&P['read']['kind']==='table'&&f['allowsTable'](P,p)),O=new Map();for(const P of N){const Q=P['read']['rowType'],R=O['get'](Q)??[];R['push'](P),O['set'](Q,R);}for(const [S,T]of O){const U=L+'|'+S;if(l['has'](U))continue;l['add'](U);const V=Math['max'](...T['map'](a0=>e['perKindCaps'][a0['id']]??e['maxFanoutPerNode']));let W,X=![];try{const a0=await a['getTable'](L,{'maxItems':V});if(readStats(a)['batches']>=e['maxRpcs'])h['exhausted']['rpcs']=!![];W=a0['items'],X=a0['truncated'];}catch{h['graph']['gaps']['push'](L+'#'+S);continue;}const Y=new Set(T['map'](a1=>a1['id'])),Z=extractTableRefs(S,L,W)['filter'](a1=>{const a2=EDGE_SCHEMA_BY_ID['get'](a1['schemaId']);return a2['read']['kind']==='derived'||Y['has'](a1['schemaId']);});for(const a1 of Z){const a2=EDGE_SCHEMA_BY_ID['get'](a1['schemaId']);let a3=a1['refs'];a2['family']==='M'&&M['coinType']&&(a3=a3['map'](a4=>({...a4,'payload':{'coinType':M['coinType'],...a4['payload']}}))),w['push']({'schema':a2,'sourceId':L,'refs':a3,'observed':a3['length']});}X&&h['markTruncation']({'nodeId':L,'schema':T[0x0]['id'],'observed':W['length'],'limit':V,'reason':'table_page'});}}const y=[...o]['filter'](a4=>{const a5=h['graph']['nodes']['get'](a4);return a5['kind']!=='wfnode'&&(a5['kind']==='eoa'||a5['state']==='fetched');}),z=new Map(),A=new Map();for(const a4 of y){const a5=h['graph']['nodes']['get'](a4);for(const a6 of EDGE_SCHEMAS){if(a6['read']['kind']!=='reverse'||!f['allows'](a6,p))continue;if(!sourceMatches(a6['source'],a5))continue;const a7=a6['read']['parent'],a8=a4+'|'+a7;if(j['has'](a8))continue;if(!z['has'](a7))z['set'](a7,[]);z['get'](a7)['push'](a4);const a9=a4+'|'+a7+'|schema',aa=A['get'](a9)??[];aa['push'](a6),A['set'](a9,aa);}}for(const [ab,ac]of z){for(const ae of ac)j['add'](ae+'|'+ab);let ad=new Map();try{ad=await a['getKeyedFields'](ab,ac);if(readStats(a)['batches']>=e['maxRpcs'])h['exhausted']['rpcs']=!![];}catch{h['graph']['gaps']['push']('reverse:'+ab);continue;}for(const af of ac){const ag=A['get'](af+'|'+ab+'|schema')??[],ah=lookupMapLower(ad,af);if(!ah)continue;const ai=extractReverseRefs(ab,ah['data']??ah);for(const aj of ag){const ak=aj['read'];for(const al of ai){if(al['schemaId']!==REVERSE_GROUP_WILDCARD&&al['schemaId']!==aj['id'])continue;let am=al['refs']['map'](an=>an['to']?an:{...an,'to':af});ak['kind']==='reverse'&&ak['filterType']&&(am=am['filter'](an=>inferObjectType(an['to'])===ak['filterType']));if(am['length']===0x0)continue;w['push']({'schema':aj,'sourceId':af,'refs':am,'observed':am['length']});}}}}for(const an of EDGE_SCHEMAS){const ao=an['read'];if(ao['kind']!=='event'||!f['allowsEvent'](an,p))continue;const ap=[...o]['filter'](ar=>{if(n['has'](ar+'|'+an['id']))return![];return sourceMatches(an['source'],h['graph']['nodes']['get'](ar));});if(ap['length']===0x0)continue;let aq=m['get'](ao['eventType']);if(!aq){aq={'events':[],'truncated':![],'failed':![]};try{const ar=await a['getEvents'](ao['eventType'],{'maxPages':e['maxEventPages']});if(readStats(a)['batches']>=e['maxRpcs'])h['exhausted']['rpcs']=!![];aq['events']=ar['events'],aq['truncated']=ar['truncated'],ar['truncated']&&ar['events']['length']===0x0&&(aq['failed']=!![],h['graph']['gaps']['push']('events:'+ao['eventType']));}catch{aq['failed']=!![],h['graph']['gaps']['push']('events:'+ao['eventType']);}m['set'](ao['eventType'],aq);}if(aq['failed']){for(const as of ap)n['add'](as+'|'+an['id']);continue;}if(aq['truncated']){h['exhausted']['eventPages']=!![];for(const at of ap){h['markTruncation']({'nodeId':at,'schema':an['id'],'observed':aq['events']['length'],'limit':e['maxEventPages'],'reason':'event_pages'});}}for(const au of ap){n['add'](au+'|'+an['id']);const av=extractEventRefs(ao,au,aq['events']);if(av['length']===0x0)continue;w['push']({'schema':an,'sourceId':au,'refs':av,'observed':av['length'],'truncated':aq['truncated']});}}const B=new Set(),C=new Map();for(const aw of w){const ax=e['perKindCaps'][aw['schema']['id']]??e['maxFanoutPerNode'],ay=C['get'](aw['sourceId'])??0x0,az=Math['max'](0x0,e['maxFanoutPerNode']-ay),aA=Math['min'](ax,az),aB=aw['refs']['slice'](0x0,aA);aw['refs']['length']>aA&&h['markTruncation']({'nodeId':aw['sourceId'],'schema':aw['schema']['id'],'observed':aw['refs']['length'],'limit':a96a,'reason':'fanout'});const aC=new Map();for(const aD of aB){const aE=aD['from']??aw['sourceId'],aF=isWfNodeId(aD['to'])?p:p+0x1,aG=h['graph']['nodes']['has'](aD['to']),aH=f['effectiveMaxHops'](aw['schema']);if(aH!==undefined){const aJ=(t(aE,new Set())['get'](aw['schema']['id'])??0x0)+0x1;if(aJ>aH&&!aG){aC['set'](aE,(aC['get'](aE)??0x0)+0x1);continue;}}if(aF>e['maxDepth']&&!aG){h['exhausted']['depth']=!![];continue;}const aI=h['addNode'](aD['to'],Math['min'](aF,e['maxDepth']),{'schema':aw['schema']['id'],'from':aE});if(!aI)break;h['addEdge'](aw['schema'],aE,aD,q,aw['truncated']===!![]||aw['refs']['length']>aA),C['set'](aw['sourceId'],ay+0x1);if(!isWfNodeId(aD['to'])&&aF<=e['maxDepth'])B['add'](aD['to']);}for(const [aK,aL]of aC){h['markTruncation']({'nodeId':aK,'schema':aw['schema']['id'],'observed':aL,'limit':f['effectiveMaxHops'](aw['schema'])??0x0,'reason':'schema_hops'});}}if(h['exhausted']['rpcs']){h['graph']['gaps']['push']('budget:maxRpcs');break;}o=B;}return h['finalize'](a);}function sourceMatches(a,b){if(a==='ANY')return!![];if(a==='EOA')return b['kind']==='eoa';return b['objectType']===a;}function lookupMapLower(a,b){const c=a['get'](b);if(c!==undefined)return c;for(const [d,e]of a)if(d['toLowerCase']()===b)return e;return undefined;}export function orderCompletionInGraph(a,b){const c=a['nodes']['get'](b['toLowerCase']()),d=c?.['raw']?.['data']??c?.['raw']??{},e=String(d['machine']??''),f=String(d['progress']??''),g=a['nodes']['get'](f['toLowerCase']()),h=String((g?.['raw']?.['data']??g?.['raw']??{})['current']??'');let i=null;if(e){const j=e['toLowerCase']()+'::node::',k=a['edges']['filter'](l=>l['schema']==='wf.transition'&&l['from']['startsWith'](j))['map'](l=>({'node':l['payload']?.['node'],'prev_node':l['payload']?.['prevNode']}));if(k['length']>0x0)i=terminalNamesOfEdges(k);}return deriveOrderCompletion({'machine':e||null,'progress':f||null,'currentNode':h||null,'terminalNames':i});}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{applyExposureGate as
|
|
1
|
+
import{applyExposureGate as a99a}from'../../config/exposure.js';export{resolveViability,factRef,parseFactRef}from'../../config/exposure.js';export const EXPOSURE_ROLES={'buyer':'buyer','merchant':'merchant','supplier':'supplier','collaborator':'collaborator','arbitrator':'arbitrator','system':'system','neutral':'neutral'};export function applyExposureGate(a,b){return a99a(a,b);}export function lossParty(a,b){return{'role':a,'basis':b};}export function gainPath(a,b,c,d){return{'role':a,'path':b,'viability':c,'gate':d};}
|
package/dist/harness/recover.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const RECOVERY_RULES={'insufficient_balance':{'error_code':'insufficient_balance','strategy':'claim_faucet','max_attempts':0x3,'automation':'semi','detail':'1.\x20Testnet:\x20claim\x20WOW\x20from\x20the\x20faucet\x202.\x20Mainnet:\x20transfer\x20ETH/USDT/USDC/WBTC\x20via\x20the\x20ETH\x20mainnet\x20cross-chain\x20bridge\x20(query\x20active\x20EVM\x20account\x20→\x20top\x20up\x20from\x20external\x20wallet\x20→\x20confirm\x20→\x20cross-chain)\x203.\x20Point\x20the\x20user\x20to\x20the\x20live\x20airdrop\x20page\x20(https://wowok.net/airdrop.html)\x20for\x20the\x20current\x20round\x204.\x20Retry\x20original\x20operation','user_prompt':'Insufficient\x20balance\x20for\x20gas\x20or\x20operation.\x20How\x20to\x20obtain\x20WOW\x20tokens:\x20(1)\x20Testnet\x20—\x20claim\x20WOW\x20from\x20the\x20faucet\x20(https://faucet.testnet.wowok.net);\x20all\x20merchant\x20and\x20order\x20testing\x20can\x20use\x20WOW\x20as\x20the\x20payment\x20token.\x20(2)\x20Mainnet\x20—\x20transfer\x20ETH\x20/\x20USDT\x20/\x20USDC\x20/\x20WBTC\x20via\x20the\x20ETH\x20mainnet\x20cross-chain\x20bridge:\x20first\x20query\x20the\x20active\x20EVM\x20account\x20(bridge_operation\x20query_active_evm_account,\x20auto-generated\x20on\x20first\x20use),\x20then\x20transfer\x20from\x20an\x20external\x20wallet\x20(e.g.\x20MetaMask)\x20to\x20that\x20address,\x20confirm\x20the\x20balance\x20arrived,\x20and\x20cross-chain\x20to\x20WOW\x20mainnet\x20(bridge_operation\x20cross_chain_evm_to_wow).\x20(3)\x20WOW\x20airdrop:\x20current\x20round\x20status,\x20pool\x20and\x20eligibility\x20are\x20published\x20live\x20at\x20https://wowok.net/airdrop.html\x20(referral:\x20https://wowok.net/refer.html)\x20—\x20open\x20that\x20page\x20rather\x20than\x20assuming\x20a\x20round\x20is\x20live\x20or\x20closed.\x20Query\x20wowok_buildin_info\x20with\x20info=\x27funding\x20guidance\x27\x20for\x20the\x20canonical\x20funding\x20guidance.'},'stock_exhausted':{'error_code':'stock_exhausted','strategy':'adjust_params','max_attempts':0x1,'automation':'semi','detail':'Merchant-side\x20inventory\x20shortfall\x20(Move\x20service:16\x20E_STOCK_NOT_ENOUGH)\x20—\x20NOT\x20a\x20buyer\x20balance\x20problem,\x20so\x20a\x20faucet\x20claim\x20will\x20NOT\x20help.\x201.\x20Reduce\x20the\x20purchase\x20quantity\x20to\x20the\x20item\x27s\x20remaining\x20stock\x202.\x20Pick\x20another\x20sale\x20item\x203.\x20Ask\x20the\x20merchant\x20to\x20restock,\x20then\x20retry','user_prompt':'The\x20sale\x20item\x27s\x20stock\x20is\x20exhausted\x20for\x20the\x20requested\x20quantity.\x20Reduce\x20the\x20quantity,\x20choose\x20another\x20item,\x20or\x20ask\x20the\x20merchant\x20to\x20restock.'},'sale_suspended':{'error_code':'sale_suspended','strategy':'adjust_params','max_attempts':0x1,'automation':'semi','detail':'The\x20merchant\x20suspended\x20this\x20sale\x20item\x20(Move\x20service:34\x20E_SALE_SUSPENDED).\x201.\x20Pick\x20another\x20(non-suspended)\x20item\x202.\x20Contact\x20the\x20merchant\x20to\x20resume\x20the\x20sale,\x20then\x20retry','user_prompt':'The\x20sale\x20item\x20is\x20suspended\x20by\x20the\x20merchant.\x20Please\x20choose\x20another\x20item\x20or\x20contact\x20the\x20merchant.'},'discount_invalid':{'error_code':'discount_invalid','strategy':'adjust_params','max_attempts':0x1,'automation':'semi','detail':'The\x20discount\x20is\x20outside\x20its\x20[time_start,\x20time_end]\x20validity\x20window\x20(Move\x20service:35\x20E_DISCOUNT_TIME_INVALID).\x201.\x20Retry\x20without\x20the\x20discount\x202.\x20Ask\x20the\x20merchant\x20for\x20a\x20fresh\x20discount,\x20then\x20retry','user_prompt':'The\x20discount\x20is\x20not\x20valid\x20at\x20the\x20current\x20time\x20(outside\x20its\x20validity\x20window).\x20Buy\x20without\x20the\x20discount\x20or\x20ask\x20the\x20merchant\x20for\x20a\x20new\x20one.'},'rate_limit':{'error_code':'rate_limit','strategy':'retry','max_attempts':0x5,'automation':'full','detail':'Rate\x20limit\x20hit\x20(HTTP\x20429).\x20Exponential\x20backoff\x20retry:\x202s\x20/\x204s\x20/\x208s\x20/\x2016s\x20/\x2032s.\x20Avoid\x20parallel\x20calls\x20while\x20the\x20limit\x20window\x20is\x20active.'},'gas_exceeded':{'error_code':'gas_exceeded','strategy':'adjust_params','max_attempts':0x3,'automation':'semi','detail':'Gas\x20budget\x20exceeded.\x201.\x20Increase\x20the\x20gas_budget\x20parameter\x202.\x20Reduce\x20the\x20operation\x20size\x20(fewer\x20objects\x20per\x20transaction)\x203.\x20Retry\x20the\x20original\x20operation','user_prompt':'Gas\x20budget\x20exceeded.\x20Increase\x20the\x20gas\x20budget\x20or\x20reduce\x20the\x20operation\x20size,\x20then\x20retry.'},'bcs_error':{'error_code':'bcs_error','strategy':'adjust_params','max_attempts':0x2,'automation':'semi','detail':'BCS\x20serialization/deserialization\x20error\x20—\x20a\x20parameter\x20does\x20not\x20match\x20the\x20expected\x20type/structure.\x201.\x20Query\x20the\x20operation\x20schema\x20(schema_query)\x202.\x20Fix\x20the\x20offending\x20parameter\x20type\x20(e.g.\x20BigInt\x20vs\x20number,\x20vector\x20element\x20type)\x203.\x20Retry','user_prompt':'A\x20parameter\x20failed\x20serialization.\x20Check\x20the\x20parameter\x20types\x20against\x20the\x20schema\x20and\x20retry.'},'signature_error':{'error_code':'signature_error','strategy':'switch_account','max_attempts':0x2,'automation':'semi','detail':'Signature\x20verification\x20failed.\x201.\x20Verify\x20the\x20account\x20is\x20not\x20suspended\x202.\x20Check\x20the\x20network\x20matches\x20the\x20account\x27s\x203.\x20Switch\x20to\x20a\x20healthy\x20account\x20and\x20retry','user_prompt':'Signature\x20verification\x20failed.\x20The\x20account\x20may\x20be\x20suspended\x20or\x20misconfigured.\x20Switch\x20accounts\x20or\x20check\x20the\x20configuration\x20and\x20retry.'},'config_error':{'error_code':'config_error','strategy':'escalate_human','max_attempts':0x1,'automation':'manual','detail':'Local\x20configuration\x20error\x20(network\x20not\x20specified,\x20persistent\x20storage\x20not\x20set).\x201.\x20Show\x20the\x20user\x20which\x20configuration\x20is\x20missing\x202.\x20Guide\x20the\x20user\x20through\x20the\x20account_operation/config\x20setup\x203.\x20Retry\x20after\x20the\x20user\x20fixes\x20it','user_prompt':'Local\x20configuration\x20is\x20incomplete.\x20Please\x20finish\x20the\x20account/network\x20setup\x20and\x20retry.'},'wip_verification_failed':{'error_code':'wip_verification_failed','strategy':'adjust_params','max_attempts':0x2,'automation':'semi','detail':'WIP\x20file\x20not\x20publicly\x20reachable\x20/\x20hash\x20mismatch.\x201.\x20Upload\x20via\x20the\x20wip\x20storage\x20service\x20(wip_file\x20type=\x27upload\x27\x20—\x20official\x20free\x20store\x20or\x20storage=\x27custom\x27)\x202.\x20Or\x20deploy\x20to\x20a\x20public\x20URL\x20(GitHub\x20Pages\x20/\x20IPFS\x20/\x20own\x20site)\x203.\x20Update\x20the\x20sale\x27s\x20wip\x20URL\x204.\x20Re-run\x20the\x20operation','user_prompt':'The\x20WIP\x20file\x20could\x20not\x20be\x20verified\x20from\x20a\x20public\x20URL.\x20Upload\x20it\x20with\x20wip_file\x20type=\x27upload\x27\x20(official\x20free\x20store\x20or\x20your\x20own\x20service)\x20or\x20deploy\x20it\x20(GitHub\x20Pages\x20/\x20IPFS),\x20update\x20the\x20sale\x27s\x20WIP\x20URL,\x20and\x20retry.'},'wip_storage_unavailable':{'error_code':'wip_storage_unavailable','strategy':'retry','max_attempts':0x3,'automation':'full','detail':'Transient\x20wip\x20storage\x20transport\x20failure.\x201.\x20Retry\x20the\x20same\x20request\x20with\x20bounded\x20backoff\x202.\x20Large\x20WIP\x20files\x20are\x20network-sensitive:\x20compress\x20images\x20before\x20generate\x20(each\x20image\x20<=\x202MB,\x20total\x20<=\x2010MB)\x203.\x20Check\x20connectivity\x20to\x20the\x20storage\x20base\x20URL\x20if\x20retries\x20keep\x20failing','user_prompt':'The\x20wip\x20storage\x20request\x20failed\x20due\x20to\x20a\x20network\x20problem.\x20Retry\x20the\x20upload;\x20if\x20it\x20keeps\x20failing,\x20reduce\x20the\x20file\x20size\x20or\x20check\x20connectivity.'},'network_error':{'error_code':'network_error','strategy':'retry','max_attempts':0x5,'automation':'full','detail':'Exponential\x20backoff\x20retry:\x201s\x20/\x202s\x20/\x204s\x20/\x208s\x20/\x2016s.\x20Switch\x20RPC\x20node\x20if\x20available.'},'transaction_expired':{'error_code':'transaction_expired','strategy':'retry','max_attempts':0x3,'automation':'full','detail':'The\x20transaction\x20expired\x20before\x20execution\x20(epoch\x20boundary\x20or\x20validator/gateway\x20outage)\x20—\x20it\x20did\x20NOT\x20land\x20and\x20nothing\x20was\x20committed.\x20Bounded\x20backoff\x20retry:\x2010s\x20/\x2030s\x20/\x2060s,\x20resubmit\x20the\x20SAME\x20call\x20unchanged.\x20If\x20a\x20dry_run\x20passes\x20while\x20the\x20real\x20call\x20keeps\x20failing,\x20the\x20fault\x20is\x20chain-side\x20—\x20wait\x20it\x20out.\x20Verify\x20with\x20onchain_events\x20if\x20unsure.'},'guard_rejected':{'error_code':'guard_rejected','strategy':'fill_submission','max_attempts':0x2,'automation':'semi','detail':'1.\x20Parse\x20Guard\x20table\x20structure\x202.\x20If\x20the\x20Guard\x20defines\x20submission\x20items,\x20fill\x20them\x20and\x20resubmit\x20with\x20call_with_submission\x203.\x20If\x20it\x20defines\x20none,\x20the\x20rule\x20evaluated\x20false\x20—\x20adjust\x20the\x20call\x27s\x20parameters\x20(signer/query/state)\x20or\x20change\x20the\x20Guard\x20(docs#40)\x204.\x20When\x20the\x20failure\x20is\x20passport\x20E_VERIFY_FAILED\x20and\x20a\x20submission\x20was\x20supplied,\x20the\x20response\x20appends\x20a\x20\x27Guard\x20diagnosis\x20(dry-run)\x27\x20line\x20naming\x20the\x20first\x20failing\x20impact\x20guard\x20—\x20fix\x20that\x20guard\x20first','user_prompt':'Guard\x20verification\x20rejected.\x20If\x20the\x20Guard\x20defines\x20submission\x20items,\x20fill\x20in\x20the\x20required\x20submission\x20data\x20and\x20resubmit;\x20if\x20it\x20defines\x20none,\x20the\x20Guard\x20rule\x20evaluated\x20false\x20—\x20adjust\x20this\x20call\x27s\x20parameters\x20or\x20change\x20the\x20Guard\x20rule.\x20When\x20the\x20response\x20includes\x20a\x20\x27Guard\x20diagnosis\x20(dry-run)\x27\x20line,\x20it\x20names\x20the\x20first\x20failing\x20impact\x20guard\x20—\x20address\x20that\x20guard\x20first.'},'time_lock_not_elapsed':{'error_code':'time_lock_not_elapsed','strategy':'wait_and_retry','max_attempts':0x1,'automation':'semi','detail':'1.\x20Verify\x20Service\x20is\x20paused\x20(bPaused=true).\x20If\x20not,\x20submit\x20pause=true\x20first.\x202.\x20Wait\x20until\x20paused_time\x20+\x20setting_lock_duration\x20<=\x20current\x20clock.\x203.\x20Retry\x20the\x20original\x20operation.\x20Do\x20NOT\x20recreate\x20the\x20object.','user_prompt':'Service\x20setting_lock_duration\x20has\x20not\x20elapsed\x20since\x20the\x20Service\x20was\x20paused.\x20Please\x20pause\x20the\x20Service\x20if\x20it\x20is\x20not\x20already\x20paused,\x20wait\x20for\x20the\x20lock\x20duration\x20to\x20elapse,\x20then\x20retry.'},'immutable_violation':{'error_code':'immutable_violation','strategy':'recreate','max_attempts':0x1,'automation':'semi','detail':'1.\x20Stop\x20modification\x20attempt\x202.\x20Evaluate\x20creating\x20a\x20new\x20object\x20as\x20replacement\x203.\x20Re-plan\x20affected\x20phases','user_prompt':'Cannot\x20modify\x20an\x20immutable\x20object.\x20A\x20new\x20object\x20must\x20be\x20created\x20as\x20a\x20replacement.\x20Confirm\x20to\x20proceed\x20with\x20recreation.'},'permission_denied':{'error_code':'permission_denied','strategy':'switch_account','max_attempts':0x2,'automation':'semi','detail':'1.\x20Query\x20object\x27s\x20permission_guard\x202.\x20List\x20accounts\x20with\x20permission\x203.\x20Switch\x20account\x20or\x20prompt\x20user\x20to\x20add\x20permission','user_prompt':'Current\x20account\x20lacks\x20permission\x20for\x20this\x20operation.\x20Switch\x20to\x20an\x20authorized\x20account\x20or\x20update\x20the\x20Permission\x20object.'},'object_not_found':{'error_code':'object_not_found','strategy':'query_and_retry','max_attempts':0x3,'automation':'semi','detail':'1.\x20Verify\x20the\x20referenced\x20name/ID\x20spelling\x20(local_mark_list)\x20and\x20that\x20the\x20object\x20exists\x20on\x20the\x20current\x20network\x202.\x20If\x20recently\x20created,\x20re-query\x20the\x20object\x20(may\x20be\x20sync\x20delay)\x203.\x20If\x20truly\x20absent,\x20search\x20for\x20similar\x20objects\x204.\x20Prompt\x20user\x20to\x20reselect','user_prompt':'Referenced\x20object\x20not\x20found.\x20First\x20verify\x20the\x20name/ID\x20spelling\x20and\x20that\x20the\x20object\x20exists\x20on\x20the\x20current\x20network;\x20if\x20it\x20was\x20created\x20recently,\x20this\x20may\x20be\x20a\x20synchronization\x20delay\x20—\x20retry.\x20If\x20the\x20issue\x20persists,\x20please\x20select\x20a\x20valid\x20object.'},'state_conflict':{'error_code':'state_conflict','strategy':'adjust_params','max_attempts':0x2,'automation':'full','detail':'1.\x20Query\x20object\x27s\x20current\x20true\x20state\x202.\x20Update\x20ODG\x20status\x20annotations\x203.\x20Adjust\x20subsequent\x20operations\x20(e.g.,\x20skip\x20completed\x20steps)'},'invalid_parameter':{'error_code':'invalid_parameter','strategy':'adjust_params','max_attempts':0x2,'automation':'semi','detail':'1.\x20Query\x20the\x20relevant\x20schema\x202.\x20Auto-fix\x20obvious\x20errors\x20(e.g.,\x20BigInt\x20vs\x20string)\x203.\x20If\x20unfixable,\x20prompt\x20user','user_prompt':'Parameter\x20validation\x20failed.\x20Please\x20check\x20the\x20parameter\x20types\x20and\x20values\x20against\x20the\x20schema\x20and\x20retry.'},'unknown':{'error_code':'unknown','strategy':'escalate_human','max_attempts':0x1,'automation':'manual','detail':'1.\x20Report\x20full\x20error\x20context\x20to\x20the\x20user\x202.\x20Escalate\x20to\x20human\x20intervention\x203.\x20Flag\x20for\x20error-classification\x20rule\x20addition','user_prompt':'An\x20unclassified\x20error\x20occurred.\x20Please\x20review\x20the\x20error\x20details\x20and\x20contact\x20support\x20if\x20needed.'}};const operationAttempts=new Map();function getAttemptCount(a,b){const c=operationAttempts['get'](a);if(!c)return 0x0;return c['get'](b)??0x0;}function incrementAttempt(a,b){!operationAttempts['has'](a)&&operationAttempts['set'](a,new Map());const c=operationAttempts['get'](a),d=(c['get'](b)??0x0)+0x1;return c['set'](b,d),d;}function getTotalAttempts(a){const b=operationAttempts['get'](a);if(!b)return 0x0;let c=0x0;for(const d of b['values']())c+=d;return c;}export function resetAttempts(a){operationAttempts['delete'](a);}export function recover(a,b,c){const d=RECOVERY_RULES[a]??RECOVERY_RULES['unknown'],e=0x5,f=getTotalAttempts(b),g=getAttemptCount(b,a);if(f>=e)return{'strategy':'stop','should_retry':![],'max_attempts':e,'current_attempt':f,'detail':'Total\x20retry\x20limit\x20('+e+')\x20reached\x20for\x20operation\x20'+b+'.\x20Escalating\x20to\x20human\x20intervention.','user_prompt':'Maximum\x20retry\x20attempts\x20reached.\x20Manual\x20intervention\x20required.'};if(g>=d['max_attempts'])return{'strategy':'escalate_human','should_retry':![],'max_attempts':d['max_attempts'],'current_attempt':g,'detail':'Per-error-code\x20retry\x20limit\x20('+d['max_attempts']+')\x20reached\x20for\x20'+a+'.\x20Escalating\x20to\x20human.','user_prompt':'Recovery\x20attempts\x20for\x20'+a+'\x20exhausted.\x20Manual\x20intervention\x20required.'};const h=incrementAttempt(b,a);return{'strategy':d['strategy'],'should_retry':d['automation']==='full'||h<d['max_attempts'],'max_attempts':d['max_attempts'],'current_attempt':h,'adjusted_params':d['adjusted_params'],'user_prompt':d['user_prompt'],'detail':d['detail']};}export function getBackoffDelay(a){return Math['pow'](0x2,a-0x1)*0x3e8;}
|
|
1
|
+
export const RECOVERY_RULES={'insufficient_balance':{'error_code':'insufficient_balance','strategy':'claim_faucet','max_attempts':0x3,'automation':'semi','detail':'1.\x20Testnet:\x20claim\x20WOW\x20from\x20the\x20faucet\x202.\x20Mainnet:\x20transfer\x20ETH/USDT/USDC/WBTC\x20via\x20the\x20ETH\x20mainnet\x20cross-chain\x20bridge\x20(query\x20active\x20EVM\x20account\x20→\x20top\x20up\x20from\x20external\x20wallet\x20→\x20confirm\x20→\x20cross-chain)\x203.\x20Point\x20the\x20user\x20to\x20the\x20live\x20airdrop\x20page\x20(https://wowok.net/airdrop.html)\x20for\x20the\x20current\x20round\x204.\x20Retry\x20original\x20operation','user_prompt':'Insufficient\x20balance\x20for\x20gas\x20or\x20operation.\x20How\x20to\x20obtain\x20WOW\x20tokens:\x20(1)\x20Testnet\x20—\x20claim\x20WOW\x20from\x20the\x20faucet\x20(https://faucet.testnet.wowok.net);\x20all\x20merchant\x20and\x20order\x20testing\x20can\x20use\x20WOW\x20as\x20the\x20payment\x20token.\x20(2)\x20Mainnet\x20—\x20transfer\x20ETH\x20/\x20USDT\x20/\x20USDC\x20/\x20WBTC\x20via\x20the\x20ETH\x20mainnet\x20cross-chain\x20bridge:\x20first\x20query\x20the\x20active\x20EVM\x20account\x20(bridge_operation\x20query_active_evm_account,\x20auto-generated\x20on\x20first\x20use),\x20then\x20transfer\x20from\x20an\x20external\x20wallet\x20(e.g.\x20MetaMask)\x20to\x20that\x20address,\x20confirm\x20the\x20balance\x20arrived,\x20and\x20cross-chain\x20to\x20WOW\x20mainnet\x20(bridge_operation\x20cross_chain_evm_to_wow).\x20(3)\x20WOW\x20airdrop:\x20current\x20round\x20status,\x20pool\x20and\x20eligibility\x20are\x20published\x20live\x20at\x20https://wowok.net/airdrop.html\x20(referral:\x20https://wowok.net/refer.html)\x20—\x20open\x20that\x20page\x20rather\x20than\x20assuming\x20a\x20round\x20is\x20live\x20or\x20closed.\x20Query\x20wowok_buildin_info\x20with\x20info=\x27funding\x20guidance\x27\x20for\x20the\x20canonical\x20funding\x20guidance.'},'stock_exhausted':{'error_code':'stock_exhausted','strategy':'adjust_params','max_attempts':0x1,'automation':'semi','detail':'Merchant-side\x20inventory\x20shortfall\x20(Move\x20service:16\x20E_STOCK_NOT_ENOUGH)\x20—\x20NOT\x20a\x20buyer\x20balance\x20problem,\x20so\x20a\x20faucet\x20claim\x20will\x20NOT\x20help.\x201.\x20Reduce\x20the\x20purchase\x20quantity\x20to\x20the\x20item\x27s\x20remaining\x20stock\x202.\x20Pick\x20another\x20sale\x20item\x203.\x20Ask\x20the\x20merchant\x20to\x20restock,\x20then\x20retry','user_prompt':'The\x20sale\x20item\x27s\x20stock\x20is\x20exhausted\x20for\x20the\x20requested\x20quantity.\x20Reduce\x20the\x20quantity,\x20choose\x20another\x20item,\x20or\x20ask\x20the\x20merchant\x20to\x20restock.'},'sale_suspended':{'error_code':'sale_suspended','strategy':'adjust_params','max_attempts':0x1,'automation':'semi','detail':'The\x20merchant\x20suspended\x20this\x20sale\x20item\x20(Move\x20service:34\x20E_SALE_SUSPENDED).\x201.\x20Pick\x20another\x20(non-suspended)\x20item\x202.\x20Contact\x20the\x20merchant\x20to\x20resume\x20the\x20sale,\x20then\x20retry','user_prompt':'The\x20sale\x20item\x20is\x20suspended\x20by\x20the\x20merchant.\x20Please\x20choose\x20another\x20item\x20or\x20contact\x20the\x20merchant.'},'discount_invalid':{'error_code':'discount_invalid','strategy':'adjust_params','max_attempts':0x1,'automation':'semi','detail':'The\x20discount\x20is\x20outside\x20its\x20[time_start,\x20time_end]\x20validity\x20window\x20(Move\x20service:35\x20E_DISCOUNT_TIME_INVALID).\x201.\x20Retry\x20without\x20the\x20discount\x202.\x20Ask\x20the\x20merchant\x20for\x20a\x20fresh\x20discount,\x20then\x20retry','user_prompt':'The\x20discount\x20is\x20not\x20valid\x20at\x20the\x20current\x20time\x20(outside\x20its\x20validity\x20window).\x20Buy\x20without\x20the\x20discount\x20or\x20ask\x20the\x20merchant\x20for\x20a\x20new\x20one.'},'rate_limit':{'error_code':'rate_limit','strategy':'retry','max_attempts':0x5,'automation':'full','detail':'Rate\x20limit\x20hit\x20(HTTP\x20429).\x20Exponential\x20backoff\x20retry:\x202s\x20/\x204s\x20/\x208s\x20/\x2016s\x20/\x2032s.\x20Avoid\x20parallel\x20calls\x20while\x20the\x20limit\x20window\x20is\x20active.'},'gas_exceeded':{'error_code':'gas_exceeded','strategy':'adjust_params','max_attempts':0x3,'automation':'semi','detail':'Gas\x20budget\x20exceeded.\x201.\x20Increase\x20the\x20gas_budget\x20parameter\x202.\x20Reduce\x20the\x20operation\x20size\x20(fewer\x20objects\x20per\x20transaction)\x203.\x20Retry\x20the\x20original\x20operation','user_prompt':'Gas\x20budget\x20exceeded.\x20Increase\x20the\x20gas\x20budget\x20or\x20reduce\x20the\x20operation\x20size,\x20then\x20retry.'},'bcs_error':{'error_code':'bcs_error','strategy':'adjust_params','max_attempts':0x2,'automation':'semi','detail':'BCS\x20serialization/deserialization\x20error\x20—\x20a\x20parameter\x20does\x20not\x20match\x20the\x20expected\x20type/structure.\x201.\x20Query\x20the\x20operation\x20schema\x20(schema_query)\x202.\x20Fix\x20the\x20offending\x20parameter\x20type\x20(e.g.\x20BigInt\x20vs\x20number,\x20vector\x20element\x20type)\x203.\x20Retry','user_prompt':'A\x20parameter\x20failed\x20serialization.\x20Check\x20the\x20parameter\x20types\x20against\x20the\x20schema\x20and\x20retry.'},'signature_error':{'error_code':'signature_error','strategy':'switch_account','max_attempts':0x2,'automation':'semi','detail':'Signature\x20verification\x20failed.\x201.\x20Verify\x20the\x20account\x20is\x20not\x20suspended\x202.\x20Check\x20the\x20network\x20matches\x20the\x20account\x27s\x203.\x20Switch\x20to\x20a\x20healthy\x20account\x20and\x20retry','user_prompt':'Signature\x20verification\x20failed.\x20The\x20account\x20may\x20be\x20suspended\x20or\x20misconfigured.\x20Switch\x20accounts\x20or\x20check\x20the\x20configuration\x20and\x20retry.'},'config_error':{'error_code':'config_error','strategy':'escalate_human','max_attempts':0x1,'automation':'manual','detail':'Local\x20configuration\x20error\x20(network\x20not\x20specified,\x20persistent\x20storage\x20not\x20set).\x201.\x20Show\x20the\x20user\x20which\x20configuration\x20is\x20missing\x202.\x20Guide\x20the\x20user\x20through\x20the\x20account_operation/config\x20setup\x203.\x20Retry\x20after\x20the\x20user\x20fixes\x20it','user_prompt':'Local\x20configuration\x20is\x20incomplete.\x20Please\x20finish\x20the\x20account/network\x20setup\x20and\x20retry.'},'wip_verification_failed':{'error_code':'wip_verification_failed','strategy':'adjust_params','max_attempts':0x2,'automation':'semi','detail':'WIP\x20file\x20not\x20publicly\x20reachable\x20/\x20hash\x20mismatch.\x201.\x20Upload\x20via\x20the\x20wip\x20storage\x20service\x20(wip_file\x20type=\x27upload\x27\x20—\x20official\x20free\x20store\x20or\x20storage=\x27custom\x27)\x202.\x20Or\x20deploy\x20to\x20a\x20public\x20URL\x20(GitHub\x20Pages\x20/\x20IPFS\x20/\x20own\x20site)\x203.\x20Update\x20the\x20sale\x27s\x20wip\x20URL\x204.\x20Re-run\x20the\x20operation','user_prompt':'The\x20WIP\x20file\x20could\x20not\x20be\x20verified\x20from\x20a\x20public\x20URL.\x20Upload\x20it\x20with\x20wip_file\x20type=\x27upload\x27\x20(official\x20free\x20store\x20or\x20your\x20own\x20service)\x20or\x20deploy\x20it\x20(GitHub\x20Pages\x20/\x20IPFS),\x20update\x20the\x20sale\x27s\x20WIP\x20URL,\x20and\x20retry.'},'wip_storage_unavailable':{'error_code':'wip_storage_unavailable','strategy':'retry','max_attempts':0x3,'automation':'full','detail':'Transient\x20wip\x20storage\x20transport\x20failure.\x201.\x20Retry\x20the\x20same\x20request\x20with\x20bounded\x20backoff\x202.\x20Large\x20WIP\x20files\x20are\x20network-sensitive:\x20compress\x20images\x20before\x20generate\x20(each\x20image\x20<=\x202MB,\x20total\x20<=\x2010MB)\x203.\x20Check\x20connectivity\x20to\x20the\x20storage\x20base\x20URL\x20if\x20retries\x20keep\x20failing','user_prompt':'The\x20wip\x20storage\x20request\x20failed\x20due\x20to\x20a\x20network\x20problem.\x20Retry\x20the\x20upload;\x20if\x20it\x20keeps\x20failing,\x20reduce\x20the\x20file\x20size\x20or\x20check\x20connectivity.'},'network_error':{'error_code':'network_error','strategy':'retry','max_attempts':0x5,'automation':'full','detail':'Exponential\x20backoff\x20retry:\x201s\x20/\x202s\x20/\x204s\x20/\x208s\x20/\x2016s.\x20Switch\x20RPC\x20node\x20if\x20available.'},'submission_unknown':{'error_code':'submission_unknown','strategy':'query_and_retry','max_attempts':0x2,'automation':'semi','detail':'Transport-level\x20failure\x20after\x20the\x20request\x20left\x20the\x20client\x20—\x20the\x20submission\x20state\x20is\x20UNKNOWN\x20and\x20the\x20transaction\x20may\x20already\x20be\x20committed.\x20NEVER\x20auto-retry\x20a\x20write\x20here.\x201.\x20Verify\x20commit\x20state\x20on-chain:\x20query_toolkit\x20for\x20the\x20object\x20this\x20call\x20would\x20create/modify\x20(resolve\x20the\x20reference\x20from\x20the\x20call\x27s\x20own\x20arguments),\x20or\x20onchain_events\x20for\x20the\x20sender\x27s\x20recent\x20transactions.\x202.\x20If\x20the\x20expected\x20object\x20EXISTS,\x20adopt\x20it\x20and\x20continue\x20the\x20workflow\x20(the\x20operation\x20succeeded\x20despite\x20the\x20transport\x20error).\x203.\x20If\x20confirmed\x20ABSENT,\x20resubmit\x20the\x20SAME\x20call\x20once.\x204.\x20Reads\x20are\x20idempotent\x20—\x20retry\x20immediately.\x20Live\x20mainnet\x20incident\x20behind\x20this\x20rule:\x20an\x20order_new\x20-32603\x20\x27did\x20not\x20complete\x27\x20had\x20committed;\x20the\x20blind\x20retry\x20created\x20a\x20second\x20order\x20with\x20a\x20second\x20full\x20escrow\x20and\x20a\x20second\x20stock\x20decrement','user_prompt':'The\x20request\x20failed\x20at\x20transport\x20level\x20but\x20may\x20have\x20already\x20been\x20committed\x20on-chain.\x20Verify\x20whether\x20the\x20expected\x20object\x20exists\x20(query\x20it)\x20before\x20any\x20retry\x20—\x20a\x20blind\x20retry\x20can\x20duplicate\x20the\x20operation\x20(double\x20escrow).\x20For\x20read\x20operations,\x20a\x20plain\x20retry\x20is\x20safe.'},'transaction_expired':{'error_code':'transaction_expired','strategy':'retry','max_attempts':0x3,'automation':'full','detail':'The\x20transaction\x20expired\x20before\x20execution\x20(epoch\x20boundary\x20or\x20validator/gateway\x20outage)\x20—\x20it\x20did\x20NOT\x20land\x20and\x20nothing\x20was\x20committed.\x20Bounded\x20backoff\x20retry:\x2010s\x20/\x2030s\x20/\x2060s,\x20resubmit\x20the\x20SAME\x20call\x20unchanged.\x20If\x20a\x20dry_run\x20passes\x20while\x20the\x20real\x20call\x20keeps\x20failing,\x20the\x20fault\x20is\x20chain-side\x20—\x20wait\x20it\x20out.\x20Verify\x20with\x20onchain_events\x20if\x20unsure.'},'guard_rejected':{'error_code':'guard_rejected','strategy':'fill_submission','max_attempts':0x2,'automation':'semi','detail':'1.\x20Parse\x20Guard\x20table\x20structure\x202.\x20If\x20the\x20Guard\x20defines\x20submission\x20items,\x20fill\x20them\x20and\x20resubmit\x20with\x20call_with_submission\x203.\x20If\x20it\x20defines\x20none,\x20the\x20rule\x20evaluated\x20false\x20—\x20typical\x20causes:\x20a\x20TIME\x20WINDOW\x20(Clock\x20deadline/opening\x20comparison\x20—\x20this\x20call\x20may\x20sit\x20outside\x20the\x20window,\x20and\x20a\x20mis-oriented\x20comparison\x20inverts\x20it:\x20everything\x20inside\x20rejected,\x20everything\x20after\x20admitted)\x20or\x20an\x20IDENTITY\x20condition\x20(signer/state\x20checks\x20—\x20the\x20caller\x20may\x20not\x20be\x20the\x20address\x20the\x20rule\x20expects);\x20adjust\x20the\x20call\x27s\x20parameters\x20or\x20change\x20the\x20Guard\x20(docs#40)\x204.\x20When\x20the\x20failure\x20is\x20passport\x20E_VERIFY_FAILED\x20and\x20a\x20submission\x20was\x20supplied,\x20the\x20response\x20appends\x20a\x20\x27Guard\x20diagnosis\x20(dry-run)\x27\x20line\x20naming\x20the\x20first\x20failing\x20impact\x20guard\x20—\x20fix\x20that\x20guard\x20first','user_prompt':'Guard\x20verification\x20rejected.\x20If\x20the\x20Guard\x20defines\x20submission\x20items,\x20fill\x20in\x20the\x20required\x20submission\x20data\x20and\x20resubmit;\x20if\x20it\x20defines\x20none,\x20the\x20Guard\x20rule\x20evaluated\x20false\x20—\x20the\x20usual\x20causes\x20are\x20a\x20time\x20window\x20(this\x20call\x20may\x20be\x20outside\x20the\x20Clock\x20deadline/opening\x20window)\x20or\x20an\x20identity\x20condition\x20(the\x20caller\x20is\x20not\x20the\x20address\x20the\x20rule\x20expects);\x20adjust\x20this\x20call\x27s\x20parameters\x20or\x20change\x20the\x20Guard\x20rule.\x20When\x20the\x20response\x20includes\x20a\x20\x27Guard\x20diagnosis\x20(dry-run)\x27\x20line,\x20it\x20names\x20the\x20first\x20failing\x20impact\x20guard\x20—\x20address\x20that\x20guard\x20first.'},'time_lock_not_elapsed':{'error_code':'time_lock_not_elapsed','strategy':'wait_and_retry','max_attempts':0x1,'automation':'semi','detail':'1.\x20Verify\x20Service\x20is\x20paused\x20(bPaused=true).\x20If\x20not,\x20submit\x20pause=true\x20first.\x202.\x20Wait\x20until\x20paused_time\x20+\x20setting_lock_duration\x20<=\x20current\x20clock.\x203.\x20Retry\x20the\x20original\x20operation.\x20Do\x20NOT\x20recreate\x20the\x20object.','user_prompt':'Service\x20setting_lock_duration\x20has\x20not\x20elapsed\x20since\x20the\x20Service\x20was\x20paused.\x20Please\x20pause\x20the\x20Service\x20if\x20it\x20is\x20not\x20already\x20paused,\x20wait\x20for\x20the\x20lock\x20duration\x20to\x20elapse,\x20then\x20retry.'},'immutable_violation':{'error_code':'immutable_violation','strategy':'recreate','max_attempts':0x1,'automation':'semi','detail':'1.\x20Stop\x20modification\x20attempt\x202.\x20Evaluate\x20creating\x20a\x20new\x20object\x20as\x20replacement\x203.\x20Re-plan\x20affected\x20phases','user_prompt':'Cannot\x20modify\x20an\x20immutable\x20object.\x20A\x20new\x20object\x20must\x20be\x20created\x20as\x20a\x20replacement.\x20Confirm\x20to\x20proceed\x20with\x20recreation.'},'permission_denied':{'error_code':'permission_denied','strategy':'switch_account','max_attempts':0x2,'automation':'semi','detail':'1.\x20Query\x20object\x27s\x20permission_guard\x202.\x20List\x20accounts\x20with\x20permission\x203.\x20Switch\x20account\x20or\x20prompt\x20user\x20to\x20add\x20permission','user_prompt':'Current\x20account\x20lacks\x20permission\x20for\x20this\x20operation.\x20Switch\x20to\x20an\x20authorized\x20account\x20or\x20update\x20the\x20Permission\x20object.'},'object_not_found':{'error_code':'object_not_found','strategy':'query_and_retry','max_attempts':0x3,'automation':'semi','detail':'1.\x20Verify\x20the\x20referenced\x20name/ID\x20spelling\x20(local_mark_list)\x20and\x20that\x20the\x20object\x20exists\x20on\x20the\x20current\x20network\x202.\x20If\x20recently\x20created,\x20re-query\x20the\x20object\x20(may\x20be\x20sync\x20delay)\x203.\x20If\x20truly\x20absent,\x20search\x20for\x20similar\x20objects\x204.\x20Prompt\x20user\x20to\x20reselect','user_prompt':'Referenced\x20object\x20not\x20found.\x20First\x20verify\x20the\x20name/ID\x20spelling\x20and\x20that\x20the\x20object\x20exists\x20on\x20the\x20current\x20network;\x20if\x20it\x20was\x20created\x20recently,\x20this\x20may\x20be\x20a\x20synchronization\x20delay\x20—\x20retry.\x20If\x20the\x20issue\x20persists,\x20please\x20select\x20a\x20valid\x20object.'},'state_conflict':{'error_code':'state_conflict','strategy':'adjust_params','max_attempts':0x2,'automation':'full','detail':'1.\x20Query\x20object\x27s\x20current\x20true\x20state\x202.\x20Update\x20ODG\x20status\x20annotations\x203.\x20Adjust\x20subsequent\x20operations\x20(e.g.,\x20skip\x20completed\x20steps)'},'invalid_parameter':{'error_code':'invalid_parameter','strategy':'adjust_params','max_attempts':0x2,'automation':'semi','detail':'1.\x20Query\x20the\x20relevant\x20schema\x202.\x20Auto-fix\x20obvious\x20errors\x20(e.g.,\x20BigInt\x20vs\x20string)\x203.\x20If\x20unfixable,\x20prompt\x20user','user_prompt':'Parameter\x20validation\x20failed.\x20Please\x20check\x20the\x20parameter\x20types\x20and\x20values\x20against\x20the\x20schema\x20and\x20retry.'},'unknown':{'error_code':'unknown','strategy':'escalate_human','max_attempts':0x1,'automation':'manual','detail':'1.\x20Report\x20full\x20error\x20context\x20to\x20the\x20user\x202.\x20Escalate\x20to\x20human\x20intervention\x203.\x20Flag\x20for\x20error-classification\x20rule\x20addition','user_prompt':'An\x20unclassified\x20error\x20occurred.\x20Please\x20review\x20the\x20error\x20details\x20and\x20contact\x20support\x20if\x20needed.'}};const operationAttempts=new Map();function getAttemptCount(a,b){const c=operationAttempts['get'](a);if(!c)return 0x0;return c['get'](b)??0x0;}function incrementAttempt(a,b){!operationAttempts['has'](a)&&operationAttempts['set'](a,new Map());const c=operationAttempts['get'](a),d=(c['get'](b)??0x0)+0x1;return c['set'](b,d),d;}function getTotalAttempts(a){const b=operationAttempts['get'](a);if(!b)return 0x0;let c=0x0;for(const d of b['values']())c+=d;return c;}export function resetAttempts(a){operationAttempts['delete'](a);}export function recover(a,b,c){const d=RECOVERY_RULES[a]??RECOVERY_RULES['unknown'],e=0x5,f=getTotalAttempts(b),g=getAttemptCount(b,a);if(f>=e)return{'strategy':'stop','should_retry':![],'max_attempts':e,'current_attempt':f,'detail':'Total\x20retry\x20limit\x20('+e+')\x20reached\x20for\x20operation\x20'+b+'.\x20Escalating\x20to\x20human\x20intervention.','user_prompt':'Maximum\x20retry\x20attempts\x20reached.\x20Manual\x20intervention\x20required.'};if(g>=d['max_attempts'])return{'strategy':'escalate_human','should_retry':![],'max_attempts':d['max_attempts'],'current_attempt':g,'detail':'Per-error-code\x20retry\x20limit\x20('+d['max_attempts']+')\x20reached\x20for\x20'+a+'.\x20Escalating\x20to\x20human.','user_prompt':'Recovery\x20attempts\x20for\x20'+a+'\x20exhausted.\x20Manual\x20intervention\x20required.'};const h=incrementAttempt(b,a);return{'strategy':d['strategy'],'should_retry':d['automation']==='full'||h<d['max_attempts'],'max_attempts':d['max_attempts'],'current_attempt':h,'adjusted_params':d['adjusted_params'],'user_prompt':d['user_prompt'],'detail':d['detail']};}export function getBackoffDelay(a){return Math['pow'](0x2,a-0x1)*0x3e8;}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{MAX_SHARING_COUNT,MAX_ALLOCATOR_COUNT}from'@wowok/wowok';export{MAX_ALLOCATOR_COUNT};export const ALLOCATION_MAX_SHARING_COUNT=MAX_SHARING_COUNT;export const ALLOCATION_MODE_AMOUNT=0x0;export const ALLOCATION_MODE_RATE=0x1;export const ALLOCATION_MODE_SURPLUS=0x2;export const ALLOCATION_MODE_RATE_GROSS=0x3;export const RATE_TOTAL_FULL=0x2710;export const ALLOCATION_ERROR_CODES={'ERECIPIENT_IDENTIFIER_NOT_ADDRESS':0x1,'EALLOCATOR_COUNT_EXCEEDED':0x2,'ENO_ALLOCATOR':0x3,'ERATE_NOT_10000':0x4,'EMULTIPLE_SURPLUS':0x5,'ERATE_EXCEEDS_10000':0x6,'EINSUFFICIENT_BALANCE':0x7,'EALLOCATORS_EMPTY':0x8,'ENO_PAYMENT_INFO':0x9,'ESHARING_COUNT_EXCEEDED':0xa,'ESHARING_MODE_INVALID':0xb,'EAMOUNT_BELOW_THRESHOLD':0xc,'EAMOUNT_EXCEEDS_MAX':0xd,'EZERO_DISTRIBUTION':0xe,'ERECIPIENT_NOT_FOR_OBJECT':0xf,'E_ONCE_TRIGGERED':0x10,'EMIXED_RATE_BASES':0x11};export const ORDER_ALLOCATION_ALREADY_SPECIFIED='E_ALLOCATION_ALREADY_SPECIFIED';export const ALLOCATION_SCENES=[{'id':'allocation_standard_three_way_split','name':'Standard\x20three-way\x20split\x20(merchant\x20/\x20platform\x20/\x20logistics)','trigger_source':'service_order_allocators','distribution_strategy':'pure_rate','coin_type_note':'All\x20three\x20Treasury\x20objects\x20must\x20use\x20the\x20same\x20Coin<T>\x20type\x20as\x20the\x20Allocation','typical_allocator_count':0x1,'sharing_who_types':['Entity'],'modes_used':['Rate'],'guard_requirement':'required','non_zero_threshold':![],'uses_max':![],'common_patterns':['Single\x20Allocator,\x203\x20Rate\x20sharing\x20items,\x20sum(rates)\x20===\x2010000','Each\x20sharing.who=Entity\x20points\x20to\x20a\x20Treasury\x20address','Guard\x20verifies\x20order.service\x20binding\x20(query\x201563)\x20to\x20prevent\x20cross-project\x20bypass','Guard\x20verifies\x20progress.current_node\x20===\x20\x27Complete\x27'],'dependencies':['Service','Treasury','Guard','Order','Progress','Machine','Payment'],'key_constraints':['F-A-05:\x20sum(rates)\x20===\x2010000\x20(pure\x20Rate\x20mode)','Treasury\x20Permission\x20should\x20match\x20Service\x20Permission\x20(R-A-12)','order_allocators\x20immutable\x20after\x20Service\x20publish\x20(R-A-10)'],'recommended_templates':['T-A-02']},{'id':'allocation_merchant_full_payment','name':'Merchant\x20full\x20payment\x20(single\x20recipient,\x20100%)','trigger_source':'service_order_allocators','distribution_strategy':'pure_rate','coin_type_note':'Simplest\x20configuration\x20—\x20single\x20Treasury\x20or\x20personal\x20address','typical_allocator_count':0x1,'sharing_who_types':['Entity'],'modes_used':['Rate'],'guard_requirement':'single_relaxed','non_zero_threshold':![],'uses_max':![],'common_patterns':['Single\x20Allocator,\x201\x20Rate\x20sharing\x20=\x2010000','Guard\x20only\x20verifies\x20order\x20status\x20(no\x20complex\x20conditions)','who=Entity\x20can\x20be\x20either\x20Treasury\x20or\x20personal\x20wallet'],'dependencies':['Service','Guard','Order','Payment'],'key_constraints':['Simplest\x20allocation\x20configuration','No\x20multi-party\x20coordination\x20required'],'recommended_templates':['T-A-01']},{'id':'allocation_refund_first_surplus_to_merchant','name':'Refund\x20first\x20+\x20surplus\x20to\x20merchant\x20(Amount\x20+\x20Surplus\x20hybrid)','trigger_source':'service_order_allocators','distribution_strategy':'amount_plus_surplus','coin_type_note':'Refund\x20amount\x20must\x20match\x20Coin<T>\x20precision','typical_allocator_count':0x1,'sharing_who_types':['Entity'],'modes_used':['Amount','Surplus'],'guard_requirement':'required','non_zero_threshold':!![],'uses_max':![],'common_patterns':['Single\x20Allocator,\x202\x20sharing\x20items','sharing[0]:\x20Amount=refund_value,\x20who=Entity(customer_address)','sharing[1]:\x20Surplus,\x20who=Entity(merchant_treasury)','fix\x20=\x20refund_value\x20(cached\x20Amount\x20sum)','threshold\x20=\x20refund_value\x20(ensure\x20sufficient\x20balance\x20for\x20Amount)'],'dependencies':['Service','Treasury','Guard','Order','Payment'],'key_constraints':['F-A-04:\x20at\x20most\x201\x20Surplus\x20per\x20Allocator','F-A-07:\x20fix\x20>=\x20threshold\x20(Amount\x20sum\x20must\x20cover\x20threshold)','fix\x20must\x20precisely\x20match\x20the\x20refund\x20amount'],'recommended_templates':['T-A-03']},{'id':'allocation_treasury_personal_alternatives','name':'Treasury\x20+\x20Personal\x20alternative\x20strategies\x20(caller-specified\x20guard)','trigger_source':'service_order_allocators','distribution_strategy':'first_match_alternatives','coin_type_note':'Both\x20target\x20addresses\x20must\x20accept\x20the\x20same\x20Coin<T>','typical_allocator_count':0x2,'sharing_who_types':['Entity'],'modes_used':['Rate'],'guard_requirement':'multiple_unique','non_zero_threshold':![],'uses_max':![],'common_patterns':['2\x20Allocators,\x20each\x20with\x201\x20Rate=10000\x20sharing','Allocator[0]:\x20guard=guard_treasury,\x20who=Entity(treasury_address)','Allocator[1]:\x20guard=guard_personal,\x20who=Entity(personal_address)','Two\x20Guard\x20objects\x20must\x20be\x20different\x20addresses\x20(R-A-11)','caller-specified\x20guard:\x20caller\x20selects\x20Treasury\x20or\x20Personal\x20path\x20via\x20alloc_by_guard;\x20the\x20Passport\x20hard-verifies\x20the\x20selected\x20Guard\x20(failure\x20aborts\x20with\x20E_VERIFY_FAILED;\x20caller\x20must\x20switch\x20guard\x20and\x20retry)'],'dependencies':['Service','Treasury','Guard','Order','Payment'],'key_constraints':['F-A-14:\x20allocators[].guard\x20must\x20be\x20unique','Treasury\x20Permission\x20should\x20match\x20Service\x20Permission\x20(R-A-12)','Guard\x20A\x20and\x20Guard\x20B\x20may\x20share\x20root/table\x20but\x20must\x20differ\x20in\x20description'],'recommended_templates':['T-A-04']},{'id':'allocation_tiered_by_order_amount','name':'Tiered\x20split\x20by\x20order\x20amount\x20(multi-Allocator\x20amount-threshold\x20switch)','trigger_source':'service_order_allocators','distribution_strategy':'tiered_by_amount','coin_type_note':'Amount\x20threshold\x20uses\x20Coin<T>\x20smallest\x20unit\x20(e.g.\x20MIST\x20for\x20WOW)','typical_allocator_count':0x2,'sharing_who_types':['Entity'],'modes_used':['Rate'],'guard_requirement':'multiple_unique','non_zero_threshold':![],'uses_max':![],'common_patterns':['2\x20Allocators\x20triggered\x20by\x20mutually\x20exclusive\x20Guard\x20conditions','Allocator[0]:\x20guard\x20verifies\x20order.amount\x20<\x20threshold,\x20Rate=10000\x20to\x20merchant','Allocator[1]:\x20guard\x20verifies\x20order.amount\x20>=\x20threshold,\x20Rate=8000/2000\x20split','caller-specified\x20guard:\x20caller\x20selects\x20the\x20matching\x20Allocator\x20based\x20on\x20order\x20amount;\x20allocator\x20order\x20is\x20irrelevant','Guard\x20queries\x20order.amount\x20(query\x201561)'],'dependencies':['Service','Treasury','Guard','Order','Payment'],'key_constraints':['Guard\x20conditions\x20must\x20be\x20mutually\x20exclusive\x20(R-A-4-02\x20design\x20clarity)','Caller\x20must\x20select\x20correct\x20guard\x20based\x20on\x20order.amount\x20(no\x20auto-fallback)'],'recommended_templates':['T-A-05']},{'id':'allocation_dynamic_recipient','name':'Multi-role\x20split\x20with\x20dynamic\x20recipient\x20(GuardIdentifier)','trigger_source':'service_order_allocators','distribution_strategy':'dynamic_recipient','coin_type_note':'Passport\x20table\x20must\x20contain\x20address-typed\x20entry\x20at\x20the\x20referenced\x20identifier','typical_allocator_count':0x1,'sharing_who_types':['Entity','GuardIdentifier'],'modes_used':['Rate'],'guard_requirement':'required','non_zero_threshold':![],'uses_max':![],'common_patterns':['Single\x20Allocator,\x203\x20Rate\x20sharing\x20items','sharing[0]:\x20Rate=8000,\x20who=Entity(merchant_treasury)','sharing[1]:\x20Rate=1000,\x20who=Entity(platform_treasury)','sharing[2]:\x20Rate=1000,\x20who=GuardIdentifier(0)\x20—\x20resolves\x20from\x20Passport\x20table','Customer\x20submits\x20Passport\x20with\x20referrer\x20address\x20at\x20identifier=0'],'dependencies':['Service','Treasury','Guard','Passport','Order','Payment'],'key_constraints':['F-A-13:\x20Passport\x20table[identifier]\x20must\x20be\x20address\x20type\x20(else\x20ERECIPIENT_IDENTIFIER_NOT_ADDRESS)','Guard\x20must\x20verify\x20Passport\x20completeness','Customer\x20order\x20must\x20include\x20Passport\x20with\x20referrer\x20address'],'recommended_templates':['T-A-06']},{'id':'allocation_arbitration_fees','name':'Arbitration\x20fees\x20split\x20(arbitrator\x20/\x20platform)','trigger_source':'arbitration_fees','distribution_strategy':'pure_rate','coin_type_note':'Coin<T>\x20must\x20match\x20Arbitration\x27s\x20fee\x20Coin\x20type','typical_allocator_count':0x1,'sharing_who_types':['Entity'],'modes_used':['Rate'],'guard_requirement':'required','non_zero_threshold':![],'uses_max':![],'common_patterns':['Triggered\x20by\x20the\x20Arbitration\x20fee-allocation\x20operation\x20(permission\x20365),\x20direct\x20or\x20Passport\x20path','Single\x20Allocator,\x202\x20Rate\x20sharing\x20items:\x208000\x20arbitrator\x20/\x202000\x20platform','payment_info\x20reuses\x20Arbitration\x27s\x20payment_info','Caller\x20must\x20hold\x20ARBITRATION_FEES_ALLOC=365\x20permission'],'dependencies':['Arbitration','Treasury','Guard','Payment'],'key_constraints':['Independent\x20from\x20Service-order\x20Allocation','Requires\x20ARBITRATION_FEES_ALLOC=365\x20permission'],'recommended_templates':['T-A-08']},{'id':'allocation_refund_to_order','name':'Refund\x20Allocator\x20(100%\x20to\x20Order\x20object)','trigger_source':'service_order_allocators','distribution_strategy':'refund_to_order','coin_type_note':'who=Entity\x20must\x20be\x20the\x20Order\x20object\x20address\x20(NOT\x20a\x20personal\x20wallet)','typical_allocator_count':0x1,'sharing_who_types':['Entity'],'modes_used':['Rate'],'guard_requirement':'required','non_zero_threshold':![],'uses_max':![],'common_patterns':['Single\x20Allocator,\x201\x20Rate=10000\x20sharing','who=Entity(order_address)\x20—\x20funds\x20flow\x20back\x20to\x20Order,\x20not\x20personal\x20wallet','Guard\x20verifies\x20customer\x20refund\x20request\x20and\x20eligibility','Customer-side\x20risk\x20assessment\x20adds\x208-point\x20weight\x20(onchain_topology\x20graph\x20evaluation)'],'dependencies':['Service','Guard','Order','Payment'],'key_constraints':['who=Entity\x20MUST\x20be\x20Order\x20object\x20address\x20(not\x20personal\x20address)','Customer\x20due-diligence\x20rewards\x20this\x20configuration\x20(8-point\x20weight)','Refund\x20funds\x20return\x20to\x20Order\x20for\x20downstream\x20handling'],'recommended_templates':['T-A-07']},{'id':'allocation_max_capped_retain','name':'Max-capped\x20allocation\x20(retain\x20residual\x20balance)','trigger_source':'service_order_allocators','distribution_strategy':'max_capped','coin_type_note':'max\x20field\x20uses\x20Coin<T>\x20smallest\x20unit','typical_allocator_count':0x1,'sharing_who_types':['Entity'],'modes_used':['Amount','Rate'],'guard_requirement':'required','non_zero_threshold':!![],'uses_max':!![],'common_patterns':['Single\x20Allocator\x20with\x20max\x20field\x20set','max\x20triple\x20role:\x20Amount\x20cap\x20+\x20NET\x20Rate\x20base\x20+\x20Surplus\x20cap','Amount\x20sharing\x20consumes\x20fix;\x20NET\x20Rate\x20sharing\x20uses\x20(max\x20-\x20fix)\x20as\x20base\x20(RateGross\x20uses\x20max\x20itself)','Residual\x20balance\x20remains\x20in\x20Allocation\x20for\x20subsequent\x20alloc()\x20calls'],'dependencies':['Service','Treasury','Guard','Order','Payment'],'key_constraints':['F-A-08:\x20Amount\x20sum\x20<=\x20max\x20(EAMOUNT_EXCEEDS_MAX)','NET\x20Rate:\x20max\x20-\x20fix\x20becomes\x20the\x20base\x20(NOT\x20balance\x20-\x20fix);\x20RateGross:\x20the\x20base\x20is\x20max\x20(fix\x20not\x20removed)','Residual\x20balance\x20may\x20be\x20claimed\x20by\x20re-triggering\x20alloc()'],'recommended_templates':[]},{'id':'allocation_multi_node_trigger','name':'Multi-Machine-node\x20triggered\x20allocation\x20(Complete\x20/\x20Refund\x20/\x20Lost)','trigger_source':'service_order_allocators','distribution_strategy':'multi_node_trigger','coin_type_note':'All\x20Allocators\x20share\x20the\x20same\x20Allocation\x27s\x20Coin<T>','typical_allocator_count':0x3,'sharing_who_types':['Entity'],'modes_used':['Rate'],'guard_requirement':'multiple_unique','non_zero_threshold':![],'uses_max':![],'common_patterns':['3\x20Allocators\x20mapped\x20to\x20Machine\x20terminal\x20nodes\x20(Complete/Refund/Lost)','Each\x20Allocator\x27s\x20Guard\x20verifies\x20progress.current_node\x20==\x20<node_name>','Mutually\x20exclusive\x20Guard\x20conditions\x20(only\x20one\x20terminal\x20node\x20active\x20at\x20a\x20time)','Machine.required_allocators[]\x20describes\x20each\x20trigger_node\x20mapping'],'dependencies':['Service','Treasury','Guard','Order','Progress','Machine','Payment'],'key_constraints':['Guard\x20conditions\x20must\x20be\x20mutually\x20exclusive','Sequence-sensitive:\x20business-flow\x20order','Machine.required_allocators[trigger_node]\x20must\x20map\x20to\x20Allocator\x20indices'],'recommended_templates':[]},{'id':'allocation_standalone_periodic_split','name':'Standalone\x20periodic\x20split\x20(investment\x20dividends\x20/\x20shared\x20income)','trigger_source':'standalone','distribution_strategy':'periodic_split','coin_type_note':'Coin<T>\x20must\x20match\x20the\x20asset\x20being\x20distributed\x20(e.g.\x20profit\x20token)','typical_allocator_count':0x1,'sharing_who_types':['Entity'],'modes_used':['Rate'],'guard_requirement':'required','non_zero_threshold':![],'uses_max':![],'common_patterns':['Single\x20Allocator,\x20N\x20Rate\x20sharing\x20items,\x20sum(rates)\x20===\x2010000','Each\x20sharing.who=Entity\x20points\x20to\x20a\x20beneficiary\x20wallet\x20(not\x20Treasury)','Guard\x20verifies\x20time-based\x20trigger\x20(e.g.\x20context(Clock).timestamp\x20>=\x20next_release)\x20or\x20signer\x20authorization','User\x20calls\x20receive()\x20to\x20deposit\x20funds,\x20then\x20alloc()\x20to\x20trigger\x20distribution','No\x20Service/Order/Progress/Machine\x20context\x20required'],'dependencies':['Treasury','Guard','Payment'],'key_constraints':['F-A-05:\x20sum(rates)\x20===\x2010000\x20(pure\x20Rate\x20mode)','R-A-3-04:\x20standalone\x20mode\x20has\x20no\x20Service-layer\x20access\x20control\x20—\x20Guard\x20+\x20Passport\x20MUST\x20be\x20sufficient','Caller\x20is\x20fully\x20responsible\x20for\x20receive\x20→\x20alloc\x20lifecycle\x20(no\x20auto-trigger)','Guard\x20should\x20bind\x20Signer\x20to\x20prevent\x20unauthorized\x20alloc()\x20calls'],'recommended_templates':['T-A-09']},{'id':'allocation_standalone_vesting','name':'Standalone\x20vesting\x20release\x20(time-locked\x20multi-stage\x20unlock)','trigger_source':'standalone','distribution_strategy':'time_locked_vesting','coin_type_note':'Coin<T>\x20must\x20match\x20the\x20vested\x20asset\x20(e.g.\x20locked\x20team\x20tokens)','typical_allocator_count':0x3,'sharing_who_types':['Entity'],'modes_used':['Amount','Rate','Surplus'],'guard_requirement':'multiple_unique','non_zero_threshold':!![],'uses_max':!![],'common_patterns':['N\x20Allocators,\x20each\x20mapped\x20to\x20a\x20vesting\x20stage\x20(e.g.\x2025%\x20at\x20month\x2012,\x2025%\x20at\x20month\x2024,\x2050%\x20surplus\x20at\x20month\x2036)','Each\x20Allocator\x27s\x20Guard\x20verifies\x20context(Clock).timestamp\x20>=\x20stage_unlock_time','Amount\x20sharing\x20per\x20stage\x20with\x20max\x20field\x20capping\x20the\x20cumulative\x20release','Final\x20Allocator\x20uses\x20Surplus\x20to\x20drain\x20remaining\x20balance\x20after\x20last\x20vesting\x20stage','Mutually\x20exclusive\x20Guard\x20conditions\x20(only\x20one\x20stage\x20active\x20at\x20a\x20time,\x20based\x20on\x20timestamp)','User\x20calls\x20receive()\x20to\x20deposit\x20locked\x20tokens,\x20then\x20alloc()\x20at\x20each\x20vesting\x20milestone'],'dependencies':['Treasury','Guard','Passport','Payment'],'key_constraints':['F-A-04:\x20at\x20most\x201\x20Surplus\x20per\x20Allocator\x20(final\x20stage\x20uses\x20Surplus\x20to\x20drain\x20remainder)','F-A-08:\x20Amount\x20sum\x20<=\x20max\x20(EAMOUNT_EXCEEDS_MAX)','R-A-3-04:\x20standalone\x20mode\x20has\x20no\x20Service-layer\x20access\x20control\x20—\x20Guard\x20time-lock\x20MUST\x20be\x20enforced','Guard\x20conditions\x20must\x20be\x20mutually\x20exclusive\x20by\x20timestamp\x20(R-A-4-02)','Caller\x20must\x20wait\x20for\x20time-lock\x20expiry\x20before\x20alloc()\x20succeeds;\x20otherwise\x20alloc()\x20silently\x20returns\x20(R-A-4-01)'],'recommended_templates':['T-A-10']}];export const ALLOCATION_LEDGER_VERSION='1.0.0';export function getScenesByTriggerSource(a){return ALLOCATION_SCENES['filter'](b=>b['trigger_source']===a);}export function getScenesByMode(a){return ALLOCATION_SCENES['filter'](b=>b['modes_used']['includes'](a));}export function getScenesByStrategy(a){return ALLOCATION_SCENES['filter'](b=>b['distribution_strategy']===a);}export function findSceneById(a){return ALLOCATION_SCENES['find'](b=>b['id']===a);}export function inferSceneFromIntent(a){const b=a['toLowerCase']();if(b['includes']('arbitration')||b['includes']('fees\x20alloc'))return findSceneById('allocation_arbitration_fees');if(b['includes']('standalone')||b['includes']('periodic\x20split')||b['includes']('investment\x20dividend')||b['includes']('shared\x20income')||b['includes']('dividend'))return findSceneById('allocation_standalone_periodic_split');if(b['includes']('vesting')||b['includes']('time-lock')||b['includes']('unlock\x20period')||b['includes']('locked\x20release')||b['includes']('token\x20unlock'))return findSceneById('allocation_standalone_vesting');if(b['includes']('refund')){if(b['includes']('order')||b['includes']('100%'))return findSceneById('allocation_refund_to_order');if(b['includes']('surplus')||b['includes']('merchant'))return findSceneById('allocation_refund_first_surplus_to_merchant');}if(b['includes']('alternative')||b['includes']('priority')||b['includes']('treasury')&&b['includes']('personal'))return findSceneById('allocation_treasury_personal_alternatives');if(b['includes']('tiered')||b['includes']('threshold\x20switch'))return findSceneById('allocation_tiered_by_order_amount');if(b['includes']('dynamic\x20recipient')||b['includes']('referrer')||b['includes']('guardidentifier'))return findSceneById('allocation_dynamic_recipient');if(b['includes']('retain')||b['includes']('max'))return findSceneById('allocation_max_capped_retain');if(b['includes']('multi-node')||b['includes']('multi\x20machine')||b['includes']('multi_node'))return findSceneById('allocation_multi_node_trigger');const c=(a['match'](/%/g)||[])['length'];if(c<=0x1)return findSceneById('allocation_merchant_full_payment');if(c>=0x2)return findSceneById('allocation_standard_three_way_split');return undefined;}export function getAllScenes(){return[...ALLOCATION_SCENES];}export function getScenesCount(){return ALLOCATION_SCENES['length'];}export function allocationModeToNumber(a){switch(a){case'Amount':return ALLOCATION_MODE_AMOUNT;case'Rate':return ALLOCATION_MODE_RATE;case'Surplus':return ALLOCATION_MODE_SURPLUS;case'RateGross':return ALLOCATION_MODE_RATE_GROSS;}}export function allocationModeFromNumber(a){switch(a){case ALLOCATION_MODE_AMOUNT:return'Amount';case ALLOCATION_MODE_RATE:return'Rate';case ALLOCATION_MODE_SURPLUS:return'Surplus';case ALLOCATION_MODE_RATE_GROSS:return'RateGross';default:throw new Error('Invalid\x20AllocationMode\x20number:\x20'+a);}}export function getRecipientType(a){if('GuardIdentifier'in a)return'GuardIdentifier';if('Entity'in a)return'Entity';return'Signer';}export function isSignerRecipient(a){return'Signer'in a;}export function isEntityRecipient(a){return'Entity'in a;}export function isGuardIdentifierRecipient(a){return'GuardIdentifier'in a;}export function getErrorName(a){for(const [b,d]of Object['entries'](ALLOCATION_ERROR_CODES)){if(d===a)return b;}return undefined;}export function getErrorDescription(a){const b={0x1:'GuardIdentifier\x20resolved\x20value\x20is\x20not\x20an\x20address\x20type',0x2:'Allocator\x20count\x20exceeds\x20MAX_ALLOCATOR_COUNT\x20(100)',0x3:'No\x20Allocator\x20in\x20the\x20allocators\x20vector',0x4:'Pure\x20Rate\x20mode\x20sum\x20!=\x2010000\x20(no\x20Surplus\x20to\x20absorb\x20remainder)',0x5:'Multiple\x20Surplus\x20sharing\x20in\x20a\x20single\x20Allocator',0x6:'Rate\x20+\x20Surplus\x20sum\x20>\x2010000',0x7:'balance\x20<\x20threshold\x20(insufficient\x20balance\x20to\x20trigger\x20alloc)',0x8:'allocators.allocators\x20is\x20empty',0x9:'payment_info\x20is\x20None\x20when\x20alloc()\x20is\x20called',0xa:'sharing\x20count\x20exceeds\x20MAX_SHARING_COUNT\x20(100)',0xb:'sharing\x20mode\x20is\x20not\x200\x20(Amount)\x20/\x201\x20(Rate)\x20/\x202\x20(Surplus)\x20/\x203\x20(RateGross)',0xc:'Amount\x20sum\x20(fix)\x20<\x20threshold',0xd:'Amount\x20sum\x20(fix)\x20>\x20max',0xe:'distribution\x20computes\x20to\x20zero\x20while\x20the\x20pool\x20still\x20holds\x20funds\x20(or\x20balance\x20is\x200)',0xf:'GuardIdentifier\x20recipient\x20address\x20!=\x20payment_info.for_object\x20anchor\x20(abort\x20fires\x20only\x20when\x20a\x20for_object\x20binding\x20is\x20declared)',0x10:'once-trigger\x20key\x20already\x20consumed\x20—\x20the\x20guard\x20submitted\x20the\x20reserved\x20identifier\x20255\x20and\x20its\x20raw\x20submission\x20bytes\x20were\x20recorded\x20as\x20a\x20(guard,\x20allocator\x20index,\x20raw\x20bytes)\x20dynamic-field\x20key\x20on\x20this\x20Allocation',0x11:'mixed\x20rate\x20bases\x20—\x20one\x20allocator\x20carries\x20both\x20NET\x20Rate\x20and\x20RateGross\x20entries\x20while\x20a\x20fixed\x20Amount\x20total\x20is\x20present\x20(rejected\x20only\x20when\x20fix\x20>\x200;\x20with\x20fix\x20==\x200\x20the\x20two\x20bases\x20coincide\x20and\x20mixing\x20is\x20allowed)',0x12:'RateGross\x20+\x20fixed\x20Amount\x20without\x20a\x20max\x20cap\x20—\x20plan\x20payability\x20unprovable\x20at\x20declaration\x20time',0x13:'guard\x20not\x20bound\x20to\x20any\x20allocator\x20on\x20this\x20Allocation\x20(was\x20a\x20silent\x20no-op\x20success\x20before)',0x14:'order_allocators_append:\x20new\x20Allocators\x20is\x20not\x20a\x20pure\x20extension\x20(prefix/threshold\x20changed)',0x15:'once-for-object\x20slot\x20(identifier\x20254)\x20armed\x20but\x20payment_info\x20declares\x20no\x20for_object\x20binding'};return b[a];}
|
|
1
|
+
import{MAX_SHARING_COUNT,MAX_ALLOCATOR_COUNT}from'@wowok/wowok';export{MAX_ALLOCATOR_COUNT};export const ALLOCATION_MAX_SHARING_COUNT=MAX_SHARING_COUNT;export const ALLOCATION_MODE_AMOUNT=0x0;export const ALLOCATION_MODE_RATE=0x1;export const ALLOCATION_MODE_SURPLUS=0x2;export const ALLOCATION_MODE_RATE_GROSS=0x3;export const RATE_TOTAL_FULL=0x2710;export const ALLOCATION_ERROR_CODES={'ERECIPIENT_IDENTIFIER_NOT_ADDRESS':0x1,'EALLOCATOR_COUNT_EXCEEDED':0x2,'ENO_ALLOCATOR':0x3,'ERATE_NOT_10000':0x4,'EMULTIPLE_SURPLUS':0x5,'ERATE_EXCEEDS_10000':0x6,'EINSUFFICIENT_BALANCE':0x7,'EALLOCATORS_EMPTY':0x8,'ENO_PAYMENT_INFO':0x9,'ESHARING_COUNT_EXCEEDED':0xa,'ESHARING_MODE_INVALID':0xb,'EAMOUNT_BELOW_THRESHOLD':0xc,'EAMOUNT_EXCEEDS_MAX':0xd,'EZERO_DISTRIBUTION':0xe,'ERECIPIENT_NOT_FOR_OBJECT':0xf,'E_ONCE_TRIGGERED':0x10,'EMIXED_RATE_BASES':0x11};export const ORDER_ALLOCATION_ALREADY_SPECIFIED='E_ALLOCATION_ALREADY_SPECIFIED';export const ALLOCATION_SCENES=[{'id':'allocation_standard_three_way_split','name':'Standard\x20three-way\x20split\x20(merchant\x20/\x20platform\x20/\x20logistics)','trigger_source':'service_order_allocators','distribution_strategy':'pure_rate','coin_type_note':'All\x20three\x20Treasury\x20objects\x20must\x20use\x20the\x20same\x20Coin<T>\x20type\x20as\x20the\x20Allocation','typical_allocator_count':0x1,'sharing_who_types':['Entity'],'modes_used':['Rate'],'guard_requirement':'required','non_zero_threshold':![],'uses_max':![],'common_patterns':['Single\x20Allocator,\x203\x20Rate\x20sharing\x20items,\x20sum(rates)\x20===\x2010000','Each\x20sharing.who=Entity\x20points\x20to\x20a\x20Treasury\x20address','Guard\x20verifies\x20order.service\x20binding\x20(query\x201563)\x20to\x20prevent\x20cross-project\x20bypass','Guard\x20verifies\x20progress.current_node\x20===\x20\x27Complete\x27'],'dependencies':['Service','Treasury','Guard','Order','Progress','Machine','Payment'],'key_constraints':['F-A-05:\x20sum(rates)\x20===\x2010000\x20(pure\x20Rate\x20mode)','Treasury\x20Permission\x20should\x20match\x20Service\x20Permission\x20(R-A-12)','order_allocators\x20immutable\x20after\x20Service\x20publish\x20(R-A-10)'],'recommended_templates':['T-A-02']},{'id':'allocation_merchant_full_payment','name':'Merchant\x20full\x20payment\x20(single\x20recipient,\x20100%)','trigger_source':'service_order_allocators','distribution_strategy':'pure_rate','coin_type_note':'Simplest\x20configuration\x20—\x20single\x20Treasury\x20or\x20personal\x20address','typical_allocator_count':0x1,'sharing_who_types':['Entity'],'modes_used':['Rate'],'guard_requirement':'single_relaxed','non_zero_threshold':![],'uses_max':![],'common_patterns':['Single\x20Allocator,\x201\x20Rate\x20sharing\x20=\x2010000','Guard\x20only\x20verifies\x20order\x20status\x20(no\x20complex\x20conditions)','who=Entity\x20can\x20be\x20either\x20Treasury\x20or\x20personal\x20wallet'],'dependencies':['Service','Guard','Order','Payment'],'key_constraints':['Simplest\x20allocation\x20configuration','No\x20multi-party\x20coordination\x20required'],'recommended_templates':['T-A-01']},{'id':'allocation_refund_first_surplus_to_merchant','name':'Refund\x20first\x20+\x20surplus\x20to\x20merchant\x20(Amount\x20+\x20Surplus\x20hybrid)','trigger_source':'service_order_allocators','distribution_strategy':'amount_plus_surplus','coin_type_note':'Refund\x20amount\x20must\x20match\x20Coin<T>\x20precision','typical_allocator_count':0x1,'sharing_who_types':['Entity'],'modes_used':['Amount','Surplus'],'guard_requirement':'required','non_zero_threshold':!![],'uses_max':![],'common_patterns':['Single\x20Allocator,\x202\x20sharing\x20items','sharing[0]:\x20Amount=refund_value,\x20who=Entity(customer_address)','sharing[1]:\x20Surplus,\x20who=Entity(merchant_treasury)','fix\x20=\x20refund_value\x20(cached\x20Amount\x20sum)','threshold\x20=\x20refund_value\x20(ensure\x20sufficient\x20balance\x20for\x20Amount)'],'dependencies':['Service','Treasury','Guard','Order','Payment'],'key_constraints':['F-A-04:\x20at\x20most\x201\x20Surplus\x20per\x20Allocator','F-A-07:\x20fix\x20>=\x20threshold\x20(Amount\x20sum\x20must\x20cover\x20threshold)','fix\x20must\x20precisely\x20match\x20the\x20refund\x20amount'],'recommended_templates':['T-A-03']},{'id':'allocation_treasury_personal_alternatives','name':'Treasury\x20+\x20Personal\x20alternative\x20strategies\x20(caller-specified\x20guard)','trigger_source':'service_order_allocators','distribution_strategy':'first_match_alternatives','coin_type_note':'Both\x20target\x20addresses\x20must\x20accept\x20the\x20same\x20Coin<T>','typical_allocator_count':0x2,'sharing_who_types':['Entity'],'modes_used':['Rate'],'guard_requirement':'multiple_unique','non_zero_threshold':![],'uses_max':![],'common_patterns':['2\x20Allocators,\x20each\x20with\x201\x20Rate=10000\x20sharing','Allocator[0]:\x20guard=guard_treasury,\x20who=Entity(treasury_address)','Allocator[1]:\x20guard=guard_personal,\x20who=Entity(personal_address)','Two\x20Guard\x20objects\x20must\x20be\x20different\x20addresses\x20(R-A-11)','caller-specified\x20guard:\x20caller\x20selects\x20Treasury\x20or\x20Personal\x20path\x20via\x20alloc_by_guard;\x20the\x20Passport\x20hard-verifies\x20the\x20selected\x20Guard\x20(failure\x20aborts\x20with\x20E_VERIFY_FAILED;\x20caller\x20must\x20switch\x20guard\x20and\x20retry)'],'dependencies':['Service','Treasury','Guard','Order','Payment'],'key_constraints':['F-A-14:\x20allocators[].guard\x20must\x20be\x20unique','Treasury\x20Permission\x20should\x20match\x20Service\x20Permission\x20(R-A-12)','Guard\x20A\x20and\x20Guard\x20B\x20may\x20share\x20root/table\x20but\x20must\x20differ\x20in\x20description'],'recommended_templates':['T-A-04']},{'id':'allocation_tiered_by_order_amount','name':'Tiered\x20split\x20by\x20order\x20amount\x20(multi-Allocator\x20amount-threshold\x20switch)','trigger_source':'service_order_allocators','distribution_strategy':'tiered_by_amount','coin_type_note':'Amount\x20threshold\x20uses\x20Coin<T>\x20smallest\x20unit\x20(e.g.\x20MIST\x20for\x20WOW)','typical_allocator_count':0x2,'sharing_who_types':['Entity'],'modes_used':['Rate'],'guard_requirement':'multiple_unique','non_zero_threshold':![],'uses_max':![],'common_patterns':['2\x20Allocators\x20triggered\x20by\x20mutually\x20exclusive\x20Guard\x20conditions','Allocator[0]:\x20guard\x20verifies\x20order.amount\x20<\x20threshold,\x20Rate=10000\x20to\x20merchant','Allocator[1]:\x20guard\x20verifies\x20order.amount\x20>=\x20threshold,\x20Rate=8000/2000\x20split','caller-specified\x20guard:\x20caller\x20selects\x20the\x20matching\x20Allocator\x20based\x20on\x20order\x20amount;\x20allocator\x20order\x20is\x20irrelevant','Guard\x20queries\x20order.amount\x20(query\x201561)'],'dependencies':['Service','Treasury','Guard','Order','Payment'],'key_constraints':['Guard\x20conditions\x20must\x20be\x20mutually\x20exclusive\x20(R-A-4-02\x20design\x20clarity)','Caller\x20must\x20select\x20correct\x20guard\x20based\x20on\x20order.amount\x20(no\x20auto-fallback)'],'recommended_templates':['T-A-05']},{'id':'allocation_dynamic_recipient','name':'Multi-role\x20split\x20with\x20dynamic\x20recipient\x20(GuardIdentifier)','trigger_source':'service_order_allocators','distribution_strategy':'dynamic_recipient','coin_type_note':'Passport\x20table\x20must\x20contain\x20address-typed\x20entry\x20at\x20the\x20referenced\x20identifier','typical_allocator_count':0x1,'sharing_who_types':['Entity','GuardIdentifier'],'modes_used':['Rate'],'guard_requirement':'required','non_zero_threshold':![],'uses_max':![],'common_patterns':['Single\x20Allocator,\x203\x20Rate\x20sharing\x20items','sharing[0]:\x20Rate=8000,\x20who=Entity(merchant_treasury)','sharing[1]:\x20Rate=1000,\x20who=Entity(platform_treasury)','sharing[2]:\x20Rate=1000,\x20who=GuardIdentifier(0)\x20—\x20resolves\x20from\x20Passport\x20table','Customer\x20submits\x20Passport\x20with\x20referrer\x20address\x20at\x20identifier=0'],'dependencies':['Service','Treasury','Guard','Passport','Order','Payment'],'key_constraints':['F-A-13:\x20Passport\x20table[identifier]\x20must\x20be\x20address\x20type\x20(else\x20ERECIPIENT_IDENTIFIER_NOT_ADDRESS)','Guard\x20must\x20verify\x20Passport\x20completeness','Customer\x20order\x20must\x20include\x20Passport\x20with\x20referrer\x20address'],'recommended_templates':['T-A-06']},{'id':'allocation_arbitration_fees','name':'Arbitration\x20fees\x20split\x20(arbitrator\x20/\x20platform)','trigger_source':'arbitration_fees','distribution_strategy':'pure_rate','coin_type_note':'Coin<T>\x20must\x20match\x20Arbitration\x27s\x20fee\x20Coin\x20type','typical_allocator_count':0x1,'sharing_who_types':['Entity'],'modes_used':['Rate'],'guard_requirement':'required','non_zero_threshold':![],'uses_max':![],'common_patterns':['Triggered\x20by\x20the\x20Arbitration\x20fee-allocation\x20operation\x20(permission\x20365),\x20direct\x20or\x20Passport\x20path','Single\x20Allocator,\x202\x20Rate\x20sharing\x20items:\x208000\x20arbitrator\x20/\x202000\x20platform','payment_info\x20reuses\x20Arbitration\x27s\x20payment_info','Caller\x20must\x20hold\x20ARBITRATION_FEES_ALLOC=365\x20permission'],'dependencies':['Arbitration','Treasury','Guard','Payment'],'key_constraints':['Independent\x20from\x20Service-order\x20Allocation','Requires\x20ARBITRATION_FEES_ALLOC=365\x20permission'],'recommended_templates':['T-A-08']},{'id':'allocation_refund_to_order','name':'Refund\x20Allocator\x20(100%\x20to\x20Order\x20object)','trigger_source':'service_order_allocators','distribution_strategy':'refund_to_order','coin_type_note':'who=Entity\x20must\x20be\x20the\x20Order\x20object\x20address\x20(NOT\x20a\x20personal\x20wallet)','typical_allocator_count':0x1,'sharing_who_types':['Entity'],'modes_used':['Rate'],'guard_requirement':'required','non_zero_threshold':![],'uses_max':![],'common_patterns':['Single\x20Allocator,\x201\x20Rate=10000\x20sharing','who=Entity(order_address)\x20—\x20funds\x20flow\x20back\x20to\x20Order,\x20not\x20personal\x20wallet','Guard\x20verifies\x20customer\x20refund\x20request\x20and\x20eligibility','Customer-side\x20risk\x20assessment\x20adds\x208-point\x20weight\x20(onchain_topology\x20graph\x20evaluation)'],'dependencies':['Service','Guard','Order','Payment'],'key_constraints':['who=Entity\x20MUST\x20be\x20Order\x20object\x20address\x20(not\x20personal\x20address)','Customer\x20due-diligence\x20rewards\x20this\x20configuration\x20(8-point\x20weight)','Refund\x20funds\x20return\x20to\x20Order\x20for\x20downstream\x20handling'],'recommended_templates':['T-A-07']},{'id':'allocation_max_capped_retain','name':'Max-capped\x20allocation\x20(retain\x20residual\x20balance)','trigger_source':'service_order_allocators','distribution_strategy':'max_capped','coin_type_note':'max\x20field\x20uses\x20Coin<T>\x20smallest\x20unit','typical_allocator_count':0x1,'sharing_who_types':['Entity'],'modes_used':['Amount','Rate'],'guard_requirement':'required','non_zero_threshold':!![],'uses_max':!![],'common_patterns':['Single\x20Allocator\x20with\x20max\x20field\x20set','max\x20triple\x20role:\x20Amount\x20cap\x20+\x20NET\x20Rate\x20base\x20+\x20Surplus\x20cap','Amount\x20sharing\x20consumes\x20fix;\x20NET\x20Rate\x20sharing\x20uses\x20(max\x20-\x20fix)\x20as\x20base\x20(RateGross\x20uses\x20max\x20itself)','Residual\x20balance\x20remains\x20in\x20Allocation\x20for\x20subsequent\x20alloc()\x20calls'],'dependencies':['Service','Treasury','Guard','Order','Payment'],'key_constraints':['F-A-08:\x20Amount\x20sum\x20<=\x20max\x20(EAMOUNT_EXCEEDS_MAX)','NET\x20Rate:\x20max\x20-\x20fix\x20becomes\x20the\x20base\x20(NOT\x20balance\x20-\x20fix);\x20RateGross:\x20the\x20base\x20is\x20max\x20(fix\x20not\x20removed)','Residual\x20balance\x20may\x20be\x20claimed\x20by\x20re-triggering\x20alloc()'],'recommended_templates':[]},{'id':'allocation_multi_node_trigger','name':'Multi-Machine-node\x20triggered\x20allocation\x20(Complete\x20/\x20Refund\x20/\x20Lost)','trigger_source':'service_order_allocators','distribution_strategy':'multi_node_trigger','coin_type_note':'All\x20Allocators\x20share\x20the\x20same\x20Allocation\x27s\x20Coin<T>','typical_allocator_count':0x3,'sharing_who_types':['Entity'],'modes_used':['Rate'],'guard_requirement':'multiple_unique','non_zero_threshold':![],'uses_max':![],'common_patterns':['3\x20Allocators\x20mapped\x20to\x20Machine\x20terminal\x20nodes\x20(Complete/Refund/Lost)','Each\x20Allocator\x27s\x20Guard\x20verifies\x20progress.current_node\x20==\x20<node_name>','Mutually\x20exclusive\x20Guard\x20conditions\x20(only\x20one\x20terminal\x20node\x20active\x20at\x20a\x20time)','Machine.required_allocators[]\x20describes\x20each\x20trigger_node\x20mapping'],'dependencies':['Service','Treasury','Guard','Order','Progress','Machine','Payment'],'key_constraints':['Guard\x20conditions\x20must\x20be\x20mutually\x20exclusive','Sequence-sensitive:\x20business-flow\x20order','Machine.required_allocators[trigger_node]\x20must\x20map\x20to\x20Allocator\x20indices'],'recommended_templates':[]},{'id':'allocation_standalone_periodic_split','name':'Standalone\x20periodic\x20split\x20(investment\x20dividends\x20/\x20shared\x20income)','trigger_source':'standalone','distribution_strategy':'periodic_split','coin_type_note':'Coin<T>\x20must\x20match\x20the\x20asset\x20being\x20distributed\x20(e.g.\x20profit\x20token)','typical_allocator_count':0x1,'sharing_who_types':['Entity'],'modes_used':['Rate'],'guard_requirement':'required','non_zero_threshold':![],'uses_max':![],'common_patterns':['Single\x20Allocator,\x20N\x20Rate\x20sharing\x20items,\x20sum(rates)\x20===\x2010000','Each\x20sharing.who=Entity\x20points\x20to\x20a\x20beneficiary\x20wallet\x20(not\x20Treasury)','Guard\x20verifies\x20time-based\x20trigger\x20(e.g.\x20context(Clock).timestamp\x20>=\x20next_release)\x20or\x20signer\x20authorization','User\x20calls\x20receive()\x20to\x20deposit\x20funds,\x20then\x20alloc()\x20to\x20trigger\x20distribution','No\x20Service/Order/Progress/Machine\x20context\x20required'],'dependencies':['Treasury','Guard','Payment'],'key_constraints':['F-A-05:\x20sum(rates)\x20===\x2010000\x20(pure\x20Rate\x20mode)','R-A-3-04:\x20standalone\x20mode\x20has\x20no\x20Service-layer\x20access\x20control\x20—\x20Guard\x20+\x20Passport\x20MUST\x20be\x20sufficient','Caller\x20is\x20fully\x20responsible\x20for\x20receive\x20→\x20alloc\x20lifecycle\x20(no\x20auto-trigger)','Guard\x20should\x20bind\x20Signer\x20to\x20prevent\x20unauthorized\x20alloc()\x20calls'],'recommended_templates':['T-A-09']},{'id':'allocation_standalone_vesting','name':'Standalone\x20vesting\x20release\x20(time-locked\x20multi-stage\x20unlock)','trigger_source':'standalone','distribution_strategy':'time_locked_vesting','coin_type_note':'Coin<T>\x20must\x20match\x20the\x20vested\x20asset\x20(e.g.\x20locked\x20team\x20tokens)','typical_allocator_count':0x3,'sharing_who_types':['Entity'],'modes_used':['Amount','Rate','Surplus'],'guard_requirement':'multiple_unique','non_zero_threshold':!![],'uses_max':!![],'common_patterns':['N\x20Allocators,\x20each\x20mapped\x20to\x20a\x20vesting\x20stage\x20(e.g.\x2025%\x20at\x20month\x2012,\x2025%\x20at\x20month\x2024,\x2050%\x20surplus\x20at\x20month\x2036)','Each\x20Allocator\x27s\x20Guard\x20verifies\x20context(Clock).timestamp\x20>=\x20stage_unlock_time','Amount\x20sharing\x20per\x20stage\x20with\x20max\x20field\x20capping\x20the\x20cumulative\x20release','Final\x20Allocator\x20uses\x20Surplus\x20to\x20drain\x20remaining\x20balance\x20after\x20last\x20vesting\x20stage','Mutually\x20exclusive\x20Guard\x20conditions\x20(only\x20one\x20stage\x20active\x20at\x20a\x20time,\x20based\x20on\x20timestamp)','User\x20calls\x20receive()\x20to\x20deposit\x20locked\x20tokens,\x20then\x20alloc()\x20at\x20each\x20vesting\x20milestone'],'dependencies':['Treasury','Guard','Passport','Payment'],'key_constraints':['F-A-04:\x20at\x20most\x201\x20Surplus\x20per\x20Allocator\x20(final\x20stage\x20uses\x20Surplus\x20to\x20drain\x20remainder)','F-A-08:\x20Amount\x20sum\x20<=\x20max\x20(EAMOUNT_EXCEEDS_MAX)','R-A-3-04:\x20standalone\x20mode\x20has\x20no\x20Service-layer\x20access\x20control\x20—\x20Guard\x20time-lock\x20MUST\x20be\x20enforced','Guard\x20conditions\x20must\x20be\x20mutually\x20exclusive\x20by\x20timestamp\x20(R-A-4-02)','Caller\x20must\x20wait\x20for\x20time-lock\x20expiry\x20before\x20alloc()\x20succeeds;\x20otherwise\x20alloc()\x20silently\x20returns\x20(R-A-4-01)'],'recommended_templates':['T-A-10']}];export const ALLOCATION_LEDGER_VERSION='1.0.0';export function getScenesByTriggerSource(a){return ALLOCATION_SCENES['filter'](b=>b['trigger_source']===a);}export function getScenesByMode(a){return ALLOCATION_SCENES['filter'](b=>b['modes_used']['includes'](a));}export function getScenesByStrategy(a){return ALLOCATION_SCENES['filter'](b=>b['distribution_strategy']===a);}export function findSceneById(a){return ALLOCATION_SCENES['find'](b=>b['id']===a);}export function inferSceneFromIntent(a){const b=a['toLowerCase']();if(b['includes']('arbitration')||b['includes']('fees\x20alloc'))return findSceneById('allocation_arbitration_fees');if(b['includes']('standalone')||b['includes']('periodic\x20split')||b['includes']('investment\x20dividend')||b['includes']('shared\x20income')||b['includes']('dividend'))return findSceneById('allocation_standalone_periodic_split');if(b['includes']('vesting')||b['includes']('time-lock')||b['includes']('unlock\x20period')||b['includes']('locked\x20release')||b['includes']('token\x20unlock'))return findSceneById('allocation_standalone_vesting');if(b['includes']('refund')){if(b['includes']('order')||b['includes']('100%'))return findSceneById('allocation_refund_to_order');if(b['includes']('surplus')||b['includes']('merchant'))return findSceneById('allocation_refund_first_surplus_to_merchant');}if(b['includes']('alternative')||b['includes']('priority')||b['includes']('treasury')&&b['includes']('personal'))return findSceneById('allocation_treasury_personal_alternatives');if(b['includes']('tiered')||b['includes']('threshold\x20switch'))return findSceneById('allocation_tiered_by_order_amount');if(b['includes']('dynamic\x20recipient')||b['includes']('referrer')||b['includes']('guardidentifier'))return findSceneById('allocation_dynamic_recipient');if(b['includes']('retain')||b['includes']('max'))return findSceneById('allocation_max_capped_retain');if(b['includes']('multi-node')||b['includes']('multi\x20machine')||b['includes']('multi_node'))return findSceneById('allocation_multi_node_trigger');const c=(a['match'](/%/g)||[])['length'];if(c<=0x1)return findSceneById('allocation_merchant_full_payment');if(c>=0x2)return findSceneById('allocation_standard_three_way_split');return undefined;}export function getAllScenes(){return[...ALLOCATION_SCENES];}export function getScenesCount(){return ALLOCATION_SCENES['length'];}export function allocationModeToNumber(a){switch(a){case'Amount':return ALLOCATION_MODE_AMOUNT;case'Rate':return ALLOCATION_MODE_RATE;case'Surplus':return ALLOCATION_MODE_SURPLUS;case'RateGross':return ALLOCATION_MODE_RATE_GROSS;}}export function allocationModeFromNumber(a){switch(a){case ALLOCATION_MODE_AMOUNT:return'Amount';case ALLOCATION_MODE_RATE:return'Rate';case ALLOCATION_MODE_SURPLUS:return'Surplus';case ALLOCATION_MODE_RATE_GROSS:return'RateGross';default:throw new Error('Invalid\x20AllocationMode\x20number:\x20'+a);}}export function getRecipientType(a){if('GuardIdentifier'in a)return'GuardIdentifier';if('Entity'in a)return'Entity';return'Signer';}export function isSignerRecipient(a){return'Signer'in a;}export function isEntityRecipient(a){return'Entity'in a;}export function isGuardIdentifierRecipient(a){return'GuardIdentifier'in a;}export function getErrorName(a){for(const [b,d]of Object['entries'](ALLOCATION_ERROR_CODES)){if(d===a)return b;}return undefined;}export function getErrorDescription(a){const b={0x1:'GuardIdentifier\x20resolved\x20value\x20is\x20not\x20an\x20address\x20type',0x2:'Allocator\x20count\x20exceeds\x20MAX_ALLOCATOR_COUNT\x20(100)',0x3:'No\x20Allocator\x20in\x20the\x20allocators\x20vector',0x4:'Pure\x20Rate\x20mode\x20sum\x20!=\x2010000\x20(no\x20Surplus\x20to\x20absorb\x20remainder)',0x5:'Multiple\x20Surplus\x20sharing\x20in\x20a\x20single\x20Allocator',0x6:'Rate\x20+\x20Surplus\x20sum\x20>\x2010000',0x7:'balance\x20<\x20threshold\x20(insufficient\x20balance\x20to\x20trigger\x20alloc)',0x8:'allocators.allocators\x20is\x20empty',0x9:'payment_info\x20is\x20None\x20when\x20alloc()\x20is\x20called',0xa:'sharing\x20count\x20exceeds\x20MAX_SHARING_COUNT\x20(100)',0xb:'sharing\x20mode\x20is\x20not\x200\x20(Amount)\x20/\x201\x20(Rate)\x20/\x202\x20(Surplus)\x20/\x203\x20(RateGross)',0xc:'Amount\x20sum\x20(fix)\x20<\x20threshold',0xd:'Amount\x20sum\x20(fix)\x20>\x20max',0xe:'distribution\x20computes\x20to\x20zero\x20while\x20the\x20pool\x20still\x20holds\x20funds\x20(or\x20balance\x20is\x200)',0xf:'GuardIdentifier\x20recipient\x20address\x20!=\x20payment_info.for_object\x20anchor\x20(abort\x20fires\x20only\x20when\x20a\x20for_object\x20binding\x20is\x20declared)',0x10:'once-trigger\x20key\x20already\x20consumed\x20—\x20the\x20guard\x20submitted\x20the\x20reserved\x20identifier\x20255\x20and\x20its\x20raw\x20submission\x20bytes\x20were\x20recorded\x20as\x20a\x20(guard,\x20allocator\x20index,\x20raw\x20bytes)\x20dynamic-field\x20key\x20on\x20this\x20Allocation',0x11:'mixed\x20rate\x20bases\x20—\x20one\x20allocator\x20carries\x20both\x20NET\x20Rate\x20and\x20RateGross\x20entries\x20while\x20a\x20fixed\x20Amount\x20total\x20is\x20present\x20(rejected\x20only\x20when\x20fix\x20>\x200;\x20with\x20fix\x20==\x200\x20the\x20two\x20bases\x20coincide\x20and\x20mixing\x20is\x20allowed)',0x12:'RateGross\x20+\x20fixed\x20Amount\x20without\x20a\x20max\x20cap\x20—\x20plan\x20payability\x20unprovable\x20at\x20declaration\x20time',0x13:'guard\x20not\x20bound\x20to\x20any\x20allocator\x20on\x20this\x20Allocation\x20(was\x20a\x20silent\x20no-op\x20success\x20before)',0x14:'allocator\x20append\x20rejected:\x20new\x20Allocators\x20is\x20not\x20a\x20pure\x20extension\x20(prefix/threshold\x20changed)',0x15:'once-for-object\x20slot\x20(identifier\x20254)\x20armed\x20but\x20payment_info\x20declares\x20no\x20for_object\x20binding'};return b[a];}
|