@wowok/agent-mcp 3.2.4 → 3.2.6
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/composition/blueprint-view.d.ts +64 -0
- package/dist/composition/blueprint-view.js +1 -0
- package/dist/evaluation/builtins/graph-service.spec.js +1 -1
- package/dist/evaluation/engine.js +1 -1
- package/dist/experience/realtime-feedback.js +1 -1
- package/dist/extensions/industry-pack.d.ts +1 -0
- package/dist/extensions/industry-pack.js +1 -1
- package/dist/extensions/modes.js +1 -1
- package/dist/extensions/registry.d.ts +1 -2
- package/dist/extensions/registry.js +1 -1
- package/dist/graph/onchain/expand.js +1 -1
- package/dist/graph/onchain/exposure.js +1 -1
- package/dist/graph/onchain/facts.js +1 -1
- package/dist/harness/recover.js +1 -1
- package/dist/knowledge/audit-rules.d.ts +2 -0
- package/dist/knowledge/audit-rules.js +1 -1
- package/dist/knowledge/baselines/rules/allocation.json +5 -5
- package/dist/knowledge/baselines/rules/arb.json +1 -1
- package/dist/knowledge/baselines/rules/guard.json +9 -9
- package/dist/knowledge/baselines/rules/machine.json +5 -5
- package/dist/knowledge/baselines/rules/order.json +1 -1
- package/dist/knowledge/builtin-templates.d.ts +2 -1
- package/dist/knowledge/builtin-templates.js +1 -1
- package/dist/knowledge/entity-recipient-guard.js +1 -1
- package/dist/knowledge/getting-started.js +1 -1
- package/dist/knowledge/guard-design-patterns.js +1 -1
- package/dist/knowledge/guard-risk.js +1 -1
- package/dist/knowledge/guard-templates.d.ts +1 -1
- package/dist/knowledge/guard-templates.js +1 -1
- package/dist/knowledge/index.js +1 -1
- package/dist/knowledge/industry-generalizer.js +1 -1
- package/dist/knowledge/industry-registry.js +1 -1
- package/dist/knowledge/jsonrpc-enum.js +1 -1
- package/dist/knowledge/order-ledger.js +1 -1
- package/dist/knowledge/scenario-modes.d.ts +2 -4
- package/dist/knowledge/scenario-modes.js +1 -1
- package/dist/knowledge/service-ledger.js +1 -1
- package/dist/knowledge/service-templates.js +1 -1
- package/dist/knowledge/template-loader.d.ts +7 -2
- package/dist/knowledge/template-loader.js +1 -1
- package/dist/knowledge/template-registry.js +1 -1
- package/dist/knowledge/template-scanner.js +1 -1
- package/dist/knowledge/template-validation.d.ts +2 -0
- package/dist/knowledge/template-validation.js +1 -0
- package/dist/monitor/MonitorLoop.js +1 -1
- package/dist/playbooks/service-build/business-puzzle.js +1 -1
- package/dist/playbooks/service-build/game-theory.d.ts +2 -2
- package/dist/playbooks/service-build/game-theory.js +1 -1
- package/dist/playbooks/service-build/machine-panorama.js +1 -1
- package/dist/playbooks/service-build/merchant-guide.d.ts +54 -11
- package/dist/playbooks/service-build/merchant-guide.js +1 -1
- package/dist/playbooks/service-build/mode-actions.js +1 -1
- package/dist/playbooks/service-build/object-panorama.js +1 -1
- package/dist/playbooks/service-build/participation-radar.js +1 -1
- package/dist/playbooks/service-build/relationship-profile.js +1 -1
- package/dist/playbooks/service-build/reverse-mapping-nk4.spec.d.ts +1 -0
- package/dist/playbooks/service-build/reverse-mapping-nk4.spec.js +1 -0
- package/dist/playbooks/service-build/reverse-mapping.d.ts +24 -0
- package/dist/playbooks/service-build/reverse-mapping.js +1 -1
- package/dist/playbooks/service-build/service-panorama.js +1 -1
- package/dist/playbooks/service-build/service-quote.js +1 -1
- package/dist/playbooks/service-build/workflow-design-assessment.d.ts +2 -2
- package/dist/playbooks/service-build/workflow-design-assessment.js +1 -1
- package/dist/review/index.js +1 -1
- package/dist/safety/confirm-gate.js +1 -1
- package/dist/schema/call/handler.js +1 -1
- package/dist/schema/call/semantic.js +1 -1
- package/dist/schema/call/service.d.ts +14 -0
- package/dist/schema/call/service.js +1 -1
- package/dist/schema/common/index.js +1 -1
- package/dist/schema/goal/planning.js +1 -1
- package/dist/schema/local/index.js +1 -1
- package/dist/schema/operations.d.ts +7 -0
- package/dist/schema/schema-version.js +1 -1
- package/dist/schema-query-impl/index.js +1 -1
- package/dist/schemas/goal_operation.schema.json +1 -1
- package/dist/schemas/index.json +1 -1
- package/dist/schemas/onchain_operations.schema.json +37 -2
- package/dist/schemas/onchain_operations_service.schema.json +37 -2
- package/dist/tools/handlers/benchmark-migration.d.ts +2 -13
- package/dist/tools/handlers/benchmark-migration.js +1 -1
- package/dist/tools/handlers/config.js +1 -1
- package/dist/tools/handlers/industry-pack.js +1 -1
- package/dist/tools/handlers/onchain.js +1 -1
- package/dist/tools/handlers/query.js +1 -1
- package/dist/tools/registry/agent.js +1 -1
- package/dist/tools/wip-deploy-assist.js +1 -1
- package/package.json +2 -2
- package/dist/playbooks/service-build/semantic-graph.d.ts +0 -99
- package/dist/playbooks/service-build/semantic-graph.js +0 -1
package/dist/extensions/modes.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{getScenarioMode}from'../knowledge/scenario-modes.js';import{getIndustryTraits}from'../knowledge/industry-registry.js';import{getIndustryRiskChecks,getIndustryNeeds}from'../customer/index.js';import{SUPPORTED_INDUSTRIES}from'../customer/user-preferences.js';import{getFlywheelForIndustry}from'../knowledge/acquisition-flywheel.js';const GENERAL_TRAITS={'has_logistics':![],'communication_heavy':![],'pure_digital':![],'long_cycle':![],'deposit_required':![],'multi_tier_allocation':![],'regulatory_intensity':'low','trust_sensitivity':'medium','consumption_frequency':'occasional','avg_ticket_size':'medium'},GENERAL_FLYWHEEL={'industry':'general','trustSellingPoints':[],'keyActions':[],'rewardStrategy':'User-defined','discountStrategy':'User-defined','trustDescription':'User-defined\x20trust\x20mechanism'},GENERAL_MACHINE_SHAPE=[{'name':'paid','role':'Entry:\x20order\x20created\x20and\x20paid'},{'name':'delivering','role':'Service\x20delivery\x20in\x20progress'},{'name':'delivered','role':'Deliverable\x20available\x20for\x20review'},{'name':'completed','role':'Service\x20completed,\x20funds\x20released'},{'name':'cancelled','role':'Pre-delivery\x20cancellation\x20—\x20triggers\x20refund\x20Allocator','operator':'order_payer'}],GENERAL_ALLOCATOR={'recipient':'signer','count':0x1,'mode':'surplus','description':'Default:\x20surplus\x20to\x20service\x20owner\x20(general\x20fallback)'},RETAIL_D2C_MACHINE_SHAPE=[{'name':'ordered','role':'Entry:\x20order\x20created\x20(funds\x20escrowed\x20in\x20Allocation)'},{'name':'shipped','role':'Merchant\x20ships\x20goods'},{'name':'delivered','role':'Goods\x20delivered\x20to\x20buyer'},{'name':'completed','role':'Buyer\x20confirms\x20receipt\x20—\x20withdraw_guard\x20releases\x20funds','operator':'order_payer'},{'name':'cancelled','role':'Pre-ship\x20cancellation\x20—\x20refund_guard\x20refunds\x20buyer','operator':'order_payer'}],RETAIL_D2C_GUARDS=[{'template_id':'withdraw_guard_delivery','host':'service','purpose':'Release\x20funds\x20to\x20merchant\x20+\x20processor\x20on\x20order\x20completion\x20(delivery\x20confirmation)'},{'template_id':'refund_guard_cancellation','host':'service','purpose':'Refund\x20100%\x20to\x20buyer\x20on\x20order\x20cancellation'}],RETAIL_D2C_ALLOCATOR={'recipient':'entity','count':0x2,'mode':'rate','description':'Merchant\x2097%\x20+\x20Processor\x203%\x20(rate-based\x20split,\x20no\x20platform\x20commission)'},RETAIL_D2C_KEY_RISK='No\x20platform\x20arbitration\x20—\x20disputes\x20rely\x20on\x20optional\x20Arbitration\x20or\x20off-chain\x20chargeback',RETAIL_D2C_BUILD_NOTES=['Allocation\x20escrow\x20replaces\x20platform\x20custody\x20—\x20funds\x20locked\x20in\x20contract\x20until\x20Guard\x20releases','withdraw_guard\x20enforces\x20delivery\x20gate\x20—\x20merchant\x20must\x20reach\x20\x27completed\x27\x20state\x20to\x20receive\x20payment','refund_guard\x20ensures\x20100%\x20refund\x20on\x20cancellation\x20—\x20no\x20merchant\x20approval\x20needed','No\x20buy_guard\x20needed\x20—\x20D2C\x20doesn\x27t\x20gate\x20purchases\x20(open\x20storefront)','Arbitration\x20is\x20optional\x20—\x20add\x20when\x20dispute\x20volume\x20justifies\x20the\x20cost','Service\x20↔\x20Guard\x20circular\x20dependency:\x20create\x20Service\x20(unpublished)\x20→\x20create\x20Guards\x20→\x20update\x20Service\x20(publish)'],SUPPORTED_INDUSTRY_SET=new Set([...SUPPORTED_INDUSTRIES,'retail_d2c']);function fetchTemplate(a){const b=a==='retail_d2c'?'retail':a,c=getIndustryTraits(b)??GENERAL_TRAITS,d=SUPPORTED_INDUSTRY_SET['has'](a),e=a==='retail_d2c'?'retail':a,f=d?getIndustryRiskChecks(e):[],g=d?getIndustryNeeds(e):[],h=getFlywheelForIndustry(b)??GENERAL_FLYWHEEL;let i,j,k,l,m;if(a==='retail_d2c')i=RETAIL_D2C_MACHINE_SHAPE,j=RETAIL_D2C_GUARDS,k=RETAIL_D2C_ALLOCATOR,l=RETAIL_D2C_KEY_RISK,m=RETAIL_D2C_BUILD_NOTES;else{if(a==='general'){const n=getScenarioMode('general');i=GENERAL_MACHINE_SHAPE,j=[],k=GENERAL_ALLOCATOR,l=n?.['key_risk']??'No\x20safety\x20net\x20—\x20user\x20must\x20design\x20all\x20trust\x20mechanisms\x20manually',m=n?.['build_notes'];}else{const o=getScenarioMode(a);if(!o)throw new Error('[modes.ts]\x20No\x20scenario\x20mode\x20found\x20for\x20industry:\x20'+a);i=o['machine_shape'],j=o['guards'],k=o['allocator'],l=o['key_risk'],m=o['build_notes'];}}return{'traits':c,'risk_checks':f,'needs':g,'flywheel':h,'machine_shape':i,'guards':j,'allocator':k,'key_risk':l,'build_notes':m};}export const BUILTIN_MODES=[{'name':'freelance','display_name':'Freelance','version':'v1','source':'builtin',...fetchTemplate('freelance'),'analyze':{'key_questions':['Are\x20WIP\x20hashes\x20bound\x20to\x20each\x20milestone,\x20so\x20delivery\x20evidence\x20cannot\x20be\x20substituted\x20after\x20acceptance?','Does\x20the\x20acceptance\x20gate\x20have\x20a\x20time-bounded\x20escape\x20(keeper-driven\x20auto-accept),\x20or\x20can\x20a\x20silent\x20buyer\x20hold\x20the\x20provider\x27s\x20funds\x20hostage\x20indefinitely?']},'capabilities_used':['permission.index_create','permission.role_assign','guard.validate_buy','guard.validate_wip_hash','machine.node_topology','treasury.owner_receive','allocation.distribute','allocation.distribute_milestone','service.publish','progress.advance','arb.vote_weighted','contact.im_create'],'config_overrides':{'service':{'setting_locked_time':'30d','engagement_type':'milestone'},'machine':{'wip_required':!![],'wip_hash_algorithm':'sha256','acceptance_gate':!![]}},'expected_benefits':[{'metric':'Dispute\x20rate\x20reduction','expected_value':'40%','evidence':'WIP\x20hash\x20+\x20milestone\x20allocation\x20enforces\x20delivery\x20evidence'},{'metric':'Delivery\x20confirmation\x20efficiency','expected_value':'+50%','evidence':'acceptance\x20gate\x20automates\x20acceptance\x20workflow'},{'metric':'Provider\x20payment\x20assurance','expected_value':'100%','evidence':'Funds\x20auto-release\x20to\x20provider\x20after\x20accepted\x20node'}],'risk_appetite':'balanced','risk_constraints':{'require_arbitration':!![],'require_compensation_fund':![],'require_wip_evidence':!![],'other_constraints':['setting_locked_time\x20>=\x207d\x20to\x20lock\x20engagement-period\x20rules','Acceptance\x20timeout\x20=\x20the\x20template\x27s\x20escrow_release_days\x20(single\x20source:\x20fee_params,\x20override\x20via\x20fee_overrides).\x20Mechanism:\x20dual-branch\x20time-gated\x20forward\x20(pattern.time_lock_progress\x20anchored\x20on\x20the\x20delivered\x20entry);\x20a\x20keeper\x20advances\x20the\x20timeout\x20path.\x20adminUnhold\x20(224)\x20is\x20ONLY\x20the\x20hold-release\x20escape\x20hatch,\x20never\x20the\x20timeout\x20mechanism.']},'applicable_conditions':{'business_scale':'small','min_daily_orders':0x1,'other_conditions':['Suitable\x20for\x20mid-to-long-term\x20project\x20delivery','Requires\x20milestone-based\x20phased\x20acceptance']},'similar_industries':['rental','education'],'novel_capabilities':['allocation.distribute_milestone'],'disabled_builtin_constraints':['require_compensation_fund']},{'name':'rental','display_name':'Rental','version':'v1','source':'builtin',...fetchTemplate('rental'),'analyze':{'key_questions':['Is\x20the\x20deposit\x20escrowed\x20on-chain\x20and\x20sized\x20against\x20the\x20item\x27s\x20full\x20replacement\x20value,\x20not\x20just\x20the\x20rental\x20fee?','Are\x20pre-handover\x20and\x20post-return\x20WIP\x20states\x20hash-recorded,\x20so\x20damage\x20attribution\x20is\x20provable\x20rather\x20than\x20asserted?']},'capabilities_used':['permission.index_create','permission.role_assign','guard.validate_buy','guard.validate_wip_hash','machine.node_topology','treasury.owner_receive','allocation.distribute','service.publish','progress.advance','arb.vote_weighted','contact.im_create'],'config_overrides':{'treasury':{'deposit_escrow':!![],'deposit_deductible':!![]},'machine':{'wip_required':!![],'wip_stages':['handover_out','returned'],'inspection_gate':!![]}},'expected_benefits':[{'metric':'Deposit\x20dispute\x20rate','expected_value':'-60%','evidence':'pre-rental\x20WIP\x20mandatorily\x20records\x20item\x27s\x20original\x20state'},{'metric':'Damage\x20liability\x20accuracy','expected_value':'+70%','evidence':'pre/post\x20WIP\x20hash\x20comparison\x20eliminates\x20unfounded\x20deductions'},{'metric':'Trust\x20score','expected_value':'+25%','evidence':'compensation_fund\x20covers\x20damage\x20risk'}],'risk_appetite':'conservative','risk_constraints':{'require_arbitration':!![],'require_compensation_fund':!![],'require_wip_evidence':!![],'max_single_transaction':0x2710,'compensation_fund_coverage_ratio':0xa,'other_constraints':['Deposit\x20must\x20be\x20escrowed\x20(no\x20direct\x20transfer)','lock_duration\x20>=\x207d\x20to\x20prevent\x20arbitrary\x20merchant\x20withdrawal']},'applicable_conditions':{'business_scale':'small','min_daily_orders':0x1,'other_conditions':['Requires\x20physical\x20item\x20handover','Has\x20logistics\x20or\x20offline\x20delivery\x20leg']},'similar_industries':['retail','travel'],'novel_capabilities':[]},{'name':'education','display_name':'Education','version':'v1','source':'builtin',...fetchTemplate('education'),'analyze':{'key_questions':['Does\x20tuition\x20release\x20per\x20attended\x20session\x20(Progress\x20node),\x20so\x20undelivered\x20sessions\x20stay\x20refundable\x20if\x20the\x20institution\x20disappears?','Does\x20setting_locked_time\x20span\x20the\x20full\x20term,\x20so\x20the\x20institution\x20cannot\x20tighten\x20refund\x20rules\x20mid-course?']},'capabilities_used':['permission.index_create','permission.role_assign','guard.validate_buy','guard.validate_wip_hash','machine.node_topology','treasury.owner_receive','allocation.distribute','allocation.distribute_milestone','service.publish','progress.advance','arb.vote_weighted','contact.im_create'],'config_overrides':{'allocation':{'strategy':{'recipient':'entity','count':0x1,'mode':'amount','description':'1/N\x20of\x20tuition\x20released\x20per\x20session\x20attendance'},'session_threshold':!![]},'service':{'setting_locked_time':'120d','anti_runaway':!![]}},'expected_benefits':[{'metric':'Refund\x20dispute\x20rate','expected_value':'-50%','evidence':'per-session\x20release\x20distributes\x20tuition\x20by\x20class'},{'metric':'Institution\x20runaway\x20risk','expected_value':'eliminated','evidence':'Funds\x20release\x20per\x20session;\x20undelivered\x20portion\x20is\x20refundable'},{'metric':'Attendance\x20traceability','expected_value':'100%','evidence':'attendance_guard\x20signs\x20each\x20session'}],'risk_appetite':'conservative','risk_constraints':{'require_arbitration':!![],'require_compensation_fund':!![],'require_wip_evidence':![],'other_constraints':['setting_locked_time\x20covers\x20the\x20entire\x20term\x20(>=90d)','Long-cycle\x20projects\x20must\x20monitor\x20>90d\x20progress']},'applicable_conditions':{'business_scale':'medium','min_daily_orders':0x1,'other_conditions':['Long-cycle\x20delivery','Requires\x20per-session\x20acceptance','Regulatory\x20intensity:\x20medium']},'similar_industries':['freelance','subscription'],'novel_capabilities':['allocation.distribute_milestone'],'disabled_builtin_constraints':['require_wip_evidence']},{'name':'travel','display_name':'Travel','version':'v1','source':'builtin',...fetchTemplate('travel'),'analyze':{'key_questions':['Does\x20each\x20itinerary\x20segment\x20have\x20its\x20own\x20guard\x20and\x20WIP\x20acceptance,\x20so\x20one\x20failed\x20leg\x20is\x20refundable\x20without\x20unwinding\x20the\x20whole\x20trip?','Is\x20the\x20multi-tier\x20allocation\x20waterfall\x20(agency\x20→\x20hotel/guide/driver)\x20visible\x20on-chain,\x20so\x20the\x20agency\x20cannot\x20silently\x20re-split\x20funds?']},'capabilities_used':['permission.index_create','permission.role_assign','guard.validate_buy','guard.validate_wip_hash','machine.node_topology','treasury.owner_receive','allocation.distribute','service.publish','progress.advance','arb.vote_weighted','contact.im_create'],'config_overrides':{'allocation':{'strategy':{'recipient':'entity','count':0x3,'mode':'amount','description':'Deposit\x2020%\x20to\x20agency,\x20final\x2080%\x20to\x20agency,\x20then\x20agency-side\x20Allocation\x20splits\x20to\x20hotel/guide/driver\x20per\x20segment'},'multi_tier_waterfall':!![],'guard_chaining':!![]},'service':{'supply_chain_suborders':!![],'segment_guard_required':!![]}},'expected_benefits':[{'metric':'Fund\x20transparency','expected_value':'100%','evidence':'multi-tier\x20allocation\x20splits\x20per\x20segment\x20to\x20hotel/guide/driver'},{'metric':'Itinerary\x20change\x20disputes','expected_value':'-45%','evidence':'segment\x20WIP\x20accepts\x20each\x20leg'},{'metric':'Breach\x20compensation\x20assurance','expected_value':'+60%','evidence':'compensation_fund\x20covers\x20itinerary\x20breach'}],'risk_appetite':'balanced','risk_constraints':{'require_arbitration':!![],'require_compensation_fund':!![],'require_wip_evidence':!![],'other_constraints':['Multi-tier\x20allocation\x20requires\x20guard\x20chaining\x20validation','deposit\x2020%\x20+\x20final\x2080%\x20two-stage\x20payment']},'applicable_conditions':{'business_scale':'medium','min_daily_orders':0x1,'other_conditions':['Multi-segment\x20itinerary\x20combination','Requires\x20hotel/guide/driver\x20multi-party\x20allocation']},'similar_industries':['rental','education'],'novel_capabilities':[]},{'name':'subscription','display_name':'Subscription','version':'v1','source':'builtin',...fetchTemplate('subscription'),'analyze':{'key_questions':['Is\x20every\x20periodic\x20charge\x20gated\x20by\x20an\x20explicit\x20user\x20confirmation,\x20with\x20no\x20auto-renew\x20default?','Can\x20the\x20subscriber\x20cancel\x20anytime\x20effective\x20next\x20period,\x20without\x20a\x20dead-end\x20node\x20in\x20the\x20machine?']},'capabilities_used':['permission.index_create','permission.role_assign','guard.validate_buy','machine.node_topology','treasury.owner_receive','allocation.distribute','service.publish','progress.advance','arb.vote_weighted','reward.claim_guard','contact.im_create'],'config_overrides':{'machine':{'no_auto_renew_trap':!![],'user_confirmed_charge':!![],'cancel_anytime':!![],'next_period_effective':!![]},'service':{'creator_data_subscription':!![],'periodic_billing':!![]}},'expected_benefits':[{'metric':'Renewal\x20rate','expected_value':'+25%','evidence':'loyalty\x20reward\x20+\x20transparent\x20subscription\x20mechanism'},{'metric':'Cancellation\x20disputes','expected_value':'eliminated','evidence':'cancel\x20anytime\x20+\x20no\x20auto-renew\x20trap'},{'metric':'Creator\x20retention','expected_value':'+30%','evidence':'deliver_guard_wip\x20prevents\x20content\x20dropout'}],'risk_appetite':'aggressive','risk_constraints':{'require_arbitration':![],'require_compensation_fund':![],'require_wip_evidence':![],'compensation_fund_coverage_ratio':0x3,'other_constraints':['Forbid\x20dead-end\x20nodes\x20(prevent\x20lock-in)','charge_guard\x20requires\x20user\x20confirmation\x20each\x20period']},'applicable_conditions':{'business_scale':'small','min_daily_orders':0x5,'other_conditions':['Pure-digital\x20delivery','Periodic\x20content\x20or\x20SaaS\x20service']},'similar_industries':['freelance','education'],'novel_capabilities':[],'disabled_builtin_constraints':['require_arbitration','require_compensation_fund','require_wip_evidence']},{'name':'retail','display_name':'Retail','version':'v1','source':'builtin',...fetchTemplate('retail'),'analyze':{'key_questions':['Is\x20the\x20logistics\x20tracking\x20number\x20recorded\x20as\x20WIP\x20before\x20the\x20confirm\x20gate,\x20so\x20receipt\x20disputes\x20have\x20carrier\x20evidence?','Is\x20the\x20refund\x20window\x20at\x20least\x207\x20days\x20with\x20an\x20on-chain\x20refund\x20path\x20that\x20does\x20not\x20rely\x20on\x20merchant\x20goodwill?']},'capabilities_used':['permission.index_create','permission.role_assign','guard.validate_buy','guard.validate_wip_hash','machine.node_topology','treasury.owner_receive','allocation.distribute','service.publish','progress.advance','arb.vote_weighted','reward.claim_guard','contact.im_create'],'config_overrides':{'machine':{'wip_required':!![],'wip_field':'tracking_number','confirm_gate':!![],'refund_requires_approval':!![]},'service':{'logistics_mode':'standard','first_order_discount':!![]}},'expected_benefits':[{'metric':'Return\x20dispute\x20rate','expected_value':'-35%','evidence':'logistics\x20WIP\x20+\x20refund\x20path\x20assurance'},{'metric':'Repurchase\x20rate','expected_value':'+20%','evidence':'spend\x20cashback\x20reward'},{'metric':'Product\x20authenticity\x20traceability','expected_value':'100%','evidence':'WIP\x20verifies\x20product/logistics\x20info'}],'risk_appetite':'conservative','risk_constraints':{'require_arbitration':!![],'require_compensation_fund':!![],'require_wip_evidence':![],'compensation_fund_coverage_ratio':0x5,'other_constraints':['refund_window\x20>=\x207d','confirm_gate:\x20only\x20buyer\x20can\x20confirm\x20receipt']},'applicable_conditions':{'business_scale':'medium','min_daily_orders':0xa,'other_conditions':['Has\x20logistics\x20shipping\x20leg','High-frequency\x20small-ticket\x20transactions']},'similar_industries':['rental','subscription'],'novel_capabilities':[],'disabled_builtin_constraints':['require_wip_evidence']},{'name':'retail_d2c','display_name':'Retail\x20D2C\x20(Direct-to-Consumer)','version':'v1','source':'builtin',...fetchTemplate('retail_d2c'),'analyze':{'key_questions':['Do\x20withdraw_guard\x20and\x20refund_guard\x20fully\x20enclose\x20the\x20Allocation\x20escrow,\x20so\x20neither\x20side\x20can\x20move\x20funds\x20outside\x20the\x20contract\x20path?','With\x20no\x20platform\x20arbitration,\x20what\x20off-chain\x20recourse\x20(if\x20any)\x20backs\x20a\x20delivery\x20failure\x20—\x20and\x20is\x20that\x20acceptable\x20for\x20the\x20ticket\x20size?']},'capabilities_used':['permission.index_create','permission.role_assign','guard.validate_withdraw','guard.validate_refund','machine.node_topology','allocation.distribute','service.publish','progress.advance','contact.im_create'],'config_overrides':{'machine':{'wip_required':![],'confirm_gate':!![],'refund_requires_approval':![]},'service':{'logistics_mode':'merchant_managed','multi_recipient_allocation':!![]}},'expected_benefits':[{'metric':'Merchant\x20revenue\x20share','expected_value':'97%','evidence':'No\x20platform\x20commission\x20—\x20only\x203%\x20processing\x20fee'},{'metric':'Fund\x20safety','expected_value':'contract-grade','evidence':'Allocation\x20escrow\x20+\x20Guard\x20verification\x20replaces\x20platform\x20custody'},{'metric':'Delivery\x20reliability','expected_value':'high','evidence':'withdraw_guard\x20enforces\x20delivery\x20confirmation\x20before\x20payment'}],'risk_appetite':'balanced','risk_constraints':{'require_arbitration':![],'require_compensation_fund':![],'require_wip_evidence':![],'other_constraints':['Allocation\x20escrow\x20required\x20(withdraw_guard\x20+\x20refund_guard)','Service\x20↔\x20Guard\x20circular\x20dependency\x20requires\x203-step\x20creation\x20pattern']},'applicable_conditions':{'business_scale':'small','min_daily_orders':0x1,'other_conditions':['Independent\x20storefront\x20(no\x20marketplace)','Merchant-managed\x20logistics','Allocation\x20escrow\x20model']},'similar_industries':['retail','subscription'],'novel_capabilities':['Allocation\x20escrow\x20as\x20platform-custody\x20alternative','Multi-recipient\x20allocation\x20(merchant\x20+\x20processor)'],'disabled_builtin_constraints':['require_arbitration','require_compensation_fund','require_wip_evidence']},{'name':'general','display_name':'General','version':'v1','source':'builtin',...fetchTemplate('general'),'analyze':{'key_questions':['Which\x20trust\x20mechanisms\x20(arbitration,\x20compensation\x20fund,\x20WIP\x20evidence)\x20are\x20missing\x20here,\x20and\x20what\x20does\x20each\x20absence\x20cost\x20in\x20the\x20worst\x20case?','What\x20is\x20the\x20single\x20point\x20of\x20failure\x20—\x20who\x20can\x20unilaterally\x20take\x20funds\x20or\x20stall\x20the\x20workflow?']},'capabilities_used':['permission.index_create','machine.node_topology','treasury.owner_receive','allocation.distribute','service.publish','progress.advance'],'expected_benefits':[{'metric':'Flexibility','expected_value':'100%','evidence':'User\x20customizes\x20all\x20trust\x20mechanism\x20parameters'},{'metric':'Degraded\x20safety','expected_value':'usable','evidence':'Can\x20fall\x20back\x20to\x20general\x20at\x20any\x20time'}],'risk_appetite':'balanced','risk_constraints':{'require_arbitration':![],'require_compensation_fund':![],'require_wip_evidence':![]},'applicable_conditions':{'business_scale':'small','other_conditions':['Fallback\x20degraded\x20mode','Hybrid\x20scenarios\x20not\x20covered\x20by\x20other\x20industries']},'similar_industries':[],'novel_capabilities':[],'disabled_builtin_constraints':['require_arbitration','require_compensation_fund','require_wip_evidence']}];
|
|
1
|
+
import{getScenarioMode}from'../knowledge/scenario-modes.js';import{BUILTIN_TEMPLATES}from'../knowledge/builtin-templates.js';import{getIndustryTraits}from'../knowledge/industry-registry.js';import{getIndustryRiskChecks,getIndustryNeeds}from'../customer/index.js';import{SUPPORTED_INDUSTRIES}from'../customer/user-preferences.js';import{getFlywheelForIndustry}from'../knowledge/acquisition-flywheel.js';const GENERAL_TRAITS={'has_logistics':![],'communication_heavy':![],'pure_digital':![],'long_cycle':![],'deposit_required':![],'multi_tier_allocation':![],'regulatory_intensity':'low','trust_sensitivity':'medium','consumption_frequency':'occasional','avg_ticket_size':'medium'},GENERAL_FLYWHEEL={'industry':'general','trustSellingPoints':[],'keyActions':[],'rewardStrategy':'User-defined','discountStrategy':'User-defined','trustDescription':'User-defined\x20trust\x20mechanism'},GENERAL_MACHINE_SHAPE=[{'name':'paid','role':'Entry:\x20order\x20created\x20and\x20paid'},{'name':'delivering','role':'Service\x20delivery\x20in\x20progress'},{'name':'delivered','role':'Deliverable\x20available\x20for\x20review'},{'name':'completed','role':'Service\x20completed,\x20funds\x20released'},{'name':'cancelled','role':'Pre-delivery\x20cancellation\x20—\x20triggers\x20refund\x20Allocator','operator':'order_payer'}],GENERAL_ALLOCATOR={'recipient':'signer','count':0x1,'mode':'surplus','description':'Default:\x20surplus\x20to\x20service\x20owner\x20(general\x20fallback)'},RETAIL_D2C_MACHINE_SHAPE=[{'name':'ordered','role':'Entry:\x20order\x20created\x20(funds\x20escrowed\x20in\x20Allocation)'},{'name':'shipped','role':'Merchant\x20ships\x20goods'},{'name':'delivered','role':'Goods\x20delivered\x20to\x20buyer'},{'name':'completed','role':'Buyer\x20confirms\x20receipt\x20—\x20withdraw_guard\x20releases\x20funds','operator':'order_payer'},{'name':'cancelled','role':'Pre-ship\x20cancellation\x20—\x20refund_guard\x20refunds\x20buyer','operator':'order_payer'}],RETAIL_D2C_GUARDS=[{'template_id':'withdraw_guard_delivery','host':'service','purpose':'Release\x20funds\x20to\x20merchant\x20+\x20processor\x20on\x20order\x20completion\x20(delivery\x20confirmation)'},{'template_id':'refund_guard_cancellation','host':'service','purpose':'Refund\x20100%\x20to\x20buyer\x20on\x20order\x20cancellation'}],RETAIL_D2C_ALLOCATOR={'recipient':'entity','count':0x2,'mode':'rate','description':'Merchant\x2097%\x20+\x20Processor\x203%\x20(rate-based\x20split,\x20no\x20platform\x20commission)'},RETAIL_D2C_KEY_RISK='No\x20platform\x20arbitration\x20—\x20disputes\x20rely\x20on\x20optional\x20Arbitration\x20or\x20off-chain\x20chargeback',RETAIL_D2C_BUILD_NOTES=['Allocation\x20escrow\x20replaces\x20platform\x20custody\x20—\x20funds\x20locked\x20in\x20contract\x20until\x20Guard\x20releases','withdraw_guard\x20enforces\x20delivery\x20gate\x20—\x20merchant\x20must\x20reach\x20\x27completed\x27\x20state\x20to\x20receive\x20payment','refund_guard\x20ensures\x20100%\x20refund\x20on\x20cancellation\x20—\x20no\x20merchant\x20approval\x20needed','No\x20buy_guard\x20needed\x20—\x20D2C\x20doesn\x27t\x20gate\x20purchases\x20(open\x20storefront)','Arbitration\x20is\x20optional\x20—\x20add\x20when\x20dispute\x20volume\x20justifies\x20the\x20cost','Service\x20↔\x20Guard\x20circular\x20dependency:\x20create\x20Service\x20(unpublished)\x20→\x20create\x20Guards\x20→\x20update\x20Service\x20(publish)'],SUPPORTED_INDUSTRY_SET=new Set([...SUPPORTED_INDUSTRIES,'retail_d2c']);function fetchTemplate(a){const b=a==='retail_d2c'?'retail':a,c=getIndustryTraits(b)??GENERAL_TRAITS,d=SUPPORTED_INDUSTRY_SET['has'](a),e=a==='retail_d2c'?'retail':a,f=d?getIndustryRiskChecks(e):[],g=d?getIndustryNeeds(e):[],h=getFlywheelForIndustry(b)??GENERAL_FLYWHEEL;let i,j,k,l,m;if(a==='retail_d2c')i=RETAIL_D2C_MACHINE_SHAPE,j=RETAIL_D2C_GUARDS,k=RETAIL_D2C_ALLOCATOR,l=RETAIL_D2C_KEY_RISK,m=RETAIL_D2C_BUILD_NOTES;else{if(a==='general'){const n=getScenarioMode('general');i=GENERAL_MACHINE_SHAPE,j=[],k=GENERAL_ALLOCATOR,l=n?.['key_risk']??'No\x20safety\x20net\x20—\x20user\x20must\x20design\x20all\x20trust\x20mechanisms\x20manually',m=n?.['build_notes'];}else{const o=getScenarioMode(a);if(!o)throw new Error('[modes.ts]\x20No\x20scenario\x20mode\x20found\x20for\x20industry:\x20'+a);const p=BUILTIN_TEMPLATES['find'](q=>q['id']===o['default_template']);if(!p)throw new Error('[modes.ts]\x20Mode\x20\x27'+a+'\x27\x20default_template\x20\x27'+o['default_template']+'\x27\x20is\x20not\x20in\x20the\x20builtin\x20template\x20catalog');i=p['machine_shape'],j=p['guards'],k=p['allocator'],l=o['key_risk'],m=o['build_notes'];}}return{'traits':c,'risk_checks':f,'needs':g,'flywheel':h,'machine_shape':i,'guards':j,'allocator':k,'key_risk':l,'build_notes':m};}export const BUILTIN_MODES=[{'name':'freelance','display_name':'Freelance','version':'v1','source':'builtin',...fetchTemplate('freelance'),'analyze':{'key_questions':['Are\x20WIP\x20hashes\x20bound\x20to\x20each\x20milestone,\x20so\x20delivery\x20evidence\x20cannot\x20be\x20substituted\x20after\x20acceptance?','Does\x20the\x20acceptance\x20gate\x20have\x20a\x20time-bounded\x20escape\x20(keeper-driven\x20auto-accept),\x20or\x20can\x20a\x20silent\x20buyer\x20hold\x20the\x20provider\x27s\x20funds\x20hostage\x20indefinitely?']},'capabilities_used':['permission.index_create','permission.role_assign','guard.validate_buy','guard.validate_wip_hash','machine.node_topology','treasury.owner_receive','allocation.distribute','allocation.distribute_milestone','service.publish','progress.advance','arb.vote_weighted','contact.im_create'],'config_overrides':{'service':{'setting_locked_time':'30d','engagement_type':'milestone'},'machine':{'wip_required':!![],'wip_hash_algorithm':'sha256','acceptance_gate':!![]}},'expected_benefits':[{'metric':'Dispute\x20rate\x20reduction','expected_value':'40%','evidence':'WIP\x20hash\x20+\x20milestone\x20allocation\x20enforces\x20delivery\x20evidence'},{'metric':'Delivery\x20confirmation\x20efficiency','expected_value':'+50%','evidence':'acceptance\x20gate\x20automates\x20acceptance\x20workflow'},{'metric':'Provider\x20payment\x20assurance','expected_value':'100%','evidence':'Funds\x20auto-release\x20to\x20provider\x20after\x20accepted\x20node'}],'risk_appetite':'balanced','risk_constraints':{'require_arbitration':!![],'require_compensation_fund':![],'require_wip_evidence':!![],'other_constraints':['setting_locked_time\x20>=\x207d\x20to\x20lock\x20engagement-period\x20rules','Acceptance\x20timeout\x20=\x20the\x20template\x27s\x20escrow_release_days\x20(single\x20source:\x20fee_params,\x20override\x20via\x20fee_overrides).\x20Mechanism:\x20dual-branch\x20time-gated\x20forward\x20(pattern.time_lock_progress\x20anchored\x20on\x20the\x20delivered\x20entry);\x20a\x20keeper\x20advances\x20the\x20timeout\x20path.\x20adminUnhold\x20(224)\x20is\x20ONLY\x20the\x20hold-release\x20escape\x20hatch,\x20never\x20the\x20timeout\x20mechanism.']},'applicable_conditions':{'business_scale':'small','min_daily_orders':0x1,'other_conditions':['Suitable\x20for\x20mid-to-long-term\x20project\x20delivery','Requires\x20milestone-based\x20phased\x20acceptance']},'similar_industries':['rental','education'],'novel_capabilities':['allocation.distribute_milestone'],'disabled_builtin_constraints':['require_compensation_fund']},{'name':'rental','display_name':'Rental','version':'v1','source':'builtin',...fetchTemplate('rental'),'analyze':{'key_questions':['Is\x20the\x20deposit\x20escrowed\x20on-chain\x20and\x20sized\x20against\x20the\x20item\x27s\x20full\x20replacement\x20value,\x20not\x20just\x20the\x20rental\x20fee?','Are\x20pre-handover\x20and\x20post-return\x20WIP\x20states\x20hash-recorded,\x20so\x20damage\x20attribution\x20is\x20provable\x20rather\x20than\x20asserted?']},'capabilities_used':['permission.index_create','permission.role_assign','guard.validate_buy','guard.validate_wip_hash','machine.node_topology','treasury.owner_receive','allocation.distribute','service.publish','progress.advance','arb.vote_weighted','contact.im_create'],'config_overrides':{'treasury':{'deposit_escrow':!![],'deposit_deductible':!![]},'machine':{'wip_required':!![],'wip_stages':['handover_out','returned'],'inspection_gate':!![]}},'expected_benefits':[{'metric':'Deposit\x20dispute\x20rate','expected_value':'-60%','evidence':'pre-rental\x20WIP\x20mandatorily\x20records\x20item\x27s\x20original\x20state'},{'metric':'Damage\x20liability\x20accuracy','expected_value':'+70%','evidence':'pre/post\x20WIP\x20hash\x20comparison\x20eliminates\x20unfounded\x20deductions'},{'metric':'Trust\x20score','expected_value':'+25%','evidence':'compensation_fund\x20covers\x20damage\x20risk'}],'risk_appetite':'conservative','risk_constraints':{'require_arbitration':!![],'require_compensation_fund':!![],'require_wip_evidence':!![],'max_single_transaction':0x2710,'compensation_fund_coverage_ratio':0xa,'other_constraints':['Deposit\x20must\x20be\x20escrowed\x20(no\x20direct\x20transfer)','lock_duration\x20>=\x207d\x20to\x20prevent\x20arbitrary\x20merchant\x20withdrawal']},'applicable_conditions':{'business_scale':'small','min_daily_orders':0x1,'other_conditions':['Requires\x20physical\x20item\x20handover','Has\x20logistics\x20or\x20offline\x20delivery\x20leg']},'similar_industries':['retail','travel'],'novel_capabilities':[]},{'name':'education','display_name':'Education','version':'v1','source':'builtin',...fetchTemplate('education'),'analyze':{'key_questions':['Does\x20tuition\x20release\x20per\x20attended\x20session\x20(Progress\x20node),\x20so\x20undelivered\x20sessions\x20stay\x20refundable\x20if\x20the\x20institution\x20disappears?','Does\x20setting_locked_time\x20span\x20the\x20full\x20term,\x20so\x20the\x20institution\x20cannot\x20tighten\x20refund\x20rules\x20mid-course?']},'capabilities_used':['permission.index_create','permission.role_assign','guard.validate_buy','guard.validate_wip_hash','machine.node_topology','treasury.owner_receive','allocation.distribute','allocation.distribute_milestone','service.publish','progress.advance','arb.vote_weighted','contact.im_create'],'config_overrides':{'allocation':{'strategy':{'recipient':'entity','count':0x1,'mode':'amount','description':'1/N\x20of\x20tuition\x20released\x20per\x20session\x20attendance'},'session_threshold':!![]},'service':{'setting_locked_time':'120d','anti_runaway':!![]}},'expected_benefits':[{'metric':'Refund\x20dispute\x20rate','expected_value':'-50%','evidence':'per-session\x20release\x20distributes\x20tuition\x20by\x20class'},{'metric':'Institution\x20runaway\x20risk','expected_value':'eliminated','evidence':'Funds\x20release\x20per\x20session;\x20undelivered\x20portion\x20is\x20refundable'},{'metric':'Attendance\x20traceability','expected_value':'100%','evidence':'attendance_guard\x20signs\x20each\x20session'}],'risk_appetite':'conservative','risk_constraints':{'require_arbitration':!![],'require_compensation_fund':!![],'require_wip_evidence':![],'other_constraints':['setting_locked_time\x20covers\x20the\x20entire\x20term\x20(>=90d)','Long-cycle\x20projects\x20must\x20monitor\x20>90d\x20progress']},'applicable_conditions':{'business_scale':'medium','min_daily_orders':0x1,'other_conditions':['Long-cycle\x20delivery','Requires\x20per-session\x20acceptance','Regulatory\x20intensity:\x20medium']},'similar_industries':['freelance','subscription'],'novel_capabilities':['allocation.distribute_milestone'],'disabled_builtin_constraints':['require_wip_evidence']},{'name':'travel','display_name':'Travel','version':'v1','source':'builtin',...fetchTemplate('travel'),'analyze':{'key_questions':['Does\x20each\x20itinerary\x20segment\x20have\x20its\x20own\x20guard\x20and\x20WIP\x20acceptance,\x20so\x20one\x20failed\x20leg\x20is\x20refundable\x20without\x20unwinding\x20the\x20whole\x20trip?','Is\x20the\x20multi-tier\x20allocation\x20waterfall\x20(agency\x20→\x20hotel/guide/driver)\x20visible\x20on-chain,\x20so\x20the\x20agency\x20cannot\x20silently\x20re-split\x20funds?']},'capabilities_used':['permission.index_create','permission.role_assign','guard.validate_buy','guard.validate_wip_hash','machine.node_topology','treasury.owner_receive','allocation.distribute','service.publish','progress.advance','arb.vote_weighted','contact.im_create'],'config_overrides':{'allocation':{'strategy':{'recipient':'entity','count':0x3,'mode':'amount','description':'Deposit\x2020%\x20to\x20agency,\x20final\x2080%\x20to\x20agency,\x20then\x20agency-side\x20Allocation\x20splits\x20to\x20hotel/guide/driver\x20per\x20segment'},'multi_tier_waterfall':!![],'guard_chaining':!![]},'service':{'supply_chain_suborders':!![],'segment_guard_required':!![]}},'expected_benefits':[{'metric':'Fund\x20transparency','expected_value':'100%','evidence':'multi-tier\x20allocation\x20splits\x20per\x20segment\x20to\x20hotel/guide/driver'},{'metric':'Itinerary\x20change\x20disputes','expected_value':'-45%','evidence':'segment\x20WIP\x20accepts\x20each\x20leg'},{'metric':'Breach\x20compensation\x20assurance','expected_value':'+60%','evidence':'compensation_fund\x20covers\x20itinerary\x20breach'}],'risk_appetite':'balanced','risk_constraints':{'require_arbitration':!![],'require_compensation_fund':!![],'require_wip_evidence':!![],'other_constraints':['Multi-tier\x20allocation\x20requires\x20guard\x20chaining\x20validation','deposit\x2020%\x20+\x20final\x2080%\x20two-stage\x20payment']},'applicable_conditions':{'business_scale':'medium','min_daily_orders':0x1,'other_conditions':['Multi-segment\x20itinerary\x20combination','Requires\x20hotel/guide/driver\x20multi-party\x20allocation']},'similar_industries':['rental','education'],'novel_capabilities':[]},{'name':'subscription','display_name':'Subscription','version':'v1','source':'builtin',...fetchTemplate('subscription'),'analyze':{'key_questions':['Is\x20every\x20periodic\x20charge\x20gated\x20by\x20an\x20explicit\x20user\x20confirmation,\x20with\x20no\x20auto-renew\x20default?','Can\x20the\x20subscriber\x20cancel\x20anytime\x20effective\x20next\x20period,\x20without\x20a\x20dead-end\x20node\x20in\x20the\x20machine?']},'capabilities_used':['permission.index_create','permission.role_assign','guard.validate_buy','machine.node_topology','treasury.owner_receive','allocation.distribute','service.publish','progress.advance','arb.vote_weighted','reward.claim_guard','contact.im_create'],'config_overrides':{'machine':{'no_auto_renew_trap':!![],'user_confirmed_charge':!![],'cancel_anytime':!![],'next_period_effective':!![]},'service':{'creator_data_subscription':!![],'periodic_billing':!![]}},'expected_benefits':[{'metric':'Renewal\x20rate','expected_value':'+25%','evidence':'loyalty\x20reward\x20+\x20transparent\x20subscription\x20mechanism'},{'metric':'Cancellation\x20disputes','expected_value':'eliminated','evidence':'cancel\x20anytime\x20+\x20no\x20auto-renew\x20trap'},{'metric':'Creator\x20retention','expected_value':'+30%','evidence':'deliver_guard_wip\x20prevents\x20content\x20dropout'}],'risk_appetite':'aggressive','risk_constraints':{'require_arbitration':![],'require_compensation_fund':![],'require_wip_evidence':![],'compensation_fund_coverage_ratio':0x3,'other_constraints':['Forbid\x20dead-end\x20nodes\x20(prevent\x20lock-in)','charge_guard\x20requires\x20user\x20confirmation\x20each\x20period']},'applicable_conditions':{'business_scale':'small','min_daily_orders':0x5,'other_conditions':['Pure-digital\x20delivery','Periodic\x20content\x20or\x20SaaS\x20service']},'similar_industries':['freelance','education'],'novel_capabilities':[],'disabled_builtin_constraints':['require_arbitration','require_compensation_fund','require_wip_evidence']},{'name':'retail','display_name':'Retail','version':'v1','source':'builtin',...fetchTemplate('retail'),'analyze':{'key_questions':['Is\x20the\x20logistics\x20tracking\x20number\x20recorded\x20as\x20WIP\x20before\x20the\x20confirm\x20gate,\x20so\x20receipt\x20disputes\x20have\x20carrier\x20evidence?','Is\x20the\x20refund\x20window\x20at\x20least\x207\x20days\x20with\x20an\x20on-chain\x20refund\x20path\x20that\x20does\x20not\x20rely\x20on\x20merchant\x20goodwill?']},'capabilities_used':['permission.index_create','permission.role_assign','guard.validate_buy','guard.validate_wip_hash','machine.node_topology','treasury.owner_receive','allocation.distribute','service.publish','progress.advance','arb.vote_weighted','reward.claim_guard','contact.im_create'],'config_overrides':{'machine':{'wip_required':!![],'wip_field':'tracking_number','confirm_gate':!![],'refund_requires_approval':!![]},'service':{'logistics_mode':'standard','first_order_discount':!![]}},'expected_benefits':[{'metric':'Return\x20dispute\x20rate','expected_value':'-35%','evidence':'logistics\x20WIP\x20+\x20refund\x20path\x20assurance'},{'metric':'Repurchase\x20rate','expected_value':'+20%','evidence':'spend\x20cashback\x20reward'},{'metric':'Product\x20authenticity\x20traceability','expected_value':'100%','evidence':'WIP\x20verifies\x20product/logistics\x20info'}],'risk_appetite':'conservative','risk_constraints':{'require_arbitration':!![],'require_compensation_fund':!![],'require_wip_evidence':![],'compensation_fund_coverage_ratio':0x5,'other_constraints':['refund_window\x20>=\x207d','confirm_gate:\x20only\x20buyer\x20can\x20confirm\x20receipt']},'applicable_conditions':{'business_scale':'medium','min_daily_orders':0xa,'other_conditions':['Has\x20logistics\x20shipping\x20leg','High-frequency\x20small-ticket\x20transactions']},'similar_industries':['rental','subscription'],'novel_capabilities':[],'disabled_builtin_constraints':['require_wip_evidence']},{'name':'retail_d2c','display_name':'Retail\x20D2C\x20(Direct-to-Consumer)','version':'v1','source':'builtin',...fetchTemplate('retail_d2c'),'analyze':{'key_questions':['Do\x20withdraw_guard\x20and\x20refund_guard\x20fully\x20enclose\x20the\x20Allocation\x20escrow,\x20so\x20neither\x20side\x20can\x20move\x20funds\x20outside\x20the\x20contract\x20path?','With\x20no\x20platform\x20arbitration,\x20what\x20off-chain\x20recourse\x20(if\x20any)\x20backs\x20a\x20delivery\x20failure\x20—\x20and\x20is\x20that\x20acceptable\x20for\x20the\x20ticket\x20size?']},'capabilities_used':['permission.index_create','permission.role_assign','guard.validate_withdraw','guard.validate_refund','machine.node_topology','allocation.distribute','service.publish','progress.advance','contact.im_create'],'config_overrides':{'machine':{'wip_required':![],'confirm_gate':!![],'refund_requires_approval':![]},'service':{'logistics_mode':'merchant_managed','multi_recipient_allocation':!![]}},'expected_benefits':[{'metric':'Merchant\x20revenue\x20share','expected_value':'97%','evidence':'No\x20platform\x20commission\x20—\x20only\x203%\x20processing\x20fee'},{'metric':'Fund\x20safety','expected_value':'contract-grade','evidence':'Allocation\x20escrow\x20+\x20Guard\x20verification\x20replaces\x20platform\x20custody'},{'metric':'Delivery\x20reliability','expected_value':'high','evidence':'withdraw_guard\x20enforces\x20delivery\x20confirmation\x20before\x20payment'}],'risk_appetite':'balanced','risk_constraints':{'require_arbitration':![],'require_compensation_fund':![],'require_wip_evidence':![],'other_constraints':['Allocation\x20escrow\x20required\x20(withdraw_guard\x20+\x20refund_guard)','Service\x20↔\x20Guard\x20circular\x20dependency\x20requires\x203-step\x20creation\x20pattern']},'applicable_conditions':{'business_scale':'small','min_daily_orders':0x1,'other_conditions':['Independent\x20storefront\x20(no\x20marketplace)','Merchant-managed\x20logistics','Allocation\x20escrow\x20model']},'similar_industries':['retail','subscription'],'novel_capabilities':['Allocation\x20escrow\x20as\x20platform-custody\x20alternative','Multi-recipient\x20allocation\x20(merchant\x20+\x20processor)'],'disabled_builtin_constraints':['require_arbitration','require_compensation_fund','require_wip_evidence']},{'name':'general','display_name':'General','version':'v1','source':'builtin',...fetchTemplate('general'),'analyze':{'key_questions':['Which\x20trust\x20mechanisms\x20(arbitration,\x20compensation\x20fund,\x20WIP\x20evidence)\x20are\x20missing\x20here,\x20and\x20what\x20does\x20each\x20absence\x20cost\x20in\x20the\x20worst\x20case?','What\x20is\x20the\x20single\x20point\x20of\x20failure\x20—\x20who\x20can\x20unilaterally\x20take\x20funds\x20or\x20stall\x20the\x20workflow?']},'capabilities_used':['permission.index_create','machine.node_topology','treasury.owner_receive','allocation.distribute','service.publish','progress.advance'],'expected_benefits':[{'metric':'Flexibility','expected_value':'100%','evidence':'User\x20customizes\x20all\x20trust\x20mechanism\x20parameters'},{'metric':'Degraded\x20safety','expected_value':'usable','evidence':'Can\x20fall\x20back\x20to\x20general\x20at\x20any\x20time'}],'risk_appetite':'balanced','risk_constraints':{'require_arbitration':![],'require_compensation_fund':![],'require_wip_evidence':![]},'applicable_conditions':{'business_scale':'small','other_conditions':['Fallback\x20degraded\x20mode','Hybrid\x20scenarios\x20not\x20covered\x20by\x20other\x20industries']},'similar_industries':[],'novel_capabilities':[],'disabled_builtin_constraints':['require_arbitration','require_compensation_fund','require_wip_evidence']}];
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { IndustryMode, UserDefinedMode
|
|
1
|
+
import type { IndustryMode, UserDefinedMode } from "./types.js";
|
|
2
2
|
export declare class IndustryModeRegistry {
|
|
3
3
|
private static instance;
|
|
4
4
|
private registrations;
|
|
@@ -16,7 +16,6 @@ export declare class IndustryModeRegistry {
|
|
|
16
16
|
resolveAlias(name: string): string;
|
|
17
17
|
hasMode(name: string): boolean;
|
|
18
18
|
unregisterMode(name: string): boolean;
|
|
19
|
-
evaluateModeObject(mode: IndustryMode): Promise<ModeEvaluation>;
|
|
20
19
|
registerUserMode(mode: UserDefinedMode, userId: string): Promise<boolean>;
|
|
21
20
|
deriveMode(sourceMode: string, modifications: Partial<UserDefinedMode>, userId: string, newName: string, newDisplayName?: string): Promise<UserDefinedMode | undefined>;
|
|
22
21
|
evolveMode(modeName: string, updates: Partial<UserDefinedMode>, userId: string, changeDescription: string, bumpVersion?: boolean): Promise<UserDefinedMode | undefined>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{CustomRegistryFile}from'./custom-registry-file.js';import{CapabilityRegistry}from'./capability-manifest.js';import{ModeEvaluator}from'./mode-evaluator.js';import{MetricRegistry}from'./metric-registry.js';import{ConstraintRegistry}from'./constraint-registry.js';import{BUILTIN_MODES}from'./modes.js';import{unannotatedBuyerActionNodes}from'../knowledge/scenario-modes.js';export class IndustryModeRegistry{static ['instance'];['registrations']=new Map();['userModes']=new Map();['aliases']=new Map();['evaluator'];['initialized']=![];['file']=CustomRegistryFile['Instance']();['userModesSyncedMtime']=-0x1;static['Instance'](){return!IndustryModeRegistry['instance']&&(IndustryModeRegistry['instance']=new IndustryModeRegistry()),IndustryModeRegistry['instance'];}constructor(){this['evaluator']=new ModeEvaluator(CapabilityRegistry['Instance'](),MetricRegistry['Instance'](),ConstraintRegistry['Instance']()),this['registerBuiltinModes'](),this['initialized']=!![];}['registerMode'](a,b){if(!a['name']||!a['traits']||!a['machine_shape'])return console['warn']('[IndustryModeRegistry]\x20registerMode\x20rejected:\x20invalid\x20mode\x20'+('(name='+(a['name']||'<missing>')+',\x20traits='+(a['traits']?'ok':'<missing>')+',\x20')+('machine_shape='+(a['machine_shape']?'ok':'<missing>')+').')),![];if(this['registrations']['has'](a['name'])){const d=this['registrations']['get'](a['name']);return console['warn']('[IndustryModeRegistry]\x20registerMode\x20rejected:\x20mode\x20\x27'+a['name']+'\x27\x20already\x20registered\x20'+('(registered_at='+new Date(d?.['registered_at']??0x0)['toISOString']()+').\x20')+'Use\x20evolveMode/deriveMode\x20for\x20user\x20modifications,\x20or\x20unregister\x20first.'),![];}this['registrations']['set'](a['name'],{'mode':a,'aliases':b,'enabled':!![],'registered_at':Date['now']()});const c=unannotatedBuyerActionNodes(a['machine_shape']);c['length']>0x0&&console['warn']('[IndustryModeRegistry]\x20mode\x20\x27'+a['name']+'\x27\x20machine_shape:\x20buyer-action\x20node(s)\x20'+(c['map'](e=>'\x27'+e+'\x27')['join'](',\x20')+'\x20lack\x20an\x20operator\x20annotation\x20')+'(R-OPER-01)\x20—\x20annotate\x20them\x20operator:\x20\x22order_payer\x22\x20or\x20buyers\x20cannot\x20advance\x20them.');if(b)for(const e of b){this['aliases']['set'](e,a['name']);}return!![];}['getMode'](a){const b=this['resolveAlias'](a);return this['registrations']['get'](b)?.['mode'];}['listModes'](){return Array['from'](this['registrations']['values']())['filter'](a=>a['enabled'])['map'](a=>a['mode']);}['resolveAlias'](a){return this['aliases']['get'](a)??a;}['hasMode'](a){const b=this['resolveAlias'](a);return this['registrations']['has'](b);}['unregisterMode'](a){const b=this['resolveAlias'](a);if(!this['registrations']['has'](b))return![];this['registrations']['delete'](b);for(const [c,d]of this['aliases']){if(d===b)this['aliases']['delete'](c);}return!![];}async['
|
|
1
|
+
import{CustomRegistryFile}from'./custom-registry-file.js';import{CapabilityRegistry}from'./capability-manifest.js';import{ModeEvaluator}from'./mode-evaluator.js';import{MetricRegistry}from'./metric-registry.js';import{ConstraintRegistry}from'./constraint-registry.js';import{BUILTIN_MODES}from'./modes.js';import{unannotatedBuyerActionNodes}from'../knowledge/scenario-modes.js';export class IndustryModeRegistry{static ['instance'];['registrations']=new Map();['userModes']=new Map();['aliases']=new Map();['evaluator'];['initialized']=![];['file']=CustomRegistryFile['Instance']();['userModesSyncedMtime']=-0x1;static['Instance'](){return!IndustryModeRegistry['instance']&&(IndustryModeRegistry['instance']=new IndustryModeRegistry()),IndustryModeRegistry['instance'];}constructor(){this['evaluator']=new ModeEvaluator(CapabilityRegistry['Instance'](),MetricRegistry['Instance'](),ConstraintRegistry['Instance']()),this['registerBuiltinModes'](),this['initialized']=!![];}['registerMode'](a,b){if(!a['name']||!a['traits']||!a['machine_shape'])return console['warn']('[IndustryModeRegistry]\x20registerMode\x20rejected:\x20invalid\x20mode\x20'+('(name='+(a['name']||'<missing>')+',\x20traits='+(a['traits']?'ok':'<missing>')+',\x20')+('machine_shape='+(a['machine_shape']?'ok':'<missing>')+').')),![];if(this['registrations']['has'](a['name'])){const d=this['registrations']['get'](a['name']);return console['warn']('[IndustryModeRegistry]\x20registerMode\x20rejected:\x20mode\x20\x27'+a['name']+'\x27\x20already\x20registered\x20'+('(registered_at='+new Date(d?.['registered_at']??0x0)['toISOString']()+').\x20')+'Use\x20evolveMode/deriveMode\x20for\x20user\x20modifications,\x20or\x20unregister\x20first.'),![];}this['registrations']['set'](a['name'],{'mode':a,'aliases':b,'enabled':!![],'registered_at':Date['now']()});const c=unannotatedBuyerActionNodes(a['machine_shape']);c['length']>0x0&&console['warn']('[IndustryModeRegistry]\x20mode\x20\x27'+a['name']+'\x27\x20machine_shape:\x20buyer-action\x20node(s)\x20'+(c['map'](e=>'\x27'+e+'\x27')['join'](',\x20')+'\x20lack\x20an\x20operator\x20annotation\x20')+'(R-OPER-01)\x20—\x20annotate\x20them\x20operator:\x20\x22order_payer\x22\x20or\x20buyers\x20cannot\x20advance\x20them.');if(b)for(const e of b){this['aliases']['set'](e,a['name']);}return!![];}['getMode'](a){const b=this['resolveAlias'](a);return this['registrations']['get'](b)?.['mode'];}['listModes'](){return Array['from'](this['registrations']['values']())['filter'](a=>a['enabled'])['map'](a=>a['mode']);}['resolveAlias'](a){return this['aliases']['get'](a)??a;}['hasMode'](a){const b=this['resolveAlias'](a);return this['registrations']['has'](b);}['unregisterMode'](a){const b=this['resolveAlias'](a);if(!this['registrations']['has'](b))return![];this['registrations']['delete'](b);for(const [c,d]of this['aliases']){if(d===b)this['aliases']['delete'](c);}return!![];}async['registerUserMode'](a,b){await this['ensureUserModesLoaded']();if(!a['name']||!a['owner']||!a['machine_shape'])return![];if(a['source']!=='custom')return![];if(a['owner']!==b)return![];const c=this['userModeKey'](a['owner'],a['name']);if(this['registrations']['has'](a['name']))return![];if(this['userModes']['has'](c))return![];return(!a['evolution_history']||a['evolution_history']['length']===0x0)&&(a['evolution_history']=[{'version':a['version']||'v1','changed_at':Date['now'](),'changes':['Initial\x20registration\x20(registerUserMode)']}]),this['userModes']['set'](c,a),await this['persistUserMode'](a),!![];}async['deriveMode'](a,b,c,d,e){await this['ensureUserModesLoaded']();const f=this['getMode'](a);if(!f)return undefined;if(!d||this['registrations']['has'](d))return undefined;const g=this['userModeKey'](c,d);if(this['userModes']['has'](g))return undefined;const h={'name':d,'display_name':e??d,'version':'v1','source':'custom','traits':b['traits']??f['traits'],'machine_shape':b['machine_shape']??f['machine_shape'],'guards':b['guards']??f['guards'],'allocator':b['allocator']??f['allocator'],'risk_checks':b['risk_checks']??f['risk_checks'],'needs':b['needs']??f['needs'],'flywheel':b['flywheel']??f['flywheel'],'key_risk':b['key_risk']??f['key_risk'],'build_notes':b['build_notes']??f['build_notes'],'analyze':b['analyze']??f['analyze'],'capabilities_used':b['capabilities_used']??f['capabilities_used'],'config_overrides':b['config_overrides']??f['config_overrides'],'config_override_rules':b['config_override_rules']??f['config_override_rules'],'expected_benefits':b['expected_benefits']??f['expected_benefits'],'risk_appetite':b['risk_appetite']??f['risk_appetite'],'risk_constraints':b['risk_constraints']??f['risk_constraints'],'applicable_conditions':b['applicable_conditions']??f['applicable_conditions'],'similar_industries':b['similar_industries']??f['similar_industries'],'novel_capabilities':b['novel_capabilities']??f['novel_capabilities'],'owner':c,'derived_from':a,'custom_metrics':b['custom_metrics']??f['custom_metrics'],'custom_constraints':b['custom_constraints']??f['custom_constraints'],'evolution_history':[{'version':'v1','changed_at':Date['now'](),'changes':['Derived\x20from\x20builtin\x20\x27'+a+'\x27']}]};return this['userModes']['set'](g,h),await this['persistUserMode'](h),h;}async['evolveMode'](a,b,c,d,e=!![]){await this['ensureUserModesLoaded']();const f=this['userModeKey'](c,a),g=this['userModes']['get'](f);if(!g)return undefined;const h=e?this['bumpPatchVersion'](g['version']):g['version'],i={...g,...b,'name':g['name'],'owner':g['owner'],'source':'custom','derived_from':g['derived_from'],'evolution_history':[...g['evolution_history']??[],{'version':h,'changed_at':Date['now'](),'changes':[d]}],'version':h};return this['userModes']['set'](f,i),await this['persistUserMode'](i),i;}async['listUserModes'](a){await this['ensureUserModesLoaded']();const b=[];for(const c of this['userModes']['values']()){c['owner']===a&&b['push'](c);}return b;}async['getUserMode'](a,b){await this['ensureUserModesLoaded']();const c=this['userModeKey'](b,a);return this['userModes']['get'](c);}async['unregisterUserMode'](a,b){await this['ensureUserModesLoaded']();const c=this['userModeKey'](b,a),d=this['userModes']['delete'](c);return d&&await this['unpersistUserMode'](b,a),d;}['userModeKey'](a,b){return a+':'+b;}async['ensureUserModesLoaded'](){const {data:a,mtime:b}=await this['file']['read']();if(b<0x0||b===this['userModesSyncedMtime'])return;this['userModesSyncedMtime']=b,this['userModes']['clear']();for(const [c,d]of Object['entries'](a['user_modes'])){const e=d;e?.['name']&&e?.['owner']&&e?.['machine_shape']?this['userModes']['set'](c,e):console['warn']('[IndustryModeRegistry]\x20Skipping\x20invalid\x20user_modes\x20file\x20entry\x20\x27'+c+'\x27.');}}async['persistUserMode'](a){await this['file']['update'](b=>{b['user_modes'][this['userModeKey'](a['owner'],a['name'])]=a;});}async['unpersistUserMode'](a,b){await this['file']['update'](c=>{delete c['user_modes'][this['userModeKey'](a,b)];});}['bumpPatchVersion'](a){const b=a['replace'](/^v/,''),c=b['split']('.');if(c['length']<0x2)return'v'+b+'.1';const d=parseInt(c[0x1]??'0',0xa);return c[0x1]=String(d+0x1),'v'+c['join']('.');}['registerBuiltinModes'](){for(const a of BUILTIN_MODES){this['registerMode'](a);}}}export function getIndustryModeRegistry(){return IndustryModeRegistry['Instance']();}export const INDUSTRY_MODE_REGISTRY_VERSION=2.3;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{EDGE_SCHEMAS,EDGE_SCHEMA_BY_ID}from'./edge-schema.js';import{extractCoinType,extractEventRefs,extractObjectEdges,extractReverseRefs,extractTableRefs,inferObjectType,REVERSE_GROUP_WILDCARD}from'./extract.js';import{mergeBudget}from'./dataplane.js';import{deriveOrderCompletion,terminalNamesOfEdges}from'./order-status.js';import{LINKER_RING_LIMIT as a96a}from'./sdk-batch.js';import{wowAddressKind}from'@wowok/wowok';function readStats(a){const b=a;if(b['stats'])return{'batches':b['stats']['batches'],'byChannel':{...b['stats']['byChannel']},'dedupHits':b['stats']['dedupHits']};if(b['batches'])return{'batches':Object['values'](b['batches'])['reduce']((c,d)=>c+d,0x0),'byChannel':{...b['batches']},'dedupHits':b['dedupHits']??0x0};return{'batches':0x0,'byChannel':{'objects':0x0,'keyedFields':0x0,'tables':0x0,'events':0x0},'dedupHits':0x0};}function isEoa(a){return wowAddressKind(a)==='user';}function isWfNodeId(a){return a['includes']('::node::');}class Gate{['wl'];constructor(a){this['wl']=a;}['allows'](a,b){if(this['wl']['deny']?.['includes'](a['id']))return![];const c=this['wl']['familyDepths']?.[a['family']];if(c!==undefined&&b>=c)return![];if(this['wl']['schemas'])return this['wl']['schemas']['includes'](a['id']);if(this['wl']['families']&&!this['wl']['families']['includes'](a['family']))return![];return!![];}['allowsTable'](a,b){if(a['read']['kind']!=='table')return![];if(this['wl']['deny']?.['includes'](a['id']))return![];const c=this['wl']['familyDepths']?.[a['family']];if(c!==undefined&&b>=c)return![];if(this['wl']['families']&&!this['wl']['families']['includes'](a['family']))return![];return!!this['wl']['tableEdges']?.['includes'](a['id']);}['allowsEvent'](a,b){if(a['read']['kind']!=='event')return![];if(this['wl']['deny']?.['includes'](a['id']))return![];const c=this['wl']['familyDepths']?.[a['family']];if(c!==undefined&&b>=c)return![];if(this['wl']['families']&&!this['wl']['families']['includes'](a['family']))return![];return!!this['wl']['eventEdges']?.['includes'](a['id']);}['effectiveMaxHops'](a){const b=a['maxHops'],c=this['wl']['schemaHops']?.[a['id']];if(b===undefined)return c;if(c===undefined)return b;return Math['min'](b,c);}}class GraphBuilder{['graph'];['edgeIds']=new Set();['budget'];['exhausted']={};constructor(a,b,c){this['budget']=c,this['graph']={'network':a,'seed':b,'builtAt':Date['now'](),'nodes':new Map(),'edges':[],'out':new Map(),'inc':new Map(),'gaps':[],'truncations':[],'rpcReport':{'batches':0x0,'byChannel':{'objects':0x0,'keyedFields':0x0,'tables':0x0,'events':0x0},'dedupHits':0x0},'budgetExhausted':{}};}['addSeed'](a){const b=inferObjectType(a),c={'id':a,'kind':isWfNodeId(a)?'wfnode':isEoa(a)?'eoa':'object','objectType':b??undefined,'state':'seed','origins':[],'depth':0x0};return this['graph']['nodes']['set'](a,c),c;}['addNode'](a,b,c){const d=this['graph']['nodes']['get'](a);if(d){if(c)d['origins']['push']({'via':c['schema'],'from':c['from'],'depth':b});return d;}if(this['graph']['nodes']['size']>=this['budget']['maxNodes'])return this['exhausted']['nodes']=!![],undefined;const e=isWfNodeId(a),f=e?undefined:inferObjectType(a),g={'id':a,'kind':e?'wfnode':isEoa(a)?'eoa':'object','objectType':f??undefined,'state':e?'stub':'seed','origins':c?[{'via':c['schema'],'from':c['from'],'depth':b}]:[],'depth':b};return this['graph']['nodes']['set'](a,g),g;}['addEdge'](a,b,c,d,e){const f=c['to'],g=c['key']?'|'+c['key']:'',h=a['id']+'|'+b+'→'+f+g;if(this['edgeIds']['has'](h))return;this['edgeIds']['add'](h);const i={'id':h,'schema':a['id'],'family':a['family'],'from':b,'to':f,'retention':a['retention'],'observedAt':d,'payload':c['payload'],'truncated':e||a['retention']==='bounded_window','key':c['key']};this['graph']['edges']['push'](i),pushMap(this['graph']['out'],b,i),pushMap(this['graph']['inc'],f,i);}['markTruncation'](a){this['graph']['truncations']['push'](a);}['finalize'](a){return this['graph']['rpcReport']=readStats(a),this['graph']['budgetExhausted']=this['exhausted'],this['graph'];}}function pushMap(a,b,c){const d=a['get'](b);if(d)d['push'](c);else a['set'](b,[c]);}export async function expandTopology(a,c){const d=c['seed']['toLowerCase'](),e=mergeBudget(c['budget']),f=new Gate(c['edges']??{}),h=new GraphBuilder(c['network'],d,e);h['addSeed'](d);const i=new Set(),j=new Set(),l=new Set(),m=new Map(),n=new Set();let o=new Set([d]);for(let p=0x0;p<=e['maxDepth'];p++){if(o['size']===0x0)break;if(h['exhausted']['nodes'])break;const q=Date['now'](),r=new Map(),t=(D,E)=>{const F=r['get'](D);if(F)return F;const G=new Map();r['set'](D,G);const H=h['graph']['nodes']['get'](D);if(H&&H['origins']['length']>0x0&&!E['has'](D)){E['add'](D);for(const I of H['origins']){if(!I['via']||!I['from']||E['has'](I['from']))continue;const J=t(I['from'],E);for(const [L,M]of J){if(M<(G['get'](L)??Infinity))G['set'](L,M);}const K=(J['get'](I['via'])??0x0)+0x1;if(K<(G['get'](I['via'])??Infinity))G['set'](I['via'],K);}E['delete'](D);}return G;},u=[...o]['filter'](D=>{const E=h['graph']['nodes']['get'](D);return E['kind']==='object'&&(E['state']==='seed'||E['state']==='stub')&&!i['has'](D);}),v=new Set();if(u['length']>0x0){const D=await a['getObjects'](u);if(readStats(a)['batches']>=e['maxRpcs'])h['exhausted']['rpcs']=!![];for(const E of u){const F=h['graph']['nodes']['get'](E),G=lookupMapLower(D,E);i['add'](E);if(!G){F['state']='error',F['error']='not_found_or_failed',h['graph']['gaps']['push'](E);continue;}F['state']='fetched',F['raw']=G,F['objectType']=String(G['type']??F['objectType']??inferObjectType(E)??''),F['coinType']=extractCoinType(G['type_raw']),v['add'](E);}}const w=[];for(const H of v){const I=h['graph']['nodes']['get'](H);if(!I['objectType']||!I['raw'])continue;for(const J of extractObjectEdges(I['objectType'],I['raw'])){const K=EDGE_SCHEMA_BY_ID['get'](J['schemaId']);if(!K||!f['allows'](K,p))continue;w['push']({'schema':K,'sourceId':H,'refs':J['refs'],'observed':J['refs']['length']});}}const x=[...v]['filter'](L=>{const M=h['graph']['nodes']['get'](L);return EDGE_SCHEMAS['some'](N=>N['source']===M['objectType']&&N['read']['kind']==='table');});for(const L of x){const M=h['graph']['nodes']['get'](L),N=EDGE_SCHEMAS['filter'](P=>P['source']===M['objectType']&&P['read']['kind']==='table'&&f['allowsTable'](P,p)),O=new Map();for(const P of N){const Q=P['read']['rowType'],R=O['get'](Q)??[];R['push'](P),O['set'](Q,R);}for(const [S,T]of O){const U=L+'|'+S;if(l['has'](U))continue;l['add'](U);const V=Math['max'](...T['map'](a0=>e['perKindCaps'][a0['id']]??e['maxFanoutPerNode']));let W,X=![];try{const a0=await a['getTable'](L,{'maxItems':V});if(readStats(a)['batches']>=e['maxRpcs'])h['exhausted']['rpcs']=!![];W=a0['items'],X=a0['truncated'];}catch{h['graph']['gaps']['push'](L+'#'+S);continue;}const Y=new Set(T['map'](a1=>a1['id'])),Z=extractTableRefs(S,L,W)['filter'](a1=>{const a2=EDGE_SCHEMA_BY_ID['get'](a1['schemaId']);return a2['read']['kind']==='derived'||Y['has'](a1['schemaId']);});for(const a1 of Z){const a2=EDGE_SCHEMA_BY_ID['get'](a1['schemaId']);let a3=a1['refs'];a2['family']==='M'&&M['coinType']&&(a3=a3['map'](a4=>({...a4,'payload':{'coinType':M['coinType'],...a4['payload']}}))),w['push']({'schema':a2,'sourceId':L,'refs':a3,'observed':a3['length']});}X&&h['markTruncation']({'nodeId':L,'schema':T[0x0]['id'],'observed':W['length'],'limit':V,'reason':'table_page'});}}const y=[...o]['filter'](a4=>{const a5=h['graph']['nodes']['get'](a4);return a5['kind']!=='wfnode'&&(a5['kind']==='eoa'||a5['state']==='fetched');}),z=new Map(),A=new Map();for(const a4 of y){const a5=h['graph']['nodes']['get'](a4);for(const a6 of EDGE_SCHEMAS){if(a6['read']['kind']!=='reverse'||!f['allows'](a6,p))continue;if(!sourceMatches(a6['source'],a5))continue;const a7=a6['read']['parent'],a8=a4+'|'+a7;if(j['has'](a8))continue;if(!z['has'](a7))z['set'](a7,[]);z['get'](a7)['push'](a4);const a9=a4+'|'+a7+'|schema',aa=A['get'](a9)??[];aa['push'](a6),A['set'](a9,aa);}}for(const [ab,ac]of z){for(const ae of ac)j['add'](ae+'|'+ab);let ad=new Map();try{ad=await a['getKeyedFields'](ab,ac);if(readStats(a)['batches']>=e['maxRpcs'])h['exhausted']['rpcs']=!![];}catch{h['graph']['gaps']['push']('reverse:'+ab);continue;}for(const af of ac){const ag=A['get'](af+'|'+ab+'|schema')??[],ah=lookupMapLower(ad,af);if(!ah)continue;const ai=extractReverseRefs(ab,ah['data']??ah);for(const aj of ag){const ak=aj['read'];for(const al of ai){if(al['schemaId']!==REVERSE_GROUP_WILDCARD&&al['schemaId']!==aj['id'])continue;let am=al['refs']['map'](an=>an['to']?an:{...an,'to':af});ak['kind']==='reverse'&&ak['filterType']&&(am=am['filter'](an=>inferObjectType(an['to'])===ak['filterType']));if(am['length']===0x0)continue;w['push']({'schema':aj,'sourceId':af,'refs':am,'observed':am['length']});}}}}for(const an of EDGE_SCHEMAS){const ao=an['read'];if(ao['kind']!=='event'||!f['allowsEvent'](an,p))continue;const ap=[...o]['filter'](ar=>{if(n['has'](ar+'|'+an['id']))return![];return sourceMatches(an['source'],h['graph']['nodes']['get'](ar));});if(ap['length']===0x0)continue;let aq=m['get'](ao['eventType']);if(!aq){aq={'events':[],'truncated':![],'failed':![]};try{const ar=await a['getEvents'](ao['eventType'],{'maxPages':e['maxEventPages']});if(readStats(a)['batches']>=e['maxRpcs'])h['exhausted']['rpcs']=!![];aq['events']=ar['events'],aq['truncated']=ar['truncated'],ar['truncated']&&ar['events']['length']===0x0&&(aq['failed']=!![],h['graph']['gaps']['push']('events:'+ao['eventType']));}catch{aq['failed']=!![],h['graph']['gaps']['push']('events:'+ao['eventType']);}m['set'](ao['eventType'],aq);}if(aq['failed']){for(const as of ap)n['add'](as+'|'+an['id']);continue;}if(aq['truncated']){h['exhausted']['eventPages']=!![];for(const at of ap){h['markTruncation']({'nodeId':at,'schema':an['id'],'observed':aq['events']['length'],'limit':e['maxEventPages'],'reason':'event_pages'});}}for(const au of ap){n['add'](au+'|'+an['id']);const av=extractEventRefs(ao,au,aq['events']);if(av['length']===0x0)continue;w['push']({'schema':an,'sourceId':au,'refs':av,'observed':av['length'],'truncated':aq['truncated']});}}const B=new Set(),C=new Map();for(const aw of w){const ax=e['perKindCaps'][aw['schema']['id']]??e['maxFanoutPerNode'],ay=C['get'](aw['sourceId'])??0x0,az=Math['max'](0x0,e['maxFanoutPerNode']-ay),aA=Math['min'](ax,az),aB=aw['refs']['slice'](0x0,aA);aw['refs']['length']>aA&&h['markTruncation']({'nodeId':aw['sourceId'],'schema':aw['schema']['id'],'observed':aw['refs']['length'],'limit':a96a,'reason':'fanout'});const aC=new Map();for(const aD of aB){const aE=aD['from']??aw['sourceId'],aF=isWfNodeId(aD['to'])?p:p+0x1,aG=h['graph']['nodes']['has'](aD['to']),aH=f['effectiveMaxHops'](aw['schema']);if(aH!==undefined){const aJ=(t(aE,new Set())['get'](aw['schema']['id'])??0x0)+0x1;if(aJ>aH&&!aG){aC['set'](aE,(aC['get'](aE)??0x0)+0x1);continue;}}if(aF>e['maxDepth']&&!aG){h['exhausted']['depth']=!![];continue;}const aI=h['addNode'](aD['to'],Math['min'](aF,e['maxDepth']),{'schema':aw['schema']['id'],'from':aE});if(!aI)break;h['addEdge'](aw['schema'],aE,aD,q,aw['truncated']===!![]||aw['refs']['length']>aA),C['set'](aw['sourceId'],ay+0x1);if(!isWfNodeId(aD['to'])&&aF<=e['maxDepth'])B['add'](aD['to']);}for(const [aK,aL]of aC){h['markTruncation']({'nodeId':aK,'schema':aw['schema']['id'],'observed':aL,'limit':f['effectiveMaxHops'](aw['schema'])??0x0,'reason':'schema_hops'});}}if(h['exhausted']['rpcs']){h['graph']['gaps']['push']('budget:maxRpcs');break;}o=B;}return h['finalize'](a);}function sourceMatches(a,b){if(a==='ANY')return!![];if(a==='EOA')return b['kind']==='eoa';return b['objectType']===a;}function lookupMapLower(a,b){const c=a['get'](b);if(c!==undefined)return c;for(const [d,e]of a)if(d['toLowerCase']()===b)return e;return undefined;}export function orderCompletionInGraph(a,b){const c=a['nodes']['get'](b['toLowerCase']()),d=c?.['raw']?.['data']??c?.['raw']??{},e=String(d['machine']??''),f=String(d['progress']??''),g=a['nodes']['get'](f['toLowerCase']()),h=String((g?.['raw']?.['data']??g?.['raw']??{})['current']??'');let i=null;if(e){const j=e['toLowerCase']()+'::node::',k=a['edges']['filter'](l=>l['schema']==='wf.transition'&&l['from']['startsWith'](j))['map'](l=>({'node':l['payload']?.['node'],'prev_node':l['payload']?.['prevNode']}));if(k['length']>0x0)i=terminalNamesOfEdges(k);}return deriveOrderCompletion({'machine':e||null,'progress':f||null,'currentNode':h||null,'terminalNames':i});}
|
|
1
|
+
import{EDGE_SCHEMAS,EDGE_SCHEMA_BY_ID}from'./edge-schema.js';import{extractCoinType,extractEventRefs,extractObjectEdges,extractReverseRefs,extractTableRefs,inferObjectType,REVERSE_GROUP_WILDCARD}from'./extract.js';import{mergeBudget}from'./dataplane.js';import{deriveOrderCompletion,terminalNamesOfEdges}from'./order-status.js';import{LINKER_RING_LIMIT as a97a}from'./sdk-batch.js';import{wowAddressKind}from'@wowok/wowok';function readStats(a){const b=a;if(b['stats'])return{'batches':b['stats']['batches'],'byChannel':{...b['stats']['byChannel']},'dedupHits':b['stats']['dedupHits']};if(b['batches'])return{'batches':Object['values'](b['batches'])['reduce']((c,d)=>c+d,0x0),'byChannel':{...b['batches']},'dedupHits':b['dedupHits']??0x0};return{'batches':0x0,'byChannel':{'objects':0x0,'keyedFields':0x0,'tables':0x0,'events':0x0},'dedupHits':0x0};}function isEoa(a){return wowAddressKind(a)==='user';}function isWfNodeId(a){return a['includes']('::node::');}class Gate{['wl'];constructor(a){this['wl']=a;}['allows'](a,b){if(this['wl']['deny']?.['includes'](a['id']))return![];const c=this['wl']['familyDepths']?.[a['family']];if(c!==undefined&&b>=c)return![];if(this['wl']['schemas'])return this['wl']['schemas']['includes'](a['id']);if(this['wl']['families']&&!this['wl']['families']['includes'](a['family']))return![];return!![];}['allowsTable'](a,b){if(a['read']['kind']!=='table')return![];if(this['wl']['deny']?.['includes'](a['id']))return![];const c=this['wl']['familyDepths']?.[a['family']];if(c!==undefined&&b>=c)return![];if(this['wl']['families']&&!this['wl']['families']['includes'](a['family']))return![];return!!this['wl']['tableEdges']?.['includes'](a['id']);}['allowsEvent'](a,b){if(a['read']['kind']!=='event')return![];if(this['wl']['deny']?.['includes'](a['id']))return![];const c=this['wl']['familyDepths']?.[a['family']];if(c!==undefined&&b>=c)return![];if(this['wl']['families']&&!this['wl']['families']['includes'](a['family']))return![];return!!this['wl']['eventEdges']?.['includes'](a['id']);}['effectiveMaxHops'](a){const b=a['maxHops'],c=this['wl']['schemaHops']?.[a['id']];if(b===undefined)return c;if(c===undefined)return b;return Math['min'](b,c);}}class GraphBuilder{['graph'];['edgeIds']=new Set();['budget'];['exhausted']={};constructor(a,b,c){this['budget']=c,this['graph']={'network':a,'seed':b,'builtAt':Date['now'](),'nodes':new Map(),'edges':[],'out':new Map(),'inc':new Map(),'gaps':[],'truncations':[],'rpcReport':{'batches':0x0,'byChannel':{'objects':0x0,'keyedFields':0x0,'tables':0x0,'events':0x0},'dedupHits':0x0},'budgetExhausted':{}};}['addSeed'](a){const b=inferObjectType(a),c={'id':a,'kind':isWfNodeId(a)?'wfnode':isEoa(a)?'eoa':'object','objectType':b??undefined,'state':'seed','origins':[],'depth':0x0};return this['graph']['nodes']['set'](a,c),c;}['addNode'](a,b,c){const d=this['graph']['nodes']['get'](a);if(d){if(c)d['origins']['push']({'via':c['schema'],'from':c['from'],'depth':b});return d;}if(this['graph']['nodes']['size']>=this['budget']['maxNodes'])return this['exhausted']['nodes']=!![],undefined;const e=isWfNodeId(a),f=e?undefined:inferObjectType(a),g={'id':a,'kind':e?'wfnode':isEoa(a)?'eoa':'object','objectType':f??undefined,'state':e?'stub':'seed','origins':c?[{'via':c['schema'],'from':c['from'],'depth':b}]:[],'depth':b};return this['graph']['nodes']['set'](a,g),g;}['addEdge'](a,b,c,d,e){const f=c['to'],g=c['key']?'|'+c['key']:'',h=a['id']+'|'+b+'→'+f+g;if(this['edgeIds']['has'](h))return;this['edgeIds']['add'](h);const i={'id':h,'schema':a['id'],'family':a['family'],'from':b,'to':f,'retention':a['retention'],'observedAt':d,'payload':c['payload'],'truncated':e||a['retention']==='bounded_window','key':c['key']};this['graph']['edges']['push'](i),pushMap(this['graph']['out'],b,i),pushMap(this['graph']['inc'],f,i);}['markTruncation'](a){this['graph']['truncations']['push'](a);}['finalize'](a){return this['graph']['rpcReport']=readStats(a),this['graph']['budgetExhausted']=this['exhausted'],this['graph'];}}function pushMap(a,b,c){const d=a['get'](b);if(d)d['push'](c);else a['set'](b,[c]);}export async function expandTopology(a,c){const d=c['seed']['toLowerCase'](),e=mergeBudget(c['budget']),f=new Gate(c['edges']??{}),h=new GraphBuilder(c['network'],d,e);h['addSeed'](d);const i=new Set(),j=new Set(),l=new Set(),m=new Map(),n=new Set();let o=new Set([d]);for(let p=0x0;p<=e['maxDepth'];p++){if(o['size']===0x0)break;if(h['exhausted']['nodes'])break;const q=Date['now'](),r=new Map(),t=(D,E)=>{const F=r['get'](D);if(F)return F;const G=new Map();r['set'](D,G);const H=h['graph']['nodes']['get'](D);if(H&&H['origins']['length']>0x0&&!E['has'](D)){E['add'](D);for(const I of H['origins']){if(!I['via']||!I['from']||E['has'](I['from']))continue;const J=t(I['from'],E);for(const [L,M]of J){if(M<(G['get'](L)??Infinity))G['set'](L,M);}const K=(J['get'](I['via'])??0x0)+0x1;if(K<(G['get'](I['via'])??Infinity))G['set'](I['via'],K);}E['delete'](D);}return G;},u=[...o]['filter'](D=>{const E=h['graph']['nodes']['get'](D);return E['kind']==='object'&&(E['state']==='seed'||E['state']==='stub')&&!i['has'](D);}),v=new Set();if(u['length']>0x0){const D=await a['getObjects'](u);if(readStats(a)['batches']>=e['maxRpcs'])h['exhausted']['rpcs']=!![];for(const E of u){const F=h['graph']['nodes']['get'](E),G=lookupMapLower(D,E);i['add'](E);if(!G){F['state']='error',F['error']='not_found_or_failed',h['graph']['gaps']['push'](E);continue;}F['state']='fetched',F['raw']=G,F['objectType']=String(G['type']??F['objectType']??inferObjectType(E)??''),F['coinType']=extractCoinType(G['type_raw']),v['add'](E);}}const w=[];for(const H of v){const I=h['graph']['nodes']['get'](H);if(!I['objectType']||!I['raw'])continue;for(const J of extractObjectEdges(I['objectType'],I['raw'])){const K=EDGE_SCHEMA_BY_ID['get'](J['schemaId']);if(!K||!f['allows'](K,p))continue;w['push']({'schema':K,'sourceId':H,'refs':J['refs'],'observed':J['refs']['length']});}}const x=[...v]['filter'](L=>{const M=h['graph']['nodes']['get'](L);return EDGE_SCHEMAS['some'](N=>N['source']===M['objectType']&&N['read']['kind']==='table');});for(const L of x){const M=h['graph']['nodes']['get'](L),N=EDGE_SCHEMAS['filter'](P=>P['source']===M['objectType']&&P['read']['kind']==='table'&&f['allowsTable'](P,p)),O=new Map();for(const P of N){const Q=P['read']['rowType'],R=O['get'](Q)??[];R['push'](P),O['set'](Q,R);}for(const [S,T]of O){const U=L+'|'+S;if(l['has'](U))continue;l['add'](U);const V=Math['max'](...T['map'](a0=>e['perKindCaps'][a0['id']]??e['maxFanoutPerNode']));let W,X=![];try{const a0=await a['getTable'](L,{'maxItems':V});if(readStats(a)['batches']>=e['maxRpcs'])h['exhausted']['rpcs']=!![];W=a0['items'],X=a0['truncated'];}catch{h['graph']['gaps']['push'](L+'#'+S);continue;}const Y=new Set(T['map'](a1=>a1['id'])),Z=extractTableRefs(S,L,W)['filter'](a1=>{const a2=EDGE_SCHEMA_BY_ID['get'](a1['schemaId']);return a2['read']['kind']==='derived'||Y['has'](a1['schemaId']);});for(const a1 of Z){const a2=EDGE_SCHEMA_BY_ID['get'](a1['schemaId']);let a3=a1['refs'];a2['family']==='M'&&M['coinType']&&(a3=a3['map'](a4=>({...a4,'payload':{'coinType':M['coinType'],...a4['payload']}}))),w['push']({'schema':a2,'sourceId':L,'refs':a3,'observed':a3['length']});}X&&h['markTruncation']({'nodeId':L,'schema':T[0x0]['id'],'observed':W['length'],'limit':V,'reason':'table_page'});}}const y=[...o]['filter'](a4=>{const a5=h['graph']['nodes']['get'](a4);return a5['kind']!=='wfnode'&&(a5['kind']==='eoa'||a5['state']==='fetched');}),z=new Map(),A=new Map();for(const a4 of y){const a5=h['graph']['nodes']['get'](a4);for(const a6 of EDGE_SCHEMAS){if(a6['read']['kind']!=='reverse'||!f['allows'](a6,p))continue;if(!sourceMatches(a6['source'],a5))continue;const a7=a6['read']['parent'],a8=a4+'|'+a7;if(j['has'](a8))continue;if(!z['has'](a7))z['set'](a7,[]);z['get'](a7)['push'](a4);const a9=a4+'|'+a7+'|schema',aa=A['get'](a9)??[];aa['push'](a6),A['set'](a9,aa);}}for(const [ab,ac]of z){for(const ae of ac)j['add'](ae+'|'+ab);let ad=new Map();try{ad=await a['getKeyedFields'](ab,ac);if(readStats(a)['batches']>=e['maxRpcs'])h['exhausted']['rpcs']=!![];}catch{h['graph']['gaps']['push']('reverse:'+ab);continue;}for(const af of ac){const ag=A['get'](af+'|'+ab+'|schema')??[],ah=lookupMapLower(ad,af);if(!ah)continue;const ai=extractReverseRefs(ab,ah['data']??ah);for(const aj of ag){const ak=aj['read'];for(const al of ai){if(al['schemaId']!==REVERSE_GROUP_WILDCARD&&al['schemaId']!==aj['id'])continue;let am=al['refs']['map'](an=>an['to']?an:{...an,'to':af});ak['kind']==='reverse'&&ak['filterType']&&(am=am['filter'](an=>inferObjectType(an['to'])===ak['filterType']));if(am['length']===0x0)continue;w['push']({'schema':aj,'sourceId':af,'refs':am,'observed':am['length']});}}}}for(const an of EDGE_SCHEMAS){const ao=an['read'];if(ao['kind']!=='event'||!f['allowsEvent'](an,p))continue;const ap=[...o]['filter'](ar=>{if(n['has'](ar+'|'+an['id']))return![];return sourceMatches(an['source'],h['graph']['nodes']['get'](ar));});if(ap['length']===0x0)continue;let aq=m['get'](ao['eventType']);if(!aq){aq={'events':[],'truncated':![],'failed':![]};try{const ar=await a['getEvents'](ao['eventType'],{'maxPages':e['maxEventPages']});if(readStats(a)['batches']>=e['maxRpcs'])h['exhausted']['rpcs']=!![];aq['events']=ar['events'],aq['truncated']=ar['truncated'],ar['truncated']&&ar['events']['length']===0x0&&(aq['failed']=!![],h['graph']['gaps']['push']('events:'+ao['eventType']));}catch{aq['failed']=!![],h['graph']['gaps']['push']('events:'+ao['eventType']);}m['set'](ao['eventType'],aq);}if(aq['failed']){for(const as of ap)n['add'](as+'|'+an['id']);continue;}if(aq['truncated']){h['exhausted']['eventPages']=!![];for(const at of ap){h['markTruncation']({'nodeId':at,'schema':an['id'],'observed':aq['events']['length'],'limit':e['maxEventPages'],'reason':'event_pages'});}}for(const au of ap){n['add'](au+'|'+an['id']);const av=extractEventRefs(ao,au,aq['events']);if(av['length']===0x0)continue;w['push']({'schema':an,'sourceId':au,'refs':av,'observed':av['length'],'truncated':aq['truncated']});}}const B=new Set(),C=new Map();for(const aw of w){const ax=e['perKindCaps'][aw['schema']['id']]??e['maxFanoutPerNode'],ay=C['get'](aw['sourceId'])??0x0,az=Math['max'](0x0,e['maxFanoutPerNode']-ay),aA=Math['min'](ax,az),aB=aw['refs']['slice'](0x0,aA);aw['refs']['length']>aA&&h['markTruncation']({'nodeId':aw['sourceId'],'schema':aw['schema']['id'],'observed':aw['refs']['length'],'limit':a97a,'reason':'fanout'});const aC=new Map();for(const aD of aB){const aE=aD['from']??aw['sourceId'],aF=isWfNodeId(aD['to'])?p:p+0x1,aG=h['graph']['nodes']['has'](aD['to']),aH=f['effectiveMaxHops'](aw['schema']);if(aH!==undefined){const aJ=(t(aE,new Set())['get'](aw['schema']['id'])??0x0)+0x1;if(aJ>aH&&!aG){aC['set'](aE,(aC['get'](aE)??0x0)+0x1);continue;}}if(aF>e['maxDepth']&&!aG){h['exhausted']['depth']=!![];continue;}const aI=h['addNode'](aD['to'],Math['min'](aF,e['maxDepth']),{'schema':aw['schema']['id'],'from':aE});if(!aI)break;h['addEdge'](aw['schema'],aE,aD,q,aw['truncated']===!![]||aw['refs']['length']>aA),C['set'](aw['sourceId'],ay+0x1);if(!isWfNodeId(aD['to'])&&aF<=e['maxDepth'])B['add'](aD['to']);}for(const [aK,aL]of aC){h['markTruncation']({'nodeId':aK,'schema':aw['schema']['id'],'observed':aL,'limit':f['effectiveMaxHops'](aw['schema'])??0x0,'reason':'schema_hops'});}}if(h['exhausted']['rpcs']){h['graph']['gaps']['push']('budget:maxRpcs');break;}o=B;}return h['finalize'](a);}function sourceMatches(a,b){if(a==='ANY')return!![];if(a==='EOA')return b['kind']==='eoa';return b['objectType']===a;}function lookupMapLower(a,b){const c=a['get'](b);if(c!==undefined)return c;for(const [d,e]of a)if(d['toLowerCase']()===b)return e;return undefined;}export function orderCompletionInGraph(a,b){const c=a['nodes']['get'](b['toLowerCase']()),d=c?.['raw']?.['data']??c?.['raw']??{},e=String(d['machine']??''),f=String(d['progress']??''),g=a['nodes']['get'](f['toLowerCase']()),h=String((g?.['raw']?.['data']??g?.['raw']??{})['current']??'');let i=null;if(e){const j=e['toLowerCase']()+'::node::',k=a['edges']['filter'](l=>l['schema']==='wf.transition'&&l['from']['startsWith'](j))['map'](l=>({'node':l['payload']?.['node'],'prev_node':l['payload']?.['prevNode']}));if(k['length']>0x0)i=terminalNamesOfEdges(k);}return deriveOrderCompletion({'machine':e||null,'progress':f||null,'currentNode':h||null,'terminalNames':i});}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{applyExposureGate as
|
|
1
|
+
import{applyExposureGate as a100a}from'../../config/exposure.js';export{resolveViability,factRef,parseFactRef}from'../../config/exposure.js';export const EXPOSURE_ROLES={'buyer':'buyer','merchant':'merchant','supplier':'supplier','collaborator':'collaborator','arbitrator':'arbitrator','system':'system','neutral':'neutral'};export function applyExposureGate(a,b){return a100a(a,b);}export function lossParty(a,b){return{'role':a,'basis':b};}export function gainPath(a,b,c,d){return{'role':a,'path':b,'viability':c,'gate':d};}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{RETENTION_RANK,pathConfidence,findingWhere}from'./analyze.js';import{orderCompletionInGraph}from'./expand.js';import{profileOf}from'./viewport.js';const STATE_RANK={'present':0x0,'empty':0x1,'gap':0x2};function worstState(c,d){return STATE_RANK[c]>=STATE_RANK[d]?c:d;}export const COVERAGE_VOCABULARY={'present':'present\x20—\x20evidence\x20retrieved\x20and\x20non-empty;\x20real\x20material\x20the\x20rules\x20can\x20score.','empty':'empty\x20—\x20the\x20read\x20completed\x20and\x20verified\x20the\x20absence\x20of\x20data\x20(e.g.\x20no\x20review\x20votes);\x20an\x20answered\x20fact\x20the\x20rules\x20may\x20score,\x20never\x20a\x20fetch\x20failure.','gap':'gap\x20—\x20the\x20evidence\x20was\x20not\x20retrieved,\x20errored,\x20or\x20was\x20truncated;\x20it\x20is\x20unverifiable,\x20so\x20it\x20is\x20excluded\x20from\x20scoring\x20and\x20listed\x20in\x20unverified,\x20never\x20defaulted\x20to\x20a\x20low\x20score.','unverified':'unverified\x20—\x20rule\x20ids\x20excluded\x20from\x20the\x20score\x20because\x20their\x20evidence\x20is\x20gap-state;\x20missing\x20here\x20means\x20every\x20rule\x20was\x20scored\x20on\x20fetched\x20facts.','completeness':'completeness\x20—\x20percentage\x20of\x20required\x20evidence\x20slots\x20that\x20carry\x20material\x20(present);\x20verified-empty\x20slots\x20lower\x20it\x20but\x20stay\x20fully\x20scoreable.'};const REQUIRED_SLOTS=[{'slot':'service_snapshot','label':'Service\x20snapshot','gloss':'The\x20service\x27s\x20own\x20on-chain\x20record\x20(publish/pause\x20status,\x20price,\x20fund\x20and\x20bindings),\x20fetched\x20directly\x20from\x20chain.'},{'slot':'arbitration','label':'Arbitration\x20binding','gloss':'Dispute-resolution\x20services\x20bound\x20to\x20this\x20shop\x20—\x20whether\x20one\x20exists,\x20carries\x20a\x20voter\x20roster,\x20has\x20a\x20funded\x20fee,\x20and\x20is\x20not\x20paused.'},{'slot':'reviews','label':'Review\x20votes','gloss':'On-chain\x20like/dislike\x20votes\x20left\x20by\x20completed-order\x20counterparties;\x20an\x20empty\x20window\x20means\x20nobody\x20voted\x20yet,\x20not\x20a\x20bad\x20rating.'},{'slot':'fulfillment_orders','label':'Recent\x20orders','gloss':'Orders\x20in\x20the\x20shop\x27s\x20recent\x20order\x20window\x20with\x20completion\x20and\x20refund\x20outcomes,\x20used\x20to\x20measure\x20real\x20fulfillment.'},{'slot':'fulfillment_workflow','label':'Fulfillment\x20workflow','gloss':'The\x20bound\x20machine\x27s\x20nodes\x20and\x20forwards\x20that\x20every\x20paid\x20order\x20must\x20progress\x20through\x20to\x20reach\x20completion\x20or\x20refund.'},{'slot':'fund_safety','label':'Compensation\x20fund\x20vs\x20exposure','gloss':'The\x20merchant\x27s\x20compensation\x20fund\x20balance\x20measured\x20against\x20recent\x20order\x20volume\x20(the\x20safety\x20buffer\x20for\x20payouts).'},{'slot':'transparency','label':'Transparency\x20profile','gloss':'The\x20shop\x27s\x20public\x20on-chain\x20profile\x20—\x20description\x20and\x20publish/pause\x20flags\x20a\x20buyer\x20can\x20verify\x20before\x20paying.'}],SLOT_FACTS={'service_snapshot':[],'arbitration':['arbitration.binding'],'reviews':['reviews.votes'],'fulfillment_orders':['fulfillment.orders'],'fulfillment_workflow':['fulfillment.workflow'],'fund_safety':['fund.compensation','fund.exposure'],'transparency':['transparency.profile']},RISK_RULE_SOURCES={'risk_workflow':{'slots':['fulfillment_workflow'],'ruleIds':['R4']},'risk_fund':{'slots':['fund_safety','fulfillment_orders'],'ruleIds':['R2','R7','AC3','AC4']},'risk_trust':{'slots':['arbitration','transparency'],'ruleIds':['R1','R3','R6']},'risk_behavior':{'slots':['fulfillment_orders'],'ruleIds':['AC1','AC2']}};function nodeData(a,b){const c=a['graph']['nodes']['get'](b['toLowerCase']()),e=c?.['raw'],f=e?.['data']??e;return f&&typeof f==='object'?f:undefined;}function isFetched(a,b){const c=a['graph']['nodes']['get'](b['toLowerCase']());return!!c&&a['visibleNodes']['has'](c['id'])&&!!c['raw']&&c['state']!=='error'&&c['state']!=='stub';}function truncationOf(a,b,c){const d=a['graph']['truncations']['find'](e=>e['nodeId']===b&&e['schema']===c);return d?{'observed':d['observed'],'limit':d['limit']}:undefined;}function outEdges(a,b,c){return a['visibleEdges']['filter'](d=>d['from']===b['toLowerCase']()&&d['schema']===c);}function incEdges(a,b,c){return a['visibleEdges']['filter'](d=>d['to']===b['toLowerCase']()&&d['schema']===c);}function toBigInt(a){if(a==null)return 0x0n;try{return BigInt(typeof a==='number'?Math['trunc'](a):String(a));}catch{return 0x0n;}}function flag(a){return a===!![]||a===0x1||a==='1';}function snapProvenance(a){return{'path':a,'retention':'complete','confidence':'exact'};}function edgeProvenance(a,b,c){const {confidence:d,window:e}=pathConfidence(a,c),f=c['reduce']((g,h)=>RETENTION_RANK[h['retention']]>RETENTION_RANK[g]?h['retention']:g,'complete');return{'path':b,'retention':f,'confidence':d,...e?{'window':e}:{}};}export function projectEvaluationFacts(a,b,c){const f=b['toLowerCase'](),g=[],h=new Map(),i=new Map(),j=(U,V,W='exact')=>{h['set'](U,V),i['set'](U,W);},k=a['graph']['nodes']['get'](f),l=a['visibleNodes']['has'](f),m=!!(l&&k&&k['raw']&&k['state']!=='error'&&k['state']!=='stub'&&k['objectType']==='Service'),o=m?nodeData(a,f)??{}:{},q=k?.['coinType'];j('service_snapshot',m?'present':'gap');const r=Array['isArray'](o['arbitrations'])?o['arbitrations']['map'](String)['filter'](Boolean):[],u=outEdges(a,f,'service.arbitration'),w=[];let x=!![];for(const U of r){if(!isFetched(a,U)){x=![];continue;}const V=nodeData(a,U)??{},W=Array['isArray'](V['voting_guard'])?V['voting_guard']:[];w['push']({'id':U['toLowerCase'](),'paused':flag(V['bPaused']),'fee':toBigInt(V['fee'])['toString'](),'votingGuards':W['length'],'usageGuard':typeof V['usage_guard']==='string'&&V['usage_guard']!==''});}if(!m)j('arbitration','gap'),g['push']({'dimension':'arbitration','key':'arbitration.binding','state':'gap','provenance':snapProvenance([f]),'evidence':'Arbitration\x20configuration\x20unverifiable:\x20the\x20service\x20snapshot\x20is\x20missing.'});else{if(r['length']===0x0)j('arbitration','empty'),g['push']({'dimension':'arbitration','key':'arbitration.binding','state':'empty','value':[],'provenance':snapProvenance([f,'Service.arbitrations']),'evidence':'Service\x20snapshot\x20shows\x20no\x20arbitration\x20service\x20configured\x20(verified\x20absence).'});else!x?(j('arbitration','gap'),g['push']({'dimension':'arbitration','key':'arbitration.binding','state':'gap','value':w,'provenance':u['length']>0x0?edgeProvenance(a,[f,'service.arbitration'],u):snapProvenance([f,'Service.arbitrations']),'evidence':w['length']+'/'+r['length']+'\x20arbitration\x20service(s)\x20resolved;\x20the\x20rest\x20failed\x20to\x20fetch.'})):(j('arbitration','present',u['length']>0x0?edgeProvenance(a,[f,'service.arbitration'],u)['confidence']:'exact'),g['push']({'dimension':'arbitration','key':'arbitration.binding','state':'present','value':w,'provenance':u['length']>0x0?edgeProvenance(a,[f,'service.arbitration'],u):snapProvenance([f,'Service.arbitrations']),'evidence':w['length']+'\x20arbitration\x20service(s)\x20resolved\x20from\x20the\x20snapshot\x20with\x20voting\x20rosters.'}));}const y=outEdges(a,f,'target.vote'),z=truncationOf(a,f,'target.vote'),A={'total':y['length'],'like':0x0,'dislike':0x0,'favor':0x0};for(const X of y){const Y=typeof X['payload']?.['voteBits']==='number'?X['payload']['voteBits']:0x0;if(Y&0x2)A['like']+=0x1;if(Y&0x4)A['dislike']+=0x1;if(Y&0x8)A['favor']+=0x1;}const B=y['length']>0x0?edgeProvenance(a,[f,'target.vote'],y):snapProvenance([f,'registrar.votes']);if(!m)j('reviews','gap'),g['push']({'dimension':'reviews','key':'reviews.votes','state':'gap','provenance':snapProvenance([f]),'evidence':'Reputation\x20unverifiable:\x20the\x20service\x20snapshot\x20is\x20missing.'});else{if(z)j('reviews','gap',B['confidence']),g['push']({'dimension':'reviews','key':'reviews.votes','state':'gap','value':A,'provenance':{...B,'window':z},'evidence':'Vote\x20window\x20truncated\x20at\x20'+z['limit']+';\x20'+A['total']+'\x20vote(s)\x20visible\x20—\x20counts\x20are\x20a\x20floor.'});else A['total']===0x0?(j('reviews','empty'),g['push']({'dimension':'reviews','key':'reviews.votes','state':'empty','value':A,'provenance':B,'evidence':'No\x20registrar\x20votes\x20recorded\x20for\x20the\x20service\x20(window\x20read\x20empty,\x20no\x20truncation).'})):(j('reviews','present',B['confidence']),g['push']({'dimension':'reviews','key':'reviews.votes','state':'present','value':A,'provenance':B,'evidence':A['total']+'\x20registrar\x20vote(s):\x20'+A['like']+'\x20like,\x20'+A['dislike']+'\x20dislike,\x20'+A['favor']+'\x20favor.'}));}const C=outEdges(a,f,'service.order'),D=truncationOf(a,f,'service.order'),E={'observed':C['length'],'completed':0x0,'inProgress':0x0,'unknown':0x0,'windowedAmount':'0'};let F=0x0n;for(const Z of C){const a0=orderCompletionInGraph(a['graph'],Z['to'])['status'];if(a0==='completed')E['completed']+=0x1;else{if(a0==='in_progress')E['inProgress']+=0x1;else E['unknown']+=0x1;}F+=toBigInt(nodeData(a,Z['to'])?.['amount']);}E['windowedAmount']=F['toString']();const G=C['length']>0x0?edgeProvenance(a,[f,'service.order','Order'],C):snapProvenance([f,'service.order']);let H;if(!m)H='gap';else{if(D)H='gap';else H=C['length']===0x0?'empty':'present';}j('fulfillment_orders',H,G['confidence']);if(H==='gap'&&m)g['push']({'dimension':'fulfillment','key':'fulfillment.orders','state':'gap','value':E,'provenance':{...G,'window':D},'evidence':'Order\x20window\x20truncated\x20at\x20'+D?.['limit']+'\x20(observed\x20'+D?.['observed']+');\x20'+E['observed']+'\x20order(s)\x20visible\x20—\x20completion\x20stats\x20are\x20a\x20partial\x20floor.'});else{if(H==='empty')g['push']({'dimension':'fulfillment','key':'fulfillment.orders','state':'empty','value':E,'provenance':G,'evidence':'No\x20orders\x20in\x20the\x20service\x20window\x20(verified\x20absence).'});else H==='present'?g['push']({'dimension':'fulfillment','key':'fulfillment.orders','state':'present','value':E,'provenance':G,'evidence':E['observed']+'\x20recent\x20order(s):\x20'+E['completed']+'\x20completed,\x20'+E['inProgress']+'\x20in\x20progress,\x20'+E['unknown']+'\x20unresolved.'}):g['push']({'dimension':'fulfillment','key':'fulfillment.orders','state':'gap','provenance':snapProvenance([f]),'evidence':'Order\x20window\x20unverifiable:\x20the\x20service\x20snapshot\x20is\x20missing.'});}const I=typeof o['machine']==='string'?o['machine']:'',J=I!==''&&isFetched(a,I),K=I===''?'':I['toLowerCase']()+'::node::',L=K===''?[]:a['graph']['edges']['filter'](a1=>a1['schema']==='wf.transition'&&a1['from']['startsWith'](K)),M=new Set();for(const a1 of L){M['add'](a1['from']);const a2=String(a1['payload']?.['node']??'');if(a2!=='')M['add'](''+K+a2);}let N,O;if(!m)N='gap',O='Workflow\x20unverifiable:\x20the\x20service\x20snapshot\x20is\x20missing.';else{if(I==='')N='empty',O='No\x20workflow\x20template\x20configured\x20(verified\x20absence).';else{if(!J)N='gap',O='Machine\x20template\x20referenced\x20but\x20not\x20fetched\x20(fetch\x20gap).';else L['length']===0x0?(N='gap',O='Machine\x20fetched\x20but\x20no\x20wf.transition\x20edges\x20—\x20terminal\x20set\x20unverifiable;\x20completion\x20states\x20stay\x20unknown.'):(N='present',O='Machine\x20template\x20resolved\x20with\x20'+M['size']+'\x20workflow\x20node(s);\x20terminal\x20set\x20verifiable.');}}j('fulfillment_workflow',N,N==='present'?'exact':N==='empty'?'exact':'windowed'),g['push']({'dimension':'fulfillment','key':'fulfillment.workflow','state':N,...I!==''&&J?{'value':{'machine':I['toLowerCase'](),'nodes':M['size']}}:{},'provenance':N==='present'?edgeProvenance(a,[f,'service.machine','wf.transition'],L):snapProvenance([f,'Service.machine']),'evidence':O});const P=toBigInt(o['compensation_fund']);if(!m)j('fund_safety','gap'),g['push']({'dimension':'fund_safety','key':'fund.compensation','state':'gap','provenance':snapProvenance([f]),'evidence':'Fund\x20backing\x20unverifiable:\x20the\x20service\x20snapshot\x20is\x20missing.'}),g['push']({'dimension':'fund_safety','key':'fund.exposure','state':'gap','provenance':snapProvenance([f]),'evidence':'Payout\x20exposure\x20unverifiable:\x20the\x20service\x20snapshot\x20is\x20missing.'});else{j('fund_safety','present'),g['push']({'dimension':'fund_safety','key':'fund.compensation','state':'present','value':{'fund':P['toString'](),...q?{'coinType':q}:{}},'provenance':snapProvenance([f,'Service.compensation_fund']),'evidence':'Compensation\x20fund\x20'+P['toString']()+'\x20base\x20units'+(q?'\x20in\x20'+q:'')+'.'});const a3=F*0x3n,a4=worstState('present',H),a5=c['find'](a6=>a6['id']==='R2:'+f);g['push']({'dimension':'fund_safety','key':'fund.exposure','state':a4,'value':{'fund':P['toString'](),'windowedCount':E['observed'],'windowedAmount':F['toString'](),'neededCeiling':a3['toString'](),'coverageMet':P>=a3},'provenance':C['length']>0x0?edgeProvenance(a,[f,'service.order','Order.amount','Service.compensation_fund'],C):snapProvenance([f,'Service.compensation_fund']),'findingIds':a5?[a5['id']]:undefined,'evidence':H==='empty'?'No\x20recent\x20orders;\x20no\x20payout\x20exposure\x20to\x20cover.':'Recent\x20orders\x20total\x20'+F['toString']()+'\x20base\x20units'+(q?'\x20in\x20'+q:'')+'\x20across\x20'+E['observed']+'\x20order(s);\x20the\x20compensation\x20fund\x20should\x20cover\x20at\x20least\x203x\x20that\x20('+a3['toString']()+'\x20base\x20units'+(q?'\x20in\x20'+q:'')+')\x20—\x20coverage\x20'+(P>=a3?'met':'not\x20met')+(D?'\x20(older\x20orders\x20outside\x20the\x20fetch\x20window,\x20floor\x20value\x20only)':'')+'.'});}if(!m)j('transparency','gap'),g['push']({'dimension':'transparency','key':'transparency.profile','state':'gap','provenance':snapProvenance([f]),'evidence':'Transparency\x20unverifiable:\x20the\x20service\x20snapshot\x20is\x20missing.'});else{const a6=typeof o['setting_lock_duration']==='number'?o['setting_lock_duration']:Number(toBigInt(o['setting_lock_duration'])),a7=flag(o['bPublished']);j('transparency','present'),g['push']({'dimension':'transparency','key':'transparency.profile','state':'present','value':{'description':typeof o['description']==='string'?o['description']:'','location':typeof o['location']==='string'?o['location']:'','settingLockDuration':Number['isFinite'](a6)?a6:0x0,'published':a7,'paused':flag(o['bPaused'])},'provenance':snapProvenance([f,'Service.bPublished','Service.setting_lock_duration']),'findingIds':c['some'](a8=>a8['id']==='R6:'+f)?['R6:'+f]:undefined,'evidence':'Service\x20profile:\x20description\x20'+(typeof o['description']==='string'&&o['description']!==''?'provided':'not\x20provided')+',\x20location\x20'+(typeof o['location']==='string'&&o['location']!==''?'provided':'not\x20provided')+',\x20service\x20lock\x20'+a6+'\x20ms,\x20'+(a7?'published':'unpublished')+'.'});}for(const a8 of['risk_workflow','risk_fund','risk_trust','risk_behavior']){const a9=RISK_RULE_SOURCES[a8];let aa='present',ab,ac=-0x1;for(const aj of a9['slots']){const ak=h['get'](aj)??'gap';STATE_RANK[ak]>ac&&(ac=STATE_RANK[ak],aa=ak,ab=aj);}let ae;if(aa==='gap')ae='windowed';else{if(aa==='empty')ae='bounded';else ae=ab&&i['get'](ab)||'exact';}const af=f['toLowerCase'](),ag=new Set([af,...[...a['graph']['nodes']['keys']()]['map'](al=>al['toLowerCase']())]),ah=(al,am)=>{if(!al['startsWith'](am+':'))return![];const an=al['slice'](am['length']+0x1)['toLowerCase'](),ao=an['split']('#')[0x0]['split']('|')[0x0];return ao['split'](':')['some'](ap=>ap['length']===0x0||ag['has'](ap));},ai=c['filter'](al=>a9['ruleIds']['some'](am=>ah(al['id'],am)));g['push']({'dimension':a8,'key':a8+'.findings','state':aa,'value':{'findings':ai['map'](al=>({'id':al['id'],'severity':al['severity'],'title':al['title']})),'where':ai['map'](al=>findingWhere(al))},'provenance':{'path':[f,...a9['slots']],'retention':'derived','confidence':ae},'findingIds':ai['map'](al=>al['id']),'evidence':aa==='gap'?'Input\x20evidence\x20has\x20fetch\x20gaps;\x20the\x20risk\x20conclusion\x20is\x20unverifiable.':aa==='empty'?'Input\x20evidence\x20is\x20configured-empty;\x20the\x20risk\x20rules\x20are\x20not\x20applicable.':ai['length']>0x0?ai['length']+'\x20structural\x20risk\x20finding(s)\x20on\x20this\x20object,\x20from\x20the\x20analyzer\x20registry.':'No\x20risk\x20fired\x20on\x20this\x20object;\x20input\x20evidence\x20slots\x20are\x20fully\x20materialized.'});}const Q=[];for(const al of a['visibleNodes']){const am=profileOf(a,al);if(!am)continue;const an=Array['isArray'](am['profileRecords'])?am['profileRecords']:undefined;Q['push']({'nodeId':al,...typeof am['registeredAt']==='number'?{'registeredAt':am['registeredAt']}:{},'hasDescription':!!am['hasDescription']||typeof am['description']==='string','recordCount':typeof am['recordCount']==='number'?am['recordCount']:an?.['length']??0x0,...typeof am['description']==='string'?{'description':am['description']}:{},...an?{'profileRecords':an}:{}});}const R=REQUIRED_SLOTS['length'],S=REQUIRED_SLOTS['filter'](({slot:ao})=>h['get'](ao)==='present')['length'],T=R===0x0?0x64:Math['round'](S/R*0x64);return{'target':f,'role':String(a['role']),'facts':g,'slots':REQUIRED_SLOTS['map'](({slot:ao,label:ap,gloss:aq})=>({'slot':ao,'label':ap,'gloss':aq,'required':!![],'state':h['get'](ao)??'gap','facts':[...SLOT_FACTS[ao]??[]]})),'completeness':T,'profiles':Q};}
|
|
1
|
+
import{RETENTION_RANK,pathConfidence,findingWhere}from'./analyze.js';import{orderCompletionInGraph}from'./expand.js';import{profileOf}from'./viewport.js';const STATE_RANK={'present':0x0,'empty':0x1,'gap':0x2};function worstState(c,d){return STATE_RANK[c]>=STATE_RANK[d]?c:d;}export const COVERAGE_VOCABULARY={'present':'present\x20—\x20evidence\x20retrieved\x20and\x20non-empty;\x20real\x20material\x20the\x20rules\x20can\x20score.','empty':'empty\x20—\x20the\x20read\x20completed\x20and\x20verified\x20the\x20absence\x20of\x20data\x20(e.g.\x20no\x20review\x20votes);\x20an\x20answered\x20fact\x20the\x20rules\x20may\x20score,\x20never\x20a\x20fetch\x20failure.','gap':'gap\x20—\x20the\x20evidence\x20was\x20not\x20retrieved,\x20errored,\x20or\x20was\x20truncated;\x20it\x20is\x20unverifiable,\x20so\x20it\x20is\x20excluded\x20from\x20scoring\x20and\x20listed\x20in\x20unverified,\x20never\x20defaulted\x20to\x20a\x20low\x20score.','unverified':'unverified\x20—\x20rule\x20ids\x20excluded\x20from\x20the\x20score\x20because\x20their\x20evidence\x20is\x20gap-state;\x20missing\x20here\x20means\x20every\x20rule\x20was\x20scored\x20on\x20fetched\x20facts.','completeness':'completeness\x20—\x20percentage\x20of\x20required\x20evidence\x20slots\x20that\x20carry\x20material\x20(present);\x20verified-empty\x20slots\x20lower\x20it\x20but\x20stay\x20fully\x20scoreable.'};const REQUIRED_SLOTS=[{'slot':'service_snapshot','label':'Service\x20snapshot','gloss':'The\x20service\x27s\x20own\x20on-chain\x20record\x20(publish/pause\x20status,\x20price,\x20fund\x20and\x20bindings),\x20fetched\x20directly\x20from\x20chain.'},{'slot':'arbitration','label':'Arbitration\x20binding','gloss':'Dispute-resolution\x20services\x20bound\x20to\x20this\x20shop\x20—\x20whether\x20one\x20exists,\x20carries\x20a\x20voter\x20roster,\x20has\x20a\x20funded\x20fee,\x20and\x20is\x20not\x20paused.'},{'slot':'reviews','label':'Review\x20votes','gloss':'On-chain\x20like/dislike\x20votes\x20left\x20by\x20completed-order\x20counterparties;\x20an\x20empty\x20window\x20means\x20nobody\x20voted\x20yet,\x20not\x20a\x20bad\x20rating.'},{'slot':'fulfillment_orders','label':'Recent\x20orders','gloss':'Orders\x20in\x20the\x20shop\x27s\x20recent\x20order\x20window\x20with\x20completion\x20and\x20refund\x20outcomes,\x20used\x20to\x20measure\x20real\x20fulfillment.'},{'slot':'fulfillment_workflow','label':'Fulfillment\x20workflow','gloss':'The\x20bound\x20machine\x27s\x20nodes\x20and\x20forwards\x20that\x20every\x20paid\x20order\x20must\x20progress\x20through\x20to\x20reach\x20completion\x20or\x20refund.'},{'slot':'fund_safety','label':'Compensation\x20fund\x20vs\x20exposure','gloss':'The\x20merchant\x27s\x20compensation\x20fund\x20balance\x20measured\x20against\x20recent\x20order\x20volume\x20(the\x20safety\x20buffer\x20for\x20payouts).'},{'slot':'transparency','label':'Transparency\x20profile','gloss':'The\x20shop\x27s\x20public\x20on-chain\x20profile\x20—\x20description\x20and\x20publish/pause\x20flags\x20a\x20buyer\x20can\x20verify\x20before\x20paying.'}],SLOT_FACTS={'service_snapshot':[],'arbitration':['arbitration.binding'],'reviews':['reviews.votes'],'fulfillment_orders':['fulfillment.orders'],'fulfillment_workflow':['fulfillment.workflow'],'fund_safety':['fund.compensation','fund.exposure'],'transparency':['transparency.profile']},RISK_RULE_SOURCES={'risk_workflow':{'slots':['fulfillment_workflow'],'ruleIds':['R4']},'risk_fund':{'slots':['fund_safety','fulfillment_orders'],'ruleIds':['R2','R7','AC3','AC4']},'risk_trust':{'slots':['arbitration','transparency'],'ruleIds':['R1','R3','R6']},'risk_behavior':{'slots':['fulfillment_orders'],'ruleIds':['AC1','AC2']}};function nodeData(a,b){const c=a['graph']['nodes']['get'](b['toLowerCase']()),e=c?.['raw'],f=e?.['data']??e;return f&&typeof f==='object'?f:undefined;}function isFetched(a,b){const c=a['graph']['nodes']['get'](b['toLowerCase']());return!!c&&a['visibleNodes']['has'](c['id'])&&!!c['raw']&&c['state']!=='error'&&c['state']!=='stub';}function truncationOf(a,b,c){const d=a['graph']['truncations']['find'](e=>e['nodeId']===b&&e['schema']===c);return d?{'observed':d['observed'],'limit':d['limit']}:undefined;}function outEdges(a,b,c){return a['visibleEdges']['filter'](d=>d['from']===b['toLowerCase']()&&d['schema']===c);}function incEdges(a,b,c){return a['visibleEdges']['filter'](d=>d['to']===b['toLowerCase']()&&d['schema']===c);}function toBigInt(a){if(a==null)return 0x0n;try{return BigInt(typeof a==='number'?Math['trunc'](a):String(a));}catch{return 0x0n;}}function flag(a){return a===!![]||a===0x1||a==='1';}function snapProvenance(a){return{'path':a,'retention':'complete','confidence':'exact'};}function edgeProvenance(a,b,c){const {confidence:d,window:e}=pathConfidence(a,c),f=c['reduce']((g,h)=>RETENTION_RANK[h['retention']]>RETENTION_RANK[g]?h['retention']:g,'complete');return{'path':b,'retention':f,'confidence':d,...e?{'window':e}:{}};}export function projectEvaluationFacts(a,b,c){const f=b['toLowerCase'](),g=[],h=new Map(),i=new Map(),j=(U,V,W='exact')=>{h['set'](U,V),i['set'](U,W);},k=a['graph']['nodes']['get'](f),l=a['visibleNodes']['has'](f),m=!!(l&&k&&k['raw']&&k['state']!=='error'&&k['state']!=='stub'&&k['objectType']==='Service'),o=m?nodeData(a,f)??{}:{},q=k?.['coinType'];j('service_snapshot',m?'present':'gap');const r=Array['isArray'](o['arbitrations'])?o['arbitrations']['map'](String)['filter'](Boolean):[],u=outEdges(a,f,'service.arbitration'),w=[];let x=!![];for(const U of r){if(!isFetched(a,U)){x=![];continue;}const V=nodeData(a,U)??{},W=Array['isArray'](V['voting_guard'])?V['voting_guard']:[];w['push']({'id':U['toLowerCase'](),'paused':flag(V['bPaused']),'fee':toBigInt(V['fee'])['toString'](),'votingGuards':W['length'],'usageGuard':typeof V['usage_guard']==='string'&&V['usage_guard']!==''});}if(!m)j('arbitration','gap'),g['push']({'dimension':'arbitration','key':'arbitration.binding','state':'gap','provenance':snapProvenance([f]),'evidence':'Arbitration\x20configuration\x20unverifiable:\x20the\x20service\x20snapshot\x20is\x20missing.'});else{if(r['length']===0x0)j('arbitration','empty'),g['push']({'dimension':'arbitration','key':'arbitration.binding','state':'empty','value':[],'provenance':snapProvenance([f,'Service.arbitrations']),'evidence':'Service\x20snapshot\x20shows\x20no\x20arbitration\x20service\x20configured\x20(verified\x20absence).'});else!x?(j('arbitration','gap'),g['push']({'dimension':'arbitration','key':'arbitration.binding','state':'gap','value':w,'provenance':u['length']>0x0?edgeProvenance(a,[f,'service.arbitration'],u):snapProvenance([f,'Service.arbitrations']),'evidence':w['length']+'/'+r['length']+'\x20arbitration\x20service(s)\x20resolved;\x20the\x20rest\x20failed\x20to\x20fetch.'})):(j('arbitration','present',u['length']>0x0?edgeProvenance(a,[f,'service.arbitration'],u)['confidence']:'exact'),g['push']({'dimension':'arbitration','key':'arbitration.binding','state':'present','value':w,'provenance':u['length']>0x0?edgeProvenance(a,[f,'service.arbitration'],u):snapProvenance([f,'Service.arbitrations']),'evidence':w['length']+'\x20arbitration\x20service(s)\x20resolved\x20from\x20the\x20snapshot\x20with\x20voting\x20rosters.'}));}const y=outEdges(a,f,'target.vote'),z=truncationOf(a,f,'target.vote'),A={'total':y['length'],'like':0x0,'dislike':0x0,'favor':0x0};for(const X of y){const Y=typeof X['payload']?.['voteBits']==='number'?X['payload']['voteBits']:0x0;if(Y&0x2)A['like']+=0x1;if(Y&0x4)A['dislike']+=0x1;if(Y&0x8)A['favor']+=0x1;}const B=y['length']>0x0?edgeProvenance(a,[f,'target.vote'],y):snapProvenance([f,'registrar.votes']);if(!m)j('reviews','gap'),g['push']({'dimension':'reviews','key':'reviews.votes','state':'gap','provenance':snapProvenance([f]),'evidence':'Reputation\x20unverifiable:\x20the\x20service\x20snapshot\x20is\x20missing.'});else{if(z)j('reviews','gap',B['confidence']),g['push']({'dimension':'reviews','key':'reviews.votes','state':'gap','value':A,'provenance':{...B,'window':z},'evidence':'Vote\x20window\x20truncated\x20at\x20'+z['limit']+';\x20'+A['total']+'\x20vote(s)\x20visible\x20—\x20counts\x20are\x20a\x20floor.'});else A['total']===0x0?(j('reviews','empty'),g['push']({'dimension':'reviews','key':'reviews.votes','state':'empty','value':A,'provenance':B,'evidence':'No\x20registrar\x20votes\x20recorded\x20for\x20the\x20service\x20(window\x20read\x20empty,\x20no\x20truncation).'})):(j('reviews','present',B['confidence']),g['push']({'dimension':'reviews','key':'reviews.votes','state':'present','value':A,'provenance':B,'evidence':A['total']+'\x20registrar\x20vote(s):\x20'+A['like']+'\x20like,\x20'+A['dislike']+'\x20dislike,\x20'+A['favor']+'\x20favor.'}));}const C=outEdges(a,f,'service.order'),D=truncationOf(a,f,'service.order'),E={'observed':C['length'],'completed':0x0,'inProgress':0x0,'unknown':0x0,'windowedAmount':'0'};let F=0x0n;for(const Z of C){const a0=orderCompletionInGraph(a['graph'],Z['to'])['status'];if(a0==='completed')E['completed']+=0x1;else{if(a0==='in_progress')E['inProgress']+=0x1;else E['unknown']+=0x1;}F+=toBigInt(nodeData(a,Z['to'])?.['amount']);}E['windowedAmount']=F['toString']();const G=C['length']>0x0?edgeProvenance(a,[f,'service.order','Order'],C):snapProvenance([f,'service.order']);let H;if(!m)H='gap';else{if(D)H='gap';else H=C['length']===0x0?'empty':'present';}j('fulfillment_orders',H,G['confidence']);if(H==='gap'&&m)g['push']({'dimension':'fulfillment','key':'fulfillment.orders','state':'gap','value':E,'provenance':{...G,'window':D},'evidence':'Order\x20window\x20truncated\x20at\x20'+D?.['limit']+'\x20(observed\x20'+D?.['observed']+');\x20'+E['observed']+'\x20order(s)\x20visible\x20—\x20completion\x20stats\x20are\x20a\x20partial\x20floor.'});else{if(H==='empty')g['push']({'dimension':'fulfillment','key':'fulfillment.orders','state':'empty','value':E,'provenance':G,'evidence':'No\x20orders\x20in\x20the\x20service\x20window\x20(verified\x20absence).'});else H==='present'?g['push']({'dimension':'fulfillment','key':'fulfillment.orders','state':'present','value':E,'provenance':G,'evidence':E['observed']+'\x20recent\x20order(s):\x20'+E['completed']+'\x20completed,\x20'+E['inProgress']+'\x20in\x20progress,\x20'+E['unknown']+'\x20unresolved.'}):g['push']({'dimension':'fulfillment','key':'fulfillment.orders','state':'gap','provenance':snapProvenance([f]),'evidence':'Order\x20window\x20unverifiable:\x20the\x20service\x20snapshot\x20is\x20missing.'});}const I=typeof o['machine']==='string'?o['machine']:'',J=I!==''&&isFetched(a,I),K=I===''?'':I['toLowerCase']()+'::node::',L=K===''?[]:a['graph']['edges']['filter'](a1=>a1['schema']==='wf.transition'&&a1['from']['startsWith'](K)),M=new Set();for(const a1 of L){M['add'](a1['from']);const a2=String(a1['payload']?.['node']??'');if(a2!=='')M['add'](''+K+a2);}let N,O;if(!m)N='gap',O='Workflow\x20unverifiable:\x20the\x20service\x20snapshot\x20is\x20missing.';else{if(I==='')N='empty',O='No\x20workflow\x20template\x20configured\x20(verified\x20absence).';else{if(!J)N='gap',O='Machine\x20template\x20referenced\x20but\x20not\x20fetched\x20(fetch\x20gap).';else L['length']===0x0?(N='gap',O='Machine\x20fetched\x20but\x20no\x20wf.transition\x20edges\x20—\x20terminal\x20set\x20unverifiable;\x20completion\x20states\x20stay\x20unknown.'):(N='present',O='Machine\x20template\x20resolved\x20with\x20'+M['size']+'\x20workflow\x20node(s);\x20terminal\x20set\x20verifiable.');}}j('fulfillment_workflow',N,N==='present'?'exact':N==='empty'?'exact':'windowed'),g['push']({'dimension':'fulfillment','key':'fulfillment.workflow','state':N,...I!==''&&J?{'value':{'machine':I['toLowerCase'](),'nodes':M['size']}}:{},'provenance':N==='present'?edgeProvenance(a,[f,'service.machine','wf.transition'],L):snapProvenance([f,'Service.machine']),'evidence':O});const P=toBigInt(o['compensation_fund']);if(!m)j('fund_safety','gap'),g['push']({'dimension':'fund_safety','key':'fund.compensation','state':'gap','provenance':snapProvenance([f]),'evidence':'Fund\x20backing\x20unverifiable:\x20the\x20service\x20snapshot\x20is\x20missing.'}),g['push']({'dimension':'fund_safety','key':'fund.exposure','state':'gap','provenance':snapProvenance([f]),'evidence':'Payout\x20exposure\x20unverifiable:\x20the\x20service\x20snapshot\x20is\x20missing.'});else{j('fund_safety','present'),g['push']({'dimension':'fund_safety','key':'fund.compensation','state':'present','value':{'fund':P['toString'](),...q?{'coinType':q}:{}},'provenance':snapProvenance([f,'Service.compensation_fund']),'evidence':'Compensation\x20fund\x20'+P['toString']()+'\x20base\x20units'+(q?'\x20in\x20'+q:'')+'.'});const a3=F*0x3n,a4=worstState('present',H),a5=c['find'](a6=>a6['id']==='R2:'+f);g['push']({'dimension':'fund_safety','key':'fund.exposure','state':a4,'value':{'fund':P['toString'](),'windowedCount':E['observed'],'windowedAmount':F['toString'](),'neededCeiling':a3['toString'](),'coverageMet':P>=a3},'provenance':C['length']>0x0?edgeProvenance(a,[f,'service.order','Order.amount','Service.compensation_fund'],C):snapProvenance([f,'Service.compensation_fund']),'findingIds':a5?[a5['id']]:undefined,'evidence':H==='empty'?'No\x20recent\x20orders;\x20no\x20payout\x20exposure\x20to\x20cover.':'Recent\x20orders\x20total\x20'+F['toString']()+'\x20base\x20units'+(q?'\x20in\x20'+q:'')+'\x20across\x20'+E['observed']+'\x20order(s);\x20the\x20compensation\x20fund\x20should\x20cover\x20at\x20least\x203x\x20that\x20('+a3['toString']()+'\x20base\x20units'+(q?'\x20in\x20'+q:'')+')\x20—\x20coverage\x20'+(P>=a3?'met':'not\x20met')+(D?'\x20(older\x20orders\x20outside\x20the\x20fetch\x20window,\x20floor\x20value\x20only)':'')+'.'});}if(!m)j('transparency','gap'),g['push']({'dimension':'transparency','key':'transparency.profile','state':'gap','provenance':snapProvenance([f]),'evidence':'Transparency\x20unverifiable:\x20the\x20service\x20snapshot\x20is\x20missing.'});else{const a6=typeof o['setting_lock_duration']==='number'?o['setting_lock_duration']:Number(toBigInt(o['setting_lock_duration'])),a7=flag(o['bPublished']);j('transparency','present'),g['push']({'dimension':'transparency','key':'transparency.profile','state':'present','value':{'description':typeof o['description']==='string'?o['description']:'','location':typeof o['location']==='string'?o['location']:'','settingLockDuration':Number['isFinite'](a6)?a6:0x0,'published':a7,'paused':flag(o['bPaused'])},'provenance':snapProvenance([f,'Service.bPublished','Service.setting_lock_duration']),'findingIds':c['some'](a8=>a8['id']==='R6:'+f)?['R6:'+f]:undefined,'evidence':'Service\x20profile:\x20description\x20'+(typeof o['description']==='string'&&o['description']!==''?'provided':'not\x20provided')+',\x20location\x20'+(typeof o['location']==='string'&&o['location']!==''?'provided':'not\x20provided')+',\x20service\x20lock\x20'+a6+'\x20ms,\x20'+(a7?'published':'unpublished')+'.'});}for(const a8 of['risk_workflow','risk_fund','risk_trust','risk_behavior']){const a9=RISK_RULE_SOURCES[a8];let aa='present',ab,ac=-0x1;for(const ak of a9['slots']){const al=h['get'](ak)??'gap';STATE_RANK[al]>ac&&(ac=STATE_RANK[al],aa=al,ab=ak);}let ae;if(aa==='gap')ae='windowed';else{if(aa==='empty')ae='bounded';else ae=ab&&i['get'](ab)||'exact';}const af=f['toLowerCase'](),ag=new Set([af]);{const am=[af];while(am['length']>0x0){const an=am['shift']();for(const ao of a['graph']['out']['get'](an)??[]){if(ao['family']!=='F'&&ao['family']!=='W'&&ao['family']!=='M')continue;const ap=ao['to']['toLowerCase']();!ag['has'](ap)&&(ag['add'](ap),am['push'](ap));}}}const ah=(aq,ar)=>{if(!aq['startsWith'](ar+':'))return![];const as=aq['slice'](ar['length']+0x1)['toLowerCase'](),at=as['split']('#')[0x0]['split']('|')[0x0],au=at['split'](':');if(au['some'](av=>av['length']===0x0))return!![];return au['some'](av=>ag['has'](av));},ai=c['filter'](aq=>a9['ruleIds']['some'](ar=>ah(aq['id'],ar))),aj=c['filter'](aq=>a9['ruleIds']['some'](ar=>aq['id']['startsWith'](ar+':')&&!ah(aq['id'],ar)))['length'];g['push']({'dimension':a8,'key':a8+'.findings','state':aa,'value':{'findings':ai['map'](aq=>({'id':aq['id'],'severity':aq['severity'],'title':aq['title']})),'where':ai['map'](aq=>findingWhere(aq))},'provenance':{'path':[f,...a9['slots']],'retention':'derived','confidence':ae},'findingIds':ai['map'](aq=>aq['id']),'evidence':aa==='gap'?'Input\x20evidence\x20has\x20fetch\x20gaps;\x20the\x20risk\x20conclusion\x20is\x20unverifiable.':aa==='empty'?'Input\x20evidence\x20is\x20configured-empty;\x20the\x20risk\x20rules\x20are\x20not\x20applicable.':ai['length']>0x0?ai['length']+'\x20structural\x20risk\x20finding(s)\x20on\x20this\x20object,\x20from\x20the\x20analyzer\x20registry.'+(aj>0x0?'\x20'+aj+'\x20further\x20finding(s)\x20on\x20NEIGHBOR\x20objects\x20(reachable\x20only\x20through\x20shared\x20reverse/social\x20edges)\x20are\x20folded\x20here\x20as\x20a\x20count\x20—\x20they\x20do\x20not\x20belong\x20to\x20this\x20object\x27s\x20score\x20(N-K5).':''):aj>0x0?'No\x20risk\x20fired\x20on\x20this\x20object\x27s\x20own\x20structure;\x20'+aj+'\x20finding(s)\x20on\x20neighbor\x20objects\x20(shared\x20edges\x20only)\x20are\x20excluded\x20from\x20the\x20score\x20(N-K5).':'No\x20risk\x20fired\x20on\x20this\x20object;\x20input\x20evidence\x20slots\x20are\x20fully\x20materialized.'});}const Q=[];for(const aq of a['visibleNodes']){const ar=profileOf(a,aq);if(!ar)continue;const as=Array['isArray'](ar['profileRecords'])?ar['profileRecords']:undefined;Q['push']({'nodeId':aq,...typeof ar['registeredAt']==='number'?{'registeredAt':ar['registeredAt']}:{},'hasDescription':!!ar['hasDescription']||typeof ar['description']==='string','recordCount':typeof ar['recordCount']==='number'?ar['recordCount']:as?.['length']??0x0,...typeof ar['description']==='string'?{'description':ar['description']}:{},...as?{'profileRecords':as}:{}});}const R=REQUIRED_SLOTS['length'],S=REQUIRED_SLOTS['filter'](({slot:at})=>h['get'](at)==='present')['length'],T=R===0x0?0x64:Math['round'](S/R*0x64);return{'target':f,'role':String(a['role']),'facts':g,'slots':REQUIRED_SLOTS['map'](({slot:at,label:au,gloss:av})=>({'slot':at,'label':au,'gloss':av,'required':!![],'state':h['get'](at)??'gap','facts':[...SLOT_FACTS[at]??[]]})),'completeness':T,'profiles':Q};}
|
package/dist/harness/recover.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const RECOVERY_RULES={'insufficient_balance':{'error_code':'insufficient_balance','strategy':'claim_faucet','max_attempts':0x3,'automation':'semi','detail':'1.\x20Testnet:\x20claim\x20WOW\x20from\x20the\x20faucet\x202.\x20Mainnet:\x20transfer\x20ETH/USDT/USDC/WBTC\x20via\x20the\x20ETH\x20mainnet\x20cross-chain\x20bridge\x20(query\x20active\x20EVM\x20account\x20→\x20top\x20up\x20from\x20external\x20wallet\x20→\x20confirm\x20→\x20cross-chain)\x203.\x20Point\x20the\x20user\x20to\x20the\x20live\x20airdrop\x20page\x20(https://wowok.net/airdrop.html)\x20for\x20the\x20current\x20round\x204.\x20Retry\x20original\x20operation','user_prompt':'Insufficient\x20balance\x20for\x20gas\x20or\x20operation.\x20How\x20to\x20obtain\x20WOW\x20tokens:\x20(1)\x20Testnet\x20—\x20claim\x20WOW\x20from\x20the\x20faucet\x20(https://faucet.testnet.wowok.net);\x20all\x20merchant\x20and\x20order\x20testing\x20can\x20use\x20WOW\x20as\x20the\x20payment\x20token.\x20(2)\x20Mainnet\x20—\x20transfer\x20ETH\x20/\x20USDT\x20/\x20USDC\x20/\x20WBTC\x20via\x20the\x20ETH\x20mainnet\x20cross-chain\x20bridge:\x20first\x20query\x20the\x20active\x20EVM\x20account\x20(bridge_operation\x20query_active_evm_account,\x20auto-generated\x20on\x20first\x20use),\x20then\x20transfer\x20from\x20an\x20external\x20wallet\x20(e.g.\x20MetaMask)\x20to\x20that\x20address,\x20confirm\x20the\x20balance\x20arrived,\x20and\x20cross-chain\x20to\x20WOW\x20mainnet\x20(bridge_operation\x20cross_chain_evm_to_wow).\x20(3)\x20WOW\x20airdrop:\x20current\x20round\x20status,\x20pool\x20and\x20eligibility\x20are\x20published\x20live\x20at\x20https://wowok.net/airdrop.html\x20(referral:\x20https://wowok.net/refer.html)\x20—\x20open\x20that\x20page\x20rather\x20than\x20assuming\x20a\x20round\x20is\x20live\x20or\x20closed.\x20Query\x20wowok_buildin_info\x20with\x20info=\x27funding\x20guidance\x27\x20for\x20the\x20canonical\x20funding\x20guidance.'},'stock_exhausted':{'error_code':'stock_exhausted','strategy':'adjust_params','max_attempts':0x1,'automation':'semi','detail':'Merchant-side\x20inventory\x20shortfall\x20(Move\x20service:16\x20E_STOCK_NOT_ENOUGH)\x20—\x20NOT\x20a\x20buyer\x20balance\x20problem,\x20so\x20a\x20faucet\x20claim\x20will\x20NOT\x20help.\x201.\x20Reduce\x20the\x20purchase\x20quantity\x20to\x20the\x20item\x27s\x20remaining\x20stock\x202.\x20Pick\x20another\x20sale\x20item\x203.\x20Ask\x20the\x20merchant\x20to\x20restock,\x20then\x20retry','user_prompt':'The\x20sale\x20item\x27s\x20stock\x20is\x20exhausted\x20for\x20the\x20requested\x20quantity.\x20Reduce\x20the\x20quantity,\x20choose\x20another\x20item,\x20or\x20ask\x20the\x20merchant\x20to\x20restock.'},'sale_suspended':{'error_code':'sale_suspended','strategy':'adjust_params','max_attempts':0x1,'automation':'semi','detail':'The\x20merchant\x20suspended\x20this\x20sale\x20item\x20(Move\x20service:34\x20E_SALE_SUSPENDED).\x201.\x20Pick\x20another\x20(non-suspended)\x20item\x202.\x20Contact\x20the\x20merchant\x20to\x20resume\x20the\x20sale,\x20then\x20retry','user_prompt':'The\x20sale\x20item\x20is\x20suspended\x20by\x20the\x20merchant.\x20Please\x20choose\x20another\x20item\x20or\x20contact\x20the\x20merchant.'},'discount_invalid':{'error_code':'discount_invalid','strategy':'adjust_params','max_attempts':0x1,'automation':'semi','detail':'The\x20discount\x20is\x20outside\x20its\x20[time_start,\x20time_end]\x20validity\x20window\x20(Move\x20service:35\x20E_DISCOUNT_TIME_INVALID).\x201.\x20Retry\x20without\x20the\x20discount\x202.\x20Ask\x20the\x20merchant\x20for\x20a\x20fresh\x20discount,\x20then\x20retry','user_prompt':'The\x20discount\x20is\x20not\x20valid\x20at\x20the\x20current\x20time\x20(outside\x20its\x20validity\x20window).\x20Buy\x20without\x20the\x20discount\x20or\x20ask\x20the\x20merchant\x20for\x20a\x20new\x20one.'},'rate_limit':{'error_code':'rate_limit','strategy':'retry','max_attempts':0x5,'automation':'full','detail':'Rate\x20limit\x20hit\x20(HTTP\x20429).\x20Exponential\x20backoff\x20retry:\x202s\x20/\x204s\x20/\x208s\x20/\x2016s\x20/\x2032s.\x20Avoid\x20parallel\x20calls\x20while\x20the\x20limit\x20window\x20is\x20active.'},'gas_exceeded':{'error_code':'gas_exceeded','strategy':'adjust_params','max_attempts':0x3,'automation':'semi','detail':'Gas\x20budget\x20exceeded.\x201.\x20Increase\x20the\x20gas_budget\x20parameter\x202.\x20Reduce\x20the\x20operation\x20size\x20(fewer\x20objects\x20per\x20transaction)\x203.\x20Retry\x20the\x20original\x20operation','user_prompt':'Gas\x20budget\x20exceeded.\x20Increase\x20the\x20gas\x20budget\x20or\x20reduce\x20the\x20operation\x20size,\x20then\x20retry.'},'bcs_error':{'error_code':'bcs_error','strategy':'adjust_params','max_attempts':0x2,'automation':'semi','detail':'BCS\x20serialization/deserialization\x20error\x20—\x20a\x20parameter\x20does\x20not\x20match\x20the\x20expected\x20type/structure.\x201.\x20Query\x20the\x20operation\x20schema\x20(schema_query)\x202.\x20Fix\x20the\x20offending\x20parameter\x20type\x20(e.g.\x20BigInt\x20vs\x20number,\x20vector\x20element\x20type)\x203.\x20Retry','user_prompt':'A\x20parameter\x20failed\x20serialization.\x20Check\x20the\x20parameter\x20types\x20against\x20the\x20schema\x20and\x20retry.'},'signature_error':{'error_code':'signature_error','strategy':'switch_account','max_attempts':0x2,'automation':'semi','detail':'Signature\x20verification\x20failed.\x201.\x20Verify\x20the\x20account\x20is\x20not\x20suspended\x202.\x20Check\x20the\x20network\x20matches\x20the\x20account\x27s\x203.\x20Switch\x20to\x20a\x20healthy\x20account\x20and\x20retry','user_prompt':'Signature\x20verification\x20failed.\x20The\x20account\x20may\x20be\x20suspended\x20or\x20misconfigured.\x20Switch\x20accounts\x20or\x20check\x20the\x20configuration\x20and\x20retry.'},'config_error':{'error_code':'config_error','strategy':'escalate_human','max_attempts':0x1,'automation':'manual','detail':'Local\x20configuration\x20error\x20(network\x20not\x20specified,\x20persistent\x20storage\x20not\x20set).\x201.\x20Show\x20the\x20user\x20which\x20configuration\x20is\x20missing\x202.\x20Guide\x20the\x20user\x20through\x20the\x20account_operation/config\x20setup\x203.\x20Retry\x20after\x20the\x20user\x20fixes\x20it','user_prompt':'Local\x20configuration\x20is\x20incomplete.\x20Please\x20finish\x20the\x20account/network\x20setup\x20and\x20retry.'},'wip_verification_failed':{'error_code':'wip_verification_failed','strategy':'adjust_params','max_attempts':0x2,'automation':'semi','detail':'WIP\x20file\x20not\x20publicly\x20reachable\x20/\x20hash\x20mismatch.\x201.\x20Upload\x20via\x20the\x20wip\x20storage\x20service\x20(wip_file\x20type=\x27upload\x27\x20—\x20official\x20free\x20store\x20or\x20storage=\x27custom\x27)\x202.\x20Or\x20deploy\x20to\x20a\x20public\x20URL\x20(GitHub\x20Pages\x20/\x20IPFS\x20/\x20own\x20site)\x203.\x20Update\x20the\x20sale\x27s\x20wip\x20URL\x204.\x20Re-run\x20the\x20operation','user_prompt':'The\x20WIP\x20file\x20could\x20not\x20be\x20verified\x20from\x20a\x20public\x20URL.\x20Upload\x20it\x20with\x20wip_file\x20type=\x27upload\x27\x20(official\x20free\x20store\x20or\x20your\x20own\x20service)\x20or\x20deploy\x20it\x20(GitHub\x20Pages\x20/\x20IPFS),\x20update\x20the\x20sale\x27s\x20WIP\x20URL,\x20and\x20retry.'},'wip_storage_unavailable':{'error_code':'wip_storage_unavailable','strategy':'retry','max_attempts':0x3,'automation':'full','detail':'Transient\x20wip\x20storage\x20transport\x20failure.\x201.\x20Retry\x20the\x20same\x20request\x20with\x20bounded\x20backoff\x202.\x20Large\x20WIP\x20files\x20are\x20network-sensitive:\x20compress\x20images\x20before\x20generate\x20(each\x20image\x20<=\x202MB,\x20total\x20<=\x2010MB)\x203.\x20Check\x20connectivity\x20to\x20the\x20storage\x20base\x20URL\x20if\x20retries\x20keep\x20failing','user_prompt':'The\x20wip\x20storage\x20request\x20failed\x20due\x20to\x20a\x20network\x20problem.\x20Retry\x20the\x20upload;\x20if\x20it\x20keeps\x20failing,\x20reduce\x20the\x20file\x20size\x20or\x20check\x20connectivity.'},'network_error':{'error_code':'network_error','strategy':'retry','max_attempts':0x5,'automation':'full','detail':'Exponential\x20backoff\x20retry:\x201s\x20/\x202s\x20/\x204s\x20/\x208s\x20/\x2016s.\x20Switch\x20RPC\x20node\x20if\x20available.'},'submission_unknown':{'error_code':'submission_unknown','strategy':'query_and_retry','max_attempts':0x2,'automation':'semi','detail':'Transport-level\x20failure\x20after\x20the\x20request\x20left\x20the\x20client\x20—\x20the\x20submission\x20state\x20is\x20UNKNOWN\x20and\x20the\x20transaction\x20may\x20already\x20be\x20committed.\x20NEVER\x20auto-retry\x20a\x20write\x20here.\x201.\x20Verify\x20commit\x20state\x20on-chain:\x20query_toolkit\x20for\x20the\x20object\x20this\x20call\x20would\x20create/modify\x20(resolve\x20the\x20reference\x20from\x20the\x20call\x27s\x20own\x20arguments),\x20or\x20onchain_events\x20for\x20the\x20sender\x27s\x20recent\x20transactions.\x202.\x20If\x20the\x20expected\x20object\x20EXISTS,\x20adopt\x20it\x20and\x20continue\x20the\x20workflow\x20(the\x20operation\x20succeeded\x20despite\x20the\x20transport\x20error).\x203.\x20If\x20confirmed\x20ABSENT,\x20resubmit\x20the\x20SAME\x20call\x20once.\x204.\x20Reads\x20are\x20idempotent\x20—\x20retry\x20immediately.\x20Live\x20mainnet\x20incident\x20behind\x20this\x20rule:\x20an\x20order_new\x20-32603\x20\x27did\x20not\x20complete\x27\x20had\x20committed;\x20the\x20blind\x20retry\x20created\x20a\x20second\x20order\x20with\x20a\x20second\x20full\x20escrow\x20and\x20a\x20second\x20stock\x20decrement','user_prompt':'The\x20request\x20failed\x20at\x20transport\x20level\x20but\x20may\x20have\x20already\x20been\x20committed\x20on-chain.\x20Verify\x20whether\x20the\x20expected\x20object\x20exists\x20(query\x20it)\x20before\x20any\x20retry\x20—\x20a\x20blind\x20retry\x20can\x20duplicate\x20the\x20operation\x20(double\x20escrow).\x20For\x20read\x20operations,\x20a\x20plain\x20retry\x20is\x20safe.'},'transaction_expired':{'error_code':'transaction_expired','strategy':'retry','max_attempts':0x3,'automation':'full','detail':'The\x20transaction\x20expired\x20before\x20execution\x20(epoch\x20boundary\x20or\x20validator/gateway\x20outage)\x20—\x20it\x20did\x20NOT\x20land\x20and\x20nothing\x20was\x20committed.\x20Bounded\x20backoff\x20retry:\x2010s\x20/\x2030s\x20/\x2060s,\x20resubmit\x20the\x20SAME\x20call\x20unchanged.\x20If\x20a\x20dry_run\x20passes\x20while\x20the\x20real\x20call\x20keeps\x20failing,\x20the\x20fault\x20is\x20chain-side\x20—\x20wait\x20it\x20out.\x20Verify\x20with\x20onchain_events\x20if\x20unsure.'},'guard_rejected':{'error_code':'guard_rejected','strategy':'fill_submission','max_attempts':0x2,'automation':'semi','detail':'1.\x20Parse\x20Guard\x20table\x20structure\x202.\x20If\x20the\x20Guard\x20defines\x20submission\x20items,\x20fill\x20them\x20and\x20resubmit\x20with\x20call_with_submission\x203.\x20If\x20it\x20defines\x20none,\x20the\x20rule\x20evaluated\x20false\x20—\x20typical\x20causes:\x20a\x20TIME\x20WINDOW\x20(Clock\x20deadline/opening\x20comparison\x20—\x20this\x20call\x20may\x20sit\x20outside\x20the\x20window,\x20and\x20a\x20mis-oriented\x20comparison\x20inverts\x20it:\x20everything\x20inside\x20rejected,\x20everything\x20after\x20admitted)\x20or\x20an\x20IDENTITY\x20condition\x20(signer/state\x20checks\x20—\x20the\x20caller\x20may\x20not\x20be\x20the\x20address\x20the\x20rule\x20expects);\x20adjust\x20the\x20call\x27s\x20parameters\x20or\x20change\x20the\x20Guard\x20(docs#40)\x204.\x20When\x20the\x20failure\x20is\x20passport\x20E_VERIFY_FAILED\x20and\x20a\x20submission\x20was\x20supplied,\x20the\x20response\x20appends\x20a\x20\x27Guard\x20diagnosis\x20(dry-run)\x27\x20line\x20naming\x20the\x20first\x20failing\x20impact\x20guard\x20—\x20fix\x20that\x20guard\x20first','user_prompt':'Guard\x20verification\x20rejected.\x20If\x20the\x20Guard\x20defines\x20submission\x20items,\x20fill\x20in\x20the\x20required\x20submission\x20data\x20and\x20resubmit;\x20if\x20it\x20defines\x20none,\x20the\x20Guard\x20rule\x20evaluated\x20false\x20—\x20the\x20usual\x20causes\x20are\x20a\x20time\x20window\x20(this\x20call\x20may\x20be\x20outside\x20the\x20Clock\x20deadline/opening\x20window)\x20or\x20an\x20identity\x20condition\x20(the\x20caller\x20is\x20not\x20the\x20address\x20the\x20rule\x20expects);\x20adjust\x20this\x20call\x27s\x20parameters\x20or\x20change\x20the\x20Guard\x20rule.\x20When\x20the\x20response\x20includes\x20a\x20\x27Guard\x20diagnosis\x20(dry-run)\x27\x20line,\x20it\x20names\x20the\x20first\x20failing\x20impact\x20guard\x20—\x20address\x20that\x20guard\x20first.'},'time_lock_not_elapsed':{'error_code':'time_lock_not_elapsed','strategy':'wait_and_retry','max_attempts':0x1,'automation':'semi','detail':'1.\x20Verify\x20Service\x20is\x20paused\x20(bPaused=true).\x20If\x20not,\x20submit\x20pause=true\x20first.\x202.\x20Wait\x20until\x20paused_time\x20+\x20setting_lock_duration\x20<=\x20current\x20clock.\x203.\x20Retry\x20the\x20original\x20operation.\x20Do\x20NOT\x20recreate\x20the\x20object.','user_prompt':'Service\x20setting_lock_duration\x20has\x20not\x20elapsed\x20since\x20the\x20Service\x20was\x20paused.\x20Please\x20pause\x20the\x20Service\x20if\x20it\x20is\x20not\x20already\x20paused,\x20wait\x20for\x20the\x20lock\x20duration\x20to\x20elapse,\x20then\x20retry.'},'immutable_violation':{'error_code':'immutable_violation','strategy':'recreate','max_attempts':0x1,'automation':'semi','detail':'1.\x20Stop\x20modification\x20attempt\x202.\x20Evaluate\x20creating\x20a\x20new\x20object\x20as\x20replacement\x203.\x20Re-plan\x20affected\x20phases','user_prompt':'Cannot\x20modify\x20an\x20immutable\x20object.\x20A\x20new\x20object\x20must\x20be\x20created\x20as\x20a\x20replacement.\x20Confirm\x20to\x20proceed\x20with\x20recreation.'},'permission_denied':{'error_code':'permission_denied','strategy':'switch_account','max_attempts':0x2,'automation':'semi','detail':'1.\x20Query\x20object\x27s\x20permission_guard\x202.\x20List\x20accounts\x20with\x20permission\x203.\x20Switch\x20account\x20or\x20prompt\x20user\x20to\x20add\x20permission','user_prompt':'Current\x20account\x20lacks\x20permission\x20for\x20this\x20operation.\x20Switch\x20to\x20an\x20authorized\x20account\x20or\x20update\x20the\x20Permission\x20object.'},'object_not_found':{'error_code':'object_not_found','strategy':'query_and_retry','max_attempts':0x3,'automation':'semi','detail':'1.\x20Verify\x20the\x20referenced\x20name/ID\x20spelling\x20(local_mark_list)\x20and\x20that\x20the\x20object\x20exists\x20on\x20the\x20current\x20network\x202.\x20If\x20recently\x20created,\x20re-query\x20the\x20object\x20(may\x20be\x20sync\x20delay)\x203.\x20If\x20truly\x20absent,\x20search\x20for\x20similar\x20objects\x204.\x20Prompt\x20user\x20to\x20reselect','user_prompt':'Referenced\x20object\x20not\x20found.\x20First\x20verify\x20the\x20name/ID\x20spelling\x20and\x20that\x20the\x20object\x20exists\x20on\x20the\x20current\x20network;\x20if\x20it\x20was\x20created\x20recently,\x20this\x20may\x20be\x20a\x20synchronization\x20delay\x20—\x20retry.\x20If\x20the\x20issue\x20persists,\x20please\x20select\x20a\x20valid\x20object.'},'state_conflict':{'error_code':'state_conflict','strategy':'adjust_params','max_attempts':0x2,'automation':'full','detail':'1.\x20Query\x20object\x27s\x20current\x20true\x20state\x202.\x20Update\x20ODG\x20status\x20annotations\x203.\x20Adjust\x20subsequent\x20operations\x20(e.g.,\x20skip\x20completed\x20steps)'},'invalid_parameter':{'error_code':'invalid_parameter','strategy':'adjust_params','max_attempts':0x2,'automation':'semi','detail':'1.\x20Query\x20the\x20relevant\x20schema\x202.\x20Auto-fix\x20obvious\x20errors\x20(e.g.,\x20BigInt\x20vs\x20string)\x203.\x20If\x20unfixable,\x20prompt\x20user','user_prompt':'Parameter\x20validation\x20failed.\x20Please\x20check\x20the\x20parameter\x20types\x20and\x20values\x20against\x20the\x20schema\x20and\x20retry.'},'unknown':{'error_code':'unknown','strategy':'escalate_human','max_attempts':0x1,'automation':'manual','detail':'1.\x20Report\x20full\x20error\x20context\x20to\x20the\x20user\x202.\x20Escalate\x20to\x20human\x20intervention\x203.\x20Flag\x20for\x20error-classification\x20rule\x20addition','user_prompt':'An\x20unclassified\x20error\x20occurred.\x20Please\x20review\x20the\x20error\x20details\x20and\x20contact\x20support\x20if\x20needed.'}};const operationAttempts=new Map();function getAttemptCount(a,b){const c=operationAttempts['get'](a);if(!c)return 0x0;return c['get'](b)??0x0;}function incrementAttempt(a,b){!operationAttempts['has'](a)&&operationAttempts['set'](a,new Map());const c=operationAttempts['get'](a),d=(c['get'](b)??0x0)+0x1;return c['set'](b,d),d;}function getTotalAttempts(a){const b=operationAttempts['get'](a);if(!b)return 0x0;let c=0x0;for(const d of b['values']())c+=d;return c;}export function resetAttempts(a){operationAttempts['delete'](a);}export function recover(a,b,c){const d=RECOVERY_RULES[a]??RECOVERY_RULES['unknown'],e=0x5,f=getTotalAttempts(b),g=getAttemptCount(b,a);if(f>=e)return{'strategy':'stop','should_retry':![],'max_attempts':e,'current_attempt':f,'detail':'Total\x20retry\x20limit\x20('+e+')\x20reached\x20for\x20operation\x20'+b+'.\x20Escalating\x20to\x20human\x20intervention.','user_prompt':'Maximum\x20retry\x20attempts\x20reached.\x20Manual\x20intervention\x20required.'};if(g>=d['max_attempts'])return{'strategy':'escalate_human','should_retry':![],'max_attempts':d['max_attempts'],'current_attempt':g,'detail':'Per-error-code\x20retry\x20limit\x20('+d['max_attempts']+')\x20reached\x20for\x20'+a+'.\x20Escalating\x20to\x20human.','user_prompt':'Recovery\x20attempts\x20for\x20'+a+'\x20exhausted.\x20Manual\x20intervention\x20required.'};const h=incrementAttempt(b,a);return{'strategy':d['strategy'],'should_retry':d['automation']==='full'||h<d['max_attempts'],'max_attempts':d['max_attempts'],'current_attempt':h,'adjusted_params':d['adjusted_params'],'user_prompt':d['user_prompt'],'detail':d['detail']};}export function getBackoffDelay(a){return Math['pow'](0x2,a-0x1)*0x3e8;}
|
|
1
|
+
export const RECOVERY_RULES={'insufficient_balance':{'error_code':'insufficient_balance','strategy':'claim_faucet','max_attempts':0x3,'automation':'semi','detail':'1.\x20Testnet:\x20claim\x20WOW\x20from\x20the\x20faucet\x202.\x20Mainnet:\x20transfer\x20ETH/USDT/USDC/WBTC\x20via\x20the\x20ETH\x20mainnet\x20cross-chain\x20bridge\x20(query\x20active\x20EVM\x20account\x20→\x20top\x20up\x20from\x20external\x20wallet\x20→\x20confirm\x20→\x20cross-chain)\x203.\x20Point\x20the\x20user\x20to\x20the\x20live\x20airdrop\x20page\x20(https://wowok.net/airdrop.html)\x20for\x20the\x20current\x20round\x204.\x20Retry\x20original\x20operation','user_prompt':'Insufficient\x20balance\x20for\x20gas\x20or\x20operation.\x20How\x20to\x20obtain\x20WOW\x20tokens:\x20(1)\x20Testnet\x20—\x20claim\x20WOW\x20from\x20the\x20faucet\x20(https://faucet.testnet.wowok.net);\x20all\x20merchant\x20and\x20order\x20testing\x20can\x20use\x20WOW\x20as\x20the\x20payment\x20token.\x20(2)\x20Mainnet\x20—\x20transfer\x20ETH\x20/\x20USDT\x20/\x20USDC\x20/\x20WBTC\x20via\x20the\x20ETH\x20mainnet\x20cross-chain\x20bridge:\x20first\x20query\x20the\x20active\x20EVM\x20account\x20(bridge_operation\x20query_active_evm_account,\x20auto-generated\x20on\x20first\x20use),\x20then\x20transfer\x20from\x20an\x20external\x20wallet\x20(e.g.\x20MetaMask)\x20to\x20that\x20address,\x20confirm\x20the\x20balance\x20arrived,\x20and\x20cross-chain\x20to\x20WOW\x20mainnet\x20(bridge_operation\x20cross_chain_evm_to_wow).\x20(3)\x20WOW\x20airdrop:\x20current\x20round\x20status,\x20pool\x20and\x20eligibility\x20are\x20published\x20live\x20at\x20https://wowok.net/airdrop.html\x20(referral:\x20https://wowok.net/refer.html)\x20—\x20open\x20that\x20page\x20rather\x20than\x20assuming\x20a\x20round\x20is\x20live\x20or\x20closed.\x20Query\x20wowok_buildin_info\x20with\x20info=\x27funding\x20guidance\x27\x20for\x20the\x20canonical\x20funding\x20guidance.'},'stock_exhausted':{'error_code':'stock_exhausted','strategy':'adjust_params','max_attempts':0x1,'automation':'semi','detail':'Merchant-side\x20inventory\x20shortfall\x20(Move\x20service:16\x20E_STOCK_NOT_ENOUGH)\x20—\x20NOT\x20a\x20buyer\x20balance\x20problem,\x20so\x20a\x20faucet\x20claim\x20will\x20NOT\x20help.\x201.\x20Reduce\x20the\x20purchase\x20quantity\x20to\x20the\x20item\x27s\x20remaining\x20stock\x202.\x20Pick\x20another\x20sale\x20item\x203.\x20Ask\x20the\x20merchant\x20to\x20restock,\x20then\x20retry','user_prompt':'The\x20sale\x20item\x27s\x20stock\x20is\x20exhausted\x20for\x20the\x20requested\x20quantity.\x20Reduce\x20the\x20quantity,\x20choose\x20another\x20item,\x20or\x20ask\x20the\x20merchant\x20to\x20restock.'},'sale_suspended':{'error_code':'sale_suspended','strategy':'adjust_params','max_attempts':0x1,'automation':'semi','detail':'The\x20merchant\x20suspended\x20this\x20sale\x20item\x20(Move\x20service:34\x20E_SALE_SUSPENDED).\x201.\x20Pick\x20another\x20(non-suspended)\x20item\x202.\x20Contact\x20the\x20merchant\x20to\x20resume\x20the\x20sale,\x20then\x20retry','user_prompt':'The\x20sale\x20item\x20is\x20suspended\x20by\x20the\x20merchant.\x20Please\x20choose\x20another\x20item\x20or\x20contact\x20the\x20merchant.'},'discount_invalid':{'error_code':'discount_invalid','strategy':'adjust_params','max_attempts':0x1,'automation':'semi','detail':'The\x20discount\x20is\x20outside\x20its\x20[time_start,\x20time_end]\x20validity\x20window\x20(Move\x20service:35\x20E_DISCOUNT_TIME_INVALID).\x201.\x20Retry\x20without\x20the\x20discount\x202.\x20Ask\x20the\x20merchant\x20for\x20a\x20fresh\x20discount,\x20then\x20retry','user_prompt':'The\x20discount\x20is\x20not\x20valid\x20at\x20the\x20current\x20time\x20(outside\x20its\x20validity\x20window).\x20Buy\x20without\x20the\x20discount\x20or\x20ask\x20the\x20merchant\x20for\x20a\x20new\x20one.'},'rate_limit':{'error_code':'rate_limit','strategy':'retry','max_attempts':0x5,'automation':'full','detail':'Rate\x20limit\x20hit\x20(HTTP\x20429).\x20Exponential\x20backoff\x20retry:\x202s\x20/\x204s\x20/\x208s\x20/\x2016s\x20/\x2032s.\x20Avoid\x20parallel\x20calls\x20while\x20the\x20limit\x20window\x20is\x20active.'},'gas_exceeded':{'error_code':'gas_exceeded','strategy':'adjust_params','max_attempts':0x3,'automation':'semi','detail':'Gas\x20budget\x20exceeded.\x201.\x20Increase\x20the\x20gas_budget\x20parameter\x202.\x20Reduce\x20the\x20operation\x20size\x20(fewer\x20objects\x20per\x20transaction)\x203.\x20Retry\x20the\x20original\x20operation','user_prompt':'Gas\x20budget\x20exceeded.\x20Increase\x20the\x20gas\x20budget\x20or\x20reduce\x20the\x20operation\x20size,\x20then\x20retry.'},'bcs_error':{'error_code':'bcs_error','strategy':'adjust_params','max_attempts':0x2,'automation':'semi','detail':'BCS\x20serialization/deserialization\x20error\x20—\x20a\x20parameter\x20does\x20not\x20match\x20the\x20expected\x20type/structure.\x201.\x20Query\x20the\x20operation\x20schema\x20(schema_query)\x202.\x20Fix\x20the\x20offending\x20parameter\x20type\x20(e.g.\x20BigInt\x20vs\x20number,\x20vector\x20element\x20type)\x203.\x20Retry','user_prompt':'A\x20parameter\x20failed\x20serialization.\x20Check\x20the\x20parameter\x20types\x20against\x20the\x20schema\x20and\x20retry.'},'signature_error':{'error_code':'signature_error','strategy':'switch_account','max_attempts':0x2,'automation':'semi','detail':'Signature\x20verification\x20failed.\x201.\x20Verify\x20the\x20account\x20is\x20not\x20suspended\x202.\x20Check\x20the\x20network\x20matches\x20the\x20account\x27s\x203.\x20Switch\x20to\x20a\x20healthy\x20account\x20and\x20retry','user_prompt':'Signature\x20verification\x20failed.\x20The\x20account\x20may\x20be\x20suspended\x20or\x20misconfigured.\x20Switch\x20accounts\x20or\x20check\x20the\x20configuration\x20and\x20retry.'},'config_error':{'error_code':'config_error','strategy':'escalate_human','max_attempts':0x1,'automation':'manual','detail':'Local\x20configuration\x20error\x20(network\x20not\x20specified,\x20persistent\x20storage\x20not\x20set).\x201.\x20Show\x20the\x20user\x20which\x20configuration\x20is\x20missing\x202.\x20Guide\x20the\x20user\x20through\x20the\x20account_operation/config\x20setup\x203.\x20Retry\x20after\x20the\x20user\x20fixes\x20it','user_prompt':'Local\x20configuration\x20is\x20incomplete.\x20Please\x20finish\x20the\x20account/network\x20setup\x20and\x20retry.'},'wip_verification_failed':{'error_code':'wip_verification_failed','strategy':'adjust_params','max_attempts':0x2,'automation':'semi','detail':'WIP\x20file\x20not\x20publicly\x20reachable\x20/\x20hash\x20mismatch.\x201.\x20Upload\x20via\x20the\x20wip\x20storage\x20service\x20(wip_file\x20type=\x27upload\x27\x20—\x20official\x20free\x20store\x20or\x20storage=\x27custom\x27)\x202.\x20Or\x20deploy\x20to\x20a\x20public\x20URL\x20(GitHub\x20Pages\x20/\x20IPFS\x20/\x20own\x20site)\x203.\x20Update\x20the\x20sale\x27s\x20wip\x20URL\x204.\x20Re-run\x20the\x20operation','user_prompt':'The\x20WIP\x20file\x20could\x20not\x20be\x20verified\x20from\x20a\x20public\x20URL.\x20Upload\x20it\x20with\x20wip_file\x20type=\x27upload\x27\x20(official\x20free\x20store\x20or\x20your\x20own\x20service)\x20or\x20deploy\x20it\x20(GitHub\x20Pages\x20/\x20IPFS),\x20update\x20the\x20sale\x27s\x20WIP\x20URL,\x20and\x20retry.'},'wip_storage_unavailable':{'error_code':'wip_storage_unavailable','strategy':'retry','max_attempts':0x3,'automation':'full','detail':'Transient\x20wip\x20storage\x20transport\x20failure.\x201.\x20Retry\x20the\x20same\x20request\x20with\x20bounded\x20backoff\x202.\x20Large\x20WIP\x20files\x20are\x20network-sensitive:\x20compress\x20images\x20before\x20generate\x20(each\x20image\x20<=\x202MB,\x20total\x20<=\x2010MB)\x203.\x20Check\x20connectivity\x20to\x20the\x20storage\x20base\x20URL\x20if\x20retries\x20keep\x20failing','user_prompt':'The\x20wip\x20storage\x20request\x20failed\x20due\x20to\x20a\x20network\x20problem.\x20Retry\x20the\x20upload;\x20if\x20it\x20keeps\x20failing,\x20reduce\x20the\x20file\x20size\x20or\x20check\x20connectivity.'},'network_error':{'error_code':'network_error','strategy':'retry','max_attempts':0x5,'automation':'full','detail':'Exponential\x20backoff\x20retry:\x201s\x20/\x202s\x20/\x204s\x20/\x208s\x20/\x2016s.\x20Switch\x20RPC\x20node\x20if\x20available.'},'submission_unknown':{'error_code':'submission_unknown','strategy':'query_and_retry','max_attempts':0x2,'automation':'semi','detail':'Transport-level\x20failure\x20after\x20the\x20request\x20left\x20the\x20client\x20—\x20the\x20submission\x20state\x20is\x20UNKNOWN\x20and\x20the\x20transaction\x20may\x20already\x20be\x20committed.\x20NEVER\x20auto-retry\x20a\x20write\x20here.\x201.\x20Verify\x20commit\x20state\x20on-chain:\x20query_toolkit\x20for\x20the\x20object\x20this\x20call\x20would\x20create/modify\x20(resolve\x20the\x20reference\x20from\x20the\x20call\x27s\x20own\x20arguments),\x20or\x20onchain_events\x20for\x20the\x20sender\x27s\x20recent\x20transactions.\x202.\x20If\x20the\x20expected\x20object\x20EXISTS,\x20adopt\x20it\x20and\x20continue\x20the\x20workflow\x20(the\x20operation\x20succeeded\x20despite\x20the\x20transport\x20error).\x203.\x20If\x20confirmed\x20ABSENT,\x20resubmit\x20the\x20SAME\x20call\x20once.\x204.\x20Reads\x20are\x20idempotent\x20—\x20retry\x20immediately.\x205.\x20M-K2\x20replay\x20discipline:\x20a\x20FAILED\x20receipt\x20is\x20final\x20—\x20its\x20digest\x20is\x20consumed\x20and\x20replaying\x20the\x20same\x20bytes\x20returns\x20the\x20same\x20failure\x20forever;\x20fix\x20the\x20cause\x20(usually\x20funding)\x20and\x20build\x20a\x20FRESH\x20transaction.\x20Live\x20mainnet\x20incident\x20behind\x20this\x20rule:\x20an\x20order_new\x20-32603\x20\x27did\x20not\x20complete\x27\x20had\x20committed;\x20the\x20blind\x20retry\x20created\x20a\x20second\x20order\x20with\x20a\x20second\x20full\x20escrow\x20and\x20a\x20second\x20stock\x20decrement','user_prompt':'The\x20request\x20failed\x20at\x20transport\x20level\x20but\x20may\x20have\x20already\x20been\x20committed\x20on-chain.\x20Verify\x20whether\x20the\x20expected\x20object\x20exists\x20(query\x20it)\x20before\x20any\x20retry\x20—\x20a\x20blind\x20retry\x20can\x20duplicate\x20the\x20operation\x20(double\x20escrow).\x20For\x20read\x20operations,\x20a\x20plain\x20retry\x20is\x20safe.'},'transaction_expired':{'error_code':'transaction_expired','strategy':'retry','max_attempts':0x3,'automation':'full','detail':'The\x20transaction\x20expired\x20before\x20execution\x20(epoch\x20boundary\x20or\x20validator/gateway\x20outage)\x20—\x20it\x20did\x20NOT\x20land\x20and\x20nothing\x20was\x20committed.\x20Bounded\x20backoff\x20retry:\x2010s\x20/\x2030s\x20/\x2060s,\x20resubmit\x20the\x20SAME\x20call\x20unchanged.\x20If\x20a\x20dry_run\x20passes\x20while\x20the\x20real\x20call\x20keeps\x20failing,\x20the\x20fault\x20is\x20chain-side\x20—\x20wait\x20it\x20out.\x20Verify\x20with\x20onchain_events\x20if\x20unsure.'},'guard_rejected':{'error_code':'guard_rejected','strategy':'fill_submission','max_attempts':0x2,'automation':'semi','detail':'1.\x20Parse\x20Guard\x20table\x20structure\x202.\x20If\x20the\x20Guard\x20defines\x20submission\x20items,\x20fill\x20them\x20and\x20resubmit\x20with\x20call_with_submission\x203.\x20If\x20it\x20defines\x20none,\x20the\x20rule\x20evaluated\x20false\x20—\x20typical\x20causes:\x20a\x20TIME\x20WINDOW\x20(Clock\x20deadline/opening\x20comparison\x20—\x20this\x20call\x20may\x20sit\x20outside\x20the\x20window,\x20and\x20a\x20mis-oriented\x20comparison\x20inverts\x20it:\x20everything\x20inside\x20rejected,\x20everything\x20after\x20admitted)\x20or\x20an\x20IDENTITY\x20condition\x20(signer/state\x20checks\x20—\x20the\x20caller\x20may\x20not\x20be\x20the\x20address\x20the\x20rule\x20expects);\x20adjust\x20the\x20call\x27s\x20parameters\x20or\x20change\x20the\x20Guard\x20(docs#40)\x204.\x20When\x20the\x20failure\x20is\x20passport\x20E_VERIFY_FAILED\x20and\x20a\x20submission\x20was\x20supplied,\x20the\x20response\x20appends\x20a\x20\x27Guard\x20diagnosis\x20(dry-run)\x27\x20line\x20naming\x20the\x20first\x20failing\x20impact\x20guard\x20—\x20fix\x20that\x20guard\x20first','user_prompt':'Guard\x20verification\x20rejected.\x20If\x20the\x20Guard\x20defines\x20submission\x20items,\x20fill\x20in\x20the\x20required\x20submission\x20data\x20and\x20resubmit;\x20if\x20it\x20defines\x20none,\x20the\x20Guard\x20rule\x20evaluated\x20false\x20—\x20the\x20usual\x20causes\x20are\x20a\x20time\x20window\x20(this\x20call\x20may\x20be\x20outside\x20the\x20Clock\x20deadline/opening\x20window)\x20or\x20an\x20identity\x20condition\x20(the\x20caller\x20is\x20not\x20the\x20address\x20the\x20rule\x20expects);\x20adjust\x20this\x20call\x27s\x20parameters\x20or\x20change\x20the\x20Guard\x20rule.\x20When\x20the\x20response\x20includes\x20a\x20\x27Guard\x20diagnosis\x20(dry-run)\x27\x20line,\x20it\x20names\x20the\x20first\x20failing\x20impact\x20guard\x20—\x20address\x20that\x20guard\x20first.'},'time_lock_not_elapsed':{'error_code':'time_lock_not_elapsed','strategy':'wait_and_retry','max_attempts':0x1,'automation':'semi','detail':'1.\x20Verify\x20Service\x20is\x20paused\x20(bPaused=true).\x20If\x20not,\x20submit\x20pause=true\x20first.\x202.\x20Wait\x20until\x20paused_time\x20+\x20setting_lock_duration\x20<=\x20current\x20clock.\x203.\x20Retry\x20the\x20original\x20operation.\x20Do\x20NOT\x20recreate\x20the\x20object.','user_prompt':'Service\x20setting_lock_duration\x20has\x20not\x20elapsed\x20since\x20the\x20Service\x20was\x20paused.\x20Please\x20pause\x20the\x20Service\x20if\x20it\x20is\x20not\x20already\x20paused,\x20wait\x20for\x20the\x20lock\x20duration\x20to\x20elapse,\x20then\x20retry.'},'immutable_violation':{'error_code':'immutable_violation','strategy':'recreate','max_attempts':0x1,'automation':'semi','detail':'1.\x20Stop\x20modification\x20attempt\x202.\x20Evaluate\x20creating\x20a\x20new\x20object\x20as\x20replacement\x203.\x20Re-plan\x20affected\x20phases','user_prompt':'Cannot\x20modify\x20an\x20immutable\x20object.\x20A\x20new\x20object\x20must\x20be\x20created\x20as\x20a\x20replacement.\x20Confirm\x20to\x20proceed\x20with\x20recreation.'},'permission_denied':{'error_code':'permission_denied','strategy':'switch_account','max_attempts':0x2,'automation':'semi','detail':'1.\x20Query\x20object\x27s\x20permission_guard\x202.\x20List\x20accounts\x20with\x20permission\x203.\x20Switch\x20account\x20or\x20prompt\x20user\x20to\x20add\x20permission','user_prompt':'Current\x20account\x20lacks\x20permission\x20for\x20this\x20operation.\x20Switch\x20to\x20an\x20authorized\x20account\x20or\x20update\x20the\x20Permission\x20object.'},'object_not_found':{'error_code':'object_not_found','strategy':'query_and_retry','max_attempts':0x3,'automation':'semi','detail':'1.\x20Verify\x20the\x20referenced\x20name/ID\x20spelling\x20(local_mark_list)\x20and\x20that\x20the\x20object\x20exists\x20on\x20the\x20current\x20network\x202.\x20If\x20recently\x20created,\x20re-query\x20the\x20object\x20(may\x20be\x20sync\x20delay)\x203.\x20If\x20truly\x20absent,\x20search\x20for\x20similar\x20objects\x204.\x20Prompt\x20user\x20to\x20reselect','user_prompt':'Referenced\x20object\x20not\x20found.\x20First\x20verify\x20the\x20name/ID\x20spelling\x20and\x20that\x20the\x20object\x20exists\x20on\x20the\x20current\x20network;\x20if\x20it\x20was\x20created\x20recently,\x20this\x20may\x20be\x20a\x20synchronization\x20delay\x20—\x20retry.\x20If\x20the\x20issue\x20persists,\x20please\x20select\x20a\x20valid\x20object.'},'state_conflict':{'error_code':'state_conflict','strategy':'adjust_params','max_attempts':0x2,'automation':'full','detail':'1.\x20Query\x20object\x27s\x20current\x20true\x20state\x202.\x20Update\x20ODG\x20status\x20annotations\x203.\x20Adjust\x20subsequent\x20operations\x20(e.g.,\x20skip\x20completed\x20steps)'},'invalid_parameter':{'error_code':'invalid_parameter','strategy':'adjust_params','max_attempts':0x2,'automation':'semi','detail':'1.\x20Query\x20the\x20relevant\x20schema\x202.\x20Auto-fix\x20obvious\x20errors\x20(e.g.,\x20BigInt\x20vs\x20string)\x203.\x20If\x20unfixable,\x20prompt\x20user','user_prompt':'Parameter\x20validation\x20failed.\x20Please\x20check\x20the\x20parameter\x20types\x20and\x20values\x20against\x20the\x20schema\x20and\x20retry.'},'unknown':{'error_code':'unknown','strategy':'escalate_human','max_attempts':0x1,'automation':'manual','detail':'1.\x20Report\x20full\x20error\x20context\x20to\x20the\x20user\x202.\x20Escalate\x20to\x20human\x20intervention\x203.\x20Flag\x20for\x20error-classification\x20rule\x20addition','user_prompt':'An\x20unclassified\x20error\x20occurred.\x20Please\x20review\x20the\x20error\x20details\x20and\x20contact\x20support\x20if\x20needed.'}};const operationAttempts=new Map();function getAttemptCount(a,b){const c=operationAttempts['get'](a);if(!c)return 0x0;return c['get'](b)??0x0;}function incrementAttempt(a,b){!operationAttempts['has'](a)&&operationAttempts['set'](a,new Map());const c=operationAttempts['get'](a),d=(c['get'](b)??0x0)+0x1;return c['set'](b,d),d;}function getTotalAttempts(a){const b=operationAttempts['get'](a);if(!b)return 0x0;let c=0x0;for(const d of b['values']())c+=d;return c;}export function resetAttempts(a){operationAttempts['delete'](a);}export function recover(a,b,c){const d=RECOVERY_RULES[a]??RECOVERY_RULES['unknown'],e=0x5,f=getTotalAttempts(b),g=getAttemptCount(b,a);if(f>=e)return{'strategy':'stop','should_retry':![],'max_attempts':e,'current_attempt':f,'detail':'Total\x20retry\x20limit\x20('+e+')\x20reached\x20for\x20operation\x20'+b+'.\x20Escalating\x20to\x20human\x20intervention.','user_prompt':'Maximum\x20retry\x20attempts\x20reached.\x20Manual\x20intervention\x20required.'};if(g>=d['max_attempts'])return{'strategy':'escalate_human','should_retry':![],'max_attempts':d['max_attempts'],'current_attempt':g,'detail':'Per-error-code\x20retry\x20limit\x20('+d['max_attempts']+')\x20reached\x20for\x20'+a+'.\x20Escalating\x20to\x20human.','user_prompt':'Recovery\x20attempts\x20for\x20'+a+'\x20exhausted.\x20Manual\x20intervention\x20required.'};const h=incrementAttempt(b,a);return{'strategy':d['strategy'],'should_retry':d['automation']==='full'||h<d['max_attempts'],'max_attempts':d['max_attempts'],'current_attempt':h,'adjusted_params':d['adjusted_params'],'user_prompt':d['user_prompt'],'detail':d['detail']};}export function getBackoffDelay(a){return Math['pow'](0x2,a-0x1)*0x3e8;}
|
|
@@ -27,6 +27,8 @@ export declare function arbitrationRefsOf(d: any): string[];
|
|
|
27
27
|
export declare function compensationFundOf(d: any): unknown;
|
|
28
28
|
export declare function serviceNameOf(d: any): string | undefined;
|
|
29
29
|
export declare function typeParameterOf(d: any): string | undefined;
|
|
30
|
+
export declare const DISPUTE_FAMILY_NODE_REGEX: RegExp;
|
|
31
|
+
export declare const FUND_TERMINAL_NODE_REGEX: RegExp;
|
|
30
32
|
export declare const ANTI_PATTERN_NODE_REGEX: RegExp;
|
|
31
33
|
export interface MachineNodeAudit {
|
|
32
34
|
critical: string[];
|