@wowok/agent-mcp 3.1.2 → 3.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/config/runtime.js +1 -1
- package/dist/customer/index.d.ts +3 -9
- package/dist/customer/index.js +1 -1
- package/dist/customer/industry-risks.d.ts +3 -17
- package/dist/customer/industry-risks.js +1 -1
- package/dist/customer/types.d.ts +1 -165
- package/dist/customer/types.js +1 -1
- package/dist/customer/user-preferences.d.ts +0 -49
- package/dist/customer/user-preferences.js +1 -1
- package/dist/evaluation/architecture.spec.d.ts +1 -0
- package/dist/evaluation/architecture.spec.js +1 -0
- package/dist/evaluation/builtins/graph-service.d.ts +16 -0
- package/dist/evaluation/builtins/graph-service.js +1 -0
- package/dist/evaluation/builtins/graph-service.spec.d.ts +1 -0
- package/dist/evaluation/builtins/graph-service.spec.js +1 -0
- package/dist/evaluation/builtins/index.d.ts +1 -1
- package/dist/evaluation/builtins/index.js +1 -1
- package/dist/evaluation/builtins/purity.spec.d.ts +1 -0
- package/dist/evaluation/builtins/purity.spec.js +1 -0
- package/dist/evaluation/engine.js +1 -1
- package/dist/evaluation/facets/catalog.d.ts +19 -0
- package/dist/evaluation/facets/catalog.js +1 -0
- package/dist/evaluation/guard-scan.d.ts +10 -0
- package/dist/evaluation/guard-scan.js +1 -0
- package/dist/evaluation/standards.d.ts +31 -0
- package/dist/evaluation/standards.js +1 -0
- package/dist/evaluation/standards.spec.d.ts +1 -0
- package/dist/evaluation/standards.spec.js +1 -0
- package/dist/evaluation/types.d.ts +9 -0
- package/dist/experience/realtime-feedback.js +1 -1
- package/dist/extensions/index.d.ts +1 -1
- package/dist/extensions/index.js +1 -1
- package/dist/extensions/industry-layers.d.ts +6 -5
- package/dist/extensions/industry-layers.js +1 -1
- package/dist/extensions/industry-pack.js +1 -1
- package/dist/graph/onchain/analyze.d.ts +13 -0
- package/dist/graph/onchain/analyze.js +1 -1
- package/dist/graph/onchain/analyze.spec.js +1 -1
- package/dist/graph/onchain/dataplane.d.ts +1 -1
- package/dist/graph/onchain/dataplane.js +1 -1
- package/dist/graph/onchain/edge-batch.spec.d.ts +1 -0
- package/dist/graph/onchain/edge-batch.spec.js +1 -0
- package/dist/graph/onchain/edge-schema.d.ts +10 -2
- package/dist/graph/onchain/edge-schema.js +1 -1
- package/dist/graph/onchain/entity-profile.spec.d.ts +1 -0
- package/dist/graph/onchain/entity-profile.spec.js +1 -0
- package/dist/graph/onchain/event-history.spec.d.ts +1 -0
- package/dist/graph/onchain/event-history.spec.js +1 -0
- package/dist/graph/onchain/expand.js +1 -1
- package/dist/graph/onchain/extract-deep.spec.d.ts +1 -0
- package/dist/graph/onchain/extract-deep.spec.js +1 -0
- package/dist/graph/onchain/extract.d.ts +11 -3
- package/dist/graph/onchain/extract.js +1 -1
- package/dist/graph/onchain/facet-projection.d.ts +99 -0
- package/dist/graph/onchain/facet-projection.js +1 -0
- package/dist/graph/onchain/facet-projection.spec.d.ts +1 -0
- package/dist/graph/onchain/facet-projection.spec.js +1 -0
- package/dist/graph/onchain/facts.d.ts +103 -0
- package/dist/graph/onchain/facts.js +1 -0
- package/dist/graph/onchain/facts.spec.d.ts +1 -0
- package/dist/graph/onchain/facts.spec.js +1 -0
- package/dist/graph/onchain/field-manifest.d.ts +29 -0
- package/dist/graph/onchain/field-manifest.js +1 -0
- package/dist/graph/onchain/field-manifest.spec.d.ts +1 -0
- package/dist/graph/onchain/field-manifest.spec.js +1 -0
- package/dist/graph/onchain/fixtures.d.ts +80 -0
- package/dist/graph/onchain/fixtures.js +1 -0
- package/dist/graph/onchain/fixtures.spec.d.ts +1 -0
- package/dist/graph/onchain/fixtures.spec.js +1 -0
- package/dist/graph/onchain/index.d.ts +8 -2
- package/dist/graph/onchain/index.js +1 -1
- package/dist/graph/onchain/interest.js +1 -1
- package/dist/graph/onchain/label-lint.spec.d.ts +1 -0
- package/dist/graph/onchain/label-lint.spec.js +1 -0
- package/dist/graph/onchain/names.d.ts +23 -0
- package/dist/graph/onchain/names.js +1 -0
- package/dist/graph/onchain/names.spec.d.ts +1 -0
- package/dist/graph/onchain/names.spec.js +1 -0
- package/dist/graph/onchain/onchain.spec.js +1 -1
- package/dist/graph/onchain/proposal-graph.d.ts +11 -0
- package/dist/graph/onchain/proposal-graph.js +1 -0
- package/dist/graph/onchain/proposal-graph.spec.d.ts +1 -0
- package/dist/graph/onchain/proposal-graph.spec.js +1 -0
- package/dist/graph/onchain/sdk-batch.d.ts +5 -1
- package/dist/graph/onchain/sdk-batch.js +1 -1
- package/dist/graph/onchain/strategy.d.ts +16 -0
- package/dist/graph/onchain/strategy.js +1 -1
- package/dist/graph/onchain/strategy.spec.js +1 -1
- package/dist/graph/onchain/table-ledger.spec.d.ts +1 -0
- package/dist/graph/onchain/table-ledger.spec.js +1 -0
- package/dist/graph/onchain/types.d.ts +46 -6
- package/dist/graph/onchain/viewport.d.ts +1 -0
- package/dist/graph/onchain/viewport.js +1 -1
- package/dist/harness/index.d.ts +1 -5
- package/dist/harness/index.js +1 -1
- package/dist/harness/verify.d.ts +6 -1
- package/dist/harness/verify.js +1 -1
- package/dist/index.js +1 -1
- package/dist/knowledge/allocation-ledger.js +1 -1
- package/dist/knowledge/allocation-risk.d.ts +0 -2
- package/dist/knowledge/allocation-risk.js +1 -1
- package/dist/knowledge/arb-risk.d.ts +0 -1
- package/dist/knowledge/arb-risk.js +1 -1
- package/dist/knowledge/arbitration-risk.d.ts +0 -2
- package/dist/knowledge/arbitration-risk.js +1 -1
- package/dist/knowledge/baselines/evaluation-baselines.json +79 -0
- package/dist/knowledge/baselines/guard-lint-baseline.spec.d.ts +1 -0
- package/dist/knowledge/baselines/guard-lint-baseline.spec.js +1 -0
- package/dist/knowledge/baselines/risk-baselines.spec.d.ts +1 -0
- package/dist/knowledge/baselines/risk-baselines.spec.js +1 -0
- package/dist/knowledge/baselines/risk-cases.d.ts +8 -0
- package/dist/knowledge/baselines/risk-cases.js +1 -0
- package/dist/knowledge/bridge-risk.d.ts +0 -1
- package/dist/knowledge/bridge-risk.js +1 -1
- package/dist/knowledge/contact-risk.d.ts +0 -1
- package/dist/knowledge/contact-risk.js +1 -1
- package/dist/knowledge/contract-invariants.d.ts +1 -0
- package/dist/knowledge/contract-invariants.js +1 -1
- package/dist/knowledge/demand-risk.d.ts +0 -1
- package/dist/knowledge/demand-risk.js +1 -1
- package/dist/knowledge/getting-started.js +1 -1
- package/dist/knowledge/guard-eval.d.ts +15 -0
- package/dist/knowledge/guard-eval.js +1 -0
- package/dist/knowledge/guard-eval.spec.d.ts +1 -0
- package/dist/knowledge/guard-eval.spec.js +1 -0
- package/dist/knowledge/guard-lint.d.ts +1 -1
- package/dist/knowledge/guard-lint.js +1 -1
- package/dist/knowledge/guard-risk.d.ts +4 -19
- package/dist/knowledge/guard-risk.js +1 -1
- package/dist/knowledge/index.d.ts +41 -43
- package/dist/knowledge/index.js +1 -1
- package/dist/knowledge/industry-registry.js +1 -1
- package/dist/knowledge/industry-rule-node.d.ts +7 -0
- package/dist/knowledge/industry-rule-node.js +1 -0
- package/dist/knowledge/jsonrpc-enum.js +1 -1
- package/dist/knowledge/machine-risk.d.ts +0 -6
- package/dist/knowledge/machine-risk.js +1 -1
- package/dist/knowledge/order-risk.d.ts +1 -9
- package/dist/knowledge/order-risk.js +1 -1
- package/dist/knowledge/payment-risk.d.ts +0 -1
- package/dist/knowledge/payment-risk.js +1 -1
- package/dist/knowledge/permission-risk.d.ts +0 -3
- package/dist/knowledge/permission-risk.js +1 -1
- package/dist/knowledge/personal-risk.d.ts +0 -1
- package/dist/knowledge/personal-risk.js +1 -1
- package/dist/knowledge/progress-risk.d.ts +0 -2
- package/dist/knowledge/progress-risk.js +1 -1
- package/dist/knowledge/proof-risk.d.ts +0 -1
- package/dist/knowledge/proof-risk.js +1 -1
- package/dist/knowledge/puzzle-projections.d.ts +11 -0
- package/dist/knowledge/puzzle-projections.js +1 -0
- package/dist/knowledge/registrar-risk.d.ts +0 -1
- package/dist/knowledge/registrar-risk.js +1 -1
- package/dist/knowledge/repository-risk.d.ts +0 -1
- package/dist/knowledge/repository-risk.js +1 -1
- package/dist/knowledge/resource-risk.d.ts +0 -1
- package/dist/knowledge/resource-risk.js +1 -1
- package/dist/knowledge/reward-risk.d.ts +1 -5
- package/dist/knowledge/reward-risk.js +1 -1
- package/dist/knowledge/rule-node-analyzers.d.ts +43 -0
- package/dist/knowledge/rule-node-analyzers.js +1 -0
- package/dist/knowledge/rule-node-analyzers.spec.d.ts +1 -0
- package/dist/knowledge/rule-node-analyzers.spec.js +1 -0
- package/dist/knowledge/rule-outcome.d.ts +5 -0
- package/dist/knowledge/rule-outcome.js +1 -0
- package/dist/knowledge/safety-rules.js +1 -1
- package/dist/knowledge/scenario-topology.js +1 -1
- package/dist/knowledge/service-risk-node.js +1 -1
- package/dist/knowledge/service-risk.d.ts +0 -3
- package/dist/knowledge/service-risk.js +1 -1
- package/dist/knowledge/template-registry.js +1 -1
- package/dist/knowledge/tools-reference.js +1 -1
- package/dist/knowledge/treasury-risk.d.ts +2 -3
- package/dist/knowledge/treasury-risk.js +1 -1
- package/dist/knowledge/util-risk.d.ts +0 -1
- package/dist/knowledge/util-risk.js +1 -1
- package/dist/monitor/MonitorLoop.js +1 -1
- package/dist/persona/bridge.js +1 -1
- package/dist/persona/facet-profile.d.ts +33 -0
- package/dist/persona/facet-profile.js +1 -0
- package/dist/persona/model.d.ts +2 -1
- package/dist/persona/model.js +1 -1
- package/dist/persona/topology-focus.d.ts +2 -2
- package/dist/persona/topology-focus.js +1 -1
- package/dist/persona/types.d.ts +12 -0
- package/dist/playbooks/service-build/business-puzzle.js +1 -1
- package/dist/playbooks/service-build/facet-money.d.ts +22 -0
- package/dist/playbooks/service-build/facet-money.js +1 -0
- package/dist/playbooks/service-build/facet-money.spec.d.ts +1 -0
- package/dist/playbooks/service-build/facet-money.spec.js +1 -0
- package/dist/playbooks/service-build/machine-panorama.d.ts +3 -0
- package/dist/playbooks/service-build/machine-panorama.js +1 -1
- package/dist/playbooks/service-build/object-panorama.d.ts +27 -27
- package/dist/playbooks/service-build/object-panorama.js +1 -1
- package/dist/playbooks/service-build/pipeline-actions.d.ts +2 -2
- package/dist/playbooks/service-build/pipeline-actions.js +1 -1
- package/dist/playbooks/service-build/risk-aggregator.d.ts +2 -1
- package/dist/playbooks/service-build/risk-aggregator.js +1 -1
- package/dist/playbooks/service-build/service-panorama.d.ts +4 -9
- package/dist/playbooks/service-build/service-panorama.js +1 -1
- package/dist/playbooks/service-build/topology-evaluation.spec.d.ts +1 -0
- package/dist/playbooks/service-build/topology-evaluation.spec.js +1 -0
- package/dist/playbooks/service-build/topology-query.d.ts +13 -2
- package/dist/playbooks/service-build/topology-query.js +1 -1
- package/dist/review/arb.d.ts +0 -2
- package/dist/review/arb.js +1 -1
- package/dist/review/order.d.ts +0 -1
- package/dist/review/order.js +1 -1
- package/dist/role/profiles.js +1 -1
- package/dist/rules.d.ts +1 -2
- package/dist/rules.js +1 -1
- package/dist/safety/confirm-gate.js +1 -1
- package/dist/schema/call/base.d.ts +3372 -668
- package/dist/schema/call/base.js +1 -1
- package/dist/schema/call/handler.js +1 -1
- package/dist/schema/call/receipt.d.ts +28 -0
- package/dist/schema/call/receipt.js +1 -0
- package/dist/schema/call/semantic-customer-advice.spec.d.ts +1 -0
- package/dist/schema/call/semantic-customer-advice.spec.js +1 -0
- package/dist/schema/call/semantic.d.ts +5 -2
- package/dist/schema/call/semantic.js +1 -1
- package/dist/schema/call/treasury.js +1 -1
- package/dist/schema/common/index.js +1 -1
- package/dist/schema/evaluation/index.d.ts +289 -211
- package/dist/schema/evaluation/index.js +1 -1
- package/dist/schema/goal/index.d.ts +1 -1
- package/dist/schema/goal/planning.d.ts +2 -2
- package/dist/schema/index.d.ts +0 -1
- package/dist/schema/index.js +1 -1
- package/dist/schema/industry-pack/index.d.ts +1 -1
- package/dist/schema/keeper/index.d.ts +1 -1
- package/dist/schema/local/index.js +1 -1
- package/dist/schema/operations.d.ts +26 -10
- package/dist/schema/operations.js +1 -1
- package/dist/schema/persona/index.d.ts +24 -24
- package/dist/schema/query/bi.d.ts +613 -0
- package/dist/schema/query/bi.js +1 -1
- package/dist/schema/query/index.d.ts +9 -9
- package/dist/schema/schema-version.js +1 -1
- package/dist/schema/workspace/index.d.ts +2 -2
- package/dist/schema-query-impl/index.js +1 -1
- package/dist/schemas/account_operation.output.json +1 -1
- package/dist/schemas/bridge_operation.output.json +1 -1
- package/dist/schemas/evaluation_operation.output.json +691 -163
- package/dist/schemas/evaluation_operation.schema.json +0 -429
- package/dist/schemas/index.json +1 -7
- package/dist/schemas/keeper_operation.output.json +1 -1
- package/dist/schemas/local_history_operation.output.json +1 -1
- package/dist/schemas/local_info_operation.output.json +1 -1
- package/dist/schemas/local_mark_operation.output.json +1 -1
- package/dist/schemas/messenger_operation.output.json +1 -1
- package/dist/schemas/monitor_events.output.json +1 -1
- package/dist/schemas/monitor_subscription.output.json +1 -1
- package/dist/schemas/onchain_events.output.json +1 -1
- package/dist/schemas/onchain_operations.output.json +6357 -3724
- package/dist/schemas/onchain_operations.schema.json +2 -2
- package/dist/schemas/onchain_operations_treasury.schema.json +2 -2
- package/dist/schemas/onchain_table_data.output.json +61 -71
- package/dist/schemas/query_toolkit.output.json +841 -8
- package/dist/schemas/query_toolkit.schema.json +59 -1
- package/dist/strategy/metrics.js +1 -1
- package/dist/tools/handlers/bridge.js +1 -1
- package/dist/tools/handlers/config.js +1 -1
- package/dist/tools/handlers/dispatch-expectations.d.ts +3 -0
- package/dist/tools/handlers/dispatch-expectations.js +1 -0
- package/dist/tools/handlers/evaluation.js +1 -1
- package/dist/tools/handlers/onchain.js +1 -1
- package/dist/tools/handlers/query.js +1 -1
- package/dist/tools/index.js +1 -1
- package/dist/tools/registry/evaluation.d.ts +2 -0
- package/dist/tools/registry/evaluation.js +1 -0
- package/dist/tools/registry/query.js +1 -1
- package/dist/tools/shared.d.ts +0 -1
- package/dist/tools/shared.js +1 -1
- package/dist/tools/wrap.js +1 -1
- package/package.json +4 -3
- package/dist/customer/customer-advice.d.ts +0 -32
- package/dist/customer/customer-advice.js +0 -1
- package/dist/customer/info-puzzle.d.ts +0 -146
- package/dist/customer/info-puzzle.js +0 -1
- package/dist/customer/order-strategy.d.ts +0 -17
- package/dist/customer/order-strategy.js +0 -1
- package/dist/customer/preorder-compare.d.ts +0 -24
- package/dist/customer/preorder-compare.js +0 -1
- package/dist/customer/reminder-system.d.ts +0 -42
- package/dist/customer/reminder-system.js +0 -1
- package/dist/customer/risk-assessment.d.ts +0 -13
- package/dist/customer/risk-assessment.js +0 -1
- package/dist/evaluation/builtins/service-risk.d.ts +0 -7
- package/dist/evaluation/builtins/service-risk.js +0 -1
- package/dist/knowledge/trust-metrics.d.ts +0 -66
- package/dist/knowledge/trust-metrics.js +0 -1
- package/dist/schema/trust/index.d.ts +0 -334
- package/dist/schema/trust/index.js +0 -1
- package/dist/schemas/trust_score.output.json +0 -847
- package/dist/schemas/trust_score.schema.json +0 -364
- package/dist/tools/handlers/trust.d.ts +0 -16
- package/dist/tools/handlers/trust.js +0 -1
- package/dist/tools/registry/trust.d.ts +0 -2
- package/dist/tools/registry/trust.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{MAX_SHARING_COUNT,MAX_ALLOCATOR_COUNT}from'@wowok/wowok';export{MAX_ALLOCATOR_COUNT};export const ALLOCATION_MAX_SHARING_COUNT=MAX_SHARING_COUNT;export const ALLOCATION_MODE_AMOUNT=0x0;export const ALLOCATION_MODE_RATE=0x1;export const ALLOCATION_MODE_SURPLUS=0x2;export const RATE_TOTAL_FULL=0x2710;export const ALLOCATION_ERROR_CODES={'ERECIPIENT_IDENTIFIER_NOT_ADDRESS':0x1,'EALLOCATOR_COUNT_EXCEEDED':0x2,'ENO_ALLOCATOR':0x3,'ERATE_NOT_10000':0x4,'EMULTIPLE_SURPLUS':0x5,'ERATE_EXCEEDS_10000':0x6,'EINSUFFICIENT_BALANCE':0x7,'EALLOCATORS_EMPTY':0x8,'ENO_PAYMENT_INFO':0x9,'ESHARING_COUNT_EXCEEDED':0xa,'ESHARING_MODE_INVALID':0xb,'EAMOUNT_BELOW_THRESHOLD':0xc,'EAMOUNT_EXCEEDS_MAX':0xd,'EZERO_DISTRIBUTION':0xe,'ERECIPIENT_NOT_FOR_OBJECT':0xf};export const ORDER_ALLOCATION_ALREADY_SPECIFIED='E_ALLOCATION_ALREADY_SPECIFIED';export const ALLOCATION_SCENES=[{'id':'allocation_standard_three_way_split','name':'Standard\x20three-way\x20split\x20(merchant\x20/\x20platform\x20/\x20logistics)','trigger_source':'service_order_allocators','distribution_strategy':'pure_rate','coin_type_note':'All\x20three\x20Treasury\x20objects\x20must\x20use\x20the\x20same\x20Coin<T>\x20type\x20as\x20the\x20Allocation','typical_allocator_count':0x1,'sharing_who_types':['Entity'],'modes_used':['Rate'],'guard_requirement':'required','non_zero_threshold':![],'uses_max':![],'common_patterns':['Single\x20Allocator,\x203\x20Rate\x20sharing\x20items,\x20sum(rates)\x20===\x2010000','Each\x20sharing.who=Entity\x20points\x20to\x20a\x20Treasury\x20address','Guard\x20verifies\x20order.service\x20binding\x20(query\x201563)\x20to\x20prevent\x20cross-project\x20bypass','Guard\x20verifies\x20progress.current_node\x20===\x20\x27Complete\x27'],'dependencies':['Service','Treasury','Guard','Order','Progress','Machine','Payment'],'key_constraints':['F-A-05:\x20sum(rates)\x20===\x2010000\x20(pure\x20Rate\x20mode)','Treasury\x20Permission\x20should\x20match\x20Service\x20Permission\x20(R-A-12)','order_allocators\x20immutable\x20after\x20Service\x20publish\x20(R-A-10)'],'recommended_templates':['T-A-02']},{'id':'allocation_merchant_full_payment','name':'Merchant\x20full\x20payment\x20(single\x20recipient,\x20100%)','trigger_source':'service_order_allocators','distribution_strategy':'pure_rate','coin_type_note':'Simplest\x20configuration\x20—\x20single\x20Treasury\x20or\x20personal\x20address','typical_allocator_count':0x1,'sharing_who_types':['Entity'],'modes_used':['Rate'],'guard_requirement':'single_relaxed','non_zero_threshold':![],'uses_max':![],'common_patterns':['Single\x20Allocator,\x201\x20Rate\x20sharing\x20=\x2010000','Guard\x20only\x20verifies\x20order\x20status\x20(no\x20complex\x20conditions)','who=Entity\x20can\x20be\x20either\x20Treasury\x20or\x20personal\x20wallet'],'dependencies':['Service','Guard','Order','Payment'],'key_constraints':['Simplest\x20allocation\x20configuration','No\x20multi-party\x20coordination\x20required'],'recommended_templates':['T-A-01']},{'id':'allocation_refund_first_surplus_to_merchant','name':'Refund\x20first\x20+\x20surplus\x20to\x20merchant\x20(Amount\x20+\x20Surplus\x20hybrid)','trigger_source':'service_order_allocators','distribution_strategy':'amount_plus_surplus','coin_type_note':'Refund\x20amount\x20must\x20match\x20Coin<T>\x20precision','typical_allocator_count':0x1,'sharing_who_types':['Entity'],'modes_used':['Amount','Surplus'],'guard_requirement':'required','non_zero_threshold':!![],'uses_max':![],'common_patterns':['Single\x20Allocator,\x202\x20sharing\x20items','sharing[0]:\x20Amount=refund_value,\x20who=Entity(customer_address)','sharing[1]:\x20Surplus,\x20who=Entity(merchant_treasury)','fix\x20=\x20refund_value\x20(cached\x20Amount\x20sum)','threshold\x20=\x20refund_value\x20(ensure\x20sufficient\x20balance\x20for\x20Amount)'],'dependencies':['Service','Treasury','Guard','Order','Payment'],'key_constraints':['F-A-04:\x20at\x20most\x201\x20Surplus\x20per\x20Allocator','F-A-07:\x20fix\x20>=\x20threshold\x20(Amount\x20sum\x20must\x20cover\x20threshold)','fix\x20must\x20precisely\x20match\x20the\x20refund\x20amount'],'recommended_templates':['T-A-03']},{'id':'allocation_treasury_personal_alternatives','name':'Treasury\x20+\x20Personal\x20alternative\x20strategies\x20(caller-specified\x20guard)','trigger_source':'service_order_allocators','distribution_strategy':'first_match_alternatives','coin_type_note':'Both\x20target\x20addresses\x20must\x20accept\x20the\x20same\x20Coin<T>','typical_allocator_count':0x2,'sharing_who_types':['Entity'],'modes_used':['Rate'],'guard_requirement':'multiple_unique','non_zero_threshold':![],'uses_max':![],'common_patterns':['2\x20Allocators,\x20each\x20with\x201\x20Rate=10000\x20sharing','Allocator[0]:\x20guard=guard_treasury,\x20who=Entity(treasury_address)','Allocator[1]:\x20guard=guard_personal,\x20who=Entity(personal_address)','Two\x20Guard\x20objects\x20must\x20be\x20different\x20addresses\x20(R-A-11)','caller-specified\x20guard:\x20caller\x20selects\x20Treasury\x20or\x20Personal\x20path\x20via\x20alloc_by_guard;\x20passport::result_for_guard\x20hard-validates\x20(failure\x20aborts\x20with\x20E_VERIFY_FAILED;\x20caller\x20must\x20switch\x20guard\x20and\x20retry)'],'dependencies':['Service','Treasury','Guard','Order','Payment'],'key_constraints':['F-A-14:\x20allocators[].guard\x20must\x20be\x20unique','Treasury\x20Permission\x20should\x20match\x20Service\x20Permission\x20(R-A-12)','Guard\x20A\x20and\x20Guard\x20B\x20may\x20share\x20root/table\x20but\x20must\x20differ\x20in\x20description'],'recommended_templates':['T-A-04']},{'id':'allocation_tiered_by_order_amount','name':'Tiered\x20split\x20by\x20order\x20amount\x20(multi-Allocator\x20amount-threshold\x20switch)','trigger_source':'service_order_allocators','distribution_strategy':'tiered_by_amount','coin_type_note':'Amount\x20threshold\x20uses\x20Coin<T>\x20smallest\x20unit\x20(e.g.\x20MIST\x20for\x20WOW)','typical_allocator_count':0x2,'sharing_who_types':['Entity'],'modes_used':['Rate'],'guard_requirement':'multiple_unique','non_zero_threshold':![],'uses_max':![],'common_patterns':['2\x20Allocators\x20triggered\x20by\x20mutually\x20exclusive\x20Guard\x20conditions','Allocator[0]:\x20guard\x20verifies\x20order.amount\x20<\x20threshold,\x20Rate=10000\x20to\x20merchant','Allocator[1]:\x20guard\x20verifies\x20order.amount\x20>=\x20threshold,\x20Rate=8000/2000\x20split','caller-specified\x20guard:\x20caller\x20selects\x20the\x20matching\x20Allocator\x20based\x20on\x20order\x20amount;\x20allocator\x20order\x20is\x20irrelevant','Guard\x20queries\x20order.amount\x20(query\x201561)'],'dependencies':['Service','Treasury','Guard','Order','Payment'],'key_constraints':['Guard\x20conditions\x20must\x20be\x20mutually\x20exclusive\x20(R-A-4-02\x20design\x20clarity)','Caller\x20must\x20select\x20correct\x20guard\x20based\x20on\x20order.amount\x20(no\x20auto-fallback)'],'recommended_templates':['T-A-05']},{'id':'allocation_dynamic_recipient','name':'Multi-role\x20split\x20with\x20dynamic\x20recipient\x20(GuardIdentifier)','trigger_source':'service_order_allocators','distribution_strategy':'dynamic_recipient','coin_type_note':'Passport\x20table\x20must\x20contain\x20address-typed\x20entry\x20at\x20the\x20referenced\x20identifier','typical_allocator_count':0x1,'sharing_who_types':['Entity','GuardIdentifier'],'modes_used':['Rate'],'guard_requirement':'required','non_zero_threshold':![],'uses_max':![],'common_patterns':['Single\x20Allocator,\x203\x20Rate\x20sharing\x20items','sharing[0]:\x20Rate=8000,\x20who=Entity(merchant_treasury)','sharing[1]:\x20Rate=1000,\x20who=Entity(platform_treasury)','sharing[2]:\x20Rate=1000,\x20who=GuardIdentifier(0)\x20—\x20resolves\x20from\x20Passport\x20table','Customer\x20submits\x20Passport\x20with\x20referrer\x20address\x20at\x20identifier=0'],'dependencies':['Service','Treasury','Guard','Passport','Order','Payment'],'key_constraints':['F-A-13:\x20Passport\x20table[identifier]\x20must\x20be\x20address\x20type\x20(else\x20ERECIPIENT_IDENTIFIER_NOT_ADDRESS)','Guard\x20must\x20verify\x20Passport\x20completeness','Customer\x20order\x20must\x20include\x20Passport\x20with\x20referrer\x20address'],'recommended_templates':['T-A-06']},{'id':'allocation_arbitration_fees','name':'Arbitration\x20fees\x20split\x20(arbitrator\x20/\x20platform)','trigger_source':'arbitration_fees','distribution_strategy':'pure_rate','coin_type_note':'Coin<T>\x20must\x20match\x20Arbitration\x27s\x20fee\x20Coin\x20type','typical_allocator_count':0x1,'sharing_who_types':['Entity'],'modes_used':['Rate'],'guard_requirement':'required','non_zero_threshold':![],'uses_max':![],'common_patterns':['Triggered\x20by\x20Arbitration.fees_alloc\x20(permission\x20365)\x20or\x20fees_alloc_with_passport','Single\x20Allocator,\x202\x20Rate\x20sharing\x20items:\x208000\x20arbitrator\x20/\x202000\x20platform','payment_info\x20reuses\x20Arbitration\x27s\x20payment_info','Caller\x20must\x20hold\x20ARBITRATION_FEES_ALLOC=365\x20permission'],'dependencies':['Arbitration','Treasury','Guard','Payment'],'key_constraints':['Independent\x20from\x20Service-order\x20Allocation','Requires\x20ARBITRATION_FEES_ALLOC=365\x20permission'],'recommended_templates':['T-A-08']},{'id':'allocation_refund_to_order','name':'Refund\x20Allocator\x20(100%\x20to\x20Order\x20object)','trigger_source':'service_order_allocators','distribution_strategy':'refund_to_order','coin_type_note':'who=Entity\x20must\x20be\x20the\x20Order\x20object\x20address\x20(NOT\x20a\x20personal\x20wallet)','typical_allocator_count':0x1,'sharing_who_types':['Entity'],'modes_used':['Rate'],'guard_requirement':'required','non_zero_threshold':![],'uses_max':![],'common_patterns':['Single\x20Allocator,\x201\x20Rate=10000\x20sharing','who=Entity(order_address)\x20—\x20funds\x20flow\x20back\x20to\x20Order,\x20not\x20personal\x20wallet','Guard\x20verifies\x20customer\x20refund\x20request\x20and\x20eligibility','Customer-side\x20risk\x20assessment\x20adds\x208-point\x20weight\x20(customer/risk-assessment.ts)'],'dependencies':['Service','Guard','Order','Payment'],'key_constraints':['who=Entity\x20MUST\x20be\x20Order\x20object\x20address\x20(not\x20personal\x20address)','Customer\x20due-diligence\x20rewards\x20this\x20configuration\x20(8-point\x20weight)','Refund\x20funds\x20return\x20to\x20Order\x20for\x20downstream\x20handling'],'recommended_templates':['T-A-07']},{'id':'allocation_max_capped_retain','name':'Max-capped\x20allocation\x20(retain\x20residual\x20balance)','trigger_source':'service_order_allocators','distribution_strategy':'max_capped','coin_type_note':'max\x20field\x20uses\x20Coin<T>\x20smallest\x20unit','typical_allocator_count':0x1,'sharing_who_types':['Entity'],'modes_used':['Amount','Rate'],'guard_requirement':'required','non_zero_threshold':!![],'uses_max':!![],'common_patterns':['Single\x20Allocator\x20with\x20max\x20field\x20set','max\x20triple\x20role:\x20Amount\x20cap\x20+\x20Rate\x20base\x20+\x20Surplus\x20cap','Amount\x20sharing\x20consumes\x20fix;\x20Rate\x20sharing\x20uses\x20(max\x20-\x20fix)\x20as\x20base','Residual\x20balance\x20remains\x20in\x20Allocation\x20for\x20subsequent\x20alloc()\x20calls'],'dependencies':['Service','Treasury','Guard','Order','Payment'],'key_constraints':['F-A-08:\x20Amount\x20sum\x20<=\x20max\x20(EAMOUNT_EXCEEDS_MAX)','max\x20-\x20fix\x20becomes\x20Rate\x20base\x20(NOT\x20balance\x20-\x20fix)','Residual\x20balance\x20may\x20be\x20claimed\x20by\x20re-triggering\x20alloc()'],'recommended_templates':[]},{'id':'allocation_multi_node_trigger','name':'Multi-Machine-node\x20triggered\x20allocation\x20(Complete\x20/\x20Refund\x20/\x20Lost)','trigger_source':'service_order_allocators','distribution_strategy':'multi_node_trigger','coin_type_note':'All\x20Allocators\x20share\x20the\x20same\x20Allocation\x27s\x20Coin<T>','typical_allocator_count':0x3,'sharing_who_types':['Entity'],'modes_used':['Rate'],'guard_requirement':'multiple_unique','non_zero_threshold':![],'uses_max':![],'common_patterns':['3\x20Allocators\x20mapped\x20to\x20Machine\x20terminal\x20nodes\x20(Complete/Refund/Lost)','Each\x20Allocator\x27s\x20Guard\x20verifies\x20progress.current_node\x20==\x20<node_name>','Mutually\x20exclusive\x20Guard\x20conditions\x20(only\x20one\x20terminal\x20node\x20active\x20at\x20a\x20time)','Machine.required_allocators[]\x20describes\x20each\x20trigger_node\x20mapping'],'dependencies':['Service','Treasury','Guard','Order','Progress','Machine','Payment'],'key_constraints':['Guard\x20conditions\x20must\x20be\x20mutually\x20exclusive','Sequence-sensitive:\x20business-flow\x20order','Machine.required_allocators[trigger_node]\x20must\x20map\x20to\x20Allocator\x20indices'],'recommended_templates':[]},{'id':'allocation_standalone_periodic_split','name':'Standalone\x20periodic\x20split\x20(investment\x20dividends\x20/\x20shared\x20income)','trigger_source':'standalone','distribution_strategy':'periodic_split','coin_type_note':'Coin<T>\x20must\x20match\x20the\x20asset\x20being\x20distributed\x20(e.g.\x20profit\x20token)','typical_allocator_count':0x1,'sharing_who_types':['Entity'],'modes_used':['Rate'],'guard_requirement':'required','non_zero_threshold':![],'uses_max':![],'common_patterns':['Single\x20Allocator,\x20N\x20Rate\x20sharing\x20items,\x20sum(rates)\x20===\x2010000','Each\x20sharing.who=Entity\x20points\x20to\x20a\x20beneficiary\x20wallet\x20(not\x20Treasury)','Guard\x20verifies\x20time-based\x20trigger\x20(e.g.\x20context(Clock).timestamp\x20>=\x20next_release)\x20or\x20signer\x20authorization','User\x20calls\x20receive()\x20to\x20deposit\x20funds,\x20then\x20alloc()\x20to\x20trigger\x20distribution','No\x20Service/Order/Progress/Machine\x20context\x20required'],'dependencies':['Treasury','Guard','Payment'],'key_constraints':['F-A-05:\x20sum(rates)\x20===\x2010000\x20(pure\x20Rate\x20mode)','R-A-3-04:\x20standalone\x20mode\x20has\x20no\x20Service-layer\x20access\x20control\x20—\x20Guard\x20+\x20Passport\x20MUST\x20be\x20sufficient','Caller\x20is\x20fully\x20responsible\x20for\x20receive\x20→\x20alloc\x20lifecycle\x20(no\x20auto-trigger)','Guard\x20should\x20bind\x20Signer\x20to\x20prevent\x20unauthorized\x20alloc()\x20calls'],'recommended_templates':['T-A-09']},{'id':'allocation_standalone_vesting','name':'Standalone\x20vesting\x20release\x20(time-locked\x20multi-stage\x20unlock)','trigger_source':'standalone','distribution_strategy':'time_locked_vesting','coin_type_note':'Coin<T>\x20must\x20match\x20the\x20vested\x20asset\x20(e.g.\x20locked\x20team\x20tokens)','typical_allocator_count':0x3,'sharing_who_types':['Entity'],'modes_used':['Amount','Rate','Surplus'],'guard_requirement':'multiple_unique','non_zero_threshold':!![],'uses_max':!![],'common_patterns':['N\x20Allocators,\x20each\x20mapped\x20to\x20a\x20vesting\x20stage\x20(e.g.\x2025%\x20at\x20month\x2012,\x2025%\x20at\x20month\x2024,\x2050%\x20surplus\x20at\x20month\x2036)','Each\x20Allocator\x27s\x20Guard\x20verifies\x20context(Clock).timestamp\x20>=\x20stage_unlock_time','Amount\x20sharing\x20per\x20stage\x20with\x20max\x20field\x20capping\x20the\x20cumulative\x20release','Final\x20Allocator\x20uses\x20Surplus\x20to\x20drain\x20remaining\x20balance\x20after\x20last\x20vesting\x20stage','Mutually\x20exclusive\x20Guard\x20conditions\x20(only\x20one\x20stage\x20active\x20at\x20a\x20time,\x20based\x20on\x20timestamp)','User\x20calls\x20receive()\x20to\x20deposit\x20locked\x20tokens,\x20then\x20alloc()\x20at\x20each\x20vesting\x20milestone'],'dependencies':['Treasury','Guard','Passport','Payment'],'key_constraints':['F-A-04:\x20at\x20most\x201\x20Surplus\x20per\x20Allocator\x20(final\x20stage\x20uses\x20Surplus\x20to\x20drain\x20remainder)','F-A-08:\x20Amount\x20sum\x20<=\x20max\x20(EAMOUNT_EXCEEDS_MAX)','R-A-3-04:\x20standalone\x20mode\x20has\x20no\x20Service-layer\x20access\x20control\x20—\x20Guard\x20time-lock\x20MUST\x20be\x20enforced','Guard\x20conditions\x20must\x20be\x20mutually\x20exclusive\x20by\x20timestamp\x20(R-A-4-02)','Caller\x20must\x20wait\x20for\x20time-lock\x20expiry\x20before\x20alloc()\x20succeeds;\x20otherwise\x20alloc()\x20silently\x20returns\x20(R-A-4-01)'],'recommended_templates':['T-A-10']}];export const ALLOCATION_LEDGER_VERSION='1.0.0';export function getScenesByTriggerSource(a){return ALLOCATION_SCENES['filter'](b=>b['trigger_source']===a);}export function getScenesByMode(a){return ALLOCATION_SCENES['filter'](b=>b['modes_used']['includes'](a));}export function getScenesByStrategy(a){return ALLOCATION_SCENES['filter'](b=>b['distribution_strategy']===a);}export function findSceneById(a){return ALLOCATION_SCENES['find'](b=>b['id']===a);}export function inferSceneFromIntent(a){const b=a['toLowerCase']();if(b['includes']('arbitration')||b['includes']('fees_alloc'))return findSceneById('allocation_arbitration_fees');if(b['includes']('standalone')||b['includes']('periodic\x20split')||b['includes']('investment\x20dividend')||b['includes']('shared\x20income')||b['includes']('dividend'))return findSceneById('allocation_standalone_periodic_split');if(b['includes']('vesting')||b['includes']('time-lock')||b['includes']('unlock\x20period')||b['includes']('locked\x20release')||b['includes']('token\x20unlock'))return findSceneById('allocation_standalone_vesting');if(b['includes']('refund')){if(b['includes']('order')||b['includes']('100%'))return findSceneById('allocation_refund_to_order');if(b['includes']('surplus')||b['includes']('merchant'))return findSceneById('allocation_refund_first_surplus_to_merchant');}if(b['includes']('alternative')||b['includes']('priority')||b['includes']('treasury')&&b['includes']('personal'))return findSceneById('allocation_treasury_personal_alternatives');if(b['includes']('tiered')||b['includes']('threshold\x20switch'))return findSceneById('allocation_tiered_by_order_amount');if(b['includes']('dynamic\x20recipient')||b['includes']('referrer')||b['includes']('guardidentifier'))return findSceneById('allocation_dynamic_recipient');if(b['includes']('retain')||b['includes']('max'))return findSceneById('allocation_max_capped_retain');if(b['includes']('multi-node')||b['includes']('multi\x20machine')||b['includes']('multi_node'))return findSceneById('allocation_multi_node_trigger');const c=(a['match'](/%/g)||[])['length'];if(c<=0x1)return findSceneById('allocation_merchant_full_payment');if(c>=0x2)return findSceneById('allocation_standard_three_way_split');return undefined;}export function getAllScenes(){return[...ALLOCATION_SCENES];}export function getScenesCount(){return ALLOCATION_SCENES['length'];}export function allocationModeToNumber(a){switch(a){case'Amount':return ALLOCATION_MODE_AMOUNT;case'Rate':return ALLOCATION_MODE_RATE;case'Surplus':return ALLOCATION_MODE_SURPLUS;}}export function allocationModeFromNumber(a){switch(a){case ALLOCATION_MODE_AMOUNT:return'Amount';case ALLOCATION_MODE_RATE:return'Rate';case ALLOCATION_MODE_SURPLUS:return'Surplus';default:throw new Error('Invalid\x20AllocationMode\x20number:\x20'+a);}}export function getRecipientType(a){if('GuardIdentifier'in a)return'GuardIdentifier';if('Entity'in a)return'Entity';return'Signer';}export function isSignerRecipient(a){return'Signer'in a;}export function isEntityRecipient(a){return'Entity'in a;}export function isGuardIdentifierRecipient(a){return'GuardIdentifier'in a;}export function getErrorName(a){for(const [b,d]of Object['entries'](ALLOCATION_ERROR_CODES)){if(d===a)return b;}return undefined;}export function getErrorDescription(a){const b={0x1:'GuardIdentifier\x20resolved\x20value\x20is\x20not\x20an\x20address\x20type',0x2:'Allocator\x20count\x20exceeds\x20MAX_ALLOCATOR_COUNT\x20(100)',0x3:'No\x20Allocator\x20in\x20the\x20allocators\x20vector',0x4:'Pure\x20Rate\x20mode\x20sum\x20!=\x2010000\x20(no\x20Surplus\x20to\x20absorb\x20remainder)',0x5:'Multiple\x20Surplus\x20sharing\x20in\x20a\x20single\x20Allocator',0x6:'Rate\x20+\x20Surplus\x20sum\x20>\x2010000',0x7:'balance\x20<\x20threshold\x20(insufficient\x20balance\x20to\x20trigger\x20alloc)',0x8:'allocators.allocators\x20is\x20empty',0x9:'payment_info\x20is\x20None\x20when\x20alloc()\x20is\x20called',0xa:'sharing\x20count\x20exceeds\x20MAX_SHARING_COUNT\x20(100)',0xb:'sharing\x20mode\x20is\x20not\x200\x20(Amount)\x20/\x201\x20(Rate)\x20/\x202\x20(Surplus)',0xc:'Amount\x20sum\x20(fix)\x20<\x20threshold',0xd:'Amount\x20sum\x20(fix)\x20>\x20max',0xe:'distribution\x20computes\x20to\x20zero\x20while\x20the\x20pool\x20still\x20holds\x20funds\x20(or\x20balance\x20is\x200)',0xf:'GuardIdentifier\x20recipient\x20address\x20!=\x20payment_info.for_object\x20anchor\x20(abort\x20fires\x20only\x20when\x20a\x20for_object\x20binding\x20is\x20declared)'};return b[a];}
|
|
1
|
+
import{MAX_SHARING_COUNT,MAX_ALLOCATOR_COUNT}from'@wowok/wowok';export{MAX_ALLOCATOR_COUNT};export const ALLOCATION_MAX_SHARING_COUNT=MAX_SHARING_COUNT;export const ALLOCATION_MODE_AMOUNT=0x0;export const ALLOCATION_MODE_RATE=0x1;export const ALLOCATION_MODE_SURPLUS=0x2;export const RATE_TOTAL_FULL=0x2710;export const ALLOCATION_ERROR_CODES={'ERECIPIENT_IDENTIFIER_NOT_ADDRESS':0x1,'EALLOCATOR_COUNT_EXCEEDED':0x2,'ENO_ALLOCATOR':0x3,'ERATE_NOT_10000':0x4,'EMULTIPLE_SURPLUS':0x5,'ERATE_EXCEEDS_10000':0x6,'EINSUFFICIENT_BALANCE':0x7,'EALLOCATORS_EMPTY':0x8,'ENO_PAYMENT_INFO':0x9,'ESHARING_COUNT_EXCEEDED':0xa,'ESHARING_MODE_INVALID':0xb,'EAMOUNT_BELOW_THRESHOLD':0xc,'EAMOUNT_EXCEEDS_MAX':0xd,'EZERO_DISTRIBUTION':0xe,'ERECIPIENT_NOT_FOR_OBJECT':0xf};export const ORDER_ALLOCATION_ALREADY_SPECIFIED='E_ALLOCATION_ALREADY_SPECIFIED';export const ALLOCATION_SCENES=[{'id':'allocation_standard_three_way_split','name':'Standard\x20three-way\x20split\x20(merchant\x20/\x20platform\x20/\x20logistics)','trigger_source':'service_order_allocators','distribution_strategy':'pure_rate','coin_type_note':'All\x20three\x20Treasury\x20objects\x20must\x20use\x20the\x20same\x20Coin<T>\x20type\x20as\x20the\x20Allocation','typical_allocator_count':0x1,'sharing_who_types':['Entity'],'modes_used':['Rate'],'guard_requirement':'required','non_zero_threshold':![],'uses_max':![],'common_patterns':['Single\x20Allocator,\x203\x20Rate\x20sharing\x20items,\x20sum(rates)\x20===\x2010000','Each\x20sharing.who=Entity\x20points\x20to\x20a\x20Treasury\x20address','Guard\x20verifies\x20order.service\x20binding\x20(query\x201563)\x20to\x20prevent\x20cross-project\x20bypass','Guard\x20verifies\x20progress.current_node\x20===\x20\x27Complete\x27'],'dependencies':['Service','Treasury','Guard','Order','Progress','Machine','Payment'],'key_constraints':['F-A-05:\x20sum(rates)\x20===\x2010000\x20(pure\x20Rate\x20mode)','Treasury\x20Permission\x20should\x20match\x20Service\x20Permission\x20(R-A-12)','order_allocators\x20immutable\x20after\x20Service\x20publish\x20(R-A-10)'],'recommended_templates':['T-A-02']},{'id':'allocation_merchant_full_payment','name':'Merchant\x20full\x20payment\x20(single\x20recipient,\x20100%)','trigger_source':'service_order_allocators','distribution_strategy':'pure_rate','coin_type_note':'Simplest\x20configuration\x20—\x20single\x20Treasury\x20or\x20personal\x20address','typical_allocator_count':0x1,'sharing_who_types':['Entity'],'modes_used':['Rate'],'guard_requirement':'single_relaxed','non_zero_threshold':![],'uses_max':![],'common_patterns':['Single\x20Allocator,\x201\x20Rate\x20sharing\x20=\x2010000','Guard\x20only\x20verifies\x20order\x20status\x20(no\x20complex\x20conditions)','who=Entity\x20can\x20be\x20either\x20Treasury\x20or\x20personal\x20wallet'],'dependencies':['Service','Guard','Order','Payment'],'key_constraints':['Simplest\x20allocation\x20configuration','No\x20multi-party\x20coordination\x20required'],'recommended_templates':['T-A-01']},{'id':'allocation_refund_first_surplus_to_merchant','name':'Refund\x20first\x20+\x20surplus\x20to\x20merchant\x20(Amount\x20+\x20Surplus\x20hybrid)','trigger_source':'service_order_allocators','distribution_strategy':'amount_plus_surplus','coin_type_note':'Refund\x20amount\x20must\x20match\x20Coin<T>\x20precision','typical_allocator_count':0x1,'sharing_who_types':['Entity'],'modes_used':['Amount','Surplus'],'guard_requirement':'required','non_zero_threshold':!![],'uses_max':![],'common_patterns':['Single\x20Allocator,\x202\x20sharing\x20items','sharing[0]:\x20Amount=refund_value,\x20who=Entity(customer_address)','sharing[1]:\x20Surplus,\x20who=Entity(merchant_treasury)','fix\x20=\x20refund_value\x20(cached\x20Amount\x20sum)','threshold\x20=\x20refund_value\x20(ensure\x20sufficient\x20balance\x20for\x20Amount)'],'dependencies':['Service','Treasury','Guard','Order','Payment'],'key_constraints':['F-A-04:\x20at\x20most\x201\x20Surplus\x20per\x20Allocator','F-A-07:\x20fix\x20>=\x20threshold\x20(Amount\x20sum\x20must\x20cover\x20threshold)','fix\x20must\x20precisely\x20match\x20the\x20refund\x20amount'],'recommended_templates':['T-A-03']},{'id':'allocation_treasury_personal_alternatives','name':'Treasury\x20+\x20Personal\x20alternative\x20strategies\x20(caller-specified\x20guard)','trigger_source':'service_order_allocators','distribution_strategy':'first_match_alternatives','coin_type_note':'Both\x20target\x20addresses\x20must\x20accept\x20the\x20same\x20Coin<T>','typical_allocator_count':0x2,'sharing_who_types':['Entity'],'modes_used':['Rate'],'guard_requirement':'multiple_unique','non_zero_threshold':![],'uses_max':![],'common_patterns':['2\x20Allocators,\x20each\x20with\x201\x20Rate=10000\x20sharing','Allocator[0]:\x20guard=guard_treasury,\x20who=Entity(treasury_address)','Allocator[1]:\x20guard=guard_personal,\x20who=Entity(personal_address)','Two\x20Guard\x20objects\x20must\x20be\x20different\x20addresses\x20(R-A-11)','caller-specified\x20guard:\x20caller\x20selects\x20Treasury\x20or\x20Personal\x20path\x20via\x20alloc_by_guard;\x20passport::result_for_guard\x20hard-validates\x20(failure\x20aborts\x20with\x20E_VERIFY_FAILED;\x20caller\x20must\x20switch\x20guard\x20and\x20retry)'],'dependencies':['Service','Treasury','Guard','Order','Payment'],'key_constraints':['F-A-14:\x20allocators[].guard\x20must\x20be\x20unique','Treasury\x20Permission\x20should\x20match\x20Service\x20Permission\x20(R-A-12)','Guard\x20A\x20and\x20Guard\x20B\x20may\x20share\x20root/table\x20but\x20must\x20differ\x20in\x20description'],'recommended_templates':['T-A-04']},{'id':'allocation_tiered_by_order_amount','name':'Tiered\x20split\x20by\x20order\x20amount\x20(multi-Allocator\x20amount-threshold\x20switch)','trigger_source':'service_order_allocators','distribution_strategy':'tiered_by_amount','coin_type_note':'Amount\x20threshold\x20uses\x20Coin<T>\x20smallest\x20unit\x20(e.g.\x20MIST\x20for\x20WOW)','typical_allocator_count':0x2,'sharing_who_types':['Entity'],'modes_used':['Rate'],'guard_requirement':'multiple_unique','non_zero_threshold':![],'uses_max':![],'common_patterns':['2\x20Allocators\x20triggered\x20by\x20mutually\x20exclusive\x20Guard\x20conditions','Allocator[0]:\x20guard\x20verifies\x20order.amount\x20<\x20threshold,\x20Rate=10000\x20to\x20merchant','Allocator[1]:\x20guard\x20verifies\x20order.amount\x20>=\x20threshold,\x20Rate=8000/2000\x20split','caller-specified\x20guard:\x20caller\x20selects\x20the\x20matching\x20Allocator\x20based\x20on\x20order\x20amount;\x20allocator\x20order\x20is\x20irrelevant','Guard\x20queries\x20order.amount\x20(query\x201561)'],'dependencies':['Service','Treasury','Guard','Order','Payment'],'key_constraints':['Guard\x20conditions\x20must\x20be\x20mutually\x20exclusive\x20(R-A-4-02\x20design\x20clarity)','Caller\x20must\x20select\x20correct\x20guard\x20based\x20on\x20order.amount\x20(no\x20auto-fallback)'],'recommended_templates':['T-A-05']},{'id':'allocation_dynamic_recipient','name':'Multi-role\x20split\x20with\x20dynamic\x20recipient\x20(GuardIdentifier)','trigger_source':'service_order_allocators','distribution_strategy':'dynamic_recipient','coin_type_note':'Passport\x20table\x20must\x20contain\x20address-typed\x20entry\x20at\x20the\x20referenced\x20identifier','typical_allocator_count':0x1,'sharing_who_types':['Entity','GuardIdentifier'],'modes_used':['Rate'],'guard_requirement':'required','non_zero_threshold':![],'uses_max':![],'common_patterns':['Single\x20Allocator,\x203\x20Rate\x20sharing\x20items','sharing[0]:\x20Rate=8000,\x20who=Entity(merchant_treasury)','sharing[1]:\x20Rate=1000,\x20who=Entity(platform_treasury)','sharing[2]:\x20Rate=1000,\x20who=GuardIdentifier(0)\x20—\x20resolves\x20from\x20Passport\x20table','Customer\x20submits\x20Passport\x20with\x20referrer\x20address\x20at\x20identifier=0'],'dependencies':['Service','Treasury','Guard','Passport','Order','Payment'],'key_constraints':['F-A-13:\x20Passport\x20table[identifier]\x20must\x20be\x20address\x20type\x20(else\x20ERECIPIENT_IDENTIFIER_NOT_ADDRESS)','Guard\x20must\x20verify\x20Passport\x20completeness','Customer\x20order\x20must\x20include\x20Passport\x20with\x20referrer\x20address'],'recommended_templates':['T-A-06']},{'id':'allocation_arbitration_fees','name':'Arbitration\x20fees\x20split\x20(arbitrator\x20/\x20platform)','trigger_source':'arbitration_fees','distribution_strategy':'pure_rate','coin_type_note':'Coin<T>\x20must\x20match\x20Arbitration\x27s\x20fee\x20Coin\x20type','typical_allocator_count':0x1,'sharing_who_types':['Entity'],'modes_used':['Rate'],'guard_requirement':'required','non_zero_threshold':![],'uses_max':![],'common_patterns':['Triggered\x20by\x20Arbitration.fees_alloc\x20(permission\x20365)\x20or\x20fees_alloc_with_passport','Single\x20Allocator,\x202\x20Rate\x20sharing\x20items:\x208000\x20arbitrator\x20/\x202000\x20platform','payment_info\x20reuses\x20Arbitration\x27s\x20payment_info','Caller\x20must\x20hold\x20ARBITRATION_FEES_ALLOC=365\x20permission'],'dependencies':['Arbitration','Treasury','Guard','Payment'],'key_constraints':['Independent\x20from\x20Service-order\x20Allocation','Requires\x20ARBITRATION_FEES_ALLOC=365\x20permission'],'recommended_templates':['T-A-08']},{'id':'allocation_refund_to_order','name':'Refund\x20Allocator\x20(100%\x20to\x20Order\x20object)','trigger_source':'service_order_allocators','distribution_strategy':'refund_to_order','coin_type_note':'who=Entity\x20must\x20be\x20the\x20Order\x20object\x20address\x20(NOT\x20a\x20personal\x20wallet)','typical_allocator_count':0x1,'sharing_who_types':['Entity'],'modes_used':['Rate'],'guard_requirement':'required','non_zero_threshold':![],'uses_max':![],'common_patterns':['Single\x20Allocator,\x201\x20Rate=10000\x20sharing','who=Entity(order_address)\x20—\x20funds\x20flow\x20back\x20to\x20Order,\x20not\x20personal\x20wallet','Guard\x20verifies\x20customer\x20refund\x20request\x20and\x20eligibility','Customer-side\x20risk\x20assessment\x20adds\x208-point\x20weight\x20(onchain_topology\x20graph\x20evaluation)'],'dependencies':['Service','Guard','Order','Payment'],'key_constraints':['who=Entity\x20MUST\x20be\x20Order\x20object\x20address\x20(not\x20personal\x20address)','Customer\x20due-diligence\x20rewards\x20this\x20configuration\x20(8-point\x20weight)','Refund\x20funds\x20return\x20to\x20Order\x20for\x20downstream\x20handling'],'recommended_templates':['T-A-07']},{'id':'allocation_max_capped_retain','name':'Max-capped\x20allocation\x20(retain\x20residual\x20balance)','trigger_source':'service_order_allocators','distribution_strategy':'max_capped','coin_type_note':'max\x20field\x20uses\x20Coin<T>\x20smallest\x20unit','typical_allocator_count':0x1,'sharing_who_types':['Entity'],'modes_used':['Amount','Rate'],'guard_requirement':'required','non_zero_threshold':!![],'uses_max':!![],'common_patterns':['Single\x20Allocator\x20with\x20max\x20field\x20set','max\x20triple\x20role:\x20Amount\x20cap\x20+\x20Rate\x20base\x20+\x20Surplus\x20cap','Amount\x20sharing\x20consumes\x20fix;\x20Rate\x20sharing\x20uses\x20(max\x20-\x20fix)\x20as\x20base','Residual\x20balance\x20remains\x20in\x20Allocation\x20for\x20subsequent\x20alloc()\x20calls'],'dependencies':['Service','Treasury','Guard','Order','Payment'],'key_constraints':['F-A-08:\x20Amount\x20sum\x20<=\x20max\x20(EAMOUNT_EXCEEDS_MAX)','max\x20-\x20fix\x20becomes\x20Rate\x20base\x20(NOT\x20balance\x20-\x20fix)','Residual\x20balance\x20may\x20be\x20claimed\x20by\x20re-triggering\x20alloc()'],'recommended_templates':[]},{'id':'allocation_multi_node_trigger','name':'Multi-Machine-node\x20triggered\x20allocation\x20(Complete\x20/\x20Refund\x20/\x20Lost)','trigger_source':'service_order_allocators','distribution_strategy':'multi_node_trigger','coin_type_note':'All\x20Allocators\x20share\x20the\x20same\x20Allocation\x27s\x20Coin<T>','typical_allocator_count':0x3,'sharing_who_types':['Entity'],'modes_used':['Rate'],'guard_requirement':'multiple_unique','non_zero_threshold':![],'uses_max':![],'common_patterns':['3\x20Allocators\x20mapped\x20to\x20Machine\x20terminal\x20nodes\x20(Complete/Refund/Lost)','Each\x20Allocator\x27s\x20Guard\x20verifies\x20progress.current_node\x20==\x20<node_name>','Mutually\x20exclusive\x20Guard\x20conditions\x20(only\x20one\x20terminal\x20node\x20active\x20at\x20a\x20time)','Machine.required_allocators[]\x20describes\x20each\x20trigger_node\x20mapping'],'dependencies':['Service','Treasury','Guard','Order','Progress','Machine','Payment'],'key_constraints':['Guard\x20conditions\x20must\x20be\x20mutually\x20exclusive','Sequence-sensitive:\x20business-flow\x20order','Machine.required_allocators[trigger_node]\x20must\x20map\x20to\x20Allocator\x20indices'],'recommended_templates':[]},{'id':'allocation_standalone_periodic_split','name':'Standalone\x20periodic\x20split\x20(investment\x20dividends\x20/\x20shared\x20income)','trigger_source':'standalone','distribution_strategy':'periodic_split','coin_type_note':'Coin<T>\x20must\x20match\x20the\x20asset\x20being\x20distributed\x20(e.g.\x20profit\x20token)','typical_allocator_count':0x1,'sharing_who_types':['Entity'],'modes_used':['Rate'],'guard_requirement':'required','non_zero_threshold':![],'uses_max':![],'common_patterns':['Single\x20Allocator,\x20N\x20Rate\x20sharing\x20items,\x20sum(rates)\x20===\x2010000','Each\x20sharing.who=Entity\x20points\x20to\x20a\x20beneficiary\x20wallet\x20(not\x20Treasury)','Guard\x20verifies\x20time-based\x20trigger\x20(e.g.\x20context(Clock).timestamp\x20>=\x20next_release)\x20or\x20signer\x20authorization','User\x20calls\x20receive()\x20to\x20deposit\x20funds,\x20then\x20alloc()\x20to\x20trigger\x20distribution','No\x20Service/Order/Progress/Machine\x20context\x20required'],'dependencies':['Treasury','Guard','Payment'],'key_constraints':['F-A-05:\x20sum(rates)\x20===\x2010000\x20(pure\x20Rate\x20mode)','R-A-3-04:\x20standalone\x20mode\x20has\x20no\x20Service-layer\x20access\x20control\x20—\x20Guard\x20+\x20Passport\x20MUST\x20be\x20sufficient','Caller\x20is\x20fully\x20responsible\x20for\x20receive\x20→\x20alloc\x20lifecycle\x20(no\x20auto-trigger)','Guard\x20should\x20bind\x20Signer\x20to\x20prevent\x20unauthorized\x20alloc()\x20calls'],'recommended_templates':['T-A-09']},{'id':'allocation_standalone_vesting','name':'Standalone\x20vesting\x20release\x20(time-locked\x20multi-stage\x20unlock)','trigger_source':'standalone','distribution_strategy':'time_locked_vesting','coin_type_note':'Coin<T>\x20must\x20match\x20the\x20vested\x20asset\x20(e.g.\x20locked\x20team\x20tokens)','typical_allocator_count':0x3,'sharing_who_types':['Entity'],'modes_used':['Amount','Rate','Surplus'],'guard_requirement':'multiple_unique','non_zero_threshold':!![],'uses_max':!![],'common_patterns':['N\x20Allocators,\x20each\x20mapped\x20to\x20a\x20vesting\x20stage\x20(e.g.\x2025%\x20at\x20month\x2012,\x2025%\x20at\x20month\x2024,\x2050%\x20surplus\x20at\x20month\x2036)','Each\x20Allocator\x27s\x20Guard\x20verifies\x20context(Clock).timestamp\x20>=\x20stage_unlock_time','Amount\x20sharing\x20per\x20stage\x20with\x20max\x20field\x20capping\x20the\x20cumulative\x20release','Final\x20Allocator\x20uses\x20Surplus\x20to\x20drain\x20remaining\x20balance\x20after\x20last\x20vesting\x20stage','Mutually\x20exclusive\x20Guard\x20conditions\x20(only\x20one\x20stage\x20active\x20at\x20a\x20time,\x20based\x20on\x20timestamp)','User\x20calls\x20receive()\x20to\x20deposit\x20locked\x20tokens,\x20then\x20alloc()\x20at\x20each\x20vesting\x20milestone'],'dependencies':['Treasury','Guard','Passport','Payment'],'key_constraints':['F-A-04:\x20at\x20most\x201\x20Surplus\x20per\x20Allocator\x20(final\x20stage\x20uses\x20Surplus\x20to\x20drain\x20remainder)','F-A-08:\x20Amount\x20sum\x20<=\x20max\x20(EAMOUNT_EXCEEDS_MAX)','R-A-3-04:\x20standalone\x20mode\x20has\x20no\x20Service-layer\x20access\x20control\x20—\x20Guard\x20time-lock\x20MUST\x20be\x20enforced','Guard\x20conditions\x20must\x20be\x20mutually\x20exclusive\x20by\x20timestamp\x20(R-A-4-02)','Caller\x20must\x20wait\x20for\x20time-lock\x20expiry\x20before\x20alloc()\x20succeeds;\x20otherwise\x20alloc()\x20silently\x20returns\x20(R-A-4-01)'],'recommended_templates':['T-A-10']}];export const ALLOCATION_LEDGER_VERSION='1.0.0';export function getScenesByTriggerSource(a){return ALLOCATION_SCENES['filter'](b=>b['trigger_source']===a);}export function getScenesByMode(a){return ALLOCATION_SCENES['filter'](b=>b['modes_used']['includes'](a));}export function getScenesByStrategy(a){return ALLOCATION_SCENES['filter'](b=>b['distribution_strategy']===a);}export function findSceneById(a){return ALLOCATION_SCENES['find'](b=>b['id']===a);}export function inferSceneFromIntent(a){const b=a['toLowerCase']();if(b['includes']('arbitration')||b['includes']('fees_alloc'))return findSceneById('allocation_arbitration_fees');if(b['includes']('standalone')||b['includes']('periodic\x20split')||b['includes']('investment\x20dividend')||b['includes']('shared\x20income')||b['includes']('dividend'))return findSceneById('allocation_standalone_periodic_split');if(b['includes']('vesting')||b['includes']('time-lock')||b['includes']('unlock\x20period')||b['includes']('locked\x20release')||b['includes']('token\x20unlock'))return findSceneById('allocation_standalone_vesting');if(b['includes']('refund')){if(b['includes']('order')||b['includes']('100%'))return findSceneById('allocation_refund_to_order');if(b['includes']('surplus')||b['includes']('merchant'))return findSceneById('allocation_refund_first_surplus_to_merchant');}if(b['includes']('alternative')||b['includes']('priority')||b['includes']('treasury')&&b['includes']('personal'))return findSceneById('allocation_treasury_personal_alternatives');if(b['includes']('tiered')||b['includes']('threshold\x20switch'))return findSceneById('allocation_tiered_by_order_amount');if(b['includes']('dynamic\x20recipient')||b['includes']('referrer')||b['includes']('guardidentifier'))return findSceneById('allocation_dynamic_recipient');if(b['includes']('retain')||b['includes']('max'))return findSceneById('allocation_max_capped_retain');if(b['includes']('multi-node')||b['includes']('multi\x20machine')||b['includes']('multi_node'))return findSceneById('allocation_multi_node_trigger');const c=(a['match'](/%/g)||[])['length'];if(c<=0x1)return findSceneById('allocation_merchant_full_payment');if(c>=0x2)return findSceneById('allocation_standard_three_way_split');return undefined;}export function getAllScenes(){return[...ALLOCATION_SCENES];}export function getScenesCount(){return ALLOCATION_SCENES['length'];}export function allocationModeToNumber(a){switch(a){case'Amount':return ALLOCATION_MODE_AMOUNT;case'Rate':return ALLOCATION_MODE_RATE;case'Surplus':return ALLOCATION_MODE_SURPLUS;}}export function allocationModeFromNumber(a){switch(a){case ALLOCATION_MODE_AMOUNT:return'Amount';case ALLOCATION_MODE_RATE:return'Rate';case ALLOCATION_MODE_SURPLUS:return'Surplus';default:throw new Error('Invalid\x20AllocationMode\x20number:\x20'+a);}}export function getRecipientType(a){if('GuardIdentifier'in a)return'GuardIdentifier';if('Entity'in a)return'Entity';return'Signer';}export function isSignerRecipient(a){return'Signer'in a;}export function isEntityRecipient(a){return'Entity'in a;}export function isGuardIdentifierRecipient(a){return'GuardIdentifier'in a;}export function getErrorName(a){for(const [b,d]of Object['entries'](ALLOCATION_ERROR_CODES)){if(d===a)return b;}return undefined;}export function getErrorDescription(a){const b={0x1:'GuardIdentifier\x20resolved\x20value\x20is\x20not\x20an\x20address\x20type',0x2:'Allocator\x20count\x20exceeds\x20MAX_ALLOCATOR_COUNT\x20(100)',0x3:'No\x20Allocator\x20in\x20the\x20allocators\x20vector',0x4:'Pure\x20Rate\x20mode\x20sum\x20!=\x2010000\x20(no\x20Surplus\x20to\x20absorb\x20remainder)',0x5:'Multiple\x20Surplus\x20sharing\x20in\x20a\x20single\x20Allocator',0x6:'Rate\x20+\x20Surplus\x20sum\x20>\x2010000',0x7:'balance\x20<\x20threshold\x20(insufficient\x20balance\x20to\x20trigger\x20alloc)',0x8:'allocators.allocators\x20is\x20empty',0x9:'payment_info\x20is\x20None\x20when\x20alloc()\x20is\x20called',0xa:'sharing\x20count\x20exceeds\x20MAX_SHARING_COUNT\x20(100)',0xb:'sharing\x20mode\x20is\x20not\x200\x20(Amount)\x20/\x201\x20(Rate)\x20/\x202\x20(Surplus)',0xc:'Amount\x20sum\x20(fix)\x20<\x20threshold',0xd:'Amount\x20sum\x20(fix)\x20>\x20max',0xe:'distribution\x20computes\x20to\x20zero\x20while\x20the\x20pool\x20still\x20holds\x20funds\x20(or\x20balance\x20is\x200)',0xf:'GuardIdentifier\x20recipient\x20address\x20!=\x20payment_info.for_object\x20anchor\x20(abort\x20fires\x20only\x20when\x20a\x20for_object\x20binding\x20is\x20declared)'};return b[a];}
|
|
@@ -62,8 +62,6 @@ export interface AllocationRiskCheckContext {
|
|
|
62
62
|
}
|
|
63
63
|
export declare const ALLOCATION_RISK_VERSION = "1.1.0";
|
|
64
64
|
export declare function getAllRiskRules(): AllocationRiskRule[];
|
|
65
|
-
export declare function getRiskRulesCount(): number;
|
|
66
|
-
export declare function getRiskRulesByCategory(category: AllocationRiskCategory): AllocationRiskRule[];
|
|
67
65
|
export interface AllocationRiskAssessment {
|
|
68
66
|
summary: string;
|
|
69
67
|
scene?: AllocationScene;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{MAX_ALLOCATOR_COUNT,RATE_TOTAL_FULL,ALLOCATION_ERROR_CODES}from'./allocation-ledger.js';import{isUnboundSignerTheft,canonicalDoctrine}from'./recipient-constraint.js';const R_A_1_01={'id':'R-A-1-01','category':'structural','trigger':'allocators\x20is\x20empty\x20or\x20sharing\x20arrays\x20are\x20empty','check':a=>{if(!a['allocators_config'])return null;const b=a['allocators_config']['allocators'];if(b['length']===0x0)return{'id':'R-A-1-01','level':'CRITICAL','category':'structural','title':'Empty\x20allocators\x20—\x20funds\x20will\x20be\x20permanently\x20locked','description':'Allocation\x20has\x20empty\x20allocators.allocators.\x20Service\x20publish\x20with\x20empty\x20order_allocators\x20causes\x20order\x20funds\x20to\x20be\x20permanently\x20locked\x20in\x20the\x20Allocation\x20object.','affected_stakeholders':['owner','service_provider','system'],'scenario':'Service\x20published\x20without\x20configuring\x20any\x20Allocator','mitigation':'Configure\x20at\x20least\x201\x20Allocator.\x20If\x20no\x20distribution\x20is\x20needed\x20yet,\x20use\x20a\x20single\x20Allocator\x20with\x20Rate=10000\x20to\x20the\x20merchant\x20address.','evidence':'allocators.length=0','related_move_error':'EALLOCATORS_EMPTY\x20(8)\x20/\x20ENO_ALLOCATOR\x20(3)','auto_fixable':![]};for(let c=0x0;c<b['length'];c++){if(b[c]['sharing']['length']===0x0)return{'id':'R-A-1-01','level':'CRITICAL','category':'structural','title':'Allocator\x20'+c+'\x20has\x20empty\x20sharing\x20—\x20will\x20never\x20distribute','description':'Allocator\x20at\x20index\x20'+c+'\x20(guard='+b[c]['guard']+')\x20has\x20empty\x20sharing\x20array.\x20Even\x20if\x20its\x20Guard\x20passes\x20verification,\x20no\x20funds\x20will\x20be\x20distributed.','affected_stakeholders':['owner','recipient'],'scenario':'Allocator\x20with\x20empty\x20sharing\x20vector','mitigation':'Add\x20at\x20least\x201\x20sharing\x20entry\x20to\x20Allocator\x20'+c,'evidence':'allocator['+c+'].sharing.length=0','related_move_error':'ENO_ALLOCATOR\x20(3)','auto_fixable':![]};}return null;}},R_A_1_02={'id':'R-A-1-02','category':'structural','trigger':'Pure\x20Rate\x20mode\x20sum\x20!=\x2010000\x20or\x20Rate+Surplus\x20sum\x20>\x2010000','check':b=>{if(!b['allocators_config'])return null;for(let c=0x0;c<b['allocators_config']['allocators']['length'];c++){const d=b['allocators_config']['allocators'][c],e=d['sharing']['filter'](g=>g['mode']==='Rate')['reduce']((g,h)=>g+Number(h['sharing']),0x0),f=d['sharing']['some'](g=>g['mode']==='Surplus');if(!f&&e>0x0&&e!==RATE_TOTAL_FULL)return{'id':'R-A-1-02','level':'HIGH','category':'structural','title':'Pure\x20Rate\x20mode\x20sum\x20'+e+'\x20!=\x20'+RATE_TOTAL_FULL,'description':'Allocator\x20'+c+'\x20(guard='+d['guard']+')\x20uses\x20pure\x20Rate\x20mode\x20(no\x20Surplus),\x20but\x20sum(rates)='+e+'\x20≠\x20'+RATE_TOTAL_FULL+'.\x20Funds\x20will\x20be\x20permanently\x20locked\x20(if\x20sum<10000)\x20or\x20Move\x20will\x20abort\x20with\x20ERATE_NOT_10000\x20(if\x20sum\x20!=\x2010000\x20exactly).','affected_stakeholders':['owner','recipient'],'scenario':'Misconfigured\x20rate\x20proportions','mitigation':'Adjust\x20sharing.sharing\x20values\x20so\x20sum(rates)='+RATE_TOTAL_FULL+',\x20OR\x20add\x201\x20Surplus\x20sharing\x20to\x20absorb\x20the\x20remainder.','evidence':'rateSum='+e+',\x20expected='+RATE_TOTAL_FULL,'related_move_error':'ERATE_NOT_10000\x20(4)','auto_fixable':!![]};if(f&&e>RATE_TOTAL_FULL)return{'id':'R-A-1-02','level':'HIGH','category':'structural','title':'Rate\x20+\x20Surplus\x20sum\x20'+e+'\x20>\x20'+RATE_TOTAL_FULL,'description':'Allocator\x20'+c+'\x20(guard='+d['guard']+')\x20uses\x20Rate+Surplus\x20mode,\x20but\x20sum(rates)='+e+'\x20>\x20'+RATE_TOTAL_FULL+'.\x20Move\x20will\x20abort\x20with\x20ERATE_EXCEEDS_10000.','affected_stakeholders':['owner'],'scenario':'Rate\x20percentages\x20exceed\x20100%\x20before\x20Surplus','mitigation':'Reduce\x20sum(rates)\x20to\x20≤\x20'+RATE_TOTAL_FULL+'.','evidence':'rateSum='+e+',\x20max='+RATE_TOTAL_FULL,'related_move_error':'ERATE_EXCEEDS_10000\x20(6)','auto_fixable':!![]};}return null;}},R_A_1_03={'id':'R-A-1-03','category':'structural','trigger':'Multiple\x20Surplus\x20sharing\x20in\x20one\x20Allocator,\x20or\x20Amount\x20sum\x20violates\x20threshold/max','check':b=>{if(!b['allocators_config'])return null;for(let c=0x0;c<b['allocators_config']['allocators']['length'];c++){const d=b['allocators_config']['allocators'][c],e=d['sharing']['filter'](h=>h['mode']==='Surplus')['length'];if(e>0x1)return{'id':'R-A-1-03','level':'MEDIUM','category':'structural','title':'Allocator\x20'+c+'\x20has\x20'+e+'\x20Surplus\x20sharing\x20—\x20at\x20most\x201\x20allowed','description':'Allocator\x20'+c+'\x20(guard='+d['guard']+')\x20has\x20'+e+'\x20Surplus\x20sharing\x20entries.\x20Move\x20will\x20abort\x20with\x20EMULTIPLE_SURPLUS\x20at\x20alloc()\x20time.','affected_stakeholders':['owner'],'scenario':'Multiple\x20Surplus\x20entries\x20in\x20one\x20Allocator','mitigation':'Keep\x20at\x20most\x201\x20Surplus\x20per\x20Allocator.\x20Use\x20Rate\x20mode\x20for\x20multi-party\x20remainder\x20distribution.','evidence':'surplusCount='+e,'related_move_error':'EMULTIPLE_SURPLUS\x20(5)','auto_fixable':!![]};const f=d['sharing']['filter'](h=>h['mode']==='Amount')['reduce']((h,j)=>h+Number(j['sharing']),0x0),g=Number(b['allocators_config']['threshold']);if(f>0x0&&f<g)return{'id':'R-A-1-03','level':'HIGH','category':'structural','title':'Amount\x20sum\x20'+f+'\x20<\x20threshold\x20'+g,'description':'Allocator\x20'+c+'\x20pure\x20Amount\x20mode\x20fix='+f+'\x20<\x20threshold='+g+'.\x20Move\x20will\x20abort\x20with\x20EAMOUNT_BELOW_THRESHOLD\x20at\x20allocator_add\x20time.','affected_stakeholders':['owner'],'scenario':'Amount\x20sum\x20insufficient\x20to\x20trigger\x20alloc','mitigation':'Either\x20lower\x20threshold\x20to\x20<=\x20fix,\x20or\x20increase\x20Amount\x20sharing\x20values.','evidence':'fix='+f+',\x20threshold='+g,'related_move_error':'EAMOUNT_BELOW_THRESHOLD\x20(12)','auto_fixable':![]};if(d['max']!=null&&f>Number(d['max']))return{'id':'R-A-1-03','level':'MEDIUM','category':'structural','title':'Amount\x20sum\x20'+f+'\x20>\x20max\x20'+Number(d['max']),'description':'Allocator\x20'+c+'\x20Amount\x20sum\x20exceeds\x20max.\x20Move\x20will\x20abort\x20with\x20EAMOUNT_EXCEEDS_MAX.','affected_stakeholders':['owner'],'scenario':'Amount\x20sum\x20exceeds\x20max\x20cap','mitigation':'Increase\x20max\x20or\x20reduce\x20Amount\x20sharing\x20values.','evidence':'fix='+f+',\x20max='+Number(d['max']),'related_move_error':'EAMOUNT_EXCEEDS_MAX\x20(13)','auto_fixable':!![]};}return null;}},R_A_2_01={'id':'R-A-2-01','category':'semantic','trigger':'sharing.who=Signer\x20without\x20Guard\x20Signer\x20binding\x20—\x20fund\x20theft\x20risk','check':b=>{if(!b['allocators_config'])return null;for(let c=0x0;c<b['allocators_config']['allocators']['length'];c++){const d=b['allocators_config']['allocators'][c],e=d['sharing']['some'](g=>'Signer'in g['who']),f=b['guard_signer_bindings']?.[d['guard']]===!![];if(isUnboundSignerTheft({'recipient_is_signer':e,'caller_identity_constrained':f})){const g=canonicalDoctrine('RC-FIND-01');return{'id':'R-A-2-01','level':g['severity'],'category':'semantic','title':g['title'],'description':'Allocator\x20'+c+'\x20(guard='+d['guard']+')\x20has\x20sharing.who=Signer,\x20but\x20the\x20Guard\x20does\x20not\x20bind\x20context(Signer)==authorized.\x20Anyone\x20who\x20passes\x20the\x20Guard\x20can\x20steal\x20100%\x20of\x20funds.\x20(Canonical\x20finding\x20RC-FIND-01,\x20linked\x20to\x20guard-risk.ts\x20R-C3-06.)','affected_stakeholders':['owner','recipient','service_provider'],'scenario':'Signer\x20recipient\x20without\x20Guard\x20Signer\x20authentication','mitigation':g['mitigation'],'evidence':'guard='+d['guard']+',\x20guardSignerBound='+f,'related_guard_risk':'R-C3-06','auto_fixable':![]};}}return null;}},R_A_2_02={'id':'R-A-2-02','category':'semantic','trigger':'sharing.who=GuardIdentifier\x20but\x20Passport\x20table\x20entry\x20is\x20not\x20address\x20type','check':b=>{if(!b['allocators_config'])return null;if(!b['passport_identifier_types'])return null;for(let c=0x0;c<b['allocators_config']['allocators']['length'];c++){const d=b['allocators_config']['allocators'][c],e=d['sharing']['find'](h=>'GuardIdentifier'in h['who']);if(!e)continue;const f=e['who']['GuardIdentifier'],g=b['passport_identifier_types'][f];if(g!==undefined&&g!=='address')return{'id':'R-A-2-02','level':'MEDIUM','category':'semantic','title':'GuardIdentifier\x20'+f+'\x20resolves\x20to\x20non-address\x20type\x20('+g+')','description':'Allocator\x20'+c+'\x20uses\x20sharing.who=GuardIdentifier('+f+'),\x20but\x20Passport\x20table['+f+']\x20is\x20of\x20type\x20'+g+',\x20not\x20address.\x20Move\x20will\x20abort\x20with\x20ERECIPIENT_IDENTIFIER_NOT_ADDRESS\x20at\x20alloc()\x20time.','affected_stakeholders':['recipient'],'scenario':'Passport\x20table\x20entry\x20type\x20mismatch','mitigation':'Ensure\x20Passport\x20table['+f+']\x20is\x20address-typed,\x20OR\x20use\x20sharing.who=Entity\x20with\x20a\x20static\x20address.','evidence':'identifier='+f+',\x20type='+g,'related_move_error':'ERECIPIENT_IDENTIFIER_NOT_ADDRESS\x20(1)','auto_fixable':![]};}return null;}},R_A_2_03={'id':'R-A-2-03','category':'semantic','trigger':'Duplicate\x20Guard\x20addresses\x20in\x20allocators\x20(alloc_by_guard\x20address\x20match\x20only\x20hits\x20the\x20first\x20one)','check':a=>{if(!a['allocators_config'])return null;const b=a['allocators_config']['allocators']['map'](d=>d['guard']),c=new Set(b);if(c['size']!==b['length']){const d=b['filter']((e,f)=>b['indexOf'](e)!==f);return{'id':'R-A-2-03','level':'MEDIUM','category':'semantic','title':'Duplicate\x20Guard\x20addresses\x20in\x20allocators','description':'Multiple\x20Allocators\x20reference\x20the\x20same\x20Guard\x20object:\x20'+d['join'](',\x20')+'.\x20alloc_by_guard\x20locates\x20the\x20Allocator\x20by\x20iterating\x20guard\x20addresses;\x20duplicate\x20addresses\x20only\x20match\x20the\x20first\x20one,\x20so\x20subsequent\x20duplicate\x20Allocators\x20are\x20unreachable\x20(dead\x20code).','affected_stakeholders':['owner','allocator'],'scenario':'Reusing\x20same\x20Guard\x20object\x20across\x20multiple\x20Allocators','mitigation':'Create\x20independent\x20Guard\x20objects\x20for\x20each\x20Allocator\x20(they\x20may\x20share\x20root/table\x20but\x20must\x20differ\x20in\x20description).','evidence':'total='+b['length']+',\x20unique='+c['size']+',\x20dupes='+d['join'](','),'auto_fixable':!![]};}return null;}},R_A_2_04={'id':'R-A-2-04','category':'semantic','trigger':'GuardIdentifier\x20recipients\x20combined\x20with\x20payment_info.for_object\x20anchor\x20state\x20(Some\x20=\x20enforced,\x20None\x20=\x20absent)','check':a=>{if(!a['allocators_config'])return null;if(a['payment_info_for_object']===undefined)return null;const b=a['allocators_config']['allocators']['some'](d=>d['sharing']['some'](e=>'GuardIdentifier'in e['who']));if(!b)return null;const c=a['payment_info_for_object'];if(c)return{'id':'R-A-2-04','level':'MEDIUM','category':'semantic','title':'payment_info.for_object\x20anchor\x20is\x20ENFORCED\x20at\x20alloc()','description':'payment_info.for_object\x20is\x20set\x20to\x20'+c+'.\x20At\x20alloc(),\x20every\x20Recipient::GuardIdentifier\x20submission\x20must\x20equal\x20this\x20address\x20or\x20the\x20whole\x20tx\x20aborts\x20with\x20ERECIPIENT_NOT_FOR_OBJECT\x20(15)\x20—\x20a\x20wrong\x20anchor\x20or\x20a\x20guard\x20whose\x20passport\x20submits\x20a\x20different\x20address\x20makes\x20alloc()\x20permanently\x20fail\x20(payment_info\x20is\x20immutable\x20after\x20create).\x20Verify\x20the\x20anchor\x20matches\x20the\x20intended\x20recipient\x20flow.','affected_stakeholders':['owner','recipient'],'scenario':'Allocation\x20created\x20with\x20a\x20declared\x20for_object\x20binding\x20and\x20GuardIdentifier\x20recipients','mitigation':'Before\x20create:\x20confirm\x20for_object\x20is\x20the\x20object\x20the\x20GuardIdentifier\x20submissions\x20will\x20resolve\x20to\x20(the\x20guard\x27s\x20passport\x20must\x20submit\x20exactly\x20this\x20address\x20for\x20the\x20recipient\x20identifier).\x20Entity/Signer\x20sharing\x20lines\x20are\x20unaffected\x20by\x20the\x20anchor.','evidence':'for_object='+c,'related_move_error':'ERECIPIENT_NOT_FOR_OBJECT\x20(15)','auto_fixable':![]};return{'id':'R-A-2-04','level':'MEDIUM','category':'semantic','title':'payment_info.for_object\x20=\x20None\x20—\x20GuardIdentifier\x20destination\x20has\x20no\x20on-chain\x20anchor','description':'payment_info.for_object\x20is\x20not\x20set:\x20alloc()\x20enforces\x20NO\x20recipient\x20binding\x20for\x20Recipient::GuardIdentifier\x20lines.\x20Whoever\x20builds\x20the\x20passport\x20chooses\x20the\x20payout\x20address;\x20nothing\x20on-chain\x20constrains\x20it.\x20This\x20is\x20legal\x20by\x20design\x20(Allocation\x20is\x20a\x20generic\x20component,\x20the\x20anchor\x20is\x20opt-in),\x20but\x20it\x20means\x20recipient\x20routing\x20is\x20trust-on-creator.','affected_stakeholders':['owner','recipient'],'scenario':'Allocation\x20created\x20without\x20a\x20for_object\x20anchor\x20while\x20using\x20GuardIdentifier\x20recipients','mitigation':'If\x20enforced\x20routing\x20is\x20desired,\x20set\x20payment_info.for_object\x20to\x20the\x20intended\x20recipient\x20anchor\x20at\x20create\x20(it\x20becomes\x20mechanism-enforced:\x20mismatch\x20aborts\x20with\x20code\x2015).\x20If\x20no\x20anchor\x20is\x20intended,\x20document\x20that\x20the\x20recipient\x20is\x20the\x20passport\x20builder\x27s\x20choice\x20and\x20constrain\x20it\x20in\x20the\x20guard\x20expression\x20instead.','evidence':'for_object=None','related_move_error':'ERECIPIENT_NOT_FOR_OBJECT\x20(15,\x20only\x20fires\x20when\x20a\x20binding\x20is\x20declared)','auto_fixable':![]};}},R_A_3_01={'id':'R-A-3-01','category':'authority','trigger':'Service\x20already\x20published\x20—\x20order_allocators\x20is\x20immutable','check':a=>{if(!a['host_service_published'])return null;return{'id':'R-A-3-01','level':'HIGH','category':'authority','title':'order_allocators\x20immutable\x20after\x20Service\x20publish','description':'Service\x20is\x20already\x20published.\x20order_allocators\x20field\x20is\x20now\x20immutable\x20(safety-rules.ts:170-174).\x20Any\x20configuration\x20error\x20(wrong\x20Guard,\x20wrong\x20sharing\x20proportion,\x20wrong\x20Entity\x20address)\x20will\x20affect\x20ALL\x20subsequent\x20orders\x20and\x20cannot\x20be\x20fixed\x20without\x20creating\x20a\x20new\x20Service.','affected_stakeholders':['owner','service_provider'],'scenario':'Attempting\x20to\x20modify\x20order_allocators\x20after\x20Service\x20publish','mitigation':'1)\x20Verify\x20the\x20configuration\x20is\x20correct\x20before\x20publish.\x202)\x20Use\x20deploy-scanner\x20pre-publish\x20validation.\x203)\x20If\x20already\x20published\x20with\x20errors,\x20create\x20a\x20new\x20Service\x20to\x20replace.','evidence':'host_service_published='+a['host_service_published'],'auto_fixable':![]};}},R_A_3_02={'id':'R-A-3-02','category':'authority','trigger':'Treasury\x20Permission\x20inconsistent\x20with\x20Service\x20Permission','check':a=>{if(!a['allocators_config'])return null;if(!a['referenced_treasuries_permissions'])return null;if(!a['host_service_permission'])return null;for(const b of a['allocators_config']['allocators']){for(const c of b['sharing']){if(!('Entity'in c['who']))continue;const d=c['who']['Entity'],e=a['referenced_treasuries_permissions'][d];if(e&&e!==a['host_service_permission'])return{'id':'R-A-3-02','level':'MEDIUM','category':'authority','title':'Treasury\x20Permission\x20inconsistent\x20with\x20Service\x20Permission','description':'sharing.who=Entity\x20points\x20to\x20Treasury\x20'+d+'\x20whose\x20Permission\x20('+e+')\x20differs\x20from\x20Service\x20Permission\x20('+a['host_service_permission']+').\x20Two\x20different\x20permission\x20organizations\x20control\x20fund\x20flow,\x20creating\x20potential\x20authority\x20conflicts.','affected_stakeholders':['owner','service_provider'],'scenario':'Treasury\x20owned\x20by\x20different\x20party\x20than\x20Service','mitigation':'Create\x20Treasury\x20with\x20the\x20same\x20Permission\x20object\x20as\x20the\x20Service,\x20OR\x20ensure\x20both\x20are\x20owned\x20by\x20the\x20same\x20address.','evidence':'treasury='+d+',\x20treasuryPerm='+e+',\x20servicePerm='+a['host_service_permission'],'auto_fixable':![]};}}return null;}},R_A_3_03={'id':'R-A-3-03','category':'authority','trigger':'No\x20ALLOCATION_*\x20builtin\x20permission\x20index\x20—\x20Allocation\x20has\x20no\x20independent\x20access\x20control','check':a=>{if(a['operation_type']!=='create')return null;const b=a['trigger_source']==='standalone';return{'id':'R-A-3-03','level':'LOW','category':'authority','title':'Allocation\x20has\x20no\x20builtin\x20permission\x20index\x20(passive-object\x20design)','description':b?'BuiltinPermissionIndex\x20has\x20no\x20ALLOCATION_*\x20entries.\x20Allocation\x27s\x20access\x20control\x20is\x20fully\x20delegated\x20to\x20Guard\x20+\x20Passport.\x20In\x20standalone\x20mode\x20(trigger_source=standalone),\x20there\x20is\x20no\x20Service/Arbitration\x20layer\x20to\x20enforce\x20caller\x20authorization\x20—\x20Guard\x20MUST\x20provide\x20sufficient\x20access\x20control\x20(see\x20R-A-3-04).\x20This\x20is\x20the\x20\x27passive\x20object\x27\x20design\x20philosophy,\x20not\x20a\x20defect,\x20but\x20standalone\x20mode\x20shifts\x20full\x20responsibility\x20to\x20the\x20Guard\x20configuration.':'BuiltinPermissionIndex\x20has\x20no\x20ALLOCATION_*\x20entries.\x20Allocation\x27s\x20access\x20control\x20is\x20fully\x20delegated\x20to\x20Service\x20(SERVICE_ORDER_ALLOCATOR=313)\x20or\x20Arbitration\x20(ARBITRATION_FEES_ALLOC=365).\x20This\x20is\x20the\x20\x27passive\x20object\x27\x20design\x20philosophy,\x20not\x20a\x20defect.\x20In\x20embedded\x20mode,\x20the\x20host\x20Service/Arbitration\x20provides\x20an\x20additional\x20access-control\x20layer\x20on\x20top\x20of\x20Guard\x20+\x20Passport.','affected_stakeholders':['system'],'scenario':b?'Standalone\x20Allocation\x20creation\x20(user-initiated,\x20no\x20Service\x20context)':'Embedded\x20Allocation\x20creation\x20(via\x20Service\x20order_allocators\x20or\x20Arbitration\x20fees_alloc)','mitigation':b?'For\x20standalone\x20Allocation,\x20ensure\x20Guard\x20binds\x20Signer\x20or\x20enforces\x20time-lock\x20(see\x20R-A-3-04).\x20Document\x20this\x20design\x20choice\x20explicitly.':'For\x20embedded\x20Allocation,\x20ensure\x20Service/Arbitration\x20permission\x20configuration\x20is\x20correct.\x20Document\x20this\x20design\x20choice\x20explicitly.','evidence':'BuiltinPermissionIndex\x20has\x20no\x20ALLOCATION_*\x20entries;\x20trigger_source='+(a['trigger_source']??'unknown'),'auto_fixable':![]};}},R_A_3_04={'id':'R-A-3-04','category':'authority','trigger':'Standalone\x20Allocation\x20(trigger_source=standalone)\x20with\x20Guard\x20lacking\x20both\x20Signer\x20binding\x20and\x20time-lock','check':b=>{if(b['trigger_source']!=='standalone')return null;if(!b['allocators_config'])return null;const c=[];for(const d of b['allocators_config']['allocators']){const e=b['guard_signer_bindings']?.[d['guard']]===!![],f=b['guard_has_time_lock']?.[d['guard']]===!![];!e&&!f&&c['push'](d['guard']);}if(c['length']===0x0)return null;return{'id':'R-A-3-04','level':'HIGH','category':'authority','title':'Standalone\x20Allocation:\x20'+c['length']+'\x20Guard(s)\x20lack\x20Signer\x20binding\x20AND\x20time-lock','description':'Standalone\x20Allocation\x20(trigger_source=standalone)\x20has\x20no\x20Service-layer\x20access\x20control.\x20The\x20following\x20Guard(s)\x20lack\x20both\x20Signer\x20binding\x20(context(Signer)==authorized)\x20and\x20time-lock\x20(context(Clock).timestamp>=unlock):\x20'+c['join'](',\x20')+'.\x20Anyone\x20who\x20passes\x20these\x20Guards\x20can\x20trigger\x20alloc()\x20and\x20receive\x20funds,\x20with\x20no\x20additional\x20authorization\x20layer.\x20This\x20is\x20the\x20most\x20severe\x20standalone-mode\x20risk.','affected_stakeholders':['owner','recipient','system'],'scenario':'Standalone\x20Allocation\x20created\x20with\x20weak\x20Guard\x20(no\x20Signer\x20binding,\x20no\x20time-lock)','mitigation':'Option\x20A\x20(preferred):\x20configure\x20Guard\x20to\x20bind\x20context(Signer)==authorized_address,\x20so\x20only\x20the\x20owner\x20can\x20trigger\x20alloc().\x20Option\x20B:\x20configure\x20Guard\x20with\x20time-lock\x20(context(Clock).timestamp>=unlock_time)\x20for\x20vesting-style\x20releases.\x20Option\x20C:\x20switch\x20to\x20embedded\x20mode\x20(via\x20Service)\x20to\x20leverage\x20Service-layer\x20access\x20control.\x20Until\x20fixed,\x20this\x20Allocation\x20should\x20not\x20receive\x20funds.','evidence':'trigger_source=standalone,\x20weakGuards='+c['join'](','),'related_guard_risk':'R-C3-06\x20(Signer\x20binding)\x20/\x20time-lock\x20patterns','auto_fixable':![]};}},R_A_4_01={'id':'R-A-4-01','category':'lifecycle','trigger':'caller-specified\x20guard\x20with\x20no\x20matching\x20Allocator\x20—\x20silent\x20return\x20causes\x20funds\x20to\x20be\x20stuck','check':a=>{if(!a['allocators_config'])return null;if(a['allocators_config']['allocators']['length']<=0x1)return null;if(a['has_fallback_allocator'])return null;return{'id':'R-A-4-01','level':'CRITICAL','category':'lifecycle','title':'caller-specified\x20guard\x20with\x20no\x20matching\x20Allocator\x20—\x20silent\x20return\x20causes\x20funds\x20to\x20be\x20stuck','description':'Multi-Allocation\x20configuration\x20('+a['allocators_config']['allocators']['length']+'\x20Allocators)\x20without\x20alternative\x20Allocator.\x20alloc()\x20is\x20driven\x20by\x20the\x20caller\x20explicitly\x20specifying\x20an\x20Allocator\x20via\x20alloc_by_guard:\x20if\x20the\x20guard\x20address\x20does\x20not\x20match\x20any\x20allocators[].guard,\x20alloc()\x20silently\x20returns\x20(no\x20error,\x20no\x20distribution),\x20funds\x20remain\x20stuck\x20in\x20Allocation.balance,\x20and\x20the\x20caller\x20gets\x20no\x20immediate\x20signal.\x20Linked\x20to\x20guard-risk.ts\x20R-X1-05.','affected_stakeholders':['owner','service_provider','system'],'scenario':'Caller\x20passes\x20a\x20guard\x20address\x20not\x20present\x20in\x20allocators[]\x20(e.g.\x20wrong\x20Guard\x20object,\x20or\x20order\x20state\x20not\x20matching\x20any\x20terminal\x20node)','mitigation':'1)\x20The\x20caller\x20should\x20verify\x20alloc_by_guard\x20∈\x20allocators[].guard\x20address\x20set\x20before\x20calling\x20alloc().\x202)\x20Provide\x20an\x20alternative\x20Allocator\x20and\x20document\x20the\x20caller\x27s\x20retry\x20strategy.\x203)\x20Caller\x20should\x20check\x20balance==0\x20after\x20alloc()\x20to\x20detect\x20no-match.','evidence':'allocators='+a['allocators_config']['allocators']['length']+',\x20hasFallback='+(a['has_fallback_allocator']??![]),'related_guard_risk':'R-X1-05','auto_fixable':![]};}},R_A_4_02={'id':'R-A-4-02','category':'lifecycle','trigger':'Multi-Allocation\x20without\x20mutually\x20exclusive\x20Guard\x20conditions\x20(design\x20clarity\x20issue,\x20not\x20a\x20correctness\x20requirement)','check':a=>{if(!a['allocators_config'])return null;if(a['allocators_config']['allocators']['length']<=0x1)return null;if(a['guard_conditions_mutually_exclusive'])return null;return{'id':'R-A-4-02','level':'MEDIUM','category':'lifecycle','title':'Multi-Allocation\x20without\x20mutually\x20exclusive\x20Guard\x20conditions','description':'Multi-Allocation\x20('+a['allocators_config']['allocators']['length']+'\x20Allocators)\x20without\x20verified\x20mutual\x20exclusion.\x20Under\x20caller-specified\x20guard\x20semantics,\x20the\x20caller\x20explicitly\x20selects\x20an\x20Allocator\x20via\x20alloc_by_guard,\x20so\x20there\x20is\x20no\x20correctness\x20problem\x20of\x20\x22the\x20latter\x20is\x20unreachable\x22;\x20however,\x20if\x20two\x20Guard\x20conditions\x20can\x20both\x20pass\x20simultaneously\x20and\x20the\x20caller\x20has\x20no\x20explicit\x20selection\x20strategy,\x20the\x20caller\x20may\x20be\x20confused\x20or\x20bind\x20to\x20an\x20unexpected\x20path.','affected_stakeholders':['owner'],'scenario':'Two\x20Guard\x20conditions\x20overlap\x20(e.g.\x20amount<1000\x20and\x20amount<500),\x20caller\x20Passport\x20satisfies\x20both','mitigation':'It\x20is\x20recommended\x20that\x20Guard\x20conditions\x20be\x20strictly\x20mutually\x20exclusive\x20(e.g.\x20amount<1000\x20vs\x20amount>=1000)\x20to\x20avoid\x20caller\x20confusion;\x20alternatively,\x20document\x20explicitly\x20which\x20path\x20the\x20caller\x20should\x20prefer.','evidence':'allocators='+a['allocators_config']['allocators']['length']+',\x20mutuallyExclusive='+(a['guard_conditions_mutually_exclusive']??![]),'auto_fixable':![]};}},R_A_4_03={'id':'R-A-4-03','category':'lifecycle','trigger':'Pure\x20Amount\x20mode\x20without\x20Surplus\x20—\x20residual\x20balance\x20reentrancy','check':b=>{if(!b['allocators_config'])return null;for(let c=0x0;c<b['allocators_config']['allocators']['length'];c++){const d=b['allocators_config']['allocators'][c],e=d['sharing']['length']>0x0&&d['sharing']['every'](f=>f['mode']==='Amount');if(!e)continue;return{'id':'R-A-4-03','level':'LOW','category':'lifecycle','title':'Pure\x20Amount\x20mode\x20without\x20Surplus\x20—\x20residual\x20balance\x20reentrancy','description':'Allocator\x20'+c+'\x20uses\x20pure\x20Amount\x20mode\x20(no\x20Rate,\x20no\x20Surplus).\x20After\x20alloc(),\x20if\x20fix\x20<\x20balance,\x20residual\x20funds\x20remain\x20in\x20Allocation.balance\x20and\x20can\x20be\x20claimed\x20by\x20re-triggering\x20alloc().\x20Linked\x20to\x20guard-risk.ts\x20reentrancy\x20LOW.','affected_stakeholders':['owner','system'],'scenario':'Pure\x20Amount\x20mode\x20leaves\x20residual\x20balance','mitigation':'1)\x20Preferred:\x20add\x20a\x20Surplus\x20sharing\x20to\x20absorb\x20remainder.\x202)\x20Or\x20use\x20Rate\x20mode.\x203)\x20Or\x20add\x20anti-reentrancy\x20Guard\x20check:\x20logic_not(query(\x27order.allocation\x20some\x27,\x20object=order)).','evidence':'allocator['+c+'].mode=pure-amount','related_guard_risk':'reentrancy\x20LOW','auto_fixable':![]};}return null;}},R_A_5_01={'id':'R-A-5-01','category':'cross_object','trigger':'Order\x20already\x20has\x20an\x20Allocation\x20bound\x20(1:1\x20constraint)','check':a=>{if(!a['order_already_has_allocation'])return null;return{'id':'R-A-5-01','level':'HIGH','category':'cross_object','title':'Order\x20already\x20has\x20an\x20Allocation\x20—\x201:1\x20constraint\x20violation','description':'Order\x20'+(a['bound_order']??'(unknown)')+'\x20already\x20has\x20an\x20Allocation\x20bound.\x20Move\x20layer\x20will\x20abort\x20with\x20E_ALLOCATION_ALREADY_SPECIFIED\x20(order.move)\x20when\x20attempting\x20to\x20bind\x20a\x20second\x20Allocation.','affected_stakeholders':['owner','service_provider'],'scenario':'Attempting\x20to\x20bind\x20a\x20second\x20Allocation\x20to\x20the\x20same\x20Order','mitigation':'Use\x20the\x20existing\x20Allocation,\x20or\x20unbind\x20it\x20first\x20(if\x20supported),\x20or\x20create\x20a\x20new\x20Order.','evidence':'bound_order='+(a['bound_order']??'unknown')+',\x20alreadyHasAllocation='+a['order_already_has_allocation'],'related_move_error':'E_ALLOCATION_ALREADY_SPECIFIED\x20(order.move)','auto_fixable':![]};}},R_A_5_02={'id':'R-A-5-02','category':'cross_object','trigger':'payment_info\x20missing\x20for\x20alloc()\x20—\x20ENO_PAYMENT_INFO','check':a=>{if(a['has_payment_info'])return null;if(a['operation_type']!=='alloc_by_guard')return null;return{'id':'R-A-5-02','level':'HIGH','category':'cross_object','title':'payment_info\x20missing\x20—\x20alloc()\x20will\x20abort\x20with\x20ENO_PAYMENT_INFO','description':'Allocation\x20has\x20no\x20payment_info\x20set.\x20Move\x20alloc()\x20requires\x20payment_info.is_some()\x20at\x20step\x201\x20(pre_check).\x20The\x20entire\x20alloc()\x20transaction\x20will\x20revert,\x20funds\x20remain\x20in\x20Allocation.','affected_stakeholders':['owner'],'scenario':'Triggering\x20alloc()\x20before\x20setting\x20payment_info','mitigation':'Ensure\x20payment_info\x20is\x20set\x20during\x20Allocation\x20creation\x20(CallAllocation_Create\x20requires\x20payment_info\x20field).','evidence':'has_payment_info='+(a['has_payment_info']??![]),'related_move_error':'ENO_PAYMENT_INFO\x20(9)','auto_fixable':![]};}},R_A_5_03={'id':'R-A-5-03','category':'cross_object','trigger':'MAX_ALLOCATOR_COUNT\x20not\x20synced\x20to\x20onchain-constants.ts','check':a=>{return{'id':'R-A-5-03','level':'LOW','category':'cross_object','title':'MAX_ALLOCATOR_COUNT\x20not\x20synced\x20to\x20onchain-constants.ts','description':'Move\x20layer\x20allocation.move:16\x20defines\x20MAX_ALLOCATOR_COUNT='+MAX_ALLOCATOR_COUNT+',\x20but\x20onchain-constants.ts\x20does\x20NOT\x20export\x20this\x20constant.\x20SDK\x20allocation.ts:318\x20defines\x20it\x20locally,\x20creating\x20a\x20double-definition\x20risk.\x20MCP\x20knowledge\x20imports\x20the\x20local\x20definition.','affected_stakeholders':['system'],'scenario':'Constant\x20sync\x20drift\x20between\x20Move\x20/\x20SDK\x20/\x20MCP','mitigation':'1)\x20Add\x20MAX_ALLOCATOR_COUNT=100\x20to\x20onchain-constants.ts.\x202)\x20Update\x20SDK\x20allocation.ts\x20to\x20import\x20from\x20onchain-constants.js.\x203)\x20Delete\x20local\x20definition.','evidence':'MAX_ALLOCATOR_COUNT='+MAX_ALLOCATOR_COUNT+'\x20(local),\x20not\x20in\x20onchain-constants.ts','auto_fixable':!![]};}},ALL_RULES=[R_A_1_01,R_A_1_02,R_A_1_03,R_A_2_01,R_A_2_02,R_A_2_03,R_A_2_04,R_A_3_01,R_A_3_02,R_A_3_03,R_A_3_04,R_A_4_01,R_A_4_02,R_A_4_03,R_A_5_01,R_A_5_02,R_A_5_03];export const ALLOCATION_RISK_VERSION='1.1.0';export function getAllRiskRules(){return[...ALL_RULES];}export function getRiskRulesCount(){return ALL_RULES['length'];}export function getRiskRulesByCategory(a){return ALL_RULES['filter'](b=>b['category']===a);}export function assessAllocationRisks(a){const b=[];for(const g of ALL_RULES){const h=g['check'](a);if(h)b['push'](h);}const c=b['length']===0x0?'LOW':b['some'](i=>i['level']==='CRITICAL')?'CRITICAL':b['some'](i=>i['level']==='HIGH')?'HIGH':b['some'](i=>i['level']==='MEDIUM')?'MEDIUM':'LOW',d={},e={};for(const i of b){d[i['category']]=(d[i['category']]??0x0)+0x1,e[i['level']]=(e[i['level']]??0x0)+0x1;}const f={};for(const j of b){for(const k of j['affected_stakeholders']){if(!f[k])f[k]=[];f[k]['push'](j['id']+':\x20'+j['mitigation']);}}return{'summary':'Assessed\x20'+b['length']+'\x20risk(s)\x20across\x20'+Object['keys'](d)['length']+'\x20categories','risks':b,'overall_risk':c,'risks_by_category':d,'risks_by_level':e,'stakeholder_advice':f,'needs_human_review':b['some'](l=>l['level']==='CRITICAL'||l['level']==='HIGH'),'blocks_publish':b['some'](l=>l['level']==='CRITICAL')};}export{ALLOCATION_ERROR_CODES};
|
|
1
|
+
import{MAX_ALLOCATOR_COUNT,RATE_TOTAL_FULL,ALLOCATION_ERROR_CODES}from'./allocation-ledger.js';import{isUnboundSignerTheft,canonicalDoctrine}from'./recipient-constraint.js';const R_A_1_01={'id':'R-A-1-01','category':'structural','trigger':'allocators\x20is\x20empty\x20or\x20sharing\x20arrays\x20are\x20empty','check':a=>{if(!a['allocators_config'])return null;const b=a['allocators_config']['allocators'];if(b['length']===0x0)return{'id':'R-A-1-01','level':'CRITICAL','category':'structural','title':'Empty\x20allocators\x20—\x20funds\x20will\x20be\x20permanently\x20locked','description':'Allocation\x20has\x20empty\x20allocators.allocators.\x20Service\x20publish\x20with\x20empty\x20order_allocators\x20causes\x20order\x20funds\x20to\x20be\x20permanently\x20locked\x20in\x20the\x20Allocation\x20object.','affected_stakeholders':['owner','service_provider','system'],'scenario':'Service\x20published\x20without\x20configuring\x20any\x20Allocator','mitigation':'Configure\x20at\x20least\x201\x20Allocator.\x20If\x20no\x20distribution\x20is\x20needed\x20yet,\x20use\x20a\x20single\x20Allocator\x20with\x20Rate=10000\x20to\x20the\x20merchant\x20address.','evidence':'allocators.length=0','related_move_error':'EALLOCATORS_EMPTY\x20(8)\x20/\x20ENO_ALLOCATOR\x20(3)','auto_fixable':![]};for(let c=0x0;c<b['length'];c++){if(b[c]['sharing']['length']===0x0)return{'id':'R-A-1-01','level':'CRITICAL','category':'structural','title':'Allocator\x20'+c+'\x20has\x20empty\x20sharing\x20—\x20will\x20never\x20distribute','description':'Allocator\x20at\x20index\x20'+c+'\x20(guard='+b[c]['guard']+')\x20has\x20empty\x20sharing\x20array.\x20Even\x20if\x20its\x20Guard\x20passes\x20verification,\x20no\x20funds\x20will\x20be\x20distributed.','affected_stakeholders':['owner','recipient'],'scenario':'Allocator\x20with\x20empty\x20sharing\x20vector','mitigation':'Add\x20at\x20least\x201\x20sharing\x20entry\x20to\x20Allocator\x20'+c,'evidence':'allocator['+c+'].sharing.length=0','related_move_error':'ENO_ALLOCATOR\x20(3)','auto_fixable':![]};}return null;}},R_A_1_02={'id':'R-A-1-02','category':'structural','trigger':'Pure\x20Rate\x20mode\x20sum\x20!=\x2010000\x20or\x20Rate+Surplus\x20sum\x20>\x2010000','check':b=>{if(!b['allocators_config'])return null;for(let c=0x0;c<b['allocators_config']['allocators']['length'];c++){const d=b['allocators_config']['allocators'][c],e=d['sharing']['filter'](g=>g['mode']==='Rate')['reduce']((g,h)=>g+Number(h['sharing']),0x0),f=d['sharing']['some'](g=>g['mode']==='Surplus');if(!f&&e>0x0&&e!==RATE_TOTAL_FULL)return{'id':'R-A-1-02','level':'HIGH','category':'structural','title':'Pure\x20Rate\x20mode\x20sum\x20'+e+'\x20!=\x20'+RATE_TOTAL_FULL,'description':'Allocator\x20'+c+'\x20(guard='+d['guard']+')\x20uses\x20pure\x20Rate\x20mode\x20(no\x20Surplus),\x20but\x20sum(rates)='+e+'\x20≠\x20'+RATE_TOTAL_FULL+'.\x20Funds\x20will\x20be\x20permanently\x20locked\x20(if\x20sum<10000)\x20or\x20Move\x20will\x20abort\x20with\x20ERATE_NOT_10000\x20(if\x20sum\x20!=\x2010000\x20exactly).','affected_stakeholders':['owner','recipient'],'scenario':'Misconfigured\x20rate\x20proportions','mitigation':'Adjust\x20sharing.sharing\x20values\x20so\x20sum(rates)='+RATE_TOTAL_FULL+',\x20OR\x20add\x201\x20Surplus\x20sharing\x20to\x20absorb\x20the\x20remainder.','evidence':'rateSum='+e+',\x20expected='+RATE_TOTAL_FULL,'related_move_error':'ERATE_NOT_10000\x20(4)','auto_fixable':!![]};if(f&&e>RATE_TOTAL_FULL)return{'id':'R-A-1-02','level':'HIGH','category':'structural','title':'Rate\x20+\x20Surplus\x20sum\x20'+e+'\x20>\x20'+RATE_TOTAL_FULL,'description':'Allocator\x20'+c+'\x20(guard='+d['guard']+')\x20uses\x20Rate+Surplus\x20mode,\x20but\x20sum(rates)='+e+'\x20>\x20'+RATE_TOTAL_FULL+'.\x20Move\x20will\x20abort\x20with\x20ERATE_EXCEEDS_10000.','affected_stakeholders':['owner'],'scenario':'Rate\x20percentages\x20exceed\x20100%\x20before\x20Surplus','mitigation':'Reduce\x20sum(rates)\x20to\x20≤\x20'+RATE_TOTAL_FULL+'.','evidence':'rateSum='+e+',\x20max='+RATE_TOTAL_FULL,'related_move_error':'ERATE_EXCEEDS_10000\x20(6)','auto_fixable':!![]};}return null;}},R_A_1_03={'id':'R-A-1-03','category':'structural','trigger':'Multiple\x20Surplus\x20sharing\x20in\x20one\x20Allocator,\x20or\x20Amount\x20sum\x20violates\x20threshold/max','check':b=>{if(!b['allocators_config'])return null;for(let c=0x0;c<b['allocators_config']['allocators']['length'];c++){const d=b['allocators_config']['allocators'][c],e=d['sharing']['filter'](h=>h['mode']==='Surplus')['length'];if(e>0x1)return{'id':'R-A-1-03','level':'MEDIUM','category':'structural','title':'Allocator\x20'+c+'\x20has\x20'+e+'\x20Surplus\x20sharing\x20—\x20at\x20most\x201\x20allowed','description':'Allocator\x20'+c+'\x20(guard='+d['guard']+')\x20has\x20'+e+'\x20Surplus\x20sharing\x20entries.\x20Move\x20will\x20abort\x20with\x20EMULTIPLE_SURPLUS\x20at\x20alloc()\x20time.','affected_stakeholders':['owner'],'scenario':'Multiple\x20Surplus\x20entries\x20in\x20one\x20Allocator','mitigation':'Keep\x20at\x20most\x201\x20Surplus\x20per\x20Allocator.\x20Use\x20Rate\x20mode\x20for\x20multi-party\x20remainder\x20distribution.','evidence':'surplusCount='+e,'related_move_error':'EMULTIPLE_SURPLUS\x20(5)','auto_fixable':!![]};const f=d['sharing']['filter'](h=>h['mode']==='Amount')['reduce']((h,j)=>h+Number(j['sharing']),0x0),g=Number(b['allocators_config']['threshold']);if(f>0x0&&f<g)return{'id':'R-A-1-03','level':'HIGH','category':'structural','title':'Amount\x20sum\x20'+f+'\x20<\x20threshold\x20'+g,'description':'Allocator\x20'+c+'\x20pure\x20Amount\x20mode\x20fix='+f+'\x20<\x20threshold='+g+'.\x20Move\x20will\x20abort\x20with\x20EAMOUNT_BELOW_THRESHOLD\x20at\x20allocator_add\x20time.','affected_stakeholders':['owner'],'scenario':'Amount\x20sum\x20insufficient\x20to\x20trigger\x20alloc','mitigation':'Either\x20lower\x20threshold\x20to\x20<=\x20fix,\x20or\x20increase\x20Amount\x20sharing\x20values.','evidence':'fix='+f+',\x20threshold='+g,'related_move_error':'EAMOUNT_BELOW_THRESHOLD\x20(12)','auto_fixable':![]};if(d['max']!=null&&f>Number(d['max']))return{'id':'R-A-1-03','level':'MEDIUM','category':'structural','title':'Amount\x20sum\x20'+f+'\x20>\x20max\x20'+Number(d['max']),'description':'Allocator\x20'+c+'\x20Amount\x20sum\x20exceeds\x20max.\x20Move\x20will\x20abort\x20with\x20EAMOUNT_EXCEEDS_MAX.','affected_stakeholders':['owner'],'scenario':'Amount\x20sum\x20exceeds\x20max\x20cap','mitigation':'Increase\x20max\x20or\x20reduce\x20Amount\x20sharing\x20values.','evidence':'fix='+f+',\x20max='+Number(d['max']),'related_move_error':'EAMOUNT_EXCEEDS_MAX\x20(13)','auto_fixable':!![]};}return null;}},R_A_2_01={'id':'R-A-2-01','category':'semantic','trigger':'sharing.who=Signer\x20without\x20Guard\x20Signer\x20binding\x20—\x20fund\x20theft\x20risk','check':b=>{if(!b['allocators_config'])return null;for(let c=0x0;c<b['allocators_config']['allocators']['length'];c++){const d=b['allocators_config']['allocators'][c],e=d['sharing']['some'](g=>'Signer'in g['who']),f=b['guard_signer_bindings']?.[d['guard']]===!![];if(isUnboundSignerTheft({'recipient_is_signer':e,'caller_identity_constrained':f})){const g=canonicalDoctrine('RC-FIND-01');return{'id':'R-A-2-01','level':g['severity'],'category':'semantic','title':g['title'],'description':'Allocator\x20'+c+'\x20(guard='+d['guard']+')\x20has\x20sharing.who=Signer,\x20but\x20the\x20Guard\x20does\x20not\x20bind\x20context(Signer)==authorized.\x20Anyone\x20who\x20passes\x20the\x20Guard\x20can\x20steal\x20100%\x20of\x20funds.\x20(Canonical\x20finding\x20RC-FIND-01,\x20linked\x20to\x20guard-risk.ts\x20R-C3-06.)','affected_stakeholders':['owner','recipient','service_provider'],'scenario':'Signer\x20recipient\x20without\x20Guard\x20Signer\x20authentication','mitigation':g['mitigation'],'evidence':'guard='+d['guard']+',\x20guardSignerBound='+f,'related_guard_risk':'R-C3-06','auto_fixable':![]};}}return null;}},R_A_2_02={'id':'R-A-2-02','category':'semantic','trigger':'sharing.who=GuardIdentifier\x20but\x20Passport\x20table\x20entry\x20is\x20not\x20address\x20type','check':b=>{if(!b['allocators_config'])return null;if(!b['passport_identifier_types'])return null;for(let c=0x0;c<b['allocators_config']['allocators']['length'];c++){const d=b['allocators_config']['allocators'][c],e=d['sharing']['find'](h=>'GuardIdentifier'in h['who']);if(!e)continue;const f=e['who']['GuardIdentifier'],g=b['passport_identifier_types'][f];if(g!==undefined&&g!=='address')return{'id':'R-A-2-02','level':'MEDIUM','category':'semantic','title':'GuardIdentifier\x20'+f+'\x20resolves\x20to\x20non-address\x20type\x20('+g+')','description':'Allocator\x20'+c+'\x20uses\x20sharing.who=GuardIdentifier('+f+'),\x20but\x20Passport\x20table['+f+']\x20is\x20of\x20type\x20'+g+',\x20not\x20address.\x20Move\x20will\x20abort\x20with\x20ERECIPIENT_IDENTIFIER_NOT_ADDRESS\x20at\x20alloc()\x20time.','affected_stakeholders':['recipient'],'scenario':'Passport\x20table\x20entry\x20type\x20mismatch','mitigation':'Ensure\x20Passport\x20table['+f+']\x20is\x20address-typed,\x20OR\x20use\x20sharing.who=Entity\x20with\x20a\x20static\x20address.','evidence':'identifier='+f+',\x20type='+g,'related_move_error':'ERECIPIENT_IDENTIFIER_NOT_ADDRESS\x20(1)','auto_fixable':![]};}return null;}},R_A_2_03={'id':'R-A-2-03','category':'semantic','trigger':'Duplicate\x20Guard\x20addresses\x20in\x20allocators\x20(alloc_by_guard\x20address\x20match\x20only\x20hits\x20the\x20first\x20one)','check':a=>{if(!a['allocators_config'])return null;const b=a['allocators_config']['allocators']['map'](d=>d['guard']),c=new Set(b);if(c['size']!==b['length']){const d=b['filter']((e,f)=>b['indexOf'](e)!==f);return{'id':'R-A-2-03','level':'MEDIUM','category':'semantic','title':'Duplicate\x20Guard\x20addresses\x20in\x20allocators','description':'Multiple\x20Allocators\x20reference\x20the\x20same\x20Guard\x20object:\x20'+d['join'](',\x20')+'.\x20alloc_by_guard\x20locates\x20the\x20Allocator\x20by\x20iterating\x20guard\x20addresses;\x20duplicate\x20addresses\x20only\x20match\x20the\x20first\x20one,\x20so\x20subsequent\x20duplicate\x20Allocators\x20are\x20unreachable\x20(dead\x20code).','affected_stakeholders':['owner','allocator'],'scenario':'Reusing\x20same\x20Guard\x20object\x20across\x20multiple\x20Allocators','mitigation':'Create\x20independent\x20Guard\x20objects\x20for\x20each\x20Allocator\x20(they\x20may\x20share\x20root/table\x20but\x20must\x20differ\x20in\x20description).','evidence':'total='+b['length']+',\x20unique='+c['size']+',\x20dupes='+d['join'](','),'auto_fixable':!![]};}return null;}},R_A_2_04={'id':'R-A-2-04','category':'semantic','trigger':'GuardIdentifier\x20recipients\x20combined\x20with\x20payment_info.for_object\x20anchor\x20state\x20(Some\x20=\x20enforced,\x20None\x20=\x20absent)','check':a=>{if(!a['allocators_config'])return null;if(a['payment_info_for_object']===undefined)return null;const b=a['allocators_config']['allocators']['some'](d=>d['sharing']['some'](e=>'GuardIdentifier'in e['who']));if(!b)return null;const c=a['payment_info_for_object'];if(c)return{'id':'R-A-2-04','level':'MEDIUM','category':'semantic','title':'payment_info.for_object\x20anchor\x20is\x20ENFORCED\x20at\x20alloc()','description':'payment_info.for_object\x20is\x20set\x20to\x20'+c+'.\x20At\x20alloc(),\x20every\x20Recipient::GuardIdentifier\x20submission\x20must\x20equal\x20this\x20address\x20or\x20the\x20whole\x20tx\x20aborts\x20with\x20ERECIPIENT_NOT_FOR_OBJECT\x20(15)\x20—\x20a\x20wrong\x20anchor\x20or\x20a\x20guard\x20whose\x20passport\x20submits\x20a\x20different\x20address\x20makes\x20alloc()\x20permanently\x20fail\x20(payment_info\x20is\x20immutable\x20after\x20create).\x20Verify\x20the\x20anchor\x20matches\x20the\x20intended\x20recipient\x20flow.','affected_stakeholders':['owner','recipient'],'scenario':'Allocation\x20created\x20with\x20a\x20declared\x20for_object\x20binding\x20and\x20GuardIdentifier\x20recipients','mitigation':'Before\x20create:\x20confirm\x20for_object\x20is\x20the\x20object\x20the\x20GuardIdentifier\x20submissions\x20will\x20resolve\x20to\x20(the\x20guard\x27s\x20passport\x20must\x20submit\x20exactly\x20this\x20address\x20for\x20the\x20recipient\x20identifier).\x20Entity/Signer\x20sharing\x20lines\x20are\x20unaffected\x20by\x20the\x20anchor.','evidence':'for_object='+c,'related_move_error':'ERECIPIENT_NOT_FOR_OBJECT\x20(15)','auto_fixable':![]};return{'id':'R-A-2-04','level':'MEDIUM','category':'semantic','title':'payment_info.for_object\x20=\x20None\x20—\x20GuardIdentifier\x20destination\x20has\x20no\x20on-chain\x20anchor','description':'payment_info.for_object\x20is\x20not\x20set:\x20alloc()\x20enforces\x20NO\x20recipient\x20binding\x20for\x20Recipient::GuardIdentifier\x20lines.\x20Whoever\x20builds\x20the\x20passport\x20chooses\x20the\x20payout\x20address;\x20nothing\x20on-chain\x20constrains\x20it.\x20This\x20is\x20legal\x20by\x20design\x20(Allocation\x20is\x20a\x20generic\x20component,\x20the\x20anchor\x20is\x20opt-in),\x20but\x20it\x20means\x20recipient\x20routing\x20is\x20trust-on-creator.','affected_stakeholders':['owner','recipient'],'scenario':'Allocation\x20created\x20without\x20a\x20for_object\x20anchor\x20while\x20using\x20GuardIdentifier\x20recipients','mitigation':'If\x20enforced\x20routing\x20is\x20desired,\x20set\x20payment_info.for_object\x20to\x20the\x20intended\x20recipient\x20anchor\x20at\x20create\x20(it\x20becomes\x20mechanism-enforced:\x20mismatch\x20aborts\x20with\x20code\x2015).\x20If\x20no\x20anchor\x20is\x20intended,\x20document\x20that\x20the\x20recipient\x20is\x20the\x20passport\x20builder\x27s\x20choice\x20and\x20constrain\x20it\x20in\x20the\x20guard\x20expression\x20instead.','evidence':'for_object=None','related_move_error':'ERECIPIENT_NOT_FOR_OBJECT\x20(15,\x20only\x20fires\x20when\x20a\x20binding\x20is\x20declared)','auto_fixable':![]};}},R_A_3_01={'id':'R-A-3-01','category':'authority','trigger':'Service\x20already\x20published\x20—\x20order_allocators\x20is\x20immutable','check':a=>{if(!a['host_service_published'])return null;return{'id':'R-A-3-01','level':'HIGH','category':'authority','title':'order_allocators\x20immutable\x20after\x20Service\x20publish','description':'Service\x20is\x20already\x20published.\x20order_allocators\x20field\x20is\x20now\x20immutable\x20(safety-rules.ts:170-174).\x20Any\x20configuration\x20error\x20(wrong\x20Guard,\x20wrong\x20sharing\x20proportion,\x20wrong\x20Entity\x20address)\x20will\x20affect\x20ALL\x20subsequent\x20orders\x20and\x20cannot\x20be\x20fixed\x20without\x20creating\x20a\x20new\x20Service.','affected_stakeholders':['owner','service_provider'],'scenario':'Attempting\x20to\x20modify\x20order_allocators\x20after\x20Service\x20publish','mitigation':'1)\x20Verify\x20the\x20configuration\x20is\x20correct\x20before\x20publish.\x202)\x20Use\x20deploy-scanner\x20pre-publish\x20validation.\x203)\x20If\x20already\x20published\x20with\x20errors,\x20create\x20a\x20new\x20Service\x20to\x20replace.','evidence':'host_service_published='+a['host_service_published'],'auto_fixable':![]};}},R_A_3_02={'id':'R-A-3-02','category':'authority','trigger':'Treasury\x20Permission\x20inconsistent\x20with\x20Service\x20Permission','check':a=>{if(!a['allocators_config'])return null;if(!a['referenced_treasuries_permissions'])return null;if(!a['host_service_permission'])return null;for(const b of a['allocators_config']['allocators']){for(const c of b['sharing']){if(!('Entity'in c['who']))continue;const d=c['who']['Entity'],e=a['referenced_treasuries_permissions'][d];if(e&&e!==a['host_service_permission'])return{'id':'R-A-3-02','level':'MEDIUM','category':'authority','title':'Treasury\x20Permission\x20inconsistent\x20with\x20Service\x20Permission','description':'sharing.who=Entity\x20points\x20to\x20Treasury\x20'+d+'\x20whose\x20Permission\x20('+e+')\x20differs\x20from\x20Service\x20Permission\x20('+a['host_service_permission']+').\x20Two\x20different\x20permission\x20organizations\x20control\x20fund\x20flow,\x20creating\x20potential\x20authority\x20conflicts.','affected_stakeholders':['owner','service_provider'],'scenario':'Treasury\x20owned\x20by\x20different\x20party\x20than\x20Service','mitigation':'Create\x20Treasury\x20with\x20the\x20same\x20Permission\x20object\x20as\x20the\x20Service,\x20OR\x20ensure\x20both\x20are\x20owned\x20by\x20the\x20same\x20address.','evidence':'treasury='+d+',\x20treasuryPerm='+e+',\x20servicePerm='+a['host_service_permission'],'auto_fixable':![]};}}return null;}},R_A_3_03={'id':'R-A-3-03','category':'authority','trigger':'No\x20ALLOCATION_*\x20builtin\x20permission\x20index\x20—\x20Allocation\x20has\x20no\x20independent\x20access\x20control','check':a=>{if(a['operation_type']!=='create')return null;const b=a['trigger_source']==='standalone';return{'id':'R-A-3-03','level':'LOW','category':'authority','title':'Allocation\x20has\x20no\x20builtin\x20permission\x20index\x20(passive-object\x20design)','description':b?'BuiltinPermissionIndex\x20has\x20no\x20ALLOCATION_*\x20entries.\x20Allocation\x27s\x20access\x20control\x20is\x20fully\x20delegated\x20to\x20Guard\x20+\x20Passport.\x20In\x20standalone\x20mode\x20(trigger_source=standalone),\x20there\x20is\x20no\x20Service/Arbitration\x20layer\x20to\x20enforce\x20caller\x20authorization\x20—\x20Guard\x20MUST\x20provide\x20sufficient\x20access\x20control\x20(see\x20R-A-3-04).\x20This\x20is\x20the\x20\x27passive\x20object\x27\x20design\x20philosophy,\x20not\x20a\x20defect,\x20but\x20standalone\x20mode\x20shifts\x20full\x20responsibility\x20to\x20the\x20Guard\x20configuration.':'BuiltinPermissionIndex\x20has\x20no\x20ALLOCATION_*\x20entries.\x20Allocation\x27s\x20access\x20control\x20is\x20fully\x20delegated\x20to\x20Service\x20(SERVICE_ORDER_ALLOCATOR=313)\x20or\x20Arbitration\x20(ARBITRATION_FEES_ALLOC=365).\x20This\x20is\x20the\x20\x27passive\x20object\x27\x20design\x20philosophy,\x20not\x20a\x20defect.\x20In\x20embedded\x20mode,\x20the\x20host\x20Service/Arbitration\x20provides\x20an\x20additional\x20access-control\x20layer\x20on\x20top\x20of\x20Guard\x20+\x20Passport.','affected_stakeholders':['system'],'scenario':b?'Standalone\x20Allocation\x20creation\x20(user-initiated,\x20no\x20Service\x20context)':'Embedded\x20Allocation\x20creation\x20(via\x20Service\x20order_allocators\x20or\x20Arbitration\x20fees_alloc)','mitigation':b?'For\x20standalone\x20Allocation,\x20ensure\x20Guard\x20binds\x20Signer\x20or\x20enforces\x20time-lock\x20(see\x20R-A-3-04).\x20Document\x20this\x20design\x20choice\x20explicitly.':'For\x20embedded\x20Allocation,\x20ensure\x20Service/Arbitration\x20permission\x20configuration\x20is\x20correct.\x20Document\x20this\x20design\x20choice\x20explicitly.','evidence':'BuiltinPermissionIndex\x20has\x20no\x20ALLOCATION_*\x20entries;\x20trigger_source='+(a['trigger_source']??'unknown'),'auto_fixable':![]};}},R_A_3_04={'id':'R-A-3-04','category':'authority','trigger':'Standalone\x20Allocation\x20(trigger_source=standalone)\x20with\x20Guard\x20lacking\x20both\x20Signer\x20binding\x20and\x20time-lock','check':b=>{if(b['trigger_source']!=='standalone')return null;if(!b['allocators_config'])return null;const c=[];for(const d of b['allocators_config']['allocators']){const e=b['guard_signer_bindings']?.[d['guard']]===!![],f=b['guard_has_time_lock']?.[d['guard']]===!![];!e&&!f&&c['push'](d['guard']);}if(c['length']===0x0)return null;return{'id':'R-A-3-04','level':'HIGH','category':'authority','title':'Standalone\x20Allocation:\x20'+c['length']+'\x20Guard(s)\x20lack\x20Signer\x20binding\x20AND\x20time-lock','description':'Standalone\x20Allocation\x20(trigger_source=standalone)\x20has\x20no\x20Service-layer\x20access\x20control.\x20The\x20following\x20Guard(s)\x20lack\x20both\x20Signer\x20binding\x20(context(Signer)==authorized)\x20and\x20time-lock\x20(context(Clock).timestamp>=unlock):\x20'+c['join'](',\x20')+'.\x20Anyone\x20who\x20passes\x20these\x20Guards\x20can\x20trigger\x20alloc()\x20and\x20receive\x20funds,\x20with\x20no\x20additional\x20authorization\x20layer.\x20This\x20is\x20the\x20most\x20severe\x20standalone-mode\x20risk.','affected_stakeholders':['owner','recipient','system'],'scenario':'Standalone\x20Allocation\x20created\x20with\x20weak\x20Guard\x20(no\x20Signer\x20binding,\x20no\x20time-lock)','mitigation':'Option\x20A\x20(preferred):\x20configure\x20Guard\x20to\x20bind\x20context(Signer)==authorized_address,\x20so\x20only\x20the\x20owner\x20can\x20trigger\x20alloc().\x20Option\x20B:\x20configure\x20Guard\x20with\x20time-lock\x20(context(Clock).timestamp>=unlock_time)\x20for\x20vesting-style\x20releases.\x20Option\x20C:\x20switch\x20to\x20embedded\x20mode\x20(via\x20Service)\x20to\x20leverage\x20Service-layer\x20access\x20control.\x20Until\x20fixed,\x20this\x20Allocation\x20should\x20not\x20receive\x20funds.','evidence':'trigger_source=standalone,\x20weakGuards='+c['join'](','),'related_guard_risk':'R-C3-06\x20(Signer\x20binding)\x20/\x20time-lock\x20patterns','auto_fixable':![]};}},R_A_4_01={'id':'R-A-4-01','category':'lifecycle','trigger':'caller-specified\x20guard\x20with\x20no\x20matching\x20Allocator\x20—\x20silent\x20return\x20causes\x20funds\x20to\x20be\x20stuck','check':a=>{if(!a['allocators_config'])return null;if(a['allocators_config']['allocators']['length']<=0x1)return null;if(a['has_fallback_allocator'])return null;return{'id':'R-A-4-01','level':'CRITICAL','category':'lifecycle','title':'caller-specified\x20guard\x20with\x20no\x20matching\x20Allocator\x20—\x20silent\x20return\x20causes\x20funds\x20to\x20be\x20stuck','description':'Multi-Allocation\x20configuration\x20('+a['allocators_config']['allocators']['length']+'\x20Allocators)\x20without\x20alternative\x20Allocator.\x20alloc()\x20is\x20driven\x20by\x20the\x20caller\x20explicitly\x20specifying\x20an\x20Allocator\x20via\x20alloc_by_guard:\x20if\x20the\x20guard\x20address\x20does\x20not\x20match\x20any\x20allocators[].guard,\x20alloc()\x20silently\x20returns\x20(no\x20error,\x20no\x20distribution),\x20funds\x20remain\x20stuck\x20in\x20Allocation.balance,\x20and\x20the\x20caller\x20gets\x20no\x20immediate\x20signal.\x20Linked\x20to\x20guard-risk.ts\x20R-X1-05.','affected_stakeholders':['owner','service_provider','system'],'scenario':'Caller\x20passes\x20a\x20guard\x20address\x20not\x20present\x20in\x20allocators[]\x20(e.g.\x20wrong\x20Guard\x20object,\x20or\x20order\x20state\x20not\x20matching\x20any\x20terminal\x20node)','mitigation':'1)\x20The\x20caller\x20should\x20verify\x20alloc_by_guard\x20∈\x20allocators[].guard\x20address\x20set\x20before\x20calling\x20alloc().\x202)\x20Provide\x20an\x20alternative\x20Allocator\x20and\x20document\x20the\x20caller\x27s\x20retry\x20strategy.\x203)\x20Caller\x20should\x20check\x20balance==0\x20after\x20alloc()\x20to\x20detect\x20no-match.','evidence':'allocators='+a['allocators_config']['allocators']['length']+',\x20hasFallback='+(a['has_fallback_allocator']??![]),'related_guard_risk':'R-X1-05','auto_fixable':![]};}},R_A_4_02={'id':'R-A-4-02','category':'lifecycle','trigger':'Multi-Allocation\x20without\x20mutually\x20exclusive\x20Guard\x20conditions\x20(design\x20clarity\x20issue,\x20not\x20a\x20correctness\x20requirement)','check':a=>{if(!a['allocators_config'])return null;if(a['allocators_config']['allocators']['length']<=0x1)return null;if(a['guard_conditions_mutually_exclusive'])return null;return{'id':'R-A-4-02','level':'MEDIUM','category':'lifecycle','title':'Multi-Allocation\x20without\x20mutually\x20exclusive\x20Guard\x20conditions','description':'Multi-Allocation\x20('+a['allocators_config']['allocators']['length']+'\x20Allocators)\x20without\x20verified\x20mutual\x20exclusion.\x20Under\x20caller-specified\x20guard\x20semantics,\x20the\x20caller\x20explicitly\x20selects\x20an\x20Allocator\x20via\x20alloc_by_guard,\x20so\x20there\x20is\x20no\x20correctness\x20problem\x20of\x20\x22the\x20latter\x20is\x20unreachable\x22;\x20however,\x20if\x20two\x20Guard\x20conditions\x20can\x20both\x20pass\x20simultaneously\x20and\x20the\x20caller\x20has\x20no\x20explicit\x20selection\x20strategy,\x20the\x20caller\x20may\x20be\x20confused\x20or\x20bind\x20to\x20an\x20unexpected\x20path.','affected_stakeholders':['owner'],'scenario':'Two\x20Guard\x20conditions\x20overlap\x20(e.g.\x20amount<1000\x20and\x20amount<500),\x20caller\x20Passport\x20satisfies\x20both','mitigation':'It\x20is\x20recommended\x20that\x20Guard\x20conditions\x20be\x20strictly\x20mutually\x20exclusive\x20(e.g.\x20amount<1000\x20vs\x20amount>=1000)\x20to\x20avoid\x20caller\x20confusion;\x20alternatively,\x20document\x20explicitly\x20which\x20path\x20the\x20caller\x20should\x20prefer.','evidence':'allocators='+a['allocators_config']['allocators']['length']+',\x20mutuallyExclusive='+(a['guard_conditions_mutually_exclusive']??![]),'auto_fixable':![]};}},R_A_4_03={'id':'R-A-4-03','category':'lifecycle','trigger':'Pure\x20Amount\x20mode\x20without\x20Surplus\x20—\x20residual\x20balance\x20reentrancy','check':b=>{if(!b['allocators_config'])return null;for(let c=0x0;c<b['allocators_config']['allocators']['length'];c++){const d=b['allocators_config']['allocators'][c],e=d['sharing']['length']>0x0&&d['sharing']['every'](f=>f['mode']==='Amount');if(!e)continue;return{'id':'R-A-4-03','level':'LOW','category':'lifecycle','title':'Pure\x20Amount\x20mode\x20without\x20Surplus\x20—\x20residual\x20balance\x20reentrancy','description':'Allocator\x20'+c+'\x20uses\x20pure\x20Amount\x20mode\x20(no\x20Rate,\x20no\x20Surplus).\x20After\x20alloc(),\x20if\x20fix\x20<\x20balance,\x20residual\x20funds\x20remain\x20in\x20Allocation.balance\x20and\x20can\x20be\x20claimed\x20by\x20re-triggering\x20alloc().\x20Linked\x20to\x20guard-risk.ts\x20reentrancy\x20LOW.','affected_stakeholders':['owner','system'],'scenario':'Pure\x20Amount\x20mode\x20leaves\x20residual\x20balance','mitigation':'1)\x20Preferred:\x20add\x20a\x20Surplus\x20sharing\x20to\x20absorb\x20remainder.\x202)\x20Or\x20use\x20Rate\x20mode.\x203)\x20Or\x20add\x20anti-reentrancy\x20Guard\x20check:\x20logic_not(query(\x27order.allocation\x20some\x27,\x20object=order)).','evidence':'allocator['+c+'].mode=pure-amount','related_guard_risk':'reentrancy\x20LOW','auto_fixable':![]};}return null;}},R_A_5_01={'id':'R-A-5-01','category':'cross_object','trigger':'Order\x20already\x20has\x20an\x20Allocation\x20bound\x20(1:1\x20constraint)','check':a=>{if(!a['order_already_has_allocation'])return null;return{'id':'R-A-5-01','level':'HIGH','category':'cross_object','title':'Order\x20already\x20has\x20an\x20Allocation\x20—\x201:1\x20constraint\x20violation','description':'Order\x20'+(a['bound_order']??'(unknown)')+'\x20already\x20has\x20an\x20Allocation\x20bound.\x20Move\x20layer\x20will\x20abort\x20with\x20E_ALLOCATION_ALREADY_SPECIFIED\x20(order.move)\x20when\x20attempting\x20to\x20bind\x20a\x20second\x20Allocation.','affected_stakeholders':['owner','service_provider'],'scenario':'Attempting\x20to\x20bind\x20a\x20second\x20Allocation\x20to\x20the\x20same\x20Order','mitigation':'Use\x20the\x20existing\x20Allocation,\x20or\x20unbind\x20it\x20first\x20(if\x20supported),\x20or\x20create\x20a\x20new\x20Order.','evidence':'bound_order='+(a['bound_order']??'unknown')+',\x20alreadyHasAllocation='+a['order_already_has_allocation'],'related_move_error':'E_ALLOCATION_ALREADY_SPECIFIED\x20(order.move)','auto_fixable':![]};}},R_A_5_02={'id':'R-A-5-02','category':'cross_object','trigger':'payment_info\x20missing\x20for\x20alloc()\x20—\x20ENO_PAYMENT_INFO','check':a=>{if(a['has_payment_info'])return null;if(a['operation_type']!=='alloc_by_guard')return null;return{'id':'R-A-5-02','level':'HIGH','category':'cross_object','title':'payment_info\x20missing\x20—\x20alloc()\x20will\x20abort\x20with\x20ENO_PAYMENT_INFO','description':'Allocation\x20has\x20no\x20payment_info\x20set.\x20Move\x20alloc()\x20requires\x20payment_info.is_some()\x20at\x20step\x201\x20(pre_check).\x20The\x20entire\x20alloc()\x20transaction\x20will\x20revert,\x20funds\x20remain\x20in\x20Allocation.','affected_stakeholders':['owner'],'scenario':'Triggering\x20alloc()\x20before\x20setting\x20payment_info','mitigation':'Ensure\x20payment_info\x20is\x20set\x20during\x20Allocation\x20creation\x20(CallAllocation_Create\x20requires\x20payment_info\x20field).','evidence':'has_payment_info='+(a['has_payment_info']??![]),'related_move_error':'ENO_PAYMENT_INFO\x20(9)','auto_fixable':![]};}},R_A_5_03={'id':'R-A-5-03','category':'cross_object','trigger':'MAX_ALLOCATOR_COUNT\x20not\x20synced\x20to\x20onchain-constants.ts','check':a=>{return{'id':'R-A-5-03','level':'LOW','category':'cross_object','title':'MAX_ALLOCATOR_COUNT\x20not\x20synced\x20to\x20onchain-constants.ts','description':'Move\x20layer\x20allocation.move:16\x20defines\x20MAX_ALLOCATOR_COUNT='+MAX_ALLOCATOR_COUNT+',\x20but\x20onchain-constants.ts\x20does\x20NOT\x20export\x20this\x20constant.\x20SDK\x20allocation.ts:318\x20defines\x20it\x20locally,\x20creating\x20a\x20double-definition\x20risk.\x20MCP\x20knowledge\x20imports\x20the\x20local\x20definition.','affected_stakeholders':['system'],'scenario':'Constant\x20sync\x20drift\x20between\x20Move\x20/\x20SDK\x20/\x20MCP','mitigation':'1)\x20Add\x20MAX_ALLOCATOR_COUNT=100\x20to\x20onchain-constants.ts.\x202)\x20Update\x20SDK\x20allocation.ts\x20to\x20import\x20from\x20onchain-constants.js.\x203)\x20Delete\x20local\x20definition.','evidence':'MAX_ALLOCATOR_COUNT='+MAX_ALLOCATOR_COUNT+'\x20(local),\x20not\x20in\x20onchain-constants.ts','auto_fixable':!![]};}},ALL_RULES=[R_A_1_01,R_A_1_02,R_A_1_03,R_A_2_01,R_A_2_02,R_A_2_03,R_A_2_04,R_A_3_01,R_A_3_02,R_A_3_03,R_A_3_04,R_A_4_01,R_A_4_02,R_A_4_03,R_A_5_01,R_A_5_02,R_A_5_03];export const ALLOCATION_RISK_VERSION='1.1.0';export function getAllRiskRules(){return[...ALL_RULES];}export function assessAllocationRisks(a){const b=[];for(const g of ALL_RULES){const h=g['check'](a);if(h)b['push'](h);}const c=b['length']===0x0?'LOW':b['some'](i=>i['level']==='CRITICAL')?'CRITICAL':b['some'](i=>i['level']==='HIGH')?'HIGH':b['some'](i=>i['level']==='MEDIUM')?'MEDIUM':'LOW',d={},e={};for(const i of b){d[i['category']]=(d[i['category']]??0x0)+0x1,e[i['level']]=(e[i['level']]??0x0)+0x1;}const f={};for(const j of b){for(const k of j['affected_stakeholders']){if(!f[k])f[k]=[];f[k]['push'](j['id']+':\x20'+j['mitigation']);}}return{'summary':'Assessed\x20'+b['length']+'\x20risk(s)\x20across\x20'+Object['keys'](d)['length']+'\x20categories','risks':b,'overall_risk':c,'risks_by_category':d,'risks_by_level':e,'stakeholder_advice':f,'needs_human_review':b['some'](l=>l['level']==='CRITICAL'||l['level']==='HIGH'),'blocks_publish':b['some'](l=>l['level']==='CRITICAL')};}export{ALLOCATION_ERROR_CODES};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{MAX_VOTOR_COUNT,WITHDRAW_DURATION_TIME}from'@wowok/wowok';const R_A_01={'rule':{'id':'R-ARB-01','level':'HIGH','category':'lifecycle','title':'7-state\x20machine\x20—\x20invalid\x20transitions\x20can\x20deadlock\x20the\x20arbitration','description':'Arb\x20has\x20a\x207-state\x20machine:\x20Principal_confirming(0)\x20→\x20Arbitrator_confirming(1)\x20→\x20'+'Voting(2)\x20→\x20Arbitrated(3)\x20→\x20Objectionable(4)\x20→\x20Finished(5)\x20→\x20Withdrawn(6).\x20reset()\x20'+'can\x20revert\x20from\x20{1,\x204}\x20back\x20to\x200.\x20Each\x20op\x20asserts\x20the\x20current\x20status;\x20calling\x20an\x20op\x20'+'out\x20of\x20order\x20aborts\x20with\x20E_STATUS_NOT_MATCH\x20(3).\x20Repeated\x20mis-calls\x20leave\x20the\x20Arb\x20'+'stuck\x20in\x20a\x20non-terminal\x20state\x20with\x20no\x20automatic\x20recovery.','affected_stakeholders':['principal','arbitrator','voter'],'scenario':'Caller\x20calls\x20vote()\x20when\x20status\x20is\x20still\x20Arbitrator_confirming;\x20abort\x20blocks\x20progress','mitigation':'Strictly\x20validate\x20the\x20current\x20status\x20before\x20submitting\x20any\x20Arb\x20op.\x20The\x20SDK\x20should\x20'+'expose\x20a\x20status-aware\x20state\x20machine\x20helper.\x20Provide\x20a\x20recovery\x20path\x20(reset)\x20for\x20'+'Arbitrator_confirming\x20and\x20Objectionable\x20states.','related_move_error':'E_STATUS_NOT_MATCH\x20(3)','auto_fixable':![]},'check':a=>{if(!a['invalid_transition'])return null;return{...R_A_01['rule'],'evidence':'invalid_transition=true\x20(status='+(a['status']??'?')+')'};}},R_A_02={'rule':{'id':'R-ARB-02','level':'MEDIUM','category':'lifecycle','title':'WITHDRAW_DURATION_TIME='+WITHDRAW_DURATION_TIME+'ms\x20(30\x20days)\x20—\x20funds\x20locked','description':'After\x20arbitration,\x20the\x20fee\x20Balance\x20can\x20only\x20be\x20withdrawn\x20after\x20'+('WITHDRAW_DURATION_TIME='+WITHDRAW_DURATION_TIME+'ms\x20(30\x20days)\x20when\x20status\x20is\x20')+'Arbitrated(3)\x20or\x20Objectionable(4).\x20From\x20Finished(5),\x20withdraw\x20is\x20immediate.\x20'+'The\x2030-day\x20lock\x20is\x20a\x20dispute-window\x20safeguard,\x20but\x20it\x20locks\x20funds\x20for\x20a\x20long\x20time\x20'+'and\x20users\x20may\x20not\x20understand\x20why.','affected_stakeholders':['principal','arbitrator'],'scenario':'Arbitrator\x20finishes\x20a\x20case\x20but\x20must\x20wait\x2030\x20days\x20to\x20claim\x20the\x20fee','mitigation':'Surface\x20the\x20unlock\x20timestamp\x20in\x20the\x20UI.\x20To\x20shorten\x20the\x20lock,\x20drive\x20the\x20case\x20to\x20'+'Finished(5)\x20via\x20finish()\x20rather\x20than\x20leaving\x20it\x20in\x20Arbitrated/Objectionable.','related_move_error':'E_WITHDRAW_DURATION_TIME_NOT_PASSED\x20(8)','auto_fixable':![]},'check':a=>{if(!a['withdraw_too_early'])return null;return{...R_A_02['rule'],'evidence':'withdraw_too_early=true\x20(limit='+WITHDRAW_DURATION_TIME+'ms)'};}},R_A_03={'rule':{'id':'R-ARB-03','level':'MEDIUM','category':'structural','title':'MAX_VOTOR_COUNT='+MAX_VOTOR_COUNT+'\x20permissive\x20—\x20voting\x20efficiency\x20cost','description':'A\x20single\x20Arb\x20may\x20record\x20up\x20to\x20MAX_VOTOR_COUNT='+MAX_VOTOR_COUNT+'\x20voters\x20(arb.move:236).\x20'+'The\x20limit\x20aborts\x20with\x20E_MAX_VOTOR_COUNT\x20(6)\x20only\x20at\x20the\x20boundary.\x20520\x20voters\x20in\x20one\x20'+'Arb\x20inflates\x20the\x20voted\x20vector,\x20slowing\x20tally\x20and\x20gas,\x20and\x20complicates\x20weighted-quorum\x20'+'reasoning.','affected_stakeholders':['voter','arbitrator'],'scenario':'Arbitration\x20allows\x20520\x20voters;\x20tallying\x20the\x20vote\x20vector\x20is\x20slow\x20and\x20gas-heavy','mitigation':'Business\x20layer\x20should\x20self-limit\x20voter\x20count\x20based\x20on\x20the\x20Arbitration\x20rule\x27s\x20quorum.\x20'+'For\x20large\x20juries,\x20shard\x20across\x20multiple\x20Arb\x20instances\x20or\x20aggregate\x20off-chain.','related_move_error':'E_MAX_VOTOR_COUNT\x20(6)','auto_fixable':![]},'check':a=>{if(a['votor_count']===undefined)return null;if(a['votor_count']<MAX_VOTOR_COUNT)return null;return{...R_A_03['rule'],'evidence':'votor_count='+a['votor_count']+',\x20limit='+MAX_VOTOR_COUNT};}},R_A_04={'rule':{'id':'R-ARB-04','level':'LOW','category':'semantic','title':'proposition_change\x20may\x20not\x20emit\x20a\x20discrete\x20event\x20—\x20indexers\x20must\x20infer','description':'proposition_change\x20(arb.move)\x20updates\x20the\x20proposition\x20vector\x20in\x20place.\x20Unlike\x20'+'state\x20transitions\x20(which\x20emit\x20ArbEvent),\x20proposition\x20edits\x20may\x20not\x20produce\x20a\x20'+'discrete\x20event\x20—\x20indexers\x20must\x20infer\x20changes\x20by\x20diffing\x20the\x20proposition\x20vector\x20'+'across\x20polls.','affected_stakeholders':['arbitrator','voter'],'scenario':'Indexer\x20expects\x20a\x20PropositionChangedEvent;\x20none\x20is\x20emitted,\x20UI\x20fails\x20to\x20refresh','mitigation':'External\x20indexers\x20should\x20poll\x20the\x20proposition\x20vector.\x20UI\x20should\x20display\x20\x27propositions\x20'+'may\x20have\x20changed\x27\x20on\x20each\x20poll\x20rather\x20than\x20relying\x20on\x20event-driven\x20refresh.','auto_fixable':![]},'check':a=>{if(!a['expects_proposition_event'])return null;return{...R_A_04['rule'],'evidence':'expects_proposition_event=true\x20(poll\x20instead)'};}},R_A_05={'rule':{'id':'R-ARB-05','level':'MEDIUM','category':'semantic','title':'voting_deadline\x20is\x20Option<u64>\x20—\x20None\x20means\x20open-ended\x20vote','description':'voting_deadline\x20is\x20Option<u64>.\x20When\x20None,\x20voting\x20has\x20no\x20deadline\x20(open-ended)\x20and\x20'+'E_VOTING_DEADLINE_PASSED\x20(7)\x20never\x20triggers.\x20When\x20Some(t),\x20vote()\x20aborts\x20if\x20'+'clock.timestamp_ms()\x20>\x20t.\x20Callers\x20who\x20assume\x20a\x20default\x20deadline\x20may\x20be\x20surprised\x20by\x20'+'an\x20open-ended\x20vote\x20that\x20never\x20finalizes.','affected_stakeholders':['voter','arbitrator'],'scenario':'Voter\x20assumes\x20a\x20deadline;\x20voting_deadline\x20is\x20None\x20and\x20the\x20case\x20stalls\x20indefinitely','mitigation':'Document\x20that\x20None\x20means\x20open-ended.\x20Arbitrators\x20should\x20set\x20an\x20explicit\x20deadline\x20via\x20'+'arbitrator_confirm\x20unless\x20they\x20intend\x20an\x20open\x20vote.\x20SDK\x20should\x20surface\x20voting_deadline\x20'+'prominently.','related_move_error':'E_VOTING_DEADLINE_PASSED\x20(7)\x20/\x20E_VOTING_DEADLINE_NOT_PASSED\x20(4)','auto_fixable':![]},'check':a=>{if(!a['voting_deadline_none'])return null;return{...R_A_05['rule'],'evidence':'voting_deadline_none=true\x20(open-ended\x20vote)'};}},R_A_06={'rule':{'id':'R-ARB-06','level':'LOW','category':'semantic','title':'indemnity\x20is\x20Option<Indemnity>\x20—\x20None\x20means\x20no\x20compensation','description':'indemnity\x20is\x20Option<Indemnity>.\x20When\x20None,\x20the\x20arbitration\x20produces\x20no\x20compensation\x20'+'(e.g.\x20a\x20pure\x20declaratory\x20ruling).\x20Consumers\x20who\x20assume\x20a\x20non-null\x20indemnity\x20will\x20'+'mis-handle\x20None\x20cases.\x20finish()\x20returns\x20the\x20indemnity\x20amount\x20(0\x20when\x20None).','affected_stakeholders':['principal'],'scenario':'Principal\x20expects\x20compensation;\x20indemnity\x20is\x20None\x20and\x20finish()\x20returns\x200','mitigation':'Document\x20that\x20None\x20means\x20no\x20compensation.\x20UI\x20should\x20show\x20\x27no\x20compensation\x20awarded\x27\x20'+'rather\x20than\x20\x27compensation\x20pending\x27.','auto_fixable':![]},'check':a=>{if(!a['indemnity_none'])return null;return{...R_A_06['rule'],'evidence':'indemnity_none=true\x20(no\x20compensation)'};}},R_A_07={'rule':{'id':'R-ARB-07','level':'MEDIUM','category':'permission','title':'Voted.weight\x20is\x20set\x20by\x20the\x20Arbitration\x20rule\x20—\x20concentrated\x20weight\x20risk','description':'Voted.weight\x20(u32)\x20is\x20assigned\x20by\x20the\x20Arbitration\x20object\x27s\x20voting_guard\x20logic,\x20not\x20'+'by\x20the\x20voter.\x20If\x20the\x20Arbitration\x20rule\x20concentrates\x20weight\x20in\x20one\x20voter\x20(e.g.\x20an\x20'+'admin\x20with\x20weight\x201000\x20vs.\x20others\x20with\x20weight\x201),\x20a\x20single\x20voter\x20can\x20dictate\x20the\x20'+'outcome.\x20The\x20Arb\x20contract\x20itself\x20does\x20not\x20detect\x20concentration\x20—\x20that\x20is\x20the\x20'+'Arbitration\x20designer\x27s\x20responsibility.','affected_stakeholders':['voter','arbitrator'],'scenario':'Arbitration\x20rule\x20gives\x20one\x20voter\x20weight\x201000;\x20that\x20voter\x20single-handedly\x20decides\x20the\x20case','mitigation':'When\x20designing\x20the\x20Arbitration\x20rule,\x20cap\x20individual\x20voter\x20weight\x20and\x20require\x20a\x20'+'quorum.\x20Audit\x20the\x20voting_guard\x20to\x20ensure\x20no\x20single\x20voter\x20can\x20exceed\x20the\x20quorum\x20alone.','auto_fixable':![]},'check':a=>{if(!a['weight_concentrated'])return null;return{...R_A_07['rule'],'evidence':'weight_concentrated=true\x20(rule-level\x20risk)'};}},R_A_08={'rule':{'id':'R-ARB-08','level':'LOW','category':'semantic','title':'Status\x20uses\x20u8\x20constants\x20—\x20Move\x20enum\x20is\x20commented\x20out','description':'The\x207\x20statuses\x20are\x20defined\x20as\x20u8\x20constants\x20(Status_Principal_confirming=0,\x20etc.).\x20'+'The\x20Move\x20enum\x20definition\x20is\x20commented\x20out\x20(arb.move).\x20Consumers\x20cannot\x20rely\x20on\x20a\x20'+'type-safe\x20enum\x20and\x20must\x20compare\x20against\x20magic\x20numbers.\x20A\x20future\x20Wow\x20release\x20enabling\x20'+'the\x20enum\x20would\x20be\x20a\x20breaking\x20change\x20to\x20downstream\x20code.','affected_stakeholders':['system'],'scenario':'Developer\x20expects\x20a\x20Status\x20enum;\x20only\x20u8\x20constants\x20are\x20available,\x20causing\x20type\x20errors','mitigation':'SDK\x20should\x20expose\x20a\x20TypeScript\x20enum\x20mirroring\x20the\x20u8\x20constants.\x20Document\x20that\x20the\x20'+'Move\x20enum\x20is\x20intentionally\x20disabled\x20and\x20may\x20be\x20enabled\x20in\x20a\x20future\x20version.','auto_fixable':![]},'check':a=>{if(!a['expects_status_enum'])return null;return{...R_A_08['rule'],'evidence':'expects_status_enum=true\x20(only\x20u8\x20constants\x20exist)'};}};export const ARB_RISK_RULES=[R_A_01,R_A_02,R_A_03,R_A_04,R_A_05,R_A_06,R_A_07,R_A_08];export const ARB_RISK_VERSION='1.0.0';export function checkArbRisks(a){const b=[];for(const c of ARB_RISK_RULES){const d=c['check'](a);if(d)b['push'](d);}return b;}export function getArbRiskById(a){return ARB_RISK_RULES['find'](b=>b['rule']['id']===a)?.['rule'];}
|
|
1
|
+
import{MAX_VOTOR_COUNT,WITHDRAW_DURATION_TIME}from'@wowok/wowok';const R_A_01={'rule':{'id':'R-ARB-01','level':'HIGH','category':'lifecycle','title':'7-state\x20machine\x20—\x20invalid\x20transitions\x20can\x20deadlock\x20the\x20arbitration','description':'Arb\x20has\x20a\x207-state\x20machine:\x20Principal_confirming(0)\x20→\x20Arbitrator_confirming(1)\x20→\x20'+'Voting(2)\x20→\x20Arbitrated(3)\x20→\x20Objectionable(4)\x20→\x20Finished(5)\x20→\x20Withdrawn(6).\x20reset()\x20'+'can\x20revert\x20from\x20{1,\x204}\x20back\x20to\x200.\x20Each\x20op\x20asserts\x20the\x20current\x20status;\x20calling\x20an\x20op\x20'+'out\x20of\x20order\x20aborts\x20with\x20E_STATUS_NOT_MATCH\x20(3).\x20Repeated\x20mis-calls\x20leave\x20the\x20Arb\x20'+'stuck\x20in\x20a\x20non-terminal\x20state\x20with\x20no\x20automatic\x20recovery.','affected_stakeholders':['principal','arbitrator','voter'],'scenario':'Caller\x20calls\x20vote()\x20when\x20status\x20is\x20still\x20Arbitrator_confirming;\x20abort\x20blocks\x20progress','mitigation':'Strictly\x20validate\x20the\x20current\x20status\x20before\x20submitting\x20any\x20Arb\x20op.\x20The\x20SDK\x20should\x20'+'expose\x20a\x20status-aware\x20state\x20machine\x20helper.\x20Provide\x20a\x20recovery\x20path\x20(reset)\x20for\x20'+'Arbitrator_confirming\x20and\x20Objectionable\x20states.','related_move_error':'E_STATUS_NOT_MATCH\x20(3)','auto_fixable':![]},'check':a=>{if(!a['invalid_transition'])return null;return{...R_A_01['rule'],'evidence':'invalid_transition=true\x20(status='+(a['status']??'?')+')'};}},R_A_02={'rule':{'id':'R-ARB-02','level':'MEDIUM','category':'lifecycle','title':'WITHDRAW_DURATION_TIME='+WITHDRAW_DURATION_TIME+'ms\x20(30\x20days)\x20—\x20funds\x20locked','description':'After\x20arbitration,\x20the\x20fee\x20Balance\x20can\x20only\x20be\x20withdrawn\x20after\x20'+('WITHDRAW_DURATION_TIME='+WITHDRAW_DURATION_TIME+'ms\x20(30\x20days)\x20when\x20status\x20is\x20')+'Arbitrated(3)\x20or\x20Objectionable(4).\x20From\x20Finished(5),\x20withdraw\x20is\x20immediate.\x20'+'The\x2030-day\x20lock\x20is\x20a\x20dispute-window\x20safeguard,\x20but\x20it\x20locks\x20funds\x20for\x20a\x20long\x20time\x20'+'and\x20users\x20may\x20not\x20understand\x20why.','affected_stakeholders':['principal','arbitrator'],'scenario':'Arbitrator\x20finishes\x20a\x20case\x20but\x20must\x20wait\x2030\x20days\x20to\x20claim\x20the\x20fee','mitigation':'Surface\x20the\x20unlock\x20timestamp\x20in\x20the\x20UI.\x20To\x20shorten\x20the\x20lock,\x20drive\x20the\x20case\x20to\x20'+'Finished(5)\x20via\x20finish()\x20rather\x20than\x20leaving\x20it\x20in\x20Arbitrated/Objectionable.','related_move_error':'E_WITHDRAW_DURATION_TIME_NOT_PASSED\x20(8)','auto_fixable':![]},'check':a=>{if(!a['withdraw_too_early'])return null;return{...R_A_02['rule'],'evidence':'withdraw_too_early=true\x20(limit='+WITHDRAW_DURATION_TIME+'ms)'};}},R_A_03={'rule':{'id':'R-ARB-03','level':'MEDIUM','category':'structural','title':'MAX_VOTOR_COUNT='+MAX_VOTOR_COUNT+'\x20permissive\x20—\x20voting\x20efficiency\x20cost','description':'A\x20single\x20Arb\x20may\x20record\x20up\x20to\x20MAX_VOTOR_COUNT='+MAX_VOTOR_COUNT+'\x20voters\x20(arb.move:236).\x20'+'The\x20limit\x20aborts\x20with\x20E_MAX_VOTOR_COUNT\x20(6)\x20only\x20at\x20the\x20boundary.\x20520\x20voters\x20in\x20one\x20'+'Arb\x20inflates\x20the\x20voted\x20vector,\x20slowing\x20tally\x20and\x20gas,\x20and\x20complicates\x20weighted-quorum\x20'+'reasoning.','affected_stakeholders':['voter','arbitrator'],'scenario':'Arbitration\x20allows\x20520\x20voters;\x20tallying\x20the\x20vote\x20vector\x20is\x20slow\x20and\x20gas-heavy','mitigation':'Business\x20layer\x20should\x20self-limit\x20voter\x20count\x20based\x20on\x20the\x20Arbitration\x20rule\x27s\x20quorum.\x20'+'For\x20large\x20juries,\x20shard\x20across\x20multiple\x20Arb\x20instances\x20or\x20aggregate\x20off-chain.','related_move_error':'E_MAX_VOTOR_COUNT\x20(6)','auto_fixable':![]},'check':a=>{if(a['votor_count']===undefined)return null;if(a['votor_count']<MAX_VOTOR_COUNT)return null;return{...R_A_03['rule'],'evidence':'votor_count='+a['votor_count']+',\x20limit='+MAX_VOTOR_COUNT};}},R_A_04={'rule':{'id':'R-ARB-04','level':'LOW','category':'semantic','title':'proposition_change\x20may\x20not\x20emit\x20a\x20discrete\x20event\x20—\x20indexers\x20must\x20infer','description':'proposition_change\x20(arb.move)\x20updates\x20the\x20proposition\x20vector\x20in\x20place.\x20Unlike\x20'+'state\x20transitions\x20(which\x20emit\x20ArbEvent),\x20proposition\x20edits\x20may\x20not\x20produce\x20a\x20'+'discrete\x20event\x20—\x20indexers\x20must\x20infer\x20changes\x20by\x20diffing\x20the\x20proposition\x20vector\x20'+'across\x20polls.','affected_stakeholders':['arbitrator','voter'],'scenario':'Indexer\x20expects\x20a\x20PropositionChangedEvent;\x20none\x20is\x20emitted,\x20UI\x20fails\x20to\x20refresh','mitigation':'External\x20indexers\x20should\x20poll\x20the\x20proposition\x20vector.\x20UI\x20should\x20display\x20\x27propositions\x20'+'may\x20have\x20changed\x27\x20on\x20each\x20poll\x20rather\x20than\x20relying\x20on\x20event-driven\x20refresh.','auto_fixable':![]},'check':a=>{if(!a['expects_proposition_event'])return null;return{...R_A_04['rule'],'evidence':'expects_proposition_event=true\x20(poll\x20instead)'};}},R_A_05={'rule':{'id':'R-ARB-05','level':'MEDIUM','category':'semantic','title':'voting_deadline\x20is\x20Option<u64>\x20—\x20None\x20means\x20open-ended\x20vote','description':'voting_deadline\x20is\x20Option<u64>.\x20When\x20None,\x20voting\x20has\x20no\x20deadline\x20(open-ended)\x20and\x20'+'E_VOTING_DEADLINE_PASSED\x20(7)\x20never\x20triggers.\x20When\x20Some(t),\x20vote()\x20aborts\x20if\x20'+'clock.timestamp_ms()\x20>\x20t.\x20Callers\x20who\x20assume\x20a\x20default\x20deadline\x20may\x20be\x20surprised\x20by\x20'+'an\x20open-ended\x20vote\x20that\x20never\x20finalizes.','affected_stakeholders':['voter','arbitrator'],'scenario':'Voter\x20assumes\x20a\x20deadline;\x20voting_deadline\x20is\x20None\x20and\x20the\x20case\x20stalls\x20indefinitely','mitigation':'Document\x20that\x20None\x20means\x20open-ended.\x20Arbitrators\x20should\x20set\x20an\x20explicit\x20deadline\x20via\x20'+'arbitrator_confirm\x20unless\x20they\x20intend\x20an\x20open\x20vote.\x20SDK\x20should\x20surface\x20voting_deadline\x20'+'prominently.','related_move_error':'E_VOTING_DEADLINE_PASSED\x20(7)\x20/\x20E_VOTING_DEADLINE_NOT_PASSED\x20(4)','auto_fixable':![]},'check':a=>{if(!a['voting_deadline_none'])return null;return{...R_A_05['rule'],'evidence':'voting_deadline_none=true\x20(open-ended\x20vote)'};}},R_A_06={'rule':{'id':'R-ARB-06','level':'LOW','category':'semantic','title':'indemnity\x20is\x20Option<Indemnity>\x20—\x20None\x20means\x20no\x20compensation','description':'indemnity\x20is\x20Option<Indemnity>.\x20When\x20None,\x20the\x20arbitration\x20produces\x20no\x20compensation\x20'+'(e.g.\x20a\x20pure\x20declaratory\x20ruling).\x20Consumers\x20who\x20assume\x20a\x20non-null\x20indemnity\x20will\x20'+'mis-handle\x20None\x20cases.\x20finish()\x20returns\x20the\x20indemnity\x20amount\x20(0\x20when\x20None).','affected_stakeholders':['principal'],'scenario':'Principal\x20expects\x20compensation;\x20indemnity\x20is\x20None\x20and\x20finish()\x20returns\x200','mitigation':'Document\x20that\x20None\x20means\x20no\x20compensation.\x20UI\x20should\x20show\x20\x27no\x20compensation\x20awarded\x27\x20'+'rather\x20than\x20\x27compensation\x20pending\x27.','auto_fixable':![]},'check':a=>{if(!a['indemnity_none'])return null;return{...R_A_06['rule'],'evidence':'indemnity_none=true\x20(no\x20compensation)'};}},R_A_07={'rule':{'id':'R-ARB-07','level':'MEDIUM','category':'permission','title':'Voted.weight\x20is\x20set\x20by\x20the\x20Arbitration\x20rule\x20—\x20concentrated\x20weight\x20risk','description':'Voted.weight\x20(u32)\x20is\x20assigned\x20by\x20the\x20Arbitration\x20object\x27s\x20voting_guard\x20logic,\x20not\x20'+'by\x20the\x20voter.\x20If\x20the\x20Arbitration\x20rule\x20concentrates\x20weight\x20in\x20one\x20voter\x20(e.g.\x20an\x20'+'admin\x20with\x20weight\x201000\x20vs.\x20others\x20with\x20weight\x201),\x20a\x20single\x20voter\x20can\x20dictate\x20the\x20'+'outcome.\x20The\x20Arb\x20contract\x20itself\x20does\x20not\x20detect\x20concentration\x20—\x20that\x20is\x20the\x20'+'Arbitration\x20designer\x27s\x20responsibility.','affected_stakeholders':['voter','arbitrator'],'scenario':'Arbitration\x20rule\x20gives\x20one\x20voter\x20weight\x201000;\x20that\x20voter\x20single-handedly\x20decides\x20the\x20case','mitigation':'When\x20designing\x20the\x20Arbitration\x20rule,\x20cap\x20individual\x20voter\x20weight\x20and\x20require\x20a\x20'+'quorum.\x20Audit\x20the\x20voting_guard\x20to\x20ensure\x20no\x20single\x20voter\x20can\x20exceed\x20the\x20quorum\x20alone.','auto_fixable':![]},'check':a=>{if(!a['weight_concentrated'])return null;return{...R_A_07['rule'],'evidence':'weight_concentrated=true\x20(rule-level\x20risk)'};}},R_A_08={'rule':{'id':'R-ARB-08','level':'LOW','category':'semantic','title':'Status\x20uses\x20u8\x20constants\x20—\x20Move\x20enum\x20is\x20commented\x20out','description':'The\x207\x20statuses\x20are\x20defined\x20as\x20u8\x20constants\x20(Status_Principal_confirming=0,\x20etc.).\x20'+'The\x20Move\x20enum\x20definition\x20is\x20commented\x20out\x20(arb.move).\x20Consumers\x20cannot\x20rely\x20on\x20a\x20'+'type-safe\x20enum\x20and\x20must\x20compare\x20against\x20magic\x20numbers.\x20A\x20future\x20Wow\x20release\x20enabling\x20'+'the\x20enum\x20would\x20be\x20a\x20breaking\x20change\x20to\x20downstream\x20code.','affected_stakeholders':['system'],'scenario':'Developer\x20expects\x20a\x20Status\x20enum;\x20only\x20u8\x20constants\x20are\x20available,\x20causing\x20type\x20errors','mitigation':'SDK\x20should\x20expose\x20a\x20TypeScript\x20enum\x20mirroring\x20the\x20u8\x20constants.\x20Document\x20that\x20the\x20'+'Move\x20enum\x20is\x20intentionally\x20disabled\x20and\x20may\x20be\x20enabled\x20in\x20a\x20future\x20version.','auto_fixable':![]},'check':a=>{if(!a['expects_status_enum'])return null;return{...R_A_08['rule'],'evidence':'expects_status_enum=true\x20(only\x20u8\x20constants\x20exist)'};}};export const ARB_RISK_RULES=[R_A_01,R_A_02,R_A_03,R_A_04,R_A_05,R_A_06,R_A_07,R_A_08];export const ARB_RISK_VERSION='1.0.0';export function checkArbRisks(a){const b=[];for(const c of ARB_RISK_RULES){const d=c['check'](a);if(d)b['push'](d);}return b;}
|
|
@@ -99,8 +99,6 @@ export interface RiskCheckContext {
|
|
|
99
99
|
}
|
|
100
100
|
export declare const ARBITRATION_RISK_VERSION = "1.0.0";
|
|
101
101
|
export declare function getAllRiskRules(): RiskRule[];
|
|
102
|
-
export declare function getRiskRulesCount(): number;
|
|
103
|
-
export declare function getRiskRulesByCategory(category: RiskCategory): RiskRule[];
|
|
104
102
|
export interface ArbitrationRiskAssessment {
|
|
105
103
|
summary: string;
|
|
106
104
|
risks: ArbitrationRisk[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{MAX_VOTING_GUARD_COUNT}from'@wowok/wowok';import{isTerminalArbStatus,isValidArbStatusTransition}from'./arbitration-ledger.js';const R_AB_1_01={'id':'R-AB-1-01','category':'structural','trigger':'voting_guard\x20count\x20exceeds\x20MAX_VOTING_GUARD_COUNT\x20(50)','check':a=>{if(!a['voting_guard'])return null;if(a['voting_guard']['op']==='add'||a['voting_guard']['op']==='set'){const b=a['voting_guard']['op']==='set'?a['voting_guard']['guards']['length']:(a['current_voting_guard_count']??0x0)+a['voting_guard']['guards']['length'];if(b>MAX_VOTING_GUARD_COUNT)return{'id':'R-AB-1-01','level':'HIGH','category':'structural','title':'voting_guard\x20count\x20exceeds\x20limit','description':'voting_guard\x20would\x20have\x20'+b+'\x20entries,\x20exceeds\x20MAX_VOTING_GUARD_COUNT\x20'+MAX_VOTING_GUARD_COUNT,'affected_stakeholders':['owner','arbiter'],'scenario':'Adding\x20too\x20many\x20voting\x20guards','mitigation':'Remove\x20unused\x20guards\x20before\x20adding\x20new\x20ones;\x20max\x20'+MAX_VOTING_GUARD_COUNT,'evidence':'count='+b};}return null;}},R_AB_1_02={'id':'R-AB-1-02','category':'structural','trigger':'Dispute\x20fee\x20below\x20arbitration.fee\x20threshold','check':a=>{if(!a['dispute']||a['current_arbitration_fee']===undefined)return null;const b=typeof a['current_arbitration_fee']==='string'?BigInt(a['current_arbitration_fee']):BigInt(a['current_arbitration_fee']),c=typeof a['dispute']['fee']==='object'&&a['dispute']['fee']!==null&&'balance'in a['dispute']['fee']?BigInt(a['dispute']['fee']['balance']??0x0):BigInt(0x0);if(c<b)return{'id':'R-AB-1-02','level':'CRITICAL','category':'structural','title':'Dispute\x20fee\x20insufficient\x20(E_FEE_NOT_ENOUGH)','description':'Provided\x20fee\x20'+c['toString']()+'\x20<\x20required\x20'+b['toString'](),'affected_stakeholders':['disputant'],'scenario':'Filing\x20dispute\x20with\x20insufficient\x20fee','mitigation':'Increase\x20dispute.fee.balance\x20to\x20>=\x20'+b['toString'](),'evidence':'provided='+c['toString']()+',\x20required='+b['toString']()};return null;}},R_AB_1_03={'id':'R-AB-1-03','category':'structural','trigger':'Arbitration\x20paused\x20(bPaused=true)\x20—\x20dispute\x20will\x20fail\x20with\x20E_PAUSED','check':a=>{if(a['dispute']&&a['current_bPaused']===!![])return{'id':'R-AB-1-03','level':'HIGH','category':'structural','title':'Arbitration\x20paused\x20—\x20cannot\x20file\x20dispute','description':'Arbitration.bPaused=true;\x20dispute()\x20will\x20abort\x20with\x20E_PAUSED','affected_stakeholders':['disputant'],'scenario':'Filing\x20dispute\x20against\x20a\x20paused\x20Arbitration','mitigation':'Call\x20pause(false)\x20(requires\x20ARBITRATION_PAUSE=356)\x20to\x20resume','evidence':'bPaused=true'};return null;}},R_AB_1_04={'id':'R-AB-1-04','category':'structural','trigger':'voting_deadline\x20in\x20the\x20past\x20—\x20vote\x20will\x20be\x20rejected','check':a=>{const b=a['confirm']?.['voting_deadline']??a['voting_deadline_change']?.['voting_deadline'];if(b!==undefined&&b!==null&&a['current_timestamp_ms']!==undefined){if(b<a['current_timestamp_ms'])return{'id':'R-AB-1-04','level':'HIGH','category':'structural','title':'voting_deadline\x20in\x20the\x20past','description':'Deadline\x20'+b+'\x20is\x20before\x20current\x20time\x20'+a['current_timestamp_ms'],'affected_stakeholders':['voter','arbiter'],'scenario':'Setting\x20voting\x20deadline\x20to\x20an\x20already-elapsed\x20timestamp','mitigation':'Use\x20a\x20future\x20timestamp\x20(e.g.\x20now\x20+\x207\x20days\x20in\x20ms)','evidence':'deadline='+b+',\x20now='+a['current_timestamp_ms']};}return null;}},R_AB_2_01={'id':'R-AB-2-01','category':'semantic','trigger':'voting_guard\x20misconfiguration\x20—\x20dispute\x20cannot\x20be\x20resolved','check':a=>{if(a['vote']&&a['vote']['voting_guard']){if(!a['current_voting_guard_addresses']||a['current_voting_guard_addresses']['length']===0x0)return{'id':'R-AB-2-01','level':'HIGH','category':'semantic','title':'voting_guard\x20misconfiguration\x20—\x20dispute\x20cannot\x20be\x20resolved','description':'vote.voting_guard\x20provided\x20but\x20Arbitration.voting_guard\x20is\x20empty;\x20E_VOTING_GUARD_NOT_FOUND\x20will\x20abort','affected_stakeholders':['voter','arbiter','disputant'],'scenario':'voting_guard\x20misconfiguration\x20prevents\x20vote\x20—\x20dispute\x20stuck','mitigation':'Either\x20add\x20the\x20Guard\x20to\x20voting_guard\x20list\x20(354)\x20or\x20use\x20open\x20vote()\x20without\x20voting_guard','evidence':'vote.voting_guard='+a['vote']['voting_guard']};if(!a['current_voting_guard_addresses']['includes'](a['vote']['voting_guard']))return{'id':'R-AB-2-01','level':'HIGH','category':'semantic','title':'voting_guard\x20misconfiguration\x20—\x20dispute\x20cannot\x20be\x20resolved','description':'vote.voting_guard\x20'+a['vote']['voting_guard']+'\x20not\x20in\x20Arbitration.voting_guard\x20list','affected_stakeholders':['voter','arbiter','disputant'],'scenario':'Voter\x27s\x20Guard\x20not\x20registered\x20—\x20vote\x20will\x20fail\x20with\x20E_VOTING_GUARD_NOT_FOUND','mitigation':'Add\x20guard\x20'+a['vote']['voting_guard']+'\x20via\x20voting_guard_add\x20(354),\x20or\x20use\x20a\x20registered\x20guard','evidence':'provided='+a['vote']['voting_guard']+',\x20registered='+a['current_voting_guard_addresses']['join'](',')};}return null;}},R_AB_2_03={'id':'R-AB-2-03','category':'semantic','trigger':'VoteValue.GuardIdentifier\x20with\x20non-numeric\x20Guard\x20submission\x20type','check':a=>{if(a['voting_guard']&&(a['voting_guard']['op']==='add'||a['voting_guard']['op']==='set'))for(const b of a['voting_guard']['guards']){const c=b['vote_weight'];if('GuardIdentifier'in c&&c['GuardIdentifier']!==undefined){if(c['GuardIdentifier']>0xff)return{'id':'R-AB-2-03','level':'HIGH','category':'semantic','title':'GuardIdentifier\x20index\x20>\x20u8::max\x20(255)','description':'GuardIdentifier\x20'+c['GuardIdentifier']+'\x20exceeds\x20u8\x20max\x20(255)','affected_stakeholders':['owner'],'scenario':'Setting\x20GuardIdentifier\x20index\x20beyond\x20u8\x20range','mitigation':'Use\x20GuardIdentifier\x20index\x200-255','evidence':'identifier='+c['GuardIdentifier']};}if('FixedValue'in c&&c['FixedValue']!==undefined){if(c['FixedValue']>0xffffffff)return{'id':'R-AB-2-03','level':'HIGH','category':'semantic','title':'FixedValue\x20>\x20u32::max\x20(4294967295)','description':'FixedValue\x20'+c['FixedValue']+'\x20exceeds\x20u32\x20max','affected_stakeholders':['owner'],'scenario':'Setting\x20FixedValue\x20beyond\x20u32\x20range','mitigation':'Use\x20FixedValue\x200-4294967295','evidence':'fixed='+c['FixedValue']};}}return null;}},R_AB_3_01={'id':'R-AB-3-01','category':'authority','trigger':'Arbiter\x20collusion\x20—\x20single\x20voter\x20controls\x20>50%\x20of\x20total\x20weight','check':a=>{if(!a['voting_guard']||a['voting_guard']['op']!=='add'&&a['voting_guard']['op']!=='set')return null;const b=a['voting_guard']['guards'];if(b['length']<0x2)return null;const c=b['filter'](f=>'FixedValue'in f['vote_weight']&&f['vote_weight']['FixedValue']!==undefined)['map'](f=>f['vote_weight']['FixedValue']);if(c['length']===0x0)return null;const d=c['reduce']((f,g)=>f+g,0x0),e=Math['max'](...c);if(d>0x0&&e/d>0.5)return{'id':'R-AB-3-01','level':'MEDIUM','category':'authority','title':'Arbiter\x20collusion\x20risk\x20—\x20single\x20guard\x20controls\x20>50%\x20weight','description':'One\x20voting_guard\x20has\x20'+e+'\x20of\x20'+d+'\x20total\x20weight\x20('+(e/d*0x64)['toFixed'](0x1)+'%)','affected_stakeholders':['owner','disputant'],'scenario':'Weighted\x20voting\x20with\x20dominant\x20arbiter\x20—\x20can\x20single-handedly\x20decide\x20rulings','mitigation':'Distribute\x20weight\x20more\x20evenly,\x20or\x20require\x20multi-arbiter\x20consensus','evidence':'max='+e+',\x20total='+d+',\x20ratio='+(e/d*0x64)['toFixed'](0x1)+'%'};return null;}},R_AB_3_02={'id':'R-AB-3-02','category':'authority','trigger':'Permission\x20over-concentration\x20—\x20single\x20admin\x20(owner)','check':a=>{if(a['builder'])return{'id':'R-AB-3-02','level':'HIGH','category':'authority','title':'Arbitration\x20ownership\x20transfer\x20—\x20IRREVERSIBLE','description':'Transferring\x20Arbitration\x20to\x20'+a['builder']+';\x20original\x20owner\x20loses\x20all\x20control\x20permanently','affected_stakeholders':['owner'],'scenario':'Transferring\x20Arbitration\x20ownership','mitigation':'1)\x20Verify\x20new\x20owner\x20twice.\x202)\x20Confirm\x20new\x20owner\x20has\x20350-368\x20permissions\x20configured.\x203)\x20Coordinate\x20before\x20transfer.','evidence':'new_owner='+a['builder']};return null;}},R_AB_3_03={'id':'R-AB-3-03','category':'authority','trigger':'ARBITRATION_ARBITRATION\x20(359)\x20granted\x20to\x20wide\x20audience','check':a=>{if(a['arbitration']&&!a['current_voting_guard_addresses']?.['length'])return{'id':'R-AB-3-03','level':'MEDIUM','category':'authority','title':'Ruling\x20without\x20voting_guard\x20—\x20single-arbiter\x20can\x20rule\x20unchallenged','description':'make_ruling\x20(359)\x20without\x20voting_guard\x20means\x20any\x20permission\x20holder\x20can\x20unilaterally\x20decide','affected_stakeholders':['disputant','voter'],'scenario':'Single-arbiter\x20Arbitration\x20without\x20consensus\x20check','mitigation':'Configure\x20voting_guard\x20(354)\x20to\x20require\x20multi-arbiter\x20consensus\x20before\x20ruling','evidence':'voting_guard=empty'};return null;}},R_AB_4_01={'id':'R-AB-4-01','category':'lifecycle','trigger':'Invalid\x20Arb\x20status\x20transition\x20(7-state\x20flow\x20violation)','check':a=>{if(!a['current_arb_status']||!a['expected_arb_status'])return null;if(a['current_arb_status']===a['expected_arb_status'])return null;if(!isValidArbStatusTransition(a['current_arb_status'],a['expected_arb_status']))return{'id':'R-AB-4-01','level':'CRITICAL','category':'lifecycle','title':'Invalid\x20Arb\x20status\x20transition','description':a['current_arb_status']+'\x20→\x20'+a['expected_arb_status']+'\x20is\x20not\x20a\x20valid\x207-state\x20flow\x20transition','affected_stakeholders':['arbiter','disputant'],'scenario':'Attempting\x20operation\x20out\x20of\x20order\x20(e.g.\x20vote\x20before\x20confirm)','mitigation':'Follow\x20the\x207-state\x20flow:\x20Principal_confirming\x20→\x20Arbitrator_confirming\x20→\x20Voting\x20→\x20Arbitrated\x20→\x20Objectionable\x20→\x20Finished/Withdrawn','evidence':a['current_arb_status']+'\x20→\x20'+a['expected_arb_status']};return null;}},R_AB_4_02={'id':'R-AB-4-02','category':'lifecycle','trigger':'Operation\x20on\x20terminal\x20Arb\x20status\x20(Finished/Withdrawn)','check':a=>{if(!a['current_arb_status'])return null;if(isTerminalArbStatus(a['current_arb_status'])){const b=a['arb_withdraw'];if(!b&&(a['vote']||a['confirm']||a['arbitration']||a['reset']||a['feedback']))return{'id':'R-AB-4-02','level':'HIGH','category':'lifecycle','title':'Operation\x20on\x20terminal\x20Arb\x20status\x20—\x20irreversible','description':'Arb\x20is\x20in\x20terminal\x20status\x20'+a['current_arb_status']+';\x20only\x20arb_withdraw\x20is\x20allowed','affected_stakeholders':['arbiter','disputant'],'scenario':'Voting/ruling/reset\x20on\x20a\x20Finished\x20or\x20Withdrawn\x20Arb','mitigation':'Open\x20a\x20new\x20Arb\x20case\x20via\x20dispute()\x20if\x20further\x20arbitration\x20is\x20needed','evidence':'status='+a['current_arb_status']};}return null;}},R_AB_4_03={'id':'R-AB-4-03','category':'lifecycle','trigger':'reset\x20operation\x20—\x20may\x20indefinitely\x20extend\x20arbitration','check':a=>{if(!a['reset'])return null;return{'id':'R-AB-4-03','level':'MEDIUM','category':'lifecycle','title':'reset\x20operation\x20—\x20arbitration\x20lifecycle\x20extended','description':'reset\x20on\x20Arb\x20'+a['reset']['arb']+'\x20restarts\x20lifecycle\x20to\x20Principal_confirming;\x20feedback\x20required','affected_stakeholders':['arbiter','disputant'],'scenario':'Disputant\x20objects\x20to\x20ruling\x20and\x20resubmits\x20materials','mitigation':'Track\x20reset\x20count\x20—\x20consider\x20capping\x20resets\x20to\x20prevent\x20abuse','evidence':'arb='+a['reset']['arb']};}},R_AB_5_01={'id':'R-AB-5-01','category':'cross_object','trigger':'fees_alloc/fees_transfer\x20unfair\x20distribution\x20—\x20destination\x20not\x20verified','check':a=>{if(!a['fees_transfer'])return null;const b='allocation'in a['fees_transfer']['to']?'Allocation\x20'+a['fees_transfer']['to']['allocation']:'Treasury\x20'+a['fees_transfer']['to']['treasury'];return{'id':'R-AB-5-01','level':'MEDIUM','category':'cross_object','title':'fees_alloc/fees_transfer\x20—\x20verify\x20destination\x20fairness','description':'All\x20Arbitration.balance\x20will\x20be\x20transferred\x20to\x20'+b+';\x20ensure\x20destination\x20policy\x20is\x20fair\x20to\x20arbiters','affected_stakeholders':['arbiter','owner'],'scenario':'Distributing\x20arbitration\x20fees\x20without\x20verifying\x20allocation\x20rules','mitigation':'Verify\x20'+b+'\x20has\x20fair\x20distribution\x20policy;\x20consider\x20allocating\x20to\x20arbiters\x27\x20Allocation','evidence':'dest='+b+',\x20remark='+a['fees_transfer']['payment_remark']};}},R_AB_5_02={'id':'R-AB-5-02','category':'cross_object','trigger':'Dispute\x20filed\x20but\x20Order\x20op\x20permission\x20not\x20verified\x20—\x20E_NOT_OP_PERMISSION','check':a=>{if(!a['dispute'])return null;return{'id':'R-AB-5-02','level':'HIGH','category':'cross_object','title':'Order\x20op\x20permission\x20required\x20for\x20dispute','description':'dispute\x20on\x20Order\x20'+a['dispute']['order']+'\x20requires\x20order::assert_op_permission;\x20signer\x20must\x20have\x20Order\x27s\x20dispute\x20permission','affected_stakeholders':['disputant'],'scenario':'Filing\x20dispute\x20without\x20Order\x20op\x20permission','mitigation':'Ensure\x20signer\x20has\x20Order\x27s\x20dispute\x20operation\x20permission\x20(custom\x20index\x20or\x20builtin)','evidence':'order='+a['dispute']['order']};}},ALL_RULES=[R_AB_1_01,R_AB_1_02,R_AB_1_03,R_AB_1_04,R_AB_2_01,R_AB_2_03,R_AB_3_01,R_AB_3_02,R_AB_3_03,R_AB_4_01,R_AB_4_02,R_AB_4_03,R_AB_5_01,R_AB_5_02];export const ARBITRATION_RISK_VERSION='1.0.0';export function getAllRiskRules(){return[...ALL_RULES];}export function getRiskRulesCount(){return ALL_RULES['length'];}export function getRiskRulesByCategory(a){return ALL_RULES['filter'](b=>b['category']===a);}export function assessArbitrationRisks(a){const b=[];for(const f of ALL_RULES){const g=f['check'](a);if(g)b['push'](g);}const c=b['length']===0x0?'LOW':b['some'](h=>h['level']==='CRITICAL')?'CRITICAL':b['some'](h=>h['level']==='HIGH')?'HIGH':b['some'](h=>h['level']==='MEDIUM')?'MEDIUM':'LOW',d={};for(const h of b){d[h['category']]=(d[h['category']]??0x0)+0x1;}const e={};for(const i of b){for(const j of i['affected_stakeholders']){if(!e[j])e[j]=[];e[j]['push'](i['id']+':\x20'+i['mitigation']);}}return{'summary':'Assessed\x20'+b['length']+'\x20risk(s)\x20across\x20'+Object['keys'](d)['length']+'\x20categories','risks':b,'overall_risk':c,'risks_by_category':d,'stakeholder_advice':e,'needs_human_review':b['some'](k=>k['level']==='CRITICAL'||k['level']==='HIGH')};}
|
|
1
|
+
import{MAX_VOTING_GUARD_COUNT}from'@wowok/wowok';import{isTerminalArbStatus,isValidArbStatusTransition}from'./arbitration-ledger.js';const R_AB_1_01={'id':'R-AB-1-01','category':'structural','trigger':'voting_guard\x20count\x20exceeds\x20MAX_VOTING_GUARD_COUNT\x20(50)','check':a=>{if(!a['voting_guard'])return null;if(a['voting_guard']['op']==='add'||a['voting_guard']['op']==='set'){const b=a['voting_guard']['op']==='set'?a['voting_guard']['guards']['length']:(a['current_voting_guard_count']??0x0)+a['voting_guard']['guards']['length'];if(b>MAX_VOTING_GUARD_COUNT)return{'id':'R-AB-1-01','level':'HIGH','category':'structural','title':'voting_guard\x20count\x20exceeds\x20limit','description':'voting_guard\x20would\x20have\x20'+b+'\x20entries,\x20exceeds\x20MAX_VOTING_GUARD_COUNT\x20'+MAX_VOTING_GUARD_COUNT,'affected_stakeholders':['owner','arbiter'],'scenario':'Adding\x20too\x20many\x20voting\x20guards','mitigation':'Remove\x20unused\x20guards\x20before\x20adding\x20new\x20ones;\x20max\x20'+MAX_VOTING_GUARD_COUNT,'evidence':'count='+b};}return null;}},R_AB_1_02={'id':'R-AB-1-02','category':'structural','trigger':'Dispute\x20fee\x20below\x20arbitration.fee\x20threshold','check':a=>{if(!a['dispute']||a['current_arbitration_fee']===undefined)return null;const b=typeof a['current_arbitration_fee']==='string'?BigInt(a['current_arbitration_fee']):BigInt(a['current_arbitration_fee']),c=typeof a['dispute']['fee']==='object'&&a['dispute']['fee']!==null&&'balance'in a['dispute']['fee']?BigInt(a['dispute']['fee']['balance']??0x0):BigInt(0x0);if(c<b)return{'id':'R-AB-1-02','level':'CRITICAL','category':'structural','title':'Dispute\x20fee\x20insufficient\x20(E_FEE_NOT_ENOUGH)','description':'Provided\x20fee\x20'+c['toString']()+'\x20<\x20required\x20'+b['toString'](),'affected_stakeholders':['disputant'],'scenario':'Filing\x20dispute\x20with\x20insufficient\x20fee','mitigation':'Increase\x20dispute.fee.balance\x20to\x20>=\x20'+b['toString'](),'evidence':'provided='+c['toString']()+',\x20required='+b['toString']()};return null;}},R_AB_1_03={'id':'R-AB-1-03','category':'structural','trigger':'Arbitration\x20paused\x20(bPaused=true)\x20—\x20dispute\x20will\x20fail\x20with\x20E_PAUSED','check':a=>{if(a['dispute']&&a['current_bPaused']===!![])return{'id':'R-AB-1-03','level':'HIGH','category':'structural','title':'Arbitration\x20paused\x20—\x20cannot\x20file\x20dispute','description':'Arbitration.bPaused=true;\x20dispute()\x20will\x20abort\x20with\x20E_PAUSED','affected_stakeholders':['disputant'],'scenario':'Filing\x20dispute\x20against\x20a\x20paused\x20Arbitration','mitigation':'Call\x20pause(false)\x20(requires\x20ARBITRATION_PAUSE=356)\x20to\x20resume','evidence':'bPaused=true'};return null;}},R_AB_1_04={'id':'R-AB-1-04','category':'structural','trigger':'voting_deadline\x20in\x20the\x20past\x20—\x20vote\x20will\x20be\x20rejected','check':a=>{const b=a['confirm']?.['voting_deadline']??a['voting_deadline_change']?.['voting_deadline'];if(b!==undefined&&b!==null&&a['current_timestamp_ms']!==undefined){if(b<a['current_timestamp_ms'])return{'id':'R-AB-1-04','level':'HIGH','category':'structural','title':'voting_deadline\x20in\x20the\x20past','description':'Deadline\x20'+b+'\x20is\x20before\x20current\x20time\x20'+a['current_timestamp_ms'],'affected_stakeholders':['voter','arbiter'],'scenario':'Setting\x20voting\x20deadline\x20to\x20an\x20already-elapsed\x20timestamp','mitigation':'Use\x20a\x20future\x20timestamp\x20(e.g.\x20now\x20+\x207\x20days\x20in\x20ms)','evidence':'deadline='+b+',\x20now='+a['current_timestamp_ms']};}return null;}},R_AB_2_01={'id':'R-AB-2-01','category':'semantic','trigger':'voting_guard\x20misconfiguration\x20—\x20dispute\x20cannot\x20be\x20resolved','check':a=>{if(a['vote']&&a['vote']['voting_guard']){if(!a['current_voting_guard_addresses']||a['current_voting_guard_addresses']['length']===0x0)return{'id':'R-AB-2-01','level':'HIGH','category':'semantic','title':'voting_guard\x20misconfiguration\x20—\x20dispute\x20cannot\x20be\x20resolved','description':'vote.voting_guard\x20provided\x20but\x20Arbitration.voting_guard\x20is\x20empty;\x20E_VOTING_GUARD_NOT_FOUND\x20will\x20abort','affected_stakeholders':['voter','arbiter','disputant'],'scenario':'voting_guard\x20misconfiguration\x20prevents\x20vote\x20—\x20dispute\x20stuck','mitigation':'Either\x20add\x20the\x20Guard\x20to\x20voting_guard\x20list\x20(354)\x20or\x20use\x20open\x20vote()\x20without\x20voting_guard','evidence':'vote.voting_guard='+a['vote']['voting_guard']};if(!a['current_voting_guard_addresses']['includes'](a['vote']['voting_guard']))return{'id':'R-AB-2-01','level':'HIGH','category':'semantic','title':'voting_guard\x20misconfiguration\x20—\x20dispute\x20cannot\x20be\x20resolved','description':'vote.voting_guard\x20'+a['vote']['voting_guard']+'\x20not\x20in\x20Arbitration.voting_guard\x20list','affected_stakeholders':['voter','arbiter','disputant'],'scenario':'Voter\x27s\x20Guard\x20not\x20registered\x20—\x20vote\x20will\x20fail\x20with\x20E_VOTING_GUARD_NOT_FOUND','mitigation':'Add\x20guard\x20'+a['vote']['voting_guard']+'\x20via\x20voting_guard_add\x20(354),\x20or\x20use\x20a\x20registered\x20guard','evidence':'provided='+a['vote']['voting_guard']+',\x20registered='+a['current_voting_guard_addresses']['join'](',')};}return null;}},R_AB_2_03={'id':'R-AB-2-03','category':'semantic','trigger':'VoteValue.GuardIdentifier\x20with\x20non-numeric\x20Guard\x20submission\x20type','check':a=>{if(a['voting_guard']&&(a['voting_guard']['op']==='add'||a['voting_guard']['op']==='set'))for(const b of a['voting_guard']['guards']){const c=b['vote_weight'];if('GuardIdentifier'in c&&c['GuardIdentifier']!==undefined){if(c['GuardIdentifier']>0xff)return{'id':'R-AB-2-03','level':'HIGH','category':'semantic','title':'GuardIdentifier\x20index\x20>\x20u8::max\x20(255)','description':'GuardIdentifier\x20'+c['GuardIdentifier']+'\x20exceeds\x20u8\x20max\x20(255)','affected_stakeholders':['owner'],'scenario':'Setting\x20GuardIdentifier\x20index\x20beyond\x20u8\x20range','mitigation':'Use\x20GuardIdentifier\x20index\x200-255','evidence':'identifier='+c['GuardIdentifier']};}if('FixedValue'in c&&c['FixedValue']!==undefined){if(c['FixedValue']>0xffffffff)return{'id':'R-AB-2-03','level':'HIGH','category':'semantic','title':'FixedValue\x20>\x20u32::max\x20(4294967295)','description':'FixedValue\x20'+c['FixedValue']+'\x20exceeds\x20u32\x20max','affected_stakeholders':['owner'],'scenario':'Setting\x20FixedValue\x20beyond\x20u32\x20range','mitigation':'Use\x20FixedValue\x200-4294967295','evidence':'fixed='+c['FixedValue']};}}return null;}},R_AB_3_01={'id':'R-AB-3-01','category':'authority','trigger':'Arbiter\x20collusion\x20—\x20single\x20voter\x20controls\x20>50%\x20of\x20total\x20weight','check':a=>{if(!a['voting_guard']||a['voting_guard']['op']!=='add'&&a['voting_guard']['op']!=='set')return null;const b=a['voting_guard']['guards'];if(b['length']<0x2)return null;const c=b['filter'](f=>'FixedValue'in f['vote_weight']&&f['vote_weight']['FixedValue']!==undefined)['map'](f=>f['vote_weight']['FixedValue']);if(c['length']===0x0)return null;const d=c['reduce']((f,g)=>f+g,0x0),e=Math['max'](...c);if(d>0x0&&e/d>0.5)return{'id':'R-AB-3-01','level':'MEDIUM','category':'authority','title':'Arbiter\x20collusion\x20risk\x20—\x20single\x20guard\x20controls\x20>50%\x20weight','description':'One\x20voting_guard\x20has\x20'+e+'\x20of\x20'+d+'\x20total\x20weight\x20('+(e/d*0x64)['toFixed'](0x1)+'%)','affected_stakeholders':['owner','disputant'],'scenario':'Weighted\x20voting\x20with\x20dominant\x20arbiter\x20—\x20can\x20single-handedly\x20decide\x20rulings','mitigation':'Distribute\x20weight\x20more\x20evenly,\x20or\x20require\x20multi-arbiter\x20consensus','evidence':'max='+e+',\x20total='+d+',\x20ratio='+(e/d*0x64)['toFixed'](0x1)+'%'};return null;}},R_AB_3_02={'id':'R-AB-3-02','category':'authority','trigger':'Permission\x20over-concentration\x20—\x20single\x20admin\x20(owner)','check':a=>{if(a['builder'])return{'id':'R-AB-3-02','level':'HIGH','category':'authority','title':'Arbitration\x20ownership\x20transfer\x20—\x20IRREVERSIBLE','description':'Transferring\x20Arbitration\x20to\x20'+a['builder']+';\x20original\x20owner\x20loses\x20all\x20control\x20permanently','affected_stakeholders':['owner'],'scenario':'Transferring\x20Arbitration\x20ownership','mitigation':'1)\x20Verify\x20new\x20owner\x20twice.\x202)\x20Confirm\x20new\x20owner\x20has\x20350-368\x20permissions\x20configured.\x203)\x20Coordinate\x20before\x20transfer.','evidence':'new_owner='+a['builder']};return null;}},R_AB_3_03={'id':'R-AB-3-03','category':'authority','trigger':'ARBITRATION_ARBITRATION\x20(359)\x20granted\x20to\x20wide\x20audience','check':a=>{if(a['arbitration']&&!a['current_voting_guard_addresses']?.['length'])return{'id':'R-AB-3-03','level':'MEDIUM','category':'authority','title':'Ruling\x20without\x20voting_guard\x20—\x20single-arbiter\x20can\x20rule\x20unchallenged','description':'make_ruling\x20(359)\x20without\x20voting_guard\x20means\x20any\x20permission\x20holder\x20can\x20unilaterally\x20decide','affected_stakeholders':['disputant','voter'],'scenario':'Single-arbiter\x20Arbitration\x20without\x20consensus\x20check','mitigation':'Configure\x20voting_guard\x20(354)\x20to\x20require\x20multi-arbiter\x20consensus\x20before\x20ruling','evidence':'voting_guard=empty'};return null;}},R_AB_4_01={'id':'R-AB-4-01','category':'lifecycle','trigger':'Invalid\x20Arb\x20status\x20transition\x20(7-state\x20flow\x20violation)','check':a=>{if(!a['current_arb_status']||!a['expected_arb_status'])return null;if(a['current_arb_status']===a['expected_arb_status'])return null;if(!isValidArbStatusTransition(a['current_arb_status'],a['expected_arb_status']))return{'id':'R-AB-4-01','level':'CRITICAL','category':'lifecycle','title':'Invalid\x20Arb\x20status\x20transition','description':a['current_arb_status']+'\x20→\x20'+a['expected_arb_status']+'\x20is\x20not\x20a\x20valid\x207-state\x20flow\x20transition','affected_stakeholders':['arbiter','disputant'],'scenario':'Attempting\x20operation\x20out\x20of\x20order\x20(e.g.\x20vote\x20before\x20confirm)','mitigation':'Follow\x20the\x207-state\x20flow:\x20Principal_confirming\x20→\x20Arbitrator_confirming\x20→\x20Voting\x20→\x20Arbitrated\x20→\x20Objectionable\x20→\x20Finished/Withdrawn','evidence':a['current_arb_status']+'\x20→\x20'+a['expected_arb_status']};return null;}},R_AB_4_02={'id':'R-AB-4-02','category':'lifecycle','trigger':'Operation\x20on\x20terminal\x20Arb\x20status\x20(Finished/Withdrawn)','check':a=>{if(!a['current_arb_status'])return null;if(isTerminalArbStatus(a['current_arb_status'])){const b=a['arb_withdraw'];if(!b&&(a['vote']||a['confirm']||a['arbitration']||a['reset']||a['feedback']))return{'id':'R-AB-4-02','level':'HIGH','category':'lifecycle','title':'Operation\x20on\x20terminal\x20Arb\x20status\x20—\x20irreversible','description':'Arb\x20is\x20in\x20terminal\x20status\x20'+a['current_arb_status']+';\x20only\x20arb_withdraw\x20is\x20allowed','affected_stakeholders':['arbiter','disputant'],'scenario':'Voting/ruling/reset\x20on\x20a\x20Finished\x20or\x20Withdrawn\x20Arb','mitigation':'Open\x20a\x20new\x20Arb\x20case\x20via\x20dispute()\x20if\x20further\x20arbitration\x20is\x20needed','evidence':'status='+a['current_arb_status']};}return null;}},R_AB_4_03={'id':'R-AB-4-03','category':'lifecycle','trigger':'reset\x20operation\x20—\x20may\x20indefinitely\x20extend\x20arbitration','check':a=>{if(!a['reset'])return null;return{'id':'R-AB-4-03','level':'MEDIUM','category':'lifecycle','title':'reset\x20operation\x20—\x20arbitration\x20lifecycle\x20extended','description':'reset\x20on\x20Arb\x20'+a['reset']['arb']+'\x20restarts\x20lifecycle\x20to\x20Principal_confirming;\x20feedback\x20required','affected_stakeholders':['arbiter','disputant'],'scenario':'Disputant\x20objects\x20to\x20ruling\x20and\x20resubmits\x20materials','mitigation':'Track\x20reset\x20count\x20—\x20consider\x20capping\x20resets\x20to\x20prevent\x20abuse','evidence':'arb='+a['reset']['arb']};}},R_AB_5_01={'id':'R-AB-5-01','category':'cross_object','trigger':'fees_alloc/fees_transfer\x20unfair\x20distribution\x20—\x20destination\x20not\x20verified','check':a=>{if(!a['fees_transfer'])return null;const b='allocation'in a['fees_transfer']['to']?'Allocation\x20'+a['fees_transfer']['to']['allocation']:'Treasury\x20'+a['fees_transfer']['to']['treasury'];return{'id':'R-AB-5-01','level':'MEDIUM','category':'cross_object','title':'fees_alloc/fees_transfer\x20—\x20verify\x20destination\x20fairness','description':'All\x20Arbitration.balance\x20will\x20be\x20transferred\x20to\x20'+b+';\x20ensure\x20destination\x20policy\x20is\x20fair\x20to\x20arbiters','affected_stakeholders':['arbiter','owner'],'scenario':'Distributing\x20arbitration\x20fees\x20without\x20verifying\x20allocation\x20rules','mitigation':'Verify\x20'+b+'\x20has\x20fair\x20distribution\x20policy;\x20consider\x20allocating\x20to\x20arbiters\x27\x20Allocation','evidence':'dest='+b+',\x20remark='+a['fees_transfer']['payment_remark']};}},R_AB_5_02={'id':'R-AB-5-02','category':'cross_object','trigger':'Dispute\x20filed\x20but\x20Order\x20op\x20permission\x20not\x20verified\x20—\x20E_NOT_OP_PERMISSION','check':a=>{if(!a['dispute'])return null;return{'id':'R-AB-5-02','level':'HIGH','category':'cross_object','title':'Order\x20op\x20permission\x20required\x20for\x20dispute','description':'dispute\x20on\x20Order\x20'+a['dispute']['order']+'\x20requires\x20order::assert_op_permission;\x20signer\x20must\x20have\x20Order\x27s\x20dispute\x20permission','affected_stakeholders':['disputant'],'scenario':'Filing\x20dispute\x20without\x20Order\x20op\x20permission','mitigation':'Ensure\x20signer\x20has\x20Order\x27s\x20dispute\x20operation\x20permission\x20(custom\x20index\x20or\x20builtin)','evidence':'order='+a['dispute']['order']};}},ALL_RULES=[R_AB_1_01,R_AB_1_02,R_AB_1_03,R_AB_1_04,R_AB_2_01,R_AB_2_03,R_AB_3_01,R_AB_3_02,R_AB_3_03,R_AB_4_01,R_AB_4_02,R_AB_4_03,R_AB_5_01,R_AB_5_02];export const ARBITRATION_RISK_VERSION='1.0.0';export function getAllRiskRules(){return[...ALL_RULES];}export function assessArbitrationRisks(a){const b=[];for(const f of ALL_RULES){const g=f['check'](a);if(g)b['push'](g);}const c=b['length']===0x0?'LOW':b['some'](h=>h['level']==='CRITICAL')?'CRITICAL':b['some'](h=>h['level']==='HIGH')?'HIGH':b['some'](h=>h['level']==='MEDIUM')?'MEDIUM':'LOW',d={};for(const h of b){d[h['category']]=(d[h['category']]??0x0)+0x1;}const e={};for(const i of b){for(const j of i['affected_stakeholders']){if(!e[j])e[j]=[];e[j]['push'](i['id']+':\x20'+i['mitigation']);}}return{'summary':'Assessed\x20'+b['length']+'\x20risk(s)\x20across\x20'+Object['keys'](d)['length']+'\x20categories','risks':b,'overall_risk':c,'risks_by_category':d,'stakeholder_advice':e,'needs_human_review':b['some'](k=>k['level']==='CRITICAL'||k['level']==='HIGH')};}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 1,
|
|
3
|
+
"description": "Graph service evaluation standards — the canonical defaults document. The engine loads weights, dimension labels, severity deductions and level bands from HERE; an account persona may override per-dimension weights at runtime (persona layer 'evaluation.weights' → UserInjection.overrides.rules[id].weight), and an explicit request injection wins over persona. Weights are relative; the aggregate renormalizes over the enabled rules.",
|
|
4
|
+
"weights": {
|
|
5
|
+
"trust_arbitration": 20,
|
|
6
|
+
"trust_reviews": 35,
|
|
7
|
+
"trust_fulfillment": 20,
|
|
8
|
+
"trust_fund_safety": 15,
|
|
9
|
+
"trust_transparency": 10,
|
|
10
|
+
"risk_workflow": 35,
|
|
11
|
+
"risk_fund": 25,
|
|
12
|
+
"risk_trust": 20,
|
|
13
|
+
"risk_behavior": 20
|
|
14
|
+
},
|
|
15
|
+
"dimensions": {
|
|
16
|
+
"trust_arbitration": {
|
|
17
|
+
"label": "Arbitration",
|
|
18
|
+
"description": "Binding arbitration coverage of the service's payment paths."
|
|
19
|
+
},
|
|
20
|
+
"trust_reviews": {
|
|
21
|
+
"label": "Reputation",
|
|
22
|
+
"description": "Verified review votes on the service's review window."
|
|
23
|
+
},
|
|
24
|
+
"trust_fulfillment": {
|
|
25
|
+
"label": "Fulfillment",
|
|
26
|
+
"description": "Observed orders and a verifiable machine workflow (terminal set)."
|
|
27
|
+
},
|
|
28
|
+
"trust_fund_safety": {
|
|
29
|
+
"label": "Fund safety",
|
|
30
|
+
"description": "Compensation fund vs 3x windowed order volume (statutory ceiling)."
|
|
31
|
+
},
|
|
32
|
+
"trust_transparency": {
|
|
33
|
+
"label": "Transparency",
|
|
34
|
+
"description": "Snapshot self-description, lock duration and published flag."
|
|
35
|
+
},
|
|
36
|
+
"risk_workflow": {
|
|
37
|
+
"label": "Workflow risk",
|
|
38
|
+
"description": "Structural analyzer findings on the machine workflow."
|
|
39
|
+
},
|
|
40
|
+
"risk_fund": {
|
|
41
|
+
"label": "Fund risk",
|
|
42
|
+
"description": "Structural analyzer findings on fund paths and payouts."
|
|
43
|
+
},
|
|
44
|
+
"risk_trust": {
|
|
45
|
+
"label": "Trust-surface risk",
|
|
46
|
+
"description": "Structural analyzer findings on the trust surface (arb/review/fund hooks)."
|
|
47
|
+
},
|
|
48
|
+
"risk_behavior": {
|
|
49
|
+
"label": "Behavior risk",
|
|
50
|
+
"description": "Structural analyzer findings on operator behavior controls."
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
"severity_deduction": {
|
|
54
|
+
"critical": 50,
|
|
55
|
+
"high": 25,
|
|
56
|
+
"medium": 10,
|
|
57
|
+
"low": 5,
|
|
58
|
+
"info": 0
|
|
59
|
+
},
|
|
60
|
+
"level_bands": [
|
|
61
|
+
{ "min": 85, "level": "low" },
|
|
62
|
+
{ "min": 70, "level": "medium_low" },
|
|
63
|
+
{ "min": 50, "level": "medium_high" },
|
|
64
|
+
{ "min": 0, "level": "high" }
|
|
65
|
+
],
|
|
66
|
+
"grade_words": {
|
|
67
|
+
"comment": "Readable per-side grade rendered from the score. trust: higher score = better service; risk: higher score = fewer findings (safer).",
|
|
68
|
+
"trust": [
|
|
69
|
+
{ "min": 70, "word": "strong" },
|
|
70
|
+
{ "min": 50, "word": "fair" },
|
|
71
|
+
{ "min": 0, "word": "weak" }
|
|
72
|
+
],
|
|
73
|
+
"risk": [
|
|
74
|
+
{ "min": 80, "word": "low risk" },
|
|
75
|
+
{ "min": 50, "word": "moderate risk" },
|
|
76
|
+
{ "min": 0, "word": "high risk" }
|
|
77
|
+
]
|
|
78
|
+
}
|
|
79
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{describe,expect,it}from'vitest';import{readFileSync,writeFileSync}from'node:fs';import{fileURLToPath}from'node:url';import{dirname,join}from'node:path';import{lintGuard}from'../guard-lint.js';const CASES={'whitelist':{'description':'Whitelist\x20purchase\x20validation','table':[{'identifier':0x0,'b_submission':![],'value_type':'VecAddress','value':['0xabc','0xdef'],'name':'Authorized\x20purchase\x20whitelist'}],'root':{'type':'vec_contains_address','nodes':[{'type':'identifier','identifier':0x0},{'type':'context','context':'Signer'}]}},'allocator_identifier':{'description':'Allocator\x20selector','table':[{'identifier':0x0,'b_submission':![],'value_type':'Address','value':'0xabc','name':'selector'}],'root':{'type':'identifier','identifier':0x0},'binding_hint':{'host_object':'Service','binding_field':'order_allocators'}}};async function runCase(a){const b=await lintGuard(a,{'auto_fix':![]});return{'risk_diagnostics':b['diagnostics']['filter'](c=>c['source']==='risk')['map'](c=>({'code':c['code'],'severity':c['severity'],'path':c['location']['path']})),'risk_assessment':(b['risk_assessment']?.['risks']??[])['map'](c=>({'id':c['id'],'level':c['level']})),'summary':{'errors':b['summary']['errors'],'warnings':b['summary']['warnings'],'infos':b['summary']['infos'],'ready':b['summary']['ready']}};}const here=dirname(fileURLToPath(import.meta.url)),SNAPSHOT=join(here,'guard-lint-baseline.json');describe('guard-lint\x20risk\x20section\x20—\x20pre-migration\x20baseline',()=>{it('matches\x20the\x20committed\x20snapshot\x20(regenerate\x20only\x20with\x20UPDATE_RISK_BASELINE=1)',async()=>{const a={};for(const [c,d]of Object['entries'](CASES)){a[c]=await runCase(d);}if(process['env']['UPDATE_RISK_BASELINE']==='1'){writeFileSync(SNAPSHOT,JSON['stringify'](a,null,0x2)+'\x0a','utf8');return;}const b=JSON['parse'](readFileSync(SNAPSHOT,'utf8'));expect(a)['toEqual'](b);}),it('every\x20case\x20reaches\x20the\x20risk\x20section\x20(at\x20least\x20one\x20risk\x20diagnostic)',async()=>{for(const [a,b]of Object['entries'](CASES)){const c=await runCase(b);expect(c['risk_diagnostics']['length'],a+':\x20risk\x20section\x20silent')['toBeGreaterThan'](0x0);}});});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|