@wowok/agent-mcp 3.1.0 → 3.1.2
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/evaluation/arbitration-game.js +1 -1
- package/dist/evaluation/location-match.js +1 -1
- package/dist/goal/GoalClassifier.js +1 -1
- package/dist/graph/onchain/analyze.d.ts +3 -3
- package/dist/graph/onchain/analyze.js +1 -1
- package/dist/graph/onchain/analyze.spec.js +1 -1
- package/dist/graph/onchain/edge-schema.d.ts +1 -1
- package/dist/graph/onchain/edge-schema.js +1 -1
- package/dist/graph/onchain/interest.js +1 -1
- package/dist/graph/onchain/sdk-dataplane.js +1 -1
- package/dist/graph/onchain/types.d.ts +5 -5
- package/dist/harness/verify.js +1 -1
- package/dist/knowledge/allocation-ledger.d.ts +2 -0
- package/dist/knowledge/allocation-ledger.js +1 -1
- package/dist/knowledge/allocation-puzzle.js +1 -1
- package/dist/knowledge/allocation-risk.d.ts +2 -1
- package/dist/knowledge/allocation-risk.js +1 -1
- package/dist/knowledge/guard-design-patterns.js +1 -1
- package/dist/knowledge/guard-field-cognition.d.ts +48 -0
- package/dist/knowledge/guard-field-cognition.js +1 -0
- package/dist/knowledge/index.d.ts +1 -0
- package/dist/knowledge/index.js +1 -1
- package/dist/knowledge/industry-registry.js +1 -1
- package/dist/knowledge/industry-strategy.js +1 -1
- package/dist/knowledge/jsonrpc-enum.js +1 -1
- package/dist/knowledge/recipient-constraint.d.ts +6 -1
- package/dist/knowledge/recipient-constraint.js +1 -1
- package/dist/knowledge/service-allocator-audit-node.d.ts +3 -0
- package/dist/knowledge/service-allocator-audit-node.js +1 -0
- package/dist/knowledge/service-risk-node.js +1 -1
- package/dist/knowledge/template-registry.js +1 -1
- package/dist/knowledge/workflow-guidance.d.ts +2 -0
- package/dist/knowledge/workflow-guidance.js +1 -1
- package/dist/monitor/MonitorLoop.js +1 -1
- package/dist/persona/strategy-intent.js +1 -1
- package/dist/playbooks/service-build/business-puzzle.js +1 -1
- package/dist/playbooks/service-build/intent-analyzer.js +1 -1
- package/dist/playbooks/service-build/object-panorama.js +1 -1
- package/dist/playbooks/service-build/risk-aggregator.js +1 -1
- package/dist/playbooks/service-build/topology-query.js +1 -1
- package/dist/safety/confirm-gate.js +1 -1
- package/dist/safety/preview.js +1 -1
- package/dist/schema/call/base.js +1 -1
- package/dist/schema/call/handler.js +1 -1
- package/dist/schema/call/semantic.js +1 -1
- package/dist/schema/common/index.js +1 -1
- package/dist/schema/evaluation/index.js +1 -1
- package/dist/schema/local/index.js +1 -1
- package/dist/schema/operations.d.ts +2 -0
- package/dist/schema/query/bi.d.ts +16 -14
- package/dist/schema/query/bi.js +1 -1
- package/dist/schema/query/index.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 +9 -9
- package/dist/schemas/account_operation.schema.json +3 -3
- package/dist/schemas/bridge_operation.output.json +9 -9
- package/dist/schemas/evaluation_operation.output.json +6 -6
- package/dist/schemas/evaluation_operation.schema.json +5 -5
- package/dist/schemas/index.json +1 -1
- package/dist/schemas/keeper_operation.output.json +9 -9
- package/dist/schemas/local_history_operation.output.json +9 -9
- package/dist/schemas/local_info_operation.output.json +9 -9
- package/dist/schemas/local_mark_operation.output.json +9 -9
- package/dist/schemas/messenger_operation.output.json +9 -9
- package/dist/schemas/monitor_events.output.json +9 -9
- package/dist/schemas/monitor_subscription.output.json +9 -9
- package/dist/schemas/onchain_events.output.json +10 -10
- package/dist/schemas/onchain_operations.output.json +9 -9
- package/dist/schemas/onchain_operations.schema.json +46 -46
- package/dist/schemas/onchain_operations_allocation.schema.json +5 -5
- package/dist/schemas/onchain_operations_arbitration.schema.json +3 -3
- package/dist/schemas/onchain_operations_contact.schema.json +2 -2
- package/dist/schemas/onchain_operations_demand.schema.json +2 -2
- package/dist/schemas/onchain_operations_machine.schema.json +2 -2
- package/dist/schemas/onchain_operations_order.schema.json +2 -2
- package/dist/schemas/onchain_operations_payment.schema.json +2 -2
- package/dist/schemas/onchain_operations_permission.schema.json +2 -2
- package/dist/schemas/onchain_operations_progress.schema.json +2 -2
- package/dist/schemas/onchain_operations_repository.schema.json +2 -2
- package/dist/schemas/onchain_operations_reward.schema.json +6 -6
- package/dist/schemas/onchain_operations_service.schema.json +8 -8
- package/dist/schemas/onchain_operations_treasury.schema.json +8 -8
- package/dist/schemas/onchain_table_data.output.json +17 -13
- package/dist/schemas/query_toolkit.output.json +47 -47
- package/dist/schemas/query_toolkit.schema.json +6 -2
- package/dist/strategy/collectors.js +1 -1
- package/dist/task/playbook.js +1 -1
- package/dist/tools/handlers/config.js +1 -1
- package/dist/tools/handlers/evaluation.spec.js +1 -1
- package/dist/tools/handlers/onchain.js +1 -1
- package/dist/tools/registry/monitor.js +1 -1
- package/dist/tools/shared.js +1 -1
- package/dist/tools/wrap.js +1 -1
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
const EOA='EOA',ANY='ANY',F_EDGES=[{'id':'service.permission','family':'F','source':'Service','target':'Permission','cardinality':0x1,'read':{'kind':'field','path':'permission'},'retention':'complete','evidence':'service.move\x20L175-194','bridgeIds':['b06','b09'],'zh':'店铺挂接的权限组(裁决回避\x20E33\x20的对照边)'},{'id':'service.machine','family':'F','source':'Service','target':'Machine','cardinality':'0..1','read':{'kind':'field','path':'machine'},'retention':'complete','evidence':'service.move\x20L175-194','bridgeIds':['b04'],'contract':{'field':'machine','frozenWhen':'after\x20publish','forbiddenActions':['set','remove'],'allowedActions':[],'unfreeze':null,'moveAnchor':'service.move\x20machine_set_imp\x20/\x20machine_none_imp\x20(assert!(!bPublished))'},'zh':'店铺绑定的工作流模板'},{'id':'service.buy_guard','family':'F','source':'Service','target':'Guard','cardinality':'0..1','read':{'kind':'field','path':'buy_guard'},'retention':'complete','evidence':'service.move\x20L175-194','bridgeIds':['b01','b10'],'contract':{'field':'buy_guard','frozenWhen':null,'forbiddenActions':[],'allowedActions':['set','remove'],'unfreeze':null,'moveAnchor':'service.move\x20buy_guard_set_imp\x20/\x20buy_guard_none_imp\x20(no\x20assert!(!bPublished))'},'zh':'下单前置校验\x20Guard'},{'id':'service.arbitration','family':'F','source':'Service','target':'Arbitration','cardinality':'N','read':{'kind':'fields','path':'arbitrations'},'retention':'complete','evidence':'service.move\x20L175-194\x20(≤20)','bridgeIds':['b06'],'contract':{'field':'arbitrations','frozenWhen':'after\x20publish','forbiddenActions':['remove','clear'],'allowedActions':['add'],'unfreeze':'pause\x20+\x20setting_lock_duration\x20elapsed','moveAnchor':'service.move\x20arbitration_remove_imp\x20/\x20arbitration_clear_imp\x20(assert_not_published)'},'zh':'店铺可选仲裁服务(≤20)'},{'id':'service.reward','family':'F','source':'Service','target':'Reward','cardinality':'N','read':{'kind':'fields','path':'rewards'},'retention':'complete','evidence':'service.move\x20L175-194\x20(≤20)','bridgeIds':['b07'],'contract':{'field':'rewards','frozenWhen':'after\x20publish','forbiddenActions':['remove','clear'],'allowedActions':['add'],'unfreeze':'pause\x20+\x20setting_lock_duration\x20elapsed','moveAnchor':'service.move\x20reward_remove_imp\x20/\x20reward_clear_imp\x20(assert_not_published)'},'zh':'店铺挂接的激励池(≤20)'},{'id':'service.repository','family':'F','source':'Service','target':'Repository','cardinality':'N','read':{'kind':'fields','path':'repositories'},'retention':'complete','evidence':'service.move\x20L175-194\x20(≤100)','bridgeIds':['b02'],'contract':{'field':'repositories','frozenWhen':null,'forbiddenActions':[],'allowedActions':['add','remove','clear'],'unfreeze':null,'moveAnchor':'service.move\x20repository_remove_imp\x20/\x20repository_clear_imp\x20(no\x20assert_not_published)'},'zh':'店铺证据资料库(≤100)'},{'id':'service.um','family':'F','source':'Service','target':'Contact','cardinality':'0..1','read':{'kind':'field','path':'um'},'retention':'complete','evidence':'service.move\x20L175-194','bridgeIds':['b11'],'zh':'店铺会员关系簿'},{'id':'service.order_allocator_guard','family':'F','source':'Service','target':'Guard','cardinality':'N','read':{'kind':'deep','segments':['order_allocators','allocators'],'field':'guard'},'retention':'complete','evidence':'service.move\x20L175-194;\x20allocation.move\x20L194-200','bridgeIds':['b05'],'zh':'店铺下单分账模板的触发\x20Guard'},{'id':'order.builder','family':'F','source':'Order','target':EOA,'cardinality':0x1,'read':{'kind':'field','path':'builder'},'retention':'complete','evidence':'order.move\x20L60-75\x20(owner;\x20SDK\x20builder)','bridgeIds':['b01'],'zh':'订单买家(owner/builder)'},{'id':'order.agent','family':'F','source':'Order','target':EOA,'cardinality':'N','read':{'kind':'fields','path':'agent'},'retention':'complete','evidence':'order.move\x20L60-75,L179\x20(≤10)','zh':'买家授权的商家代理人(≤10,买家调用\x20agent_set)'},{'id':'order.service','family':'F','source':'Order','target':'Service','cardinality':0x1,'read':{'kind':'field','path':'service'},'retention':'complete','evidence':'order.move\x20L60-75','bridgeIds':['b01'],'zh':'订单购买的店铺(购买快照)'},{'id':'order.machine','family':'F','source':'Order','target':'Machine','cardinality':'0..1','read':{'kind':'field','path':'machine'},'retention':'complete','evidence':'order.move\x20L130\x20(machine⇒progress)','bridgeIds':['b01','b04'],'zh':'订单绑定的工作流(购买快照)'},{'id':'order.progress','family':'F','source':'Order','target':'Progress','cardinality':'0..1','read':{'kind':'field','path':'progress'},'retention':'complete','evidence':'order.move\x20L130','bridgeIds':['b04'],'zh':'订单履约进度'},{'id':'order.allocation','family':'F','source':'Order','target':'Allocation','cardinality':'0..1','read':{'kind':'field','path':'allocation'},'retention':'complete','evidence':'order.move\x20L130\x20(amount>0⇒allocation)','bridgeIds':['b05'],'zh':'订单分账模板'},{'id':'order.discount','family':'F','source':'Order','target':'Discount','cardinality':'0..1','read':{'kind':'field','path':'discount'},'retention':'complete','evidence':'order.move\x20L60-75','bridgeIds':['b01'],'zh':'订单使用的折扣'},{'id':'order.dispute','family':'F','source':'Order','target':'Arb','cardinality':'N','read':{'kind':'fields','path':'dispute'},'retention':'complete','evidence':'order.move\x20L60-75','bridgeIds':['b06'],'zh':'订单关联的仲裁案件'},{'id':'order.claimed_by','family':'F','source':'Order','target':EOA,'cardinality':'0..1','read':{'kind':'field','path':'claimed_by'},'retention':'complete','evidence':'order.move\x20L86-96\x20(single-use)','bridgeIds':['b06'],'zh':'赔付领取人(单次)'},{'id':'progress.machine','family':'F','source':'Progress','target':'Machine','cardinality':0x1,'read':{'kind':'field','path':'machine'},'retention':'complete','evidence':'progress.move\x20L76-86','bridgeIds':['b04'],'contract':{'field':'machine','frozenWhen':'bound\x20at\x20creation','forbiddenActions':['set','remove'],'allowedActions':[],'unfreeze':null,'moveAnchor':'progress.move\x20new_imp\x20(machine\x20bound\x20at\x20creation;\x20no\x20mutation\x20entry)'},'zh':'进度对应的工作流模板'},{'id':'progress.task','family':'F','source':'Progress','target':'Order','cardinality':'0..1','read':{'kind':'field','path':'task'},'retention':'complete','evidence':'progress.move\x20L76-86','bridgeIds':['b04'],'contract':{'field':'task','frozenWhen':'after\x20task_set','forbiddenActions':['set'],'allowedActions':[],'unfreeze':null,'moveAnchor':'progress.move\x20task_set_imp\x20(assert!\x20option::is_none\x20→\x20E_TASK_ALREADY_SET)'},'zh':'进度关联的订单'},{'id':'progress.named_operator','family':'F','source':'Progress','target':EOA,'cardinality':'N','read':{'kind':'deep','segments':['namedOperator','operators'],'field':''},'retention':'complete','evidence':'progress.move\x20L76-86\x20(≤80)','bridgeIds':['b04'],'zh':'具名操作员运行时绑定(≤80\x20地址)'},{'id':'machine.permission','family':'F','source':'Machine','target':'Permission','cardinality':0x1,'read':{'kind':'field','path':'permission'},'retention':'complete','evidence':'machine.move\x20L299-308','bridgeIds':['b09'],'zh':'工作流的权限组'},{'id':'machine.consensus_repository','family':'F','source':'Machine','target':'Repository','cardinality':'N','read':{'kind':'fields','path':'consensus_repositories'},'retention':'complete','evidence':'machine.move\x20L299-308','contract':{'field':'consensus_repositories','frozenWhen':null,'forbiddenActions':[],'allowedActions':['add','remove','clear'],'unfreeze':null,'moveAnchor':'machine.move\x20consensus_repositories_remove_imp\x20(no\x20assert_not_published)'},'zh':'工作流共识资料库'},{'id':'machine.um','family':'F','source':'Machine','target':'Contact','cardinality':'0..1','read':{'kind':'field','path':'um'},'retention':'complete','evidence':'machine.move\x20L299-308','bridgeIds':['b11'],'zh':'工作流会员关系簿'},{'id':'allocation.guard','family':'F','source':'Allocation','target':'Guard','cardinality':'N','read':{'kind':'deep','segments':['allocators','allocators'],'field':'guard'},'retention':'complete','evidence':'allocation.move\x20L194-200','bridgeIds':['b05'],'contract':{'field':'allocators','frozenWhen':'after\x20create\x20(share)','forbiddenActions':['add','remove','clear','set'],'allowedActions':[],'unfreeze':null,'moveAnchor':'allocation.move\x20create\x20(bound\x20via\x20new_with_balance;\x20no\x20mutation\x20entry)'},'zh':'分账段触发\x20Guard'},{'id':'arbitration.permission','family':'F','source':'Arbitration','target':'Permission','cardinality':0x1,'read':{'kind':'field','path':'permission'},'retention':'complete','evidence':'arbitration.move\x20L48-59','bridgeIds':['b06','b09'],'zh':'仲裁服务的权限组(须与店铺\x20permission\x20不同,E33)'},{'id':'arbitration.voting_guard','family':'F','source':'Arbitration','target':'Guard','cardinality':'N','read':{'kind':'structFields','path':'voting_guard','field':'guard'},'retention':'complete','evidence':'arbitration.move\x20L48-59','bridgeIds':['b06','b10'],'zh':'仲裁投票权\x20Guard(空=人人可投)'},{'id':'arbitration.usage_guard','family':'F','source':'Arbitration','target':'Guard','cardinality':'0..1','read':{'kind':'field','path':'usage_guard'},'retention':'complete','evidence':'arbitration.move\x20L48-59','bridgeIds':['b06','b10'],'zh':'仲裁服务使用门槛\x20Guard'},{'id':'arbitration.um','family':'F','source':'Arbitration','target':'Contact','cardinality':'0..1','read':{'kind':'field','path':'um'},'retention':'complete','evidence':'arbitration.move\x20L48-59','bridgeIds':['b11'],'zh':'仲裁会员关系簿'},{'id':'arb.order','family':'F','source':'Arb','target':'Order','cardinality':0x1,'read':{'kind':'field','path':'order'},'retention':'complete','evidence':'arb.move\x20L96-111','bridgeIds':['b06'],'zh':'仲裁案件对应的订单'},{'id':'arb.arbitration_service','family':'F','source':'Arb','target':'Arbitration','cardinality':'0..1','read':{'kind':'field','path':'arbitration'},'retention':'complete','evidence':'arb.move\x20L96-111','bridgeIds':['b06'],'zh':'案件适用的仲裁服务'},{'id':'arb.voter','family':'S','source':'Arb','target':EOA,'cardinality':'N','read':{'kind':'structFields','path':'voted','field':'voter'},'retention':'complete','evidence':'arb.move\x20L96-111\x20(voted≤520)','bridgeIds':['b06'],'zh':'案件实际投票人及权重(≤520)'},{'id':'demand.permission','family':'F','source':'Demand','target':'Permission','cardinality':0x1,'read':{'kind':'field','path':'permission'},'retention':'complete','evidence':'demand.move\x20L68-77','bridgeIds':['b09'],'zh':'需求的权限组(需求方)'},{'id':'demand.guard','family':'F','source':'Demand','target':'Guard','cardinality':'N','read':{'kind':'structFields','path':'guards','field':'guard'},'retention':'complete','evidence':'demand.move\x20L68-77','bridgeIds':['b03','b10'],'zh':'需求接单\x20Guard(裸\x20present\x20时须为空)'},{'id':'demand.reward','family':'F','source':'Demand','target':'Reward','cardinality':'N','read':{'kind':'fields','path':'rewards'},'retention':'complete','evidence':'demand.move\x20L68-77','bridgeIds':['b07'],'zh':'需求托管激励池'},{'id':'demand.um','family':'F','source':'Demand','target':'Contact','cardinality':'0..1','read':{'kind':'field','path':'um'},'retention':'complete','evidence':'demand.move\x20L68-77','bridgeIds':['b11'],'zh':'需求会员关系簿'},{'id':'reward.permission','family':'F','source':'Reward','target':'Permission','cardinality':0x1,'read':{'kind':'field','path':'permission'},'retention':'complete','evidence':'reward.move\x20L129','bridgeIds':['b09'],'zh':'激励池权限组'},{'id':'reward.guard','family':'F','source':'Reward','target':'Guard','cardinality':'N','read':{'kind':'structFields','path':'guards','field':'guard'},'retention':'complete','evidence':'reward.move\x20L129','bridgeIds':['b07'],'zh':'激励领取\x20Guard'},{'id':'reward.um','family':'F','source':'Reward','target':'Contact','cardinality':'0..1','read':{'kind':'field','path':'um'},'retention':'complete','evidence':'reward.move\x20L129','bridgeIds':['b11'],'zh':'激励池会员关系簿'},{'id':'repository.permission','family':'F','source':'Repository','target':'Permission','cardinality':0x1,'read':{'kind':'field','path':'permission'},'retention':'complete','evidence':'repository.move\x20(struct)','bridgeIds':['b02','b09'],'zh':'资料库权限组'},{'id':'repository.reward','family':'F','source':'Repository','target':'Reward','cardinality':'N','read':{'kind':'fields','path':'rewards'},'retention':'complete','evidence':'repository.move\x20(struct)','bridgeIds':['b07'],'zh':'资料库挂接的激励池'},{'id':'repository.policy_guard','family':'F','source':'Repository','target':'Guard','cardinality':'N','read':{'kind':'structFields','path':'policies','field':'guard'},'retention':'complete','evidence':'repository.move\x20(read/write\x20policies)','bridgeIds':['b02','b10'],'zh':'资料库读写策略\x20Guard(值门控)'},{'id':'contact.permission','family':'F','source':'Contact','target':'Permission','cardinality':0x1,'read':{'kind':'field','path':'permission'},'retention':'complete','evidence':'contact.move\x20L25-31','bridgeIds':['b09','b11'],'zh':'客服会员簿的权限组'},{'id':'permission.admin','family':'F','source':'Permission','target':EOA,'cardinality':'N','read':{'kind':'fields','path':'admin'},'retention':'complete','evidence':'permission.move\x20L34-42\x20(admin\x20vector)','bridgeIds':['b09'],'zh':'权限组管理员\x20EOA\x20列表'},{'id':'guard.relies','family':'F','source':'Guard','target':'Guard','cardinality':'N','read':{'kind':'fields','path':'relies'},'retention':'complete','evidence':'guard.move\x20L85-95\x20(≤4,\x20one\x20level)','bridgeIds':['b10'],'zh':'Guard\x20依赖的子\x20Guard(≤4,仅一层)'},{'id':'passport.signer','family':'F','source':'Passport','target':EOA,'cardinality':0x1,'read':{'kind':'field','path':'signer'},'retention':'complete','evidence':'passport.move\x20L41-49,L94-98','bridgeIds':['b12'],'zh':'通行证签署人(单笔\x20tx\x20一次性)'},{'id':'passport.guard','family':'F','source':'Passport','target':'Guard','cardinality':'N','read':{'kind':'structFields','path':'guard','field':'guard'},'retention':'complete','evidence':'passport.move\x20L41-49','bridgeIds':['b10','b12'],'zh':'通行证持有的\x20Guard\x20校验票据'},{'id':'proof.signer','family':'F','source':'Proof','target':EOA,'cardinality':0x1,'read':{'kind':'field','path':'signer'},'retention':'complete','evidence':'proof.move\x20L14-25','bridgeIds':['b12'],'zh':'WTS\x20证据签名人'},{'id':'proof.about','family':'F','source':'Proof','target':ANY,'cardinality':'0..1','read':{'kind':'field','path':'about'},'retention':'complete','evidence':'proof.move\x20L14-25','bridgeIds':['b12'],'zh':'证据关联对象'},{'id':'treasury.permission','family':'F','source':'Treasury','target':'Permission','cardinality':0x1,'read':{'kind':'field','path':'permission'},'retention':'complete','evidence':'treasury.move\x20L72-83','bridgeIds':['b09'],'zh':'金库权限组'},{'id':'treasury.external_guard','family':'F','source':'Treasury','target':'Guard','cardinality':'N','read':{'kind':'fields','path':'external_guards'},'retention':'complete','evidence':'treasury.move\x20L72-83','bridgeIds':['b10'],'zh':'金库外部存取\x20Guard'}],R_EDGES=[{'id':'eoa.permission','family':'R','source':EOA,'target':'Permission','cardinality':'N','read':{'kind':'reverse','parent':'0xaad'},'retention':'membership','evidence':'entity_permission.move\x20L32\x20(bits\x201/2/4)','bridgeIds':['b09'],'zh':'账号当前参与的权限组(成员关系,移除即消失)'},{'id':'eoa.order','family':'R','source':EOA,'target':'Order','cardinality':'N','read':{'kind':'reverse','parent':'0xaa8'},'retention':'bounded_window','evidence':'entity_order.move\x20L31\x20(FIFO\x205200)','bridgeIds':['b01'],'zh':'账号作为买家/代理人参与的订单(买家视角,FIFO\x205200)'},{'id':'eoa.contact','family':'R','source':EOA,'target':'Contact','cardinality':'N','read':{'kind':'reverse','parent':'0xaa9'},'retention':'membership','evidence':'entity_contact.move\x20L24','bridgeIds':['b11'],'zh':'账号当前加入的客服会员簿'},{'id':'permission.core_binding','family':'R','source':'Permission','target':ANY,'cardinality':'N','read':{'kind':'reverse','parent':'0xaae'},'retention':'bounded_exact','evidence':'object_linker.move\x20L37,L88\x20(≤5200\x20aborts)','bridgeIds':['b09'],'zh':'权限组无损挂接的核心对象(Service/Demand/Machine/…)'},{'id':'permission.tx_binding','family':'R','source':'Permission','target':ANY,'cardinality':'N','read':{'kind':'reverse','parent':'0xaaf'},'retention':'bounded_window','evidence':'object_linker.move\x20L43\x20(FIFO\x205200\x20operational)','bridgeIds':['b09'],'zh':'权限组运行期触碰对象(FIFO\x205200\x20下界)'},{'id':'service.order','family':'R','source':'Service','target':'Order','cardinality':'N','read':{'kind':'reverse','parent':'0xaaf','filterType':'Order'},'retention':'bounded_window','evidence':'object_linker.move\x20L43,L136-140\x20(FIFO\x205200)','bridgeIds':['b01'],'zh':'店铺订单(商家视角权威路径,FIFO\x205200\x20下界;全量走事件通道)'},{'id':'target.vote','family':'S','source':ANY,'target':EOA,'cardinality':'N','read':{'kind':'reverse','parent':'0xaaa'},'retention':'bounded_window','evidence':'registrar.move\x20L154-171\x20(ring\x205200,\x20bits\x200x02/0x04/0x08)','zh':'目标地址收到的\x20like/dislike/favor\x20投票(环形\x205200)'}],TABLE_EDGES=[{'id':'permission.entity','family':'R','source':'Permission','target':ANY,'cardinality':'N','read':{'kind':'table','rowType':'PermissionPerm'},'retention':'membership','evidence':'permission.move\x20L34-42\x20(entity\x20may\x20be\x20EOA\x20or\x20Guard\x20address)','bridgeIds':['b04','b09'],'zh':'权限组实体表成员(EOA\x20或\x20Guard,携带\x20perm\x20索引位)'},{'id':'demand.presenter','family':'R','source':'Demand','target':EOA,'cardinality':'N','read':{'kind':'table','rowType':'DemandPresenter'},'retention':'membership','evidence':'demand.move\x20L68-77\x20(presenters\x20table)','bridgeIds':['b03'],'zh':'向需求提案的供应方及\x20acceptance_score'},{'id':'machine.node','family':'W','source':'Machine','target':'MachineNode','cardinality':'N','read':{'kind':'table','rowType':'MachineNode'},'retention':'complete','evidence':'machine.move\x20L299-308\x20(immutable\x20after\x20publish)','bridgeIds':['b04'],'contract':{'field':'nodes','frozenWhen':'after\x20publish','forbiddenActions':['add','remove','update'],'allowedActions':[],'unfreeze':null,'moveAnchor':'machine.move\x20node_add_imp\x20/\x20node_remove_imp\x20/\x20node_rename_imp\x20(assert_not_published)'},'zh':'工作流节点表(发布后不可变)'}],W_EDGES=[{'id':'wf.transition','family':'W','source':'MachineNode','target':'MachineNode','cardinality':'N','read':{'kind':'derived','producer':'machineRows'},'retention':'derived','evidence':'machine.move\x20L101\x20NodePair,L269','bridgeIds':['b04'],'zh':'节点对有向边(prev_node→node,携带\x20threshold)'},{'id':'wf.forward_guard','family':'W','source':'MachineNode','target':'Guard','cardinality':'N','read':{'kind':'derived','producer':'machineRows'},'retention':'derived','evidence':'machine.move\x20L63\x20Forward','bridgeIds':['b04','b05','b10','b12'],'zh':'节点前进操作的后置\x20Guard(供应链/赔付分账挂点)'}],M_EDGES=[{'id':'payment.recipient','family':'M','source':'Payment','target':EOA,'cardinality':'N','read':{'kind':'structFields','path':'record','field':'recipient'},'retention':'complete','evidence':'payment.move\x20L93-101\x20(Revenue≤200)','bridgeIds':['b05','b08'],'zh':'支付分账收款人(携带金额,逐腿)'},{'id':'payment.from_object','family':'M','source':'Payment','target':ANY,'cardinality':'0..1','read':{'kind':'field','path':'from_object'},'retention':'complete','evidence':'payment.move\x20L149-161\x20(framework-only)','bridgeIds':['b05','b08'],'zh':'资金来源池(Treasury/Allocation/Service,仅框架可设)'},{'id':'payment.for_object','family':'M','source':'Payment','target':ANY,'cardinality':'0..1','read':{'kind':'field','path':'info.for_object'},'retention':'complete','evidence':'payment.move\x20L93-101\x20(info\x20routing\x20hint)','bridgeIds':['b05','b08'],'zh':'业务路由对象(用户可设)'},{'id':'payment.for_guard','family':'M','source':'Payment','target':'Guard','cardinality':'0..1','read':{'kind':'field','path':'info.for_guard'},'retention':'complete','evidence':'payment.move\x20L93-101','bridgeIds':['b05'],'zh':'业务路由\x20Guard'}];export const EDGE_SCHEMAS=[...F_EDGES,...R_EDGES,...TABLE_EDGES,...W_EDGES,...M_EDGES];export const EDGE_SCHEMA_BY_ID=new Map(EDGE_SCHEMAS['map'](a=>[a['id'],a]));export function outgoingSchemaIds(a){return EDGE_SCHEMAS['filter'](b=>b['source']===a||b['source']===ANY)['map'](b=>b['id']);}export const COVERED_OBJECT_TYPES=[...new Set(EDGE_SCHEMAS['flatMap'](a=>[a['source'],a['target']])['filter'](a=>a!==EOA&&a!==ANY&&a!=='MachineNode'))];
|
|
1
|
+
const EOA='EOA',ANY='ANY',F_EDGES=[{'id':'service.permission','family':'F','source':'Service','target':'Permission','cardinality':0x1,'read':{'kind':'field','path':'permission'},'retention':'complete','evidence':'service.move\x20L175-194','bridgeIds':['b06','b09'],'label':'Permission\x20group\x20attached\x20to\x20the\x20service\x20(counter-edge\x20for\x20the\x20E33\x20arbitrator-recusal\x20check)'},{'id':'service.machine','family':'F','source':'Service','target':'Machine','cardinality':'0..1','read':{'kind':'field','path':'machine'},'retention':'complete','evidence':'service.move\x20L175-194','bridgeIds':['b04'],'contract':{'field':'machine','frozenWhen':'after\x20publish','forbiddenActions':['set','remove'],'allowedActions':[],'unfreeze':null,'moveAnchor':'service.move\x20machine_set_imp\x20/\x20machine_none_imp\x20(assert!(!bPublished))'},'label':'Workflow\x20template\x20bound\x20to\x20the\x20service'},{'id':'service.buy_guard','family':'F','source':'Service','target':'Guard','cardinality':'0..1','read':{'kind':'field','path':'buy_guard'},'retention':'complete','evidence':'service.move\x20L175-194','bridgeIds':['b01','b10'],'contract':{'field':'buy_guard','frozenWhen':null,'forbiddenActions':[],'allowedActions':['set','remove'],'unfreeze':null,'moveAnchor':'service.move\x20buy_guard_set_imp\x20/\x20buy_guard_none_imp\x20(no\x20assert!(!bPublished))'},'label':'Pre-order\x20validation\x20Guard'},{'id':'service.arbitration','family':'F','source':'Service','target':'Arbitration','cardinality':'N','read':{'kind':'fields','path':'arbitrations'},'retention':'complete','evidence':'service.move\x20L175-194\x20(≤20)','bridgeIds':['b06'],'contract':{'field':'arbitrations','frozenWhen':'after\x20publish','forbiddenActions':['remove','clear'],'allowedActions':['add'],'unfreeze':'pause\x20+\x20setting_lock_duration\x20elapsed','moveAnchor':'service.move\x20arbitration_remove_imp\x20/\x20arbitration_clear_imp\x20(assert_not_published)'},'label':'Arbitration\x20services\x20selectable\x20by\x20the\x20shop\x20(<=20)'},{'id':'service.reward','family':'F','source':'Service','target':'Reward','cardinality':'N','read':{'kind':'fields','path':'rewards'},'retention':'complete','evidence':'service.move\x20L175-194\x20(≤20)','bridgeIds':['b07'],'contract':{'field':'rewards','frozenWhen':'after\x20publish','forbiddenActions':['remove','clear'],'allowedActions':['add'],'unfreeze':'pause\x20+\x20setting_lock_duration\x20elapsed','moveAnchor':'service.move\x20reward_remove_imp\x20/\x20reward_clear_imp\x20(assert_not_published)'},'label':'Reward\x20pools\x20attached\x20to\x20the\x20shop\x20(<=20)'},{'id':'service.repository','family':'F','source':'Service','target':'Repository','cardinality':'N','read':{'kind':'fields','path':'repositories'},'retention':'complete','evidence':'service.move\x20L175-194\x20(≤100)','bridgeIds':['b02'],'contract':{'field':'repositories','frozenWhen':null,'forbiddenActions':[],'allowedActions':['add','remove','clear'],'unfreeze':null,'moveAnchor':'service.move\x20repository_remove_imp\x20/\x20repository_clear_imp\x20(no\x20assert_not_published)'},'label':'Shop\x20evidence\x20repository\x20(<=100)'},{'id':'service.um','family':'F','source':'Service','target':'Contact','cardinality':'0..1','read':{'kind':'field','path':'um'},'retention':'complete','evidence':'service.move\x20L175-194','bridgeIds':['b11'],'label':'Shop\x20membership\x20book'},{'id':'service.order_allocator_guard','family':'F','source':'Service','target':'Guard','cardinality':'N','read':{'kind':'deep','segments':['order_allocators','allocators'],'field':'guard'},'retention':'complete','evidence':'service.move\x20L175-194;\x20allocation.move\x20L194-200','bridgeIds':['b05'],'label':'Trigger\x20Guards\x20of\x20the\x20shop\x27s\x20order-allocation\x20template'},{'id':'order.builder','family':'F','source':'Order','target':EOA,'cardinality':0x1,'read':{'kind':'field','path':'builder'},'retention':'complete','evidence':'order.move\x20L60-75\x20(owner;\x20SDK\x20builder)','bridgeIds':['b01'],'label':'Order\x20buyer\x20(owner/builder)'},{'id':'order.agent','family':'F','source':'Order','target':EOA,'cardinality':'N','read':{'kind':'fields','path':'agent'},'retention':'complete','evidence':'order.move\x20L60-75,L179\x20(≤10)','label':'Merchant\x20agents\x20authorized\x20by\x20the\x20buyer\x20(<=10,\x20buyer\x20calls\x20agent_set)'},{'id':'order.service','family':'F','source':'Order','target':'Service','cardinality':0x1,'read':{'kind':'field','path':'service'},'retention':'complete','evidence':'order.move\x20L60-75','bridgeIds':['b01'],'label':'Shop\x20the\x20order\x20purchases\x20(purchase\x20snapshot)'},{'id':'order.machine','family':'F','source':'Order','target':'Machine','cardinality':'0..1','read':{'kind':'field','path':'machine'},'retention':'complete','evidence':'order.move\x20L130\x20(machine⇒progress)','bridgeIds':['b01','b04'],'label':'Workflow\x20bound\x20to\x20the\x20order\x20(purchase\x20snapshot)'},{'id':'order.progress','family':'F','source':'Order','target':'Progress','cardinality':'0..1','read':{'kind':'field','path':'progress'},'retention':'complete','evidence':'order.move\x20L130','bridgeIds':['b04'],'label':'Order\x20fulfillment\x20progress'},{'id':'order.allocation','family':'F','source':'Order','target':'Allocation','cardinality':'0..1','read':{'kind':'field','path':'allocation'},'retention':'complete','evidence':'order.move\x20L130\x20(amount>0⇒allocation)','bridgeIds':['b05'],'label':'Order\x20allocation\x20template'},{'id':'order.discount','family':'F','source':'Order','target':'Discount','cardinality':'0..1','read':{'kind':'field','path':'discount'},'retention':'complete','evidence':'order.move\x20L60-75','bridgeIds':['b01'],'label':'Discount\x20applied\x20to\x20the\x20order'},{'id':'order.dispute','family':'F','source':'Order','target':'Arb','cardinality':'N','read':{'kind':'fields','path':'dispute'},'retention':'complete','evidence':'order.move\x20L60-75','bridgeIds':['b06'],'label':'Arbitration\x20cases\x20linked\x20to\x20the\x20order'},{'id':'order.claimed_by','family':'F','source':'Order','target':EOA,'cardinality':'0..1','read':{'kind':'field','path':'claimed_by'},'retention':'complete','evidence':'order.move\x20L86-96\x20(single-use)','bridgeIds':['b06'],'label':'Compensation\x20claimant\x20(single\x20use)'},{'id':'progress.machine','family':'F','source':'Progress','target':'Machine','cardinality':0x1,'read':{'kind':'field','path':'machine'},'retention':'complete','evidence':'progress.move\x20L76-86','bridgeIds':['b04'],'contract':{'field':'machine','frozenWhen':'bound\x20at\x20creation','forbiddenActions':['set','remove'],'allowedActions':[],'unfreeze':null,'moveAnchor':'progress.move\x20new_imp\x20(machine\x20bound\x20at\x20creation;\x20no\x20mutation\x20entry)'},'label':'Workflow\x20template\x20the\x20progress\x20belongs\x20to'},{'id':'progress.task','family':'F','source':'Progress','target':'Order','cardinality':'0..1','read':{'kind':'field','path':'task'},'retention':'complete','evidence':'progress.move\x20L76-86','bridgeIds':['b04'],'contract':{'field':'task','frozenWhen':'after\x20task_set','forbiddenActions':['set'],'allowedActions':[],'unfreeze':null,'moveAnchor':'progress.move\x20task_set_imp\x20(assert!\x20option::is_none\x20→\x20E_TASK_ALREADY_SET)'},'label':'Order\x20the\x20progress\x20belongs\x20to'},{'id':'progress.named_operator','family':'F','source':'Progress','target':EOA,'cardinality':'N','read':{'kind':'deep','segments':['namedOperator','operators'],'field':''},'retention':'complete','evidence':'progress.move\x20L76-86\x20(≤80)','bridgeIds':['b04'],'label':'Runtime\x20named-operator\x20bindings\x20(<=80\x20addresses)'},{'id':'machine.permission','family':'F','source':'Machine','target':'Permission','cardinality':0x1,'read':{'kind':'field','path':'permission'},'retention':'complete','evidence':'machine.move\x20L299-308','bridgeIds':['b09'],'label':'Workflow\x20permission\x20group'},{'id':'machine.consensus_repository','family':'F','source':'Machine','target':'Repository','cardinality':'N','read':{'kind':'fields','path':'consensus_repositories'},'retention':'complete','evidence':'machine.move\x20L299-308','contract':{'field':'consensus_repositories','frozenWhen':null,'forbiddenActions':[],'allowedActions':['add','remove','clear'],'unfreeze':null,'moveAnchor':'machine.move\x20consensus_repositories_remove_imp\x20(no\x20assert_not_published)'},'label':'Workflow\x20consensus\x20repository'},{'id':'machine.um','family':'F','source':'Machine','target':'Contact','cardinality':'0..1','read':{'kind':'field','path':'um'},'retention':'complete','evidence':'machine.move\x20L299-308','bridgeIds':['b11'],'label':'Workflow\x20membership\x20book'},{'id':'allocation.guard','family':'F','source':'Allocation','target':'Guard','cardinality':'N','read':{'kind':'deep','segments':['allocators','allocators'],'field':'guard'},'retention':'complete','evidence':'allocation.move\x20L194-200','bridgeIds':['b05'],'contract':{'field':'allocators','frozenWhen':'after\x20create\x20(share)','forbiddenActions':['add','remove','clear','set'],'allowedActions':[],'unfreeze':null,'moveAnchor':'allocation.move\x20create\x20(bound\x20via\x20new_with_balance;\x20no\x20mutation\x20entry)'},'label':'Allocation-segment\x20trigger\x20Guards'},{'id':'arbitration.permission','family':'F','source':'Arbitration','target':'Permission','cardinality':0x1,'read':{'kind':'field','path':'permission'},'retention':'complete','evidence':'arbitration.move\x20L48-59','bridgeIds':['b06','b09'],'label':'Arbitration\x20service\x20permission\x20group\x20(must\x20differ\x20from\x20the\x20shop\x20permission,\x20E33)'},{'id':'arbitration.voting_guard','family':'F','source':'Arbitration','target':'Guard','cardinality':'N','read':{'kind':'structFields','path':'voting_guard','field':'guard'},'retention':'complete','evidence':'arbitration.move\x20L48-59','bridgeIds':['b06','b10'],'label':'Arbitration\x20voting\x20Guards\x20(empty\x20=\x20open\x20to\x20all\x20members)'},{'id':'arbitration.usage_guard','family':'F','source':'Arbitration','target':'Guard','cardinality':'0..1','read':{'kind':'field','path':'usage_guard'},'retention':'complete','evidence':'arbitration.move\x20L48-59','bridgeIds':['b06','b10'],'label':'Arbitration\x20service\x20usage-gate\x20Guard'},{'id':'arbitration.um','family':'F','source':'Arbitration','target':'Contact','cardinality':'0..1','read':{'kind':'field','path':'um'},'retention':'complete','evidence':'arbitration.move\x20L48-59','bridgeIds':['b11'],'label':'Arbitration\x20membership\x20book'},{'id':'arb.order','family':'F','source':'Arb','target':'Order','cardinality':0x1,'read':{'kind':'field','path':'order'},'retention':'complete','evidence':'arb.move\x20L96-111','bridgeIds':['b06'],'label':'Order\x20the\x20arbitration\x20case\x20is\x20about'},{'id':'arb.arbitration_service','family':'F','source':'Arb','target':'Arbitration','cardinality':'0..1','read':{'kind':'field','path':'arbitration'},'retention':'complete','evidence':'arb.move\x20L96-111','bridgeIds':['b06'],'label':'Arbitration\x20service\x20applied\x20to\x20the\x20case'},{'id':'arb.voter','family':'S','source':'Arb','target':EOA,'cardinality':'N','read':{'kind':'structFields','path':'voted','field':'voter'},'retention':'complete','evidence':'arb.move\x20L96-111\x20(voted≤520)','bridgeIds':['b06'],'label':'Actual\x20case\x20voters\x20and\x20weights\x20(<=520)'},{'id':'demand.permission','family':'F','source':'Demand','target':'Permission','cardinality':0x1,'read':{'kind':'field','path':'permission'},'retention':'complete','evidence':'demand.move\x20L68-77','bridgeIds':['b09'],'label':'Demand\x20permission\x20group\x20(the\x20demanding\x20side)'},{'id':'demand.guard','family':'F','source':'Demand','target':'Guard','cardinality':'N','read':{'kind':'structFields','path':'guards','field':'guard'},'retention':'complete','evidence':'demand.move\x20L68-77','bridgeIds':['b03','b10'],'label':'Demand\x20acceptance\x20Guards\x20(must\x20be\x20empty\x20for\x20a\x20bare\x20present)'},{'id':'demand.reward','family':'F','source':'Demand','target':'Reward','cardinality':'N','read':{'kind':'fields','path':'rewards'},'retention':'complete','evidence':'demand.move\x20L68-77','bridgeIds':['b07'],'label':'Escrowed\x20reward\x20pools\x20of\x20the\x20demand'},{'id':'demand.um','family':'F','source':'Demand','target':'Contact','cardinality':'0..1','read':{'kind':'field','path':'um'},'retention':'complete','evidence':'demand.move\x20L68-77','bridgeIds':['b11'],'label':'Demand\x20membership\x20book'},{'id':'reward.permission','family':'F','source':'Reward','target':'Permission','cardinality':0x1,'read':{'kind':'field','path':'permission'},'retention':'complete','evidence':'reward.move\x20L129','bridgeIds':['b09'],'label':'Reward\x20pool\x20permission\x20group'},{'id':'reward.guard','family':'F','source':'Reward','target':'Guard','cardinality':'N','read':{'kind':'structFields','path':'guards','field':'guard'},'retention':'complete','evidence':'reward.move\x20L129','bridgeIds':['b07'],'label':'Reward\x20claim\x20Guards'},{'id':'reward.um','family':'F','source':'Reward','target':'Contact','cardinality':'0..1','read':{'kind':'field','path':'um'},'retention':'complete','evidence':'reward.move\x20L129','bridgeIds':['b11'],'label':'Reward\x20pool\x20membership\x20book'},{'id':'repository.permission','family':'F','source':'Repository','target':'Permission','cardinality':0x1,'read':{'kind':'field','path':'permission'},'retention':'complete','evidence':'repository.move\x20(struct)','bridgeIds':['b02','b09'],'label':'Repository\x20permission\x20group'},{'id':'repository.reward','family':'F','source':'Repository','target':'Reward','cardinality':'N','read':{'kind':'fields','path':'rewards'},'retention':'complete','evidence':'repository.move\x20(struct)','bridgeIds':['b07'],'label':'Reward\x20pools\x20attached\x20to\x20the\x20repository'},{'id':'repository.policy_guard','family':'F','source':'Repository','target':'Guard','cardinality':'N','read':{'kind':'structFields','path':'policies','field':'guard'},'retention':'complete','evidence':'repository.move\x20(read/write\x20policies)','bridgeIds':['b02','b10'],'label':'Repository\x20read/write\x20policy\x20Guards\x20(value\x20gating)'},{'id':'contact.permission','family':'F','source':'Contact','target':'Permission','cardinality':0x1,'read':{'kind':'field','path':'permission'},'retention':'complete','evidence':'contact.move\x20L25-31','bridgeIds':['b09','b11'],'label':'Contact\x20book\x20permission\x20group'},{'id':'permission.admin','family':'F','source':'Permission','target':EOA,'cardinality':'N','read':{'kind':'fields','path':'admin'},'retention':'complete','evidence':'permission.move\x20L34-42\x20(admin\x20vector)','bridgeIds':['b09'],'label':'Admin\x20EOA\x20list\x20of\x20the\x20permission\x20group'},{'id':'guard.relies','family':'F','source':'Guard','target':'Guard','cardinality':'N','read':{'kind':'fields','path':'relies'},'retention':'complete','evidence':'guard.move\x20L85-95\x20(≤4,\x20one\x20level)','bridgeIds':['b10'],'label':'Sub-Guards\x20the\x20Guard\x20relies\x20on\x20(<=4,\x20one\x20level)'},{'id':'passport.signer','family':'F','source':'Passport','target':EOA,'cardinality':0x1,'read':{'kind':'field','path':'signer'},'retention':'complete','evidence':'passport.move\x20L41-49,L94-98','bridgeIds':['b12'],'label':'Passport\x20signer\x20(one-shot\x20per\x20transaction)'},{'id':'passport.guard','family':'F','source':'Passport','target':'Guard','cardinality':'N','read':{'kind':'structFields','path':'guard','field':'guard'},'retention':'complete','evidence':'passport.move\x20L41-49','bridgeIds':['b10','b12'],'label':'Guard\x20verification\x20tickets\x20held\x20by\x20the\x20passport'},{'id':'proof.signer','family':'F','source':'Proof','target':EOA,'cardinality':0x1,'read':{'kind':'field','path':'signer'},'retention':'complete','evidence':'proof.move\x20L14-25','bridgeIds':['b12'],'label':'WTS\x20evidence\x20signer'},{'id':'proof.about','family':'F','source':'Proof','target':ANY,'cardinality':'0..1','read':{'kind':'field','path':'about'},'retention':'complete','evidence':'proof.move\x20L14-25','bridgeIds':['b12'],'label':'Object\x20the\x20evidence\x20is\x20about'},{'id':'treasury.permission','family':'F','source':'Treasury','target':'Permission','cardinality':0x1,'read':{'kind':'field','path':'permission'},'retention':'complete','evidence':'treasury.move\x20L72-83','bridgeIds':['b09'],'label':'Treasury\x20permission\x20group'},{'id':'treasury.external_guard','family':'F','source':'Treasury','target':'Guard','cardinality':'N','read':{'kind':'fields','path':'external_guards'},'retention':'complete','evidence':'treasury.move\x20L72-83','bridgeIds':['b10'],'label':'Treasury\x20external\x20deposit/withdraw\x20Guards'}],R_EDGES=[{'id':'eoa.permission','family':'R','source':EOA,'target':'Permission','cardinality':'N','read':{'kind':'reverse','parent':'0xaad'},'retention':'membership','evidence':'entity_permission.move\x20L32\x20(bits\x201/2/4)','bridgeIds':['b09'],'label':'Permission\x20groups\x20the\x20account\x20currently\x20belongs\x20to\x20(membership;\x20disappears\x20on\x20removal)'},{'id':'eoa.order','family':'R','source':EOA,'target':'Order','cardinality':'N','read':{'kind':'reverse','parent':'0xaa8'},'retention':'bounded_window','evidence':'entity_order.move\x20L31\x20(FIFO\x205200)','bridgeIds':['b01'],'label':'Orders\x20the\x20account\x20joined\x20as\x20buyer/agent\x20(buyer\x20view,\x20FIFO\x205200)'},{'id':'eoa.contact','family':'R','source':EOA,'target':'Contact','cardinality':'N','read':{'kind':'reverse','parent':'0xaa9'},'retention':'membership','evidence':'entity_contact.move\x20L24','bridgeIds':['b11'],'label':'Contact\x20books\x20the\x20account\x20currently\x20joined'},{'id':'permission.core_binding','family':'R','source':'Permission','target':ANY,'cardinality':'N','read':{'kind':'reverse','parent':'0xaae'},'retention':'bounded_exact','evidence':'object_linker.move\x20L37,L88\x20(≤5200\x20aborts)','bridgeIds':['b09'],'label':'Core\x20objects\x20losslessly\x20linked\x20to\x20the\x20permission\x20group\x20(Service/Demand/Machine/...)'},{'id':'permission.tx_binding','family':'R','source':'Permission','target':ANY,'cardinality':'N','read':{'kind':'reverse','parent':'0xaaf'},'retention':'bounded_window','evidence':'object_linker.move\x20L43\x20(FIFO\x205200\x20operational)','bridgeIds':['b09'],'label':'Objects\x20touched\x20by\x20the\x20permission\x20group\x20at\x20runtime\x20(FIFO\x205200\x20lower\x20bound)'},{'id':'service.order','family':'R','source':'Service','target':'Order','cardinality':'N','read':{'kind':'reverse','parent':'0xaaf','filterType':'Order'},'retention':'bounded_window','evidence':'object_linker.move\x20L43,L136-140\x20(FIFO\x205200)','bridgeIds':['b01'],'label':'Shop\x20orders\x20(authoritative\x20merchant\x20view,\x20FIFO\x205200\x20lower\x20bound;\x20full\x20history\x20via\x20the\x20event\x20channel)'},{'id':'target.vote','family':'S','source':ANY,'target':EOA,'cardinality':'N','read':{'kind':'reverse','parent':'0xaaa'},'retention':'bounded_window','evidence':'registrar.move\x20L154-171\x20(ring\x205200,\x20bits\x200x02/0x04/0x08)','label':'like/dislike/favor\x20votes\x20received\x20by\x20the\x20target\x20address\x20(ring\x205200)'}],TABLE_EDGES=[{'id':'permission.entity','family':'R','source':'Permission','target':ANY,'cardinality':'N','read':{'kind':'table','rowType':'PermissionPerm'},'retention':'membership','evidence':'permission.move\x20L34-42\x20(entity\x20may\x20be\x20EOA\x20or\x20Guard\x20address)','bridgeIds':['b04','b09'],'label':'Entity-table\x20members\x20of\x20the\x20permission\x20group\x20(EOA\x20or\x20Guard,\x20carrying\x20perm\x20index\x20bits)'},{'id':'demand.presenter','family':'R','source':'Demand','target':EOA,'cardinality':'N','read':{'kind':'table','rowType':'DemandPresenter'},'retention':'membership','evidence':'demand.move\x20L68-77\x20(presenters\x20table)','bridgeIds':['b03'],'label':'Suppliers\x20that\x20presented\x20to\x20the\x20demand,\x20with\x20acceptance_score'},{'id':'machine.node','family':'W','source':'Machine','target':'MachineNode','cardinality':'N','read':{'kind':'table','rowType':'MachineNode'},'retention':'complete','evidence':'machine.move\x20L299-308\x20(immutable\x20after\x20publish)','bridgeIds':['b04'],'contract':{'field':'nodes','frozenWhen':'after\x20publish','forbiddenActions':['add','remove','update'],'allowedActions':[],'unfreeze':null,'moveAnchor':'machine.move\x20node_add_imp\x20/\x20node_remove_imp\x20/\x20node_rename_imp\x20(assert_not_published)'},'label':'Workflow\x20node\x20table\x20(immutable\x20after\x20publish)'}],W_EDGES=[{'id':'wf.transition','family':'W','source':'MachineNode','target':'MachineNode','cardinality':'N','read':{'kind':'derived','producer':'machineRows'},'retention':'derived','evidence':'machine.move\x20L101\x20NodePair,L269','bridgeIds':['b04'],'label':'Node-pair\x20directed\x20edges\x20(prev_node→node,\x20carrying\x20threshold)'},{'id':'wf.forward_guard','family':'W','source':'MachineNode','target':'Guard','cardinality':'N','read':{'kind':'derived','producer':'machineRows'},'retention':'derived','evidence':'machine.move\x20L63\x20Forward','bridgeIds':['b04','b05','b10','b12'],'label':'Post-guards\x20of\x20forward\x20operations\x20(supply-chain/payout\x20allocation\x20attach\x20points)'}],M_EDGES=[{'id':'payment.recipient','family':'M','source':'Payment','target':EOA,'cardinality':'N','read':{'kind':'structFields','path':'record','field':'recipient'},'retention':'complete','evidence':'payment.move\x20L93-101\x20(Revenue≤200)','bridgeIds':['b05','b08'],'label':'Payment\x20allocation\x20recipients\x20(with\x20amounts,\x20leg\x20by\x20leg)'},{'id':'payment.from_object','family':'M','source':'Payment','target':ANY,'cardinality':'0..1','read':{'kind':'field','path':'from_object'},'retention':'complete','evidence':'payment.move\x20L149-161\x20(framework-only)','bridgeIds':['b05','b08'],'label':'Funding\x20source\x20pool\x20(Treasury/Allocation/Service;\x20framework-settable\x20only)'},{'id':'payment.for_object','family':'M','source':'Payment','target':ANY,'cardinality':'0..1','read':{'kind':'field','path':'info.for_object'},'retention':'complete','evidence':'payment.move\x20L93-101\x20(info\x20routing\x20hint)','bridgeIds':['b05','b08'],'label':'Business\x20routing\x20object\x20(user-settable)'},{'id':'payment.for_guard','family':'M','source':'Payment','target':'Guard','cardinality':'0..1','read':{'kind':'field','path':'info.for_guard'},'retention':'complete','evidence':'payment.move\x20L93-101','bridgeIds':['b05'],'label':'Business\x20routing\x20Guard'}];export const EDGE_SCHEMAS=[...F_EDGES,...R_EDGES,...TABLE_EDGES,...W_EDGES,...M_EDGES];export const EDGE_SCHEMA_BY_ID=new Map(EDGE_SCHEMAS['map'](a=>[a['id'],a]));export function outgoingSchemaIds(a){return EDGE_SCHEMAS['filter'](b=>b['source']===a||b['source']===ANY)['map'](b=>b['id']);}export const COVERED_OBJECT_TYPES=[...new Set(EDGE_SCHEMAS['flatMap'](a=>[a['source'],a['target']])['filter'](a=>a!==EOA&&a!==ANY&&a!=='MachineNode'))];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{COMMERCIAL_ROLES}from'../../role/types.js';import{resolveInterests,ROLE_INTERESTS}from'../../evaluation/game-strategy.js';import{evaluateNodeGame}from'../../evaluation/node-game.js';import{evaluateArbGame}from'../../evaluation/arbitration-game.js';import{consequenceOf,recommendedCallForExecutionPath}from'../../participation/radar-core.js';import{buildViewport}from'./viewport.js';import{buildControlIndex,pathConfidence,runAnalyzers}from'./analyze.js';import{orderCompletionInGraph}from'./expand.js';const VIEWER_OF={'customer':'buyer','prospect':'buyer','demander':'demander','merchant':'merchant','collaborator':'collaborator','supplier':'supplier','arbitrator':'arbitrator','neutral':'neutral','system':'system'},COMMERCIAL_ROLE_SET=new Set(COMMERCIAL_ROLES);export function toCommercialRole(a){if(a==='buyer')return'customer';return COMMERCIAL_ROLE_SET['has'](a)?a:'neutral';}export function viewerRoleOf(a){return VIEWER_OF[a];}function root(a){const b=a?.['raw'],c=b?.['data']??b;return c&&typeof c==='object'?c:undefined;}function str(a){return typeof a==='string'&&a!=='0x0'?a:undefined;}function objNode(a,b){const c=a['graph']['nodes']['get'](b['toLowerCase']());return c&&a['visibleNodes']['has'](c['id'])&&c['kind']==='object'&&c['raw']?c:undefined;}function visible(a,b){return a['visibleEdges']['filter'](c=>c['schema']===b);}function outEdges(a,b,c){const d=b['toLowerCase']();return a['visibleEdges']['filter'](f=>f['schema']===c&&f['from']===d);}function incEdges(a,b,c){const d=b['toLowerCase']();return a['visibleEdges']['filter'](f=>f['schema']===c&&f['to']===d);}function wfMachineOf(a){const b=a['indexOf']('::node::');return b>=0x0?a['slice'](0x0,b):'';}function wfNodeName(a){const b=a['indexOf']('::node::');return b>=0x0?a['slice'](b+'::node::'['length']):a;}function heldPermissionIndices(a,c){const d=new Map();for(const f of outEdges(a,c,'eoa.permission')){const g=new Set();d['set'](f['to'],g);for(const h of outEdges(a,f['to'],'permission.entity')){for(const i of Array['isArray'](h['payload']?.['permIndices'])?h['payload']['permIndices']:[]){const j=Number(i);if(Number['isInteger'](j))g['add'](j);}}}return d;}const MAX_STAKES=0x10;function orderStake(a,b,c,e){const f=objNode(a,b),g=root(f)??{},h=orderCompletionInGraph(a['graph'],b);return{'object':b['toLowerCase'](),'object_type':f?.['objectType']??'Order','positions':c,...str(g['amount'])?{'amount':String(g['amount'])}:{},...f?.['coinType']?{'coin_type':f['coinType']}:{},...h['status']!=='unknown'||f?{'state':h['status']}:{},'evidence':e};}function arbState(a,b){return str(root(objNode(a,b))?.['status']);}function collectStakes(a,b,c,d){const f=new Map(),g=(j,k,l,m)=>{const n=j['toLowerCase'](),o=f['get'](n);if(o){if(!o['positions']['includes'](k))o['positions']['push'](k);for(const p of l)if(!o['evidence']['includes'](p))o['evidence']['push'](p);return;}if(f['size']>=MAX_STAKES)return;f['set'](n,m([k],l));},h=new Set();for(const j of outEdges(a,b,'eoa.order'))h['add'](j['to']);for(const k of incEdges(a,b,'order.builder'))h['add'](k['from']);for(const l of h){g(l,'buyer',['eoa.order','order.builder'],(m,n)=>orderStake(a,l,m,n));}const i=new Set(d['keys']());for(const m of outEdges(a,b,'eoa.permission'))i['add'](m['to']);for(const [n,o]of c['objectsByEoa']){if(n!==b)continue;for(const p of o){const q=a['graph']['nodes']['get'](p);q?.['objectType']==='Demand'?g(p,'demand_owner',['eoa.permission','demand.permission'],(r,s)=>{const t=outEdges(a,p,'demand.presenter')['length'];return{'object':p['toLowerCase'](),'object_type':'Demand','positions':r,'state':t+'\x20presenter(s)','evidence':s};}):g(p,'controller',['eoa.permission','permission.core_binding'],(r,s)=>({'object':p['toLowerCase'](),'object_type':q?.['objectType']??'object','positions':r,'evidence':s}));}}for(const r of visible(a,'demand.permission')){if(!i['has'](r['to']))continue;g(r['from'],'demand_owner',['demand.permission'],(s,t)=>{const u=outEdges(a,r['from'],'demand.presenter')['length'];return{'object':r['from']['toLowerCase'](),'object_type':'Demand','positions':s,'state':u+'\x20presenter(s)','evidence':t};});}for(const [s,t]of c['objectsByEoa']){if(s!==b)continue;for(const u of t){if(a['graph']['nodes']['get'](u)?.['objectType']!=='Service')continue;for(const w of outEdges(a,u,'service.order')){g(w['to'],'seller',['service.order'],(x,y)=>orderStake(a,w['to'],x,y));}}}for(const x of incEdges(a,b,'demand.presenter')){g(x['from'],'presenter',['demand.presenter'],(y,z)=>({'object':x['from']['toLowerCase'](),'object_type':a['graph']['nodes']['get'](x['from'])?.['objectType']??'Demand','positions':y,'evidence':z}));}for(const y of incEdges(a,b,'arb.voter')){g(y['from'],'voter',['arb.voter'],(z,A)=>{const B=arbState(a,y['from']);return{'object':y['from']['toLowerCase'](),'object_type':'Arb','positions':z,...B?{'state':B}:{},'evidence':A};});}for(const [z,A]of c['objectsByEoa']){if(z!==b)continue;for(const B of A){if(a['graph']['nodes']['get'](B)?.['objectType']!=='Arbitration')continue;for(const C of incEdges(a,B,'arb.arbitration_service')){g(C['from'],'arbitration_owner',['arb.arbitration_service'],(D,E)=>{const F=arbState(a,C['from']);return{'object':C['from']['toLowerCase'](),'object_type':'Arb','positions':D,...F?{'state':F}:{},'evidence':E};});}}}for(const [D,E]of f){if(a['graph']['nodes']['get'](D)?.['objectType']!=='Order')continue;if(outEdges(a,D,'order.dispute')['length']>0x0&&!E['positions']['includes']('disputant')){E['positions']['push']('disputant');if(!E['evidence']['includes']('order.dispute'))E['evidence']['push']('order.dispute');}}return[...f['values']()];}const MAX_ACTION_GROUPS=0x8;function forwardsAt(a,b,c){const d=b['toLowerCase']()+'::node::',f=[];for(const g of a['visibleEdges']){if(g['schema']!=='wf.transition'||!g['from']['startsWith'](d))continue;if(wfNodeName(g['from'])!==c)continue;f['push']({'edge':g,'name':String(g['payload']?.['forward']??g['payload']?.['prevNode']+'→'+g['payload']?.['node']),'toNode':String(g['payload']?.['node']??wfNodeName(g['to'])),'permissionIndex':typeof g['payload']?.['permissionIndex']==='number'?g['payload']['permissionIndex']:null,'namedOperator':typeof g['payload']?.['namedOperator']==='string'?g['payload']['namedOperator']:null,'guard':str(g['payload']?.['guard']),'weight':typeof g['payload']?.['weight']==='number'?g['payload']['weight']:undefined,'threshold':typeof g['payload']?.['threshold']==='number'?g['payload']['threshold']:undefined});}return f;}function executionPathOf(a,b,c){if(a['permissionIndex']!=null)return c['has'](a['permissionIndex'])?'permission':'not_available';if(a['namedOperator']==='')return b?'order_holder':'not_available';return'not_available';}function allocationSummaryOf(a,b,c,e){const f=outEdges(a,b,'order.allocation')[0x0]?.['to'];if(!f)return undefined;const g=root(objNode(a,f)),h=Array['isArray'](g?.['allocators'])?g['allocators']:[];if(h['length']===0x0)return undefined;let i=0x0,j=0x0,k=0x0,l=0x0;const m=o=>{if(typeof o==='string')return o['startsWith']('0x')||o['startsWith']('00')?o['toLowerCase']():undefined;if(o&&typeof o==='object'){const p=o;if('Entity'in p)return typeof p['Entity']==='string'?p['Entity']['toLowerCase']():undefined;}return undefined;},n=o=>(o&&typeof o==='object'&&'GuardIdentifier'in o)===!![];for(const o of h){const p=o??{};for(const q of Array['isArray'](p['sharing'])?p['sharing']:[]){const r=q??{};i++;const t=m(r['who']);if(t===c['toLowerCase']())k++;else{if(e&&t===e['toLowerCase']())l++;else{if(r['who']==='Signer')l++;else{if(n(r['who']))j++;}}}}}if(i===0x0)return undefined;return{'recipient_slots':i,'guard_gated_slots':j,'direct_to_me_slots':k,'to_payer_slots':l};}function actionGroupFor(a,b,c,e,g,h,i){const j=objNode(a,g),k=root(j)??{},l=str(k['progress']),m=str(k['machine'])??wfMachineOf(l??''),n=l?root(objNode(a,l)):undefined,o=str(n?.['current'])??'';if(!m||!o||!l)return undefined;const p=forwardsAt(a,m,o);if(p['length']===0x0)return undefined;const q=outEdges(a,g,'order.service')[0x0]?.['to'],r=q?root(objNode(a,q)):undefined,s=outEdges(a,g,'order.builder')[0x0]?.['to'],t=[],u=[],w=new Map(),x=[];for(const A of p){const B=executionPathOf(A,h,i);if(B==='not_available'){const D=A['permissionIndex']!=null?'requires\x20permission\x20index\x20'+A['permissionIndex']+'\x20(not\x20held\x20by\x20the\x20observer\x20in\x20this\x20view)':A['namedOperator']!=null&&A['namedOperator']!==''?'named\x20operator\x20\x27'+A['namedOperator']+'\x27\x20resolves\x20off-chain\x20(LocalMark)\x20—\x20not\x20decidable\x20from\x20graph\x20evidence':'unbound\x20forward\x20—\x20only\x20a\x20guard\x20or\x20the\x20payer\x27s\x20transaction\x20can\x20advance\x20it';u['push']({'forward':A['name'],'reason':D});const E=A['permissionIndex']!=null?'permission\x20index\x20'+A['permissionIndex']:A['namedOperator']!=null&&A['namedOperator']!==''?'named\x20operator\x20\x27'+A['namedOperator']+'\x27':'guard/payer-direct\x20only',F=w['get'](E)??[];F['push'](A['name']),w['set'](E,F);continue;}const C=recommendedCallForExecutionPath(B,A['guard']!=null);t['push']({'name':A['name'],'to_node':A['toNode'],'execution_path':B,...A['guard']?{'guard':A['guard']}:{},'consequence':consequenceOf(A['toNode'],undefined),...A['weight']!==undefined?{'weight':A['weight']}:{}});if(C)x['push']({'forward':A['name'],'call':C});}const y=Math['max'](0x1,...p['map'](G=>G['threshold']??0x1)),z=evaluateNodeGame({'current_node':o,'perspective':c,...e?.['risk_appetite']?{'appetite':e['risk_appetite']}:{},...y>0x1?{'threshold':y}:{},'allocation':allocationSummaryOf(a,g,b,s),...e?.['requirements']?{'requirements':e['requirements']}:{},...str(k['amount'])?{'order_amount':String(k['amount'])}:{},...r&&str(r['compensation_fund'])?{'compensation_fund':String(r['compensation_fund'])}:{},'operable':t,'waiting_on':[...w['entries']()]['map'](([G,H])=>({'role':G,'forwards':H}))});return{'order':g['toLowerCase'](),'machine':m['toLowerCase'](),'current_node':o,'advice':z,'recommended_calls':x,'blocked_forwards':u};}function collectActions(a,c,d,e,f,g){const h=new Set();for(const j of g['values']())for(const k of j)h['add'](k);const i=[];for(const l of f){if(i['length']>=MAX_ACTION_GROUPS)break;if(a['graph']['nodes']['get'](l['object'])?.['objectType']!=='Order')continue;const m=l['positions']['includes']('buyer'),n=actionGroupFor(a,c,d,e,l['object'],m,h);n&&(n['advice']['actions']['length']>0x0||n['blocked_forwards']['length']>0x0)&&i['push'](n);}return i;}function arbPerspectiveOf(a,b,c){if(c['positions']['includes']('voter')||c['positions']['includes']('arbitration_owner'))return'arbitrator';if(c['positions']['includes']('buyer')||c['positions']['includes']('disputant'))return'customer';if(c['positions']['includes']('seller'))return'merchant';return undefined;}function collectArbActions(a,b,c,d){const e=[];for(const f of d){if(a['graph']['nodes']['get'](f['object'])?.['objectType']!=='Arb')continue;const g=arbPerspectiveOf(a,b,f),h=arbState(a,f['object']);if(!g||!h)continue;e['push'](evaluateArbGame(h,g,{...c?.['risk_appetite']?{'risk_appetite':c['risk_appetite']}:{},...c?.['requirements']?{'requirements':c['requirements']}:{}}));}return e;}const SEVERITY_RANK={'info':0x0,'low':0x1,'medium':0x2,'high':0x3},MAX_COUNTERPARTIES=0x8;function collectCounterparties(a,b,c,d,e,f){const g=resolveInterests(c,d),h=[],i=(j,k,l)=>{if(h['length']>=MAX_COUNTERPARTIES)return;const m=ROLE_INTERESTS[k],n=[...g['prefer']['filter'](r=>m['avoid']['includes'](r)),...g['avoid']['filter'](r=>m['prefer']['includes'](r))],o=g['prefer']['filter'](r=>m['prefer']['includes'](r)),p=n['length']>0x0?'conflict':o['length']>0x0?'aligned':'neutral',q=p==='conflict'?'结构性利益冲突:你偏好\x20'+(g['prefer']['filter'](r=>m['avoid']['includes'](r))['join']('、')||'(无)')+',而\x20'+k+'\x20将其视为风险;对方追求\x20'+(m['prefer']['join']('、')||'(无)')+'。':p==='aligned'?'利益一致:双方都偏好\x20'+o['join']('、')+'。':'无直接利益交叠('+k+'\x20偏好\x20'+(m['prefer']['join']('、')||'无')+'、回避\x20'+(m['avoid']['join']('、')||'无')+')。';h['push']({'object':j['toLowerCase'](),'counter_role':k,'who':l,'their_prefer':m['prefer'],'their_avoid':m['avoid'],'alignment':p,'noteZh':q});};for(const j of e){if(a['graph']['nodes']['get'](j['object'])?.['objectType']!=='Order')continue;const k=outEdges(a,j['object'],'order.service')[0x0]?.['to'],l=k?[...f['controllers']['get'](k['toLowerCase']())??[]]:[];i(j['object'],'merchant',l);const m=outEdges(a,j['object'],'order.builder')[0x0]?.['to'];if(m&&m!==b['toLowerCase']())i(j['object'],'customer',[m]);if(outEdges(a,j['object'],'order.dispute')['length']>0x0)i(j['object'],'arbitrator',[]);}return h;}const MAX_RISK_REMINDERS=0xa;function collectRiskReminders(a,b){try{return runAnalyzers(a,{'kinds':['risk']})['filter'](c=>c['roles']['includes'](b)||c['roles']['includes']('neutral'))['sort']((c,d)=>SEVERITY_RANK[d['severity']]-SEVERITY_RANK[c['severity']])['slice'](0x0,MAX_RISK_REMINDERS);}catch{return[];}}export function buildRoleInterest(a,b,c,d){const e=b['toLowerCase'](),f=VIEWER_OF[c],g=buildViewport(a,e,f),h=buildControlIndex(g),i=heldPermissionIndices(g,e),j=collectStakes(g,e,h,i),k=collectActions(g,e,c,d,j,i),l=collectArbActions(g,e,d,j),m=collectCounterparties(g,e,c,d,j,h),n=collectRiskReminders(g,f),o=k['find'](y=>y['advice']['actions']['length']>0x0)?.['advice']['actions'][0x0],p=m['find'](y=>y['alignment']==='conflict'),q='以\x20'+c+'\x20身份观察\x20'+e+':'+(j['length']+'\x20项在途利益('+j['map'](y=>y['object_type']+':'+y['positions']['join']('/'))['slice'](0x0,0x4)['join']('、')+(j['length']>0x4?'\x20等':'')+');')+(o?'当前可执行的最优操作为订单\x20'+(k['find'](y=>y['advice']['actions'][0x0]===o)?.['order']??'')+'\x20的\x20\x27'+o['forward']+'\x27('+o['payoff_note']+');':k['length']>0x0?'存在在途订单但无可由本视角执行的操作(等待他方或链下解析);':'当前无可操作的在途订单;')+(l['length']>0x0?l['length']+'\x20个仲裁案件的行动建议;':'')+(p?'最大结构性对手张力:'+p['counter_role']+'('+p['noteZh']+')':'无明显对手张力')+(n['length']>0x0?';'+n['length']+'\x20条角色相关风险提醒。':'。'),r={'role':c,'observer':e,...d&&(d['risk_appetite']||d['requirements']?.['length'])?{'drive':d}:{},'stakes':j,'actions':k,'arb_actions':l,'counterparties':m,'risk_finding_ids':n['map'](y=>y['id']),'summaryZh':q},s=g['visibleEdges']['filter'](y=>['eoa.order','service.order','demand.presenter','arb.voter','order.dispute']['includes'](y['schema'])),{confidence:t,window:u}=pathConfidence(g,s),w=n['length']>0x0&&SEVERITY_RANK[n[0x0]['severity']]>=SEVERITY_RANK['medium']?n[0x0]['severity']:'info',x={'id':'IR:'+c+':'+e,'kind':'game','severity':w,'titleZh':'角色利益视图('+c+'):'+j['length']+'\x20项在途利益'+(o?',最优操作\x20\x27'+o['forward']+'\x27':''),'path':[e,...j['map'](y=>y['object'])],'confidence':t,...u?{'window':u}:{},'roles':[f],'detailZh':q,'suggestionZh':o?'按\x20advice\x20排序执行(\x27'+o['forward']+'\x27\x20需'+(o['guard']?'先通过\x20Guard\x20护照校验、':'')+'经\x20recommended_calls\x20给出的工具路由);对手张力与风险提醒见\x20payload。':'无可执行操作时:关注\x20blocked_forwards\x20的等待条件与对手张力变化,或切换\x20role/context_account\x20重新投影。','interest':r};return{'finding':x,'view':r};}
|
|
1
|
+
import{COMMERCIAL_ROLES}from'../../role/types.js';import{resolveInterests,ROLE_INTERESTS}from'../../evaluation/game-strategy.js';import{evaluateNodeGame}from'../../evaluation/node-game.js';import{evaluateArbGame}from'../../evaluation/arbitration-game.js';import{consequenceOf,recommendedCallForExecutionPath}from'../../participation/radar-core.js';import{buildViewport}from'./viewport.js';import{buildControlIndex,pathConfidence,runAnalyzers}from'./analyze.js';import{orderCompletionInGraph}from'./expand.js';const VIEWER_OF={'customer':'buyer','prospect':'buyer','demander':'demander','merchant':'merchant','collaborator':'collaborator','supplier':'supplier','arbitrator':'arbitrator','neutral':'neutral','system':'system'},COMMERCIAL_ROLE_SET=new Set(COMMERCIAL_ROLES);export function toCommercialRole(a){if(a==='buyer')return'customer';return COMMERCIAL_ROLE_SET['has'](a)?a:'neutral';}export function viewerRoleOf(a){return VIEWER_OF[a];}function root(a){const b=a?.['raw'],c=b?.['data']??b;return c&&typeof c==='object'?c:undefined;}function str(a){return typeof a==='string'&&a!=='0x0'?a:undefined;}function objNode(a,b){const c=a['graph']['nodes']['get'](b['toLowerCase']());return c&&a['visibleNodes']['has'](c['id'])&&c['kind']==='object'&&c['raw']?c:undefined;}function visible(a,b){return a['visibleEdges']['filter'](c=>c['schema']===b);}function outEdges(a,b,c){const d=b['toLowerCase']();return a['visibleEdges']['filter'](f=>f['schema']===c&&f['from']===d);}function incEdges(a,b,c){const d=b['toLowerCase']();return a['visibleEdges']['filter'](f=>f['schema']===c&&f['to']===d);}function wfMachineOf(a){const b=a['indexOf']('::node::');return b>=0x0?a['slice'](0x0,b):'';}function wfNodeName(a){const b=a['indexOf']('::node::');return b>=0x0?a['slice'](b+'::node::'['length']):a;}function heldPermissionIndices(a,c){const d=new Map();for(const f of outEdges(a,c,'eoa.permission')){const g=new Set();d['set'](f['to'],g);for(const h of outEdges(a,f['to'],'permission.entity')){for(const i of Array['isArray'](h['payload']?.['permIndices'])?h['payload']['permIndices']:[]){const j=Number(i);if(Number['isInteger'](j))g['add'](j);}}}return d;}const MAX_STAKES=0x10;function orderStake(a,b,c,e){const f=objNode(a,b),g=root(f)??{},h=orderCompletionInGraph(a['graph'],b);return{'object':b['toLowerCase'](),'object_type':f?.['objectType']??'Order','positions':c,...str(g['amount'])?{'amount':String(g['amount'])}:{},...f?.['coinType']?{'coin_type':f['coinType']}:{},...h['status']!=='unknown'||f?{'state':h['status']}:{},'evidence':e};}function arbState(a,b){return str(root(objNode(a,b))?.['status']);}function collectStakes(a,b,c,d){const f=new Map(),g=(j,k,l,m)=>{const n=j['toLowerCase'](),o=f['get'](n);if(o){if(!o['positions']['includes'](k))o['positions']['push'](k);for(const p of l)if(!o['evidence']['includes'](p))o['evidence']['push'](p);return;}if(f['size']>=MAX_STAKES)return;f['set'](n,m([k],l));},h=new Set();for(const j of outEdges(a,b,'eoa.order'))h['add'](j['to']);for(const k of incEdges(a,b,'order.builder'))h['add'](k['from']);for(const l of h){g(l,'buyer',['eoa.order','order.builder'],(m,n)=>orderStake(a,l,m,n));}const i=new Set(d['keys']());for(const m of outEdges(a,b,'eoa.permission'))i['add'](m['to']);for(const [n,o]of c['objectsByEoa']){if(n!==b)continue;for(const p of o){const q=a['graph']['nodes']['get'](p);q?.['objectType']==='Demand'?g(p,'demand_owner',['eoa.permission','demand.permission'],(r,s)=>{const t=outEdges(a,p,'demand.presenter')['length'];return{'object':p['toLowerCase'](),'object_type':'Demand','positions':r,'state':t+'\x20presenter(s)','evidence':s};}):g(p,'controller',['eoa.permission','permission.core_binding'],(r,s)=>({'object':p['toLowerCase'](),'object_type':q?.['objectType']??'object','positions':r,'evidence':s}));}}for(const r of visible(a,'demand.permission')){if(!i['has'](r['to']))continue;g(r['from'],'demand_owner',['demand.permission'],(s,t)=>{const u=outEdges(a,r['from'],'demand.presenter')['length'];return{'object':r['from']['toLowerCase'](),'object_type':'Demand','positions':s,'state':u+'\x20presenter(s)','evidence':t};});}for(const [s,t]of c['objectsByEoa']){if(s!==b)continue;for(const u of t){if(a['graph']['nodes']['get'](u)?.['objectType']!=='Service')continue;for(const w of outEdges(a,u,'service.order')){g(w['to'],'seller',['service.order'],(x,y)=>orderStake(a,w['to'],x,y));}}}for(const x of incEdges(a,b,'demand.presenter')){g(x['from'],'presenter',['demand.presenter'],(y,z)=>({'object':x['from']['toLowerCase'](),'object_type':a['graph']['nodes']['get'](x['from'])?.['objectType']??'Demand','positions':y,'evidence':z}));}for(const y of incEdges(a,b,'arb.voter')){g(y['from'],'voter',['arb.voter'],(z,A)=>{const B=arbState(a,y['from']);return{'object':y['from']['toLowerCase'](),'object_type':'Arb','positions':z,...B?{'state':B}:{},'evidence':A};});}for(const [z,A]of c['objectsByEoa']){if(z!==b)continue;for(const B of A){if(a['graph']['nodes']['get'](B)?.['objectType']!=='Arbitration')continue;for(const C of incEdges(a,B,'arb.arbitration_service')){g(C['from'],'arbitration_owner',['arb.arbitration_service'],(D,E)=>{const F=arbState(a,C['from']);return{'object':C['from']['toLowerCase'](),'object_type':'Arb','positions':D,...F?{'state':F}:{},'evidence':E};});}}}for(const [D,E]of f){if(a['graph']['nodes']['get'](D)?.['objectType']!=='Order')continue;if(outEdges(a,D,'order.dispute')['length']>0x0&&!E['positions']['includes']('disputant')){E['positions']['push']('disputant');if(!E['evidence']['includes']('order.dispute'))E['evidence']['push']('order.dispute');}}return[...f['values']()];}const MAX_ACTION_GROUPS=0x8;function forwardsAt(a,b,c){const d=b['toLowerCase']()+'::node::',f=[];for(const g of a['visibleEdges']){if(g['schema']!=='wf.transition'||!g['from']['startsWith'](d))continue;if(wfNodeName(g['from'])!==c)continue;f['push']({'edge':g,'name':String(g['payload']?.['forward']??g['payload']?.['prevNode']+'→'+g['payload']?.['node']),'toNode':String(g['payload']?.['node']??wfNodeName(g['to'])),'permissionIndex':typeof g['payload']?.['permissionIndex']==='number'?g['payload']['permissionIndex']:null,'namedOperator':typeof g['payload']?.['namedOperator']==='string'?g['payload']['namedOperator']:null,'guard':str(g['payload']?.['guard']),'weight':typeof g['payload']?.['weight']==='number'?g['payload']['weight']:undefined,'threshold':typeof g['payload']?.['threshold']==='number'?g['payload']['threshold']:undefined});}return f;}function executionPathOf(a,b,c){if(a['permissionIndex']!=null)return c['has'](a['permissionIndex'])?'permission':'not_available';if(a['namedOperator']==='')return b?'order_holder':'not_available';return'not_available';}function allocationSummaryOf(a,b,c,e){const f=outEdges(a,b,'order.allocation')[0x0]?.['to'];if(!f)return undefined;const g=root(objNode(a,f)),h=Array['isArray'](g?.['allocators'])?g['allocators']:[];if(h['length']===0x0)return undefined;let i=0x0,j=0x0,k=0x0,l=0x0;const m=o=>{if(typeof o==='string')return o['startsWith']('0x')||o['startsWith']('00')?o['toLowerCase']():undefined;if(o&&typeof o==='object'){const p=o;if('Entity'in p)return typeof p['Entity']==='string'?p['Entity']['toLowerCase']():undefined;}return undefined;},n=o=>(o&&typeof o==='object'&&'GuardIdentifier'in o)===!![];for(const o of h){const p=o??{};for(const q of Array['isArray'](p['sharing'])?p['sharing']:[]){const r=q??{};i++;const t=m(r['who']);if(t===c['toLowerCase']())k++;else{if(e&&t===e['toLowerCase']())l++;else{if(r['who']==='Signer')l++;else{if(n(r['who']))j++;}}}}}if(i===0x0)return undefined;return{'recipient_slots':i,'guard_gated_slots':j,'direct_to_me_slots':k,'to_payer_slots':l};}function actionGroupFor(a,b,c,e,g,h,i){const j=objNode(a,g),k=root(j)??{},l=str(k['progress']),m=str(k['machine'])??wfMachineOf(l??''),n=l?root(objNode(a,l)):undefined,o=str(n?.['current'])??'';if(!m||!o||!l)return undefined;const p=forwardsAt(a,m,o);if(p['length']===0x0)return undefined;const q=outEdges(a,g,'order.service')[0x0]?.['to'],r=q?root(objNode(a,q)):undefined,s=outEdges(a,g,'order.builder')[0x0]?.['to'],t=[],u=[],w=new Map(),x=[];for(const A of p){const B=executionPathOf(A,h,i);if(B==='not_available'){const D=A['permissionIndex']!=null?'requires\x20permission\x20index\x20'+A['permissionIndex']+'\x20(not\x20held\x20by\x20the\x20observer\x20in\x20this\x20view)':A['namedOperator']!=null&&A['namedOperator']!==''?'named\x20operator\x20\x27'+A['namedOperator']+'\x27\x20resolves\x20off-chain\x20(LocalMark)\x20—\x20not\x20decidable\x20from\x20graph\x20evidence':'unbound\x20forward\x20—\x20only\x20a\x20guard\x20or\x20the\x20payer\x27s\x20transaction\x20can\x20advance\x20it';u['push']({'forward':A['name'],'reason':D});const E=A['permissionIndex']!=null?'permission\x20index\x20'+A['permissionIndex']:A['namedOperator']!=null&&A['namedOperator']!==''?'named\x20operator\x20\x27'+A['namedOperator']+'\x27':'guard/payer-direct\x20only',F=w['get'](E)??[];F['push'](A['name']),w['set'](E,F);continue;}const C=recommendedCallForExecutionPath(B,A['guard']!=null);t['push']({'name':A['name'],'to_node':A['toNode'],'execution_path':B,...A['guard']?{'guard':A['guard']}:{},'consequence':consequenceOf(A['toNode'],undefined),...A['weight']!==undefined?{'weight':A['weight']}:{}});if(C)x['push']({'forward':A['name'],'call':C});}const y=Math['max'](0x1,...p['map'](G=>G['threshold']??0x1)),z=evaluateNodeGame({'current_node':o,'perspective':c,...e?.['risk_appetite']?{'appetite':e['risk_appetite']}:{},...y>0x1?{'threshold':y}:{},'allocation':allocationSummaryOf(a,g,b,s),...e?.['requirements']?{'requirements':e['requirements']}:{},...str(k['amount'])?{'order_amount':String(k['amount'])}:{},...r&&str(r['compensation_fund'])?{'compensation_fund':String(r['compensation_fund'])}:{},'operable':t,'waiting_on':[...w['entries']()]['map'](([G,H])=>({'role':G,'forwards':H}))});return{'order':g['toLowerCase'](),'machine':m['toLowerCase'](),'current_node':o,'advice':z,'recommended_calls':x,'blocked_forwards':u};}function collectActions(a,c,d,e,f,g){const h=new Set();for(const j of g['values']())for(const k of j)h['add'](k);const i=[];for(const l of f){if(i['length']>=MAX_ACTION_GROUPS)break;if(a['graph']['nodes']['get'](l['object'])?.['objectType']!=='Order')continue;const m=l['positions']['includes']('buyer'),n=actionGroupFor(a,c,d,e,l['object'],m,h);n&&(n['advice']['actions']['length']>0x0||n['blocked_forwards']['length']>0x0)&&i['push'](n);}return i;}function arbPerspectiveOf(a,b,c){if(c['positions']['includes']('voter')||c['positions']['includes']('arbitration_owner'))return'arbitrator';if(c['positions']['includes']('buyer')||c['positions']['includes']('disputant'))return'customer';if(c['positions']['includes']('seller'))return'merchant';return undefined;}function collectArbActions(a,b,c,d){const e=[];for(const f of d){if(a['graph']['nodes']['get'](f['object'])?.['objectType']!=='Arb')continue;const g=arbPerspectiveOf(a,b,f),h=arbState(a,f['object']);if(!g||!h)continue;e['push'](evaluateArbGame(h,g,{...c?.['risk_appetite']?{'risk_appetite':c['risk_appetite']}:{},...c?.['requirements']?{'requirements':c['requirements']}:{}}));}return e;}const SEVERITY_RANK={'info':0x0,'low':0x1,'medium':0x2,'high':0x3},MAX_COUNTERPARTIES=0x8;function collectCounterparties(a,b,c,d,e,f){const g=resolveInterests(c,d),h=[],i=(j,k,l)=>{if(h['length']>=MAX_COUNTERPARTIES)return;const m=ROLE_INTERESTS[k],n=[...g['prefer']['filter'](r=>m['avoid']['includes'](r)),...g['avoid']['filter'](r=>m['prefer']['includes'](r))],o=g['prefer']['filter'](r=>m['prefer']['includes'](r)),p=n['length']>0x0?'conflict':o['length']>0x0?'aligned':'neutral',q=p==='conflict'?'Structural\x20conflict\x20of\x20interest:\x20you\x20prefer\x20'+(g['prefer']['filter'](r=>m['avoid']['includes'](r))['join'](',\x20')||'(none)')+',\x20which\x20'+k+'\x20treats\x20as\x20a\x20risk;\x20they\x20pursue\x20'+(m['prefer']['join'](',\x20')||'(none)')+'.':p==='aligned'?'Aligned\x20interests:\x20both\x20sides\x20prefer\x20'+o['join'](',\x20')+'.':'No\x20direct\x20interest\x20overlap\x20('+k+'\x20prefers\x20'+(m['prefer']['join'](',\x20')||'none')+'\x20and\x20avoids\x20'+(m['avoid']['join'](',\x20')||'none')+').';h['push']({'object':j['toLowerCase'](),'counter_role':k,'who':l,'their_prefer':m['prefer'],'their_avoid':m['avoid'],'alignment':p,'note':q});};for(const j of e){if(a['graph']['nodes']['get'](j['object'])?.['objectType']!=='Order')continue;const k=outEdges(a,j['object'],'order.service')[0x0]?.['to'],l=k?[...f['controllers']['get'](k['toLowerCase']())??[]]:[];i(j['object'],'merchant',l);const m=outEdges(a,j['object'],'order.builder')[0x0]?.['to'];if(m&&m!==b['toLowerCase']())i(j['object'],'customer',[m]);if(outEdges(a,j['object'],'order.dispute')['length']>0x0)i(j['object'],'arbitrator',[]);}return h;}const MAX_RISK_REMINDERS=0xa;function collectRiskReminders(a,b){try{return runAnalyzers(a,{'kinds':['risk']})['filter'](c=>c['roles']['includes'](b)||c['roles']['includes']('neutral'))['sort']((c,d)=>SEVERITY_RANK[d['severity']]-SEVERITY_RANK[c['severity']])['slice'](0x0,MAX_RISK_REMINDERS);}catch{return[];}}export function buildRoleInterest(a,b,c,d){const e=b['toLowerCase'](),f=VIEWER_OF[c],g=buildViewport(a,e,f),h=buildControlIndex(g),i=heldPermissionIndices(g,e),j=collectStakes(g,e,h,i),k=collectActions(g,e,c,d,j,i),l=collectArbActions(g,e,d,j),m=collectCounterparties(g,e,c,d,j,h),n=collectRiskReminders(g,f),o=k['find'](y=>y['advice']['actions']['length']>0x0)?.['advice']['actions'][0x0],p=m['find'](y=>y['alignment']==='conflict'),q='Viewing\x20'+e+'\x20as\x20'+c+':\x20'+(j['length']+'\x20stake(s)\x20in\x20flight\x20('+j['map'](y=>y['object_type']+':'+y['positions']['join']('/'))['slice'](0x0,0x4)['join'](',\x20')+(j['length']>0x4?'\x20etc.':'')+');\x20')+(o?'the\x20best\x20currently\x20operable\x20action\x20is\x20\x27'+o['forward']+'\x27\x20on\x20order\x20'+(k['find'](y=>y['advice']['actions'][0x0]===o)?.['order']??'')+'\x20('+o['payoff_note']+');\x20':k['length']>0x0?'orders\x20in\x20flight\x20but\x20no\x20action\x20operable\x20from\x20this\x20view\x20(waiting\x20on\x20others\x20or\x20off-chain\x20resolution);\x20':'no\x20operable\x20in-flight\x20orders;\x20')+(l['length']>0x0?l['length']+'\x20arbitration\x20case\x20action\x20suggestion(s);\x20':'')+(p?'largest\x20structural\x20counterparty\x20tension:\x20'+p['counter_role']+'\x20('+p['note']+')':'no\x20notable\x20counterparty\x20tension')+(n['length']>0x0?'\x20'+n['length']+'\x20role-relevant\x20risk\x20reminder(s).':''),r={'role':c,'observer':e,...d&&(d['risk_appetite']||d['requirements']?.['length'])?{'drive':d}:{},'stakes':j,'actions':k,'arb_actions':l,'counterparties':m,'risk_finding_ids':n['map'](y=>y['id']),'summary':q},s=g['visibleEdges']['filter'](y=>['eoa.order','service.order','demand.presenter','arb.voter','order.dispute']['includes'](y['schema'])),{confidence:t,window:u}=pathConfidence(g,s),w=n['length']>0x0&&SEVERITY_RANK[n[0x0]['severity']]>=SEVERITY_RANK['medium']?n[0x0]['severity']:'info',x={'id':'IR:'+c+':'+e,'kind':'game','severity':w,'title':'Role\x20interest\x20view\x20('+c+'):\x20'+j['length']+'\x20stake(s)\x20in\x20flight'+(o?',\x20best\x20action\x20\x27'+o['forward']+'\x27':''),'path':[e,...j['map'](y=>y['object'])],'confidence':t,...u?{'window':u}:{},'roles':[f],'detail':q,'suggestion':o?'Execute\x20in\x20advice\x20order\x20(\x27'+o['forward']+'\x27\x20'+(o['guard']?'requires\x20Guard\x20passport\x20verification\x20first\x20and\x20':'')+'goes\x20through\x20the\x20tool\x20routing\x20in\x20recommended_calls);\x20see\x20the\x20payload\x20for\x20counterparty\x20tension\x20and\x20risk\x20reminders.':'When\x20no\x20action\x20is\x20operable:\x20watch\x20blocked_forwards\x20waiting\x20conditions\x20and\x20counterparty\x20tension\x20changes,\x20or\x20re-project\x20with\x20a\x20different\x20role/context_account.','interest':r};return{'finding':x,'view':r};}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{bcs,deriveDynamicFieldID,query_events,query_objects,query_table,LocalMark}from'@wowok/wowok';import{chunk50,mapPool}from'./dataplane.js';export class SdkDataPlane{['network'];['opts'];['objectCache']=new
|
|
1
|
+
import{bcs,deriveDynamicFieldID,query_events,query_objects,query_table,LocalMark,lastWriteAtAny}from'@wowok/wowok';import{chunk50,mapPool}from'./dataplane.js';const SESSION_CACHE_TTL_MS=0x5*0x3c*0x3e8;let sessionWatermark=lastWriteAtAny();function checkWriteClock(){const a=lastWriteAtAny();a>sessionWatermark&&(sessionWatermark=a,sessionEntries['clear']());}const sessionEntries=new Set();class SessionMap{['map']=new Map();['registered']=![];['get'](a){const b=this['map']['get'](a);if(!b)return undefined;if(Date['now']()-b['at']>SESSION_CACHE_TTL_MS)return this['map']['delete'](a),undefined;return b['value'];}['set'](a,b){!this['registered']&&(sessionEntries['add'](this),this['registered']=!![]),this['map']['set'](a,{'value':b,'at':Date['now']()});}['clear'](){this['map']['clear']();}}export class SdkDataPlane{['network'];['opts'];['objectCache']=new SessionMap();['keyedCache']=new Map();['stats']={'batches':0x0,'byChannel':{'objects':0x0,'keyedFields':0x0,'tables':0x0,'events':0x0},'dedupHits':0x0};constructor(a,b){this['network']=a,this['opts']=b;}async['getObjects'](a,b){const c=a['map'](j=>String(j)['toLowerCase']()),d=await LocalMark['Instance']()['get_many_address'](c),e=[...new Set(d['filter'](j=>!!j))],f=new Map(),g=[],h=this['opts']?.['noCache']===!![];if(!h)checkWriteClock();for(const j of e){const k=h?undefined:this['objectCache']['get'](j);k?(this['stats']['dedupHits']++,f['set'](j,k)):g['push'](j);}if(g['length']===0x0)return f;const i=chunk50(g);return await mapPool(i,this['opts']?.['concurrency']??0x4,async l=>{this['stats']['batches']++,this['stats']['byChannel']['objects']++;try{const m=await query_objects({'objects':l,'no_cache':this['opts']?.['noCache'],'network':this['network']});for(const n of m?.['objects']??[]){const p=String(n?.['object']??'')['toLowerCase']();if(!p)continue;if(!h)this['objectCache']['set'](p,n);f['set'](p,n);}}catch(q){if(b?.['strict'])throw q;}}),f;}async['getKeyedFields'](a,b,c){const d=c?.['keyType']??'address',e=String(a)['toLowerCase'](),f=a+':'+d,g=this['opts']?.['noCache']===!![];if(!g)checkWriteClock();const h=g?undefined:this['keyedCache']['get'](f),i=new Map(),j=[];for(const o of b){const p=String(o)['toLowerCase'](),q=h?.['get'](p);if(q){this['stats']['dedupHits']++,i['set'](p,q);continue;}const r=d==='u64'?bcs['u64']()['serialize'](Number(p))['toBytes']():bcs['Address']['serialize'](p)['toBytes'](),s=deriveDynamicFieldID(e,d,r)['toLowerCase']();j['push']({'key':p,'fieldId':s});}if(j['length']===0x0)return i;const k=new Map();for(const t of j)k['set'](t['fieldId'],t['key']);const l=chunk50(j)['length'],m=await this['getObjects']([...k['keys']()],{'strict':c?.['strict']});this['stats']['byChannel']['objects']=Math['max'](0x0,this['stats']['byChannel']['objects']-l),this['stats']['byChannel']['keyedFields']+=l;const n=h??new SessionMap();for(const [u,v]of k){const x=m['get'](u);if(!x)continue;const y=x['data']??x,z=y;n['set'](v,z),i['set'](v,z);}if(!g)this['keyedCache']['set'](f,n);return i;}async['getTable'](a,b){const c=[];let d=![],f;for(;;){this['stats']['batches']++,this['stats']['byChannel']['tables']++;let g;try{g=await query_table({'parent':a,'cursor':f??undefined,'limit':b?.['pageLimit'],'no_cache':this['opts']?.['noCache'],'network':this['network']});}catch{break;}for(const h of g?.['items']??[]){const i=String(h?.['object']??'')['toLowerCase']();if(i['startsWith']('0x'))c['push']({'key':String(h?.['key']?.['value']??''),'objectId':i});}if(b?.['maxItems']!=null&&c['length']>=b['maxItems']){c['length']=b['maxItems'],d=g?.['hasNextPage']===!![];break;}if(g?.['hasNextPage']!==!![]||!g['nextCursor'])break;f=String(g['nextCursor']);}if(b?.['fetchValues']!==![]&&c['length']>0x0){const j=await this['getObjects'](c['map'](k=>k['objectId']));for(const k of c)k['object']=j['get'](k['objectId']);}return{'items':c,'truncated':d};}async['getEvents'](a,b){const c=[];let d=b?.['cursor']??null;const e=b?.['maxPages']??0x1,f=b?.['limit']??0x32;let g=![];for(let h=0x0;h<e;h++){this['stats']['batches']++,this['stats']['byChannel']['events']++;let i;try{i=await query_events({'type':a,'cursor':d,'limit':f,'order':'descending','no_cache':this['opts']?.['noCache'],'network':this['network']});}catch{g=!![];break;}const j=i?.['data']??[];c['push'](...j);if(i?.['hasNextPage']!==!![]||!i['nextCursor']){d=i?.['nextCursor']??null;break;}d=i['nextCursor'];if(h+0x1===e)g=!![];}return{'events':c,'cursor':d,'truncated':g};}}
|
|
@@ -170,7 +170,7 @@ export interface Finding {
|
|
|
170
170
|
id: string;
|
|
171
171
|
kind: FindingKind;
|
|
172
172
|
severity: FindingSeverity;
|
|
173
|
-
|
|
173
|
+
title: string;
|
|
174
174
|
path: string[];
|
|
175
175
|
confidence: Confidence;
|
|
176
176
|
window?: {
|
|
@@ -178,8 +178,8 @@ export interface Finding {
|
|
|
178
178
|
limit: number;
|
|
179
179
|
};
|
|
180
180
|
roles: ViewerRole[];
|
|
181
|
-
|
|
182
|
-
|
|
181
|
+
detail: string;
|
|
182
|
+
suggestion: string;
|
|
183
183
|
interest?: InterestPayload;
|
|
184
184
|
}
|
|
185
185
|
export interface InterestStake {
|
|
@@ -212,7 +212,7 @@ export interface InterestCounterparty {
|
|
|
212
212
|
their_prefer: string[];
|
|
213
213
|
their_avoid: string[];
|
|
214
214
|
alignment: "conflict" | "aligned" | "neutral";
|
|
215
|
-
|
|
215
|
+
note: string;
|
|
216
216
|
}
|
|
217
217
|
export interface InterestPayload {
|
|
218
218
|
role: CommercialRole;
|
|
@@ -223,7 +223,7 @@ export interface InterestPayload {
|
|
|
223
223
|
arb_actions: ArbGameAdvice[];
|
|
224
224
|
counterparties: InterestCounterparty[];
|
|
225
225
|
risk_finding_ids: string[];
|
|
226
|
-
|
|
226
|
+
summary: string;
|
|
227
227
|
}
|
|
228
228
|
export interface Analyzer {
|
|
229
229
|
id: string;
|
package/dist/harness/verify.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
function verifyCreated(a,b){const c=[],d=a['expected']['semantic_created']??[],e=b['semantic']?.['created']??[];for(const f of d){const g=e['find'](h=>h['role']===f['role']);!g&&c['push']({'dimension':'created','expected':'role='+f['role'],'actual':'not\x20found','severity':'fail','detail':'Expected\x20to\x20create\x20object\x20with\x20role\x20\x27'+f['role']+'\x27,\x20but\x20none\x20was\x20created'});}for(const h of e){const i=d['find'](j=>j['role']===h['role']);!i&&c['push']({'dimension':'created','expected':'no\x20object\x20with\x20role='+h['role'],'actual':'role='+h['role'],'severity':'warn','detail':'Unexpected\x20object\x20created\x20with\x20role\x20\x27'+h['role']+'\x27\x20—\x20may\x20indicate\x20rule\x20table\x20gap'});}return c;}function verifyModified(a,b){const c=[],d=a['expected']['semantic_modified']??[],e=b['semantic']?.['modified']??[];for(const f of d){const g=e['find'](h=>h['role']===f['role']);!g&&c['push']({'dimension':'modified','expected':'role='+f['role']+'\x20fields='+JSON['stringify'](f['expect_fields']??{}),'actual':'not\x20modified','severity':'fail','detail':'Expected\x20to\x20modify\x20object\x20with\x20role\x20\x27'+f['role']+'\x27,\x20but\x20it\x20was\x20not\x20modified'});}return c;}function verifyReleased(a,b){const c=[],d=a['expected']['semantic_released']??[],e=b['semantic']?.['released']??[];for(const f of d){const g=e['find'](h=>h['role']===f['role']);!g?c['push']({'dimension':'released','expected':'role='+f['role']+'\x20amount='+(f['amount']??'?')+'\x20from='+(f['from']??'?')+'\x20to='+(f['to']??'?'),'actual':'no\x20fund\x20movement','severity':'fail','detail':'Expected\x20fund\x20movement\x20with\x20role\x20\x27'+f['role']+'\x27,\x20but\x20none\x20occurred\x20—\x20fund\x20flow\x20risk'}):(f['amount']&&f['amount']!==g['amount']&&c['push']({'dimension':'released','expected':'amount='+f['amount'],'actual':'amount='+g['amount'],'severity':'fail','detail':'Fund\x20amount\x20mismatch\x20for\x20role\x20\x27'+f['role']+'\x27\x20—\x20fund\x20flow\x20risk'}),f['from']&&g['from']&&f['from']!==g['from']&&c['push']({'dimension':'released','expected':'from='+f['from'],'actual':'from='+g['from'],'severity':'fail','detail':'Fund\x20source\x20mismatch\x20for\x20role\x20\x27'+f['role']+'\x27\x20—\x20fund\x20flow\x20direction\x20risk'}),f['to']&&g['to']&&f['to']!==g['to']&&c['push']({'dimension':'released','expected':'to='+f['to'],'actual':'to='+g['to'],'severity':'fail','detail':'Fund\x20destination\x20mismatch\x20for\x20role\x20\x27'+f['role']+'\x27\x20—\x20fund\x20flow\x20direction\x20risk'}));}return c;}function verifyEvents(a,b){const c=[],d=a['expected']['events']??[],e=b['semantic']?.['events']??[];for(const f of d){const g=e['find'](h=>h['event_type']['includes'](f['type'])||h['business_meaning']['toLowerCase']()['includes'](f['type']['toLowerCase']()));!g&&c['push']({'dimension':'event','expected':'event_type\x20contains\x20\x27'+f['type']+'\x27','actual':'event\x20not\x20found','severity':'warn','detail':'Expected\x20event\x20\x27'+f['type']+'\x27\x20was\x20not\x20found\x20—\x20may\x20indicate\x20semantic\x20layer\x20gap\x20or\x20operation\x20didn\x27t\x20trigger\x20it'});}return c;}function verifyStateTransition(a,b){const c=[],d=a['expected']['state_transition'];if(!d)return c;if(b['semantic']?.['status']==='success')return c;return b['semantic']?.['status']==='failed'&&c['push']({'dimension':'state','expected':d['from']+'\x20→\x20'+d['to'],'actual':'operation\x20failed','severity':'fail','detail':'Expected\x20state\x20transition\x20\x27'+d['from']+'\x20→\x20'+d['to']+'\x27\x20failed\x20—\x20operation\x20did\x20not\x20succeed'}),c;}export function verify(a){const b=[...verifyCreated(a['expected'],a['actual']),...verifyModified(a['expected'],a['actual']),...verifyReleased(a['expected'],a['actual']),...verifyEvents(a['expected'],a['actual']),...verifyStateTransition(a['expected'],a['actual'])],c=b['some'](i=>i['severity']==='fail'),d=b['some'](i=>i['severity']==='warn'),e=c?'fail':d?'warn':'pass',f=b['filter'](i=>i['severity']==='fail')['length'],g=b['filter'](i=>i['severity']==='warn')['length'];let h;if(e==='pass')h='All\x20verifications\x20passed\x20—\x20expected\x20results\x20match\x20actual\x20results';else e==='warn'?h=g+'\x20warning(s)\x20—\x20operation\x20succeeded\x20with\x20minor\x20discrepancies':h=f+'\x20failure(s),\x20'+g+'\x20warning(s)\x20—\x20expected\x20results\x20do\x20not\x20match\x20actual\x20results';return{'status':e,'mismatches':b,'summary':h,'timestamp':new Date()['toISOString']()};}export function generateExpected(a,b,c,d){const e={'result_type':'transaction'};switch(c){case'service':d?.['publish']===!![]||d?.['bPublished']===!![]
|
|
1
|
+
function verifyCreated(a,b){const c=[],d=a['expected']['semantic_created']??[],e=b['semantic']?.['created']??[];for(const f of d){const g=e['find'](h=>h['role']===f['role']);!g&&c['push']({'dimension':'created','expected':'role='+f['role'],'actual':'not\x20found','severity':'fail','detail':'Expected\x20to\x20create\x20object\x20with\x20role\x20\x27'+f['role']+'\x27,\x20but\x20none\x20was\x20created'});}for(const h of e){const i=d['find'](j=>j['role']===h['role']);!i&&c['push']({'dimension':'created','expected':'no\x20object\x20with\x20role='+h['role'],'actual':'role='+h['role'],'severity':'warn','detail':'Unexpected\x20object\x20created\x20with\x20role\x20\x27'+h['role']+'\x27\x20—\x20may\x20indicate\x20rule\x20table\x20gap'});}return c;}function verifyModified(a,b){const c=[],d=a['expected']['semantic_modified']??[],e=b['semantic']?.['modified']??[];for(const f of d){const g=e['find'](h=>h['role']===f['role']);!g&&c['push']({'dimension':'modified','expected':'role='+f['role']+'\x20fields='+JSON['stringify'](f['expect_fields']??{}),'actual':'not\x20modified','severity':'fail','detail':'Expected\x20to\x20modify\x20object\x20with\x20role\x20\x27'+f['role']+'\x27,\x20but\x20it\x20was\x20not\x20modified'});}return c;}function verifyReleased(a,b){const c=[],d=a['expected']['semantic_released']??[],e=b['semantic']?.['released']??[];for(const f of d){const g=e['find'](h=>h['role']===f['role']);!g?c['push']({'dimension':'released','expected':'role='+f['role']+'\x20amount='+(f['amount']??'?')+'\x20from='+(f['from']??'?')+'\x20to='+(f['to']??'?'),'actual':'no\x20fund\x20movement','severity':'fail','detail':'Expected\x20fund\x20movement\x20with\x20role\x20\x27'+f['role']+'\x27,\x20but\x20none\x20occurred\x20—\x20fund\x20flow\x20risk'}):(f['amount']&&f['amount']!==g['amount']&&c['push']({'dimension':'released','expected':'amount='+f['amount'],'actual':'amount='+g['amount'],'severity':'fail','detail':'Fund\x20amount\x20mismatch\x20for\x20role\x20\x27'+f['role']+'\x27\x20—\x20fund\x20flow\x20risk'}),f['from']&&g['from']&&f['from']!==g['from']&&c['push']({'dimension':'released','expected':'from='+f['from'],'actual':'from='+g['from'],'severity':'fail','detail':'Fund\x20source\x20mismatch\x20for\x20role\x20\x27'+f['role']+'\x27\x20—\x20fund\x20flow\x20direction\x20risk'}),f['to']&&g['to']&&f['to']!==g['to']&&c['push']({'dimension':'released','expected':'to='+f['to'],'actual':'to='+g['to'],'severity':'fail','detail':'Fund\x20destination\x20mismatch\x20for\x20role\x20\x27'+f['role']+'\x27\x20—\x20fund\x20flow\x20direction\x20risk'}));}return c;}function verifyEvents(a,b){const c=[],d=a['expected']['events']??[],e=b['semantic']?.['events']??[];for(const f of d){const g=e['find'](h=>h['event_type']['includes'](f['type'])||h['business_meaning']['toLowerCase']()['includes'](f['type']['toLowerCase']()));!g&&c['push']({'dimension':'event','expected':'event_type\x20contains\x20\x27'+f['type']+'\x27','actual':'event\x20not\x20found','severity':'warn','detail':'Expected\x20event\x20\x27'+f['type']+'\x27\x20was\x20not\x20found\x20—\x20may\x20indicate\x20semantic\x20layer\x20gap\x20or\x20operation\x20didn\x27t\x20trigger\x20it'});}return c;}function verifyStateTransition(a,b){const c=[],d=a['expected']['state_transition'];if(!d)return c;if(b['semantic']?.['status']==='success')return c;return b['semantic']?.['status']==='failed'&&c['push']({'dimension':'state','expected':d['from']+'\x20→\x20'+d['to'],'actual':'operation\x20failed','severity':'fail','detail':'Expected\x20state\x20transition\x20\x27'+d['from']+'\x20→\x20'+d['to']+'\x27\x20failed\x20—\x20operation\x20did\x20not\x20succeed'}),c;}export function verify(a){const b=[...verifyCreated(a['expected'],a['actual']),...verifyModified(a['expected'],a['actual']),...verifyReleased(a['expected'],a['actual']),...verifyEvents(a['expected'],a['actual']),...verifyStateTransition(a['expected'],a['actual'])],c=b['some'](i=>i['severity']==='fail'),d=b['some'](i=>i['severity']==='warn'),e=c?'fail':d?'warn':'pass',f=b['filter'](i=>i['severity']==='fail')['length'],g=b['filter'](i=>i['severity']==='warn')['length'];let h;if(e==='pass')h='All\x20verifications\x20passed\x20—\x20expected\x20results\x20match\x20actual\x20results';else e==='warn'?h=g+'\x20warning(s)\x20—\x20operation\x20succeeded\x20with\x20minor\x20discrepancies':h=f+'\x20failure(s),\x20'+g+'\x20warning(s)\x20—\x20expected\x20results\x20do\x20not\x20match\x20actual\x20results';return{'status':e,'mismatches':b,'summary':h,'timestamp':new Date()['toISOString']()};}export function generateExpected(a,b,c,d){const e={'result_type':'transaction'};switch(c){case'service':if(d?.['publish']===!![]||d?.['bPublished']===!![])e['semantic_modified']=[{'role':'Service','expect_fields':{'bPublished':!![]}}],e['state_transition']={'from':'unpublished','to':'published'},e['events']=[{'type':'ServiceEvent','expect_count':'>=1'}];else d?.['object']!==undefined&&d?.['object']!==null?e['semantic_modified']=[{'role':'Service'}]:e['semantic_created']=[{'role':'Service'}];break;case'machine':e['semantic_created']=[{'role':'Machine'}];break;case'guard':e['semantic_created']=[{'role':'Guard'}];break;case'permission':e['semantic_created']=[{'role':'Permission'}];break;case'order':d?.['arb']!==undefined?(e['state_transition']={'from':'ordered','to':'arbitration'},e['events']=[{'type':'ArbEvent','expect_count':'>=1'}]):(e['semantic_created']=[{'role':'Order'}],e['semantic_released']=[{'role':'payment'}],e['events']=[{'type':'NewOrderEvent','expect_count':'>=1'}]);break;case'payment':e['semantic_released']=[{'role':'payment'}],e['events']=[{'type':'NewPaymentEvent','expect_count':'>=1'}];break;case'treasury':d?.['deposit']!==undefined?e['semantic_released']=[{'role':'deposit'}]:e['semantic_released']=[{'role':'release'}];e['events']=[{'type':'TreasuryEvent','expect_count':'>=1'},{'type':'NewPaymentEvent','expect_count':'>=1'}];break;case'reward':if(d?.['claim']!==undefined||d?.['withdraw']!==undefined)e['semantic_released']=[{'role':'reward'}],e['events']=[{'type':'RewardClaimEvent','expect_count':'>=1'}];else d?.['coin']!==undefined||d?.['add']!==undefined?e['events']=[{'type':'RewardFundEvent','expect_count':'>=1'}]:e['semantic_created']=[{'role':'Reward'}];break;case'allocation':e['semantic_released']=[{'role':'release'}],e['events']=[{'type':'AllocationEvent','expect_count':'>=1'},{'type':'NewPaymentEvent','expect_count':'>=1'}];break;case'demand':if(d?.['submit']!==undefined||d?.['present']!==undefined)e['semantic_modified']=[{'role':'Demand'}],e['events']=[{'type':'DemandPresentEvent','expect_count':'>=1'}];else d?.['reward']!==undefined||d?.['rewards']!==undefined?e['events']=[{'type':'DemandChangedEvent','expect_count':'>=1'}]:e['semantic_created']=[{'role':'Demand'}];break;case'progress':e['events']=[{'type':'ProgressEvent','expect_count':'>=1'}];break;default:break;}return{'operation':a,'intent':b,'pre_conditions':[],'expected':e};}
|
|
@@ -39,6 +39,8 @@ export declare const ALLOCATION_ERROR_CODES: {
|
|
|
39
39
|
readonly ESHARING_MODE_INVALID: 11;
|
|
40
40
|
readonly EAMOUNT_BELOW_THRESHOLD: 12;
|
|
41
41
|
readonly EAMOUNT_EXCEEDS_MAX: 13;
|
|
42
|
+
readonly EZERO_DISTRIBUTION: 14;
|
|
43
|
+
readonly ERECIPIENT_NOT_FOR_OBJECT: 15;
|
|
42
44
|
};
|
|
43
45
|
export declare const ORDER_ALLOCATION_ALREADY_SPECIFIED = "E_ALLOCATION_ALREADY_SPECIFIED";
|
|
44
46
|
export declare const ALLOCATION_SCENES: AllocationScene[];
|
|
@@ -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 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};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;\x20passport::result_for_guard\x20hard-validates\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\x20Arbitration.fees_alloc\x20(permission\x20365)\x20or\x20fees_alloc_with_passport','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(customer/risk-assessment.ts)'],'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+\x20Rate\x20base\x20+\x20Surplus\x20cap','Amount\x20sharing\x20consumes\x20fix;\x20Rate\x20sharing\x20uses\x20(max\x20-\x20fix)\x20as\x20base','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)','max\x20-\x20fix\x20becomes\x20Rate\x20base\x20(NOT\x20balance\x20-\x20fix)','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_alloc'))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;}}export function allocationModeFromNumber(a){switch(a){case ALLOCATION_MODE_AMOUNT:return'Amount';case ALLOCATION_MODE_RATE:return'Rate';case ALLOCATION_MODE_SURPLUS:return'Surplus';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)',0xc:'Amount\x20sum\x20(fix)\x20<\x20threshold',0xd:'Amount\x20sum\x20(fix)\x20>\x20max'};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 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};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;\x20passport::result_for_guard\x20hard-validates\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\x20Arbitration.fees_alloc\x20(permission\x20365)\x20or\x20fees_alloc_with_passport','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(customer/risk-assessment.ts)'],'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+\x20Rate\x20base\x20+\x20Surplus\x20cap','Amount\x20sharing\x20consumes\x20fix;\x20Rate\x20sharing\x20uses\x20(max\x20-\x20fix)\x20as\x20base','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)','max\x20-\x20fix\x20becomes\x20Rate\x20base\x20(NOT\x20balance\x20-\x20fix)','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_alloc'))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;}}export function allocationModeFromNumber(a){switch(a){case ALLOCATION_MODE_AMOUNT:return'Amount';case ALLOCATION_MODE_RATE:return'Rate';case ALLOCATION_MODE_SURPLUS:return'Surplus';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)',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)'};return b[a];}
|