@wowok/agent-mcp 3.0.6 → 3.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/evaluation/arbitration-game.js +1 -1
- package/dist/evaluation/location-match.js +1 -1
- package/dist/goal/GoalClassifier.js +1 -1
- package/dist/graph/onchain/analyze.d.ts +3 -3
- package/dist/graph/onchain/analyze.js +1 -1
- package/dist/graph/onchain/analyze.spec.js +1 -1
- package/dist/graph/onchain/edge-schema.d.ts +1 -1
- package/dist/graph/onchain/edge-schema.js +1 -1
- package/dist/graph/onchain/interest.js +1 -1
- package/dist/graph/onchain/sdk-dataplane.js +1 -1
- package/dist/graph/onchain/types.d.ts +5 -5
- package/dist/harness/verify.js +1 -1
- package/dist/index.js +1 -1
- package/dist/knowledge/allocation-ledger.d.ts +2 -0
- package/dist/knowledge/allocation-ledger.js +1 -1
- package/dist/knowledge/allocation-puzzle.js +1 -1
- package/dist/knowledge/allocation-risk.d.ts +2 -1
- package/dist/knowledge/allocation-risk.js +1 -1
- package/dist/knowledge/guard-design-patterns.js +1 -1
- package/dist/knowledge/guard-field-cognition.d.ts +48 -0
- package/dist/knowledge/guard-field-cognition.js +1 -0
- package/dist/knowledge/index.d.ts +1 -0
- package/dist/knowledge/index.js +1 -1
- package/dist/knowledge/industry-registry.js +1 -1
- package/dist/knowledge/industry-strategy.js +1 -1
- package/dist/knowledge/jsonrpc-enum.js +1 -1
- package/dist/knowledge/recipient-constraint.d.ts +6 -1
- package/dist/knowledge/recipient-constraint.js +1 -1
- package/dist/knowledge/service-allocator-audit-node.d.ts +3 -0
- package/dist/knowledge/service-allocator-audit-node.js +1 -0
- package/dist/knowledge/service-risk-node.js +1 -1
- package/dist/knowledge/template-registry.js +1 -1
- package/dist/knowledge/workflow-guidance.d.ts +2 -0
- package/dist/knowledge/workflow-guidance.js +1 -1
- package/dist/monitor/MonitorLoop.js +1 -1
- package/dist/persona/strategy-intent.js +1 -1
- package/dist/playbooks/service-build/business-puzzle.js +1 -1
- package/dist/playbooks/service-build/intent-analyzer.js +1 -1
- package/dist/playbooks/service-build/object-panorama.js +1 -1
- package/dist/playbooks/service-build/risk-aggregator.js +1 -1
- package/dist/playbooks/service-build/topology-query.js +1 -1
- package/dist/safety/confirm-gate.js +1 -1
- package/dist/safety/preview.js +1 -1
- package/dist/schema/call/base.js +1 -1
- package/dist/schema/call/handler.js +1 -1
- package/dist/schema/call/semantic.js +1 -1
- package/dist/schema/call/service.d.ts +6 -6
- package/dist/schema/common/index.js +1 -1
- package/dist/schema/evaluation/index.js +1 -1
- package/dist/schema/local/index.js +1 -1
- package/dist/schema/operations.d.ts +4 -2
- package/dist/schema/operations.js +1 -1
- package/dist/schema/query/bi.d.ts +16 -14
- package/dist/schema/query/bi.js +1 -1
- package/dist/schema/query/index.d.ts +10 -10
- package/dist/schema/query/index.js +1 -1
- package/dist/schema/schema-version.js +1 -1
- package/dist/schema-query-impl/index.js +1 -1
- package/dist/schemas/account_operation.output.json +9 -9
- package/dist/schemas/account_operation.schema.json +3 -3
- package/dist/schemas/bridge_operation.output.json +9 -9
- package/dist/schemas/bridge_operation.schema.json +4 -4
- package/dist/schemas/evaluation_operation.output.json +6 -6
- package/dist/schemas/evaluation_operation.schema.json +5 -5
- package/dist/schemas/guard2file.schema.json +1 -1
- package/dist/schemas/index.json +1 -1
- package/dist/schemas/keeper_operation.output.json +9 -9
- package/dist/schemas/local_history_operation.output.json +9 -9
- package/dist/schemas/local_history_operation.schema.json +1 -1
- package/dist/schemas/local_info_operation.output.json +9 -9
- package/dist/schemas/local_mark_operation.output.json +9 -9
- package/dist/schemas/machineNode2file.schema.json +1 -1
- package/dist/schemas/messenger_operation.output.json +9 -9
- package/dist/schemas/monitor_events.output.json +9 -9
- package/dist/schemas/monitor_subscription.output.json +9 -9
- package/dist/schemas/onchain_events.output.json +10 -10
- package/dist/schemas/onchain_operations.output.json +9 -9
- package/dist/schemas/onchain_operations.schema.json +70 -72
- package/dist/schemas/onchain_operations_allocation.schema.json +6 -6
- package/dist/schemas/onchain_operations_arbitration.schema.json +4 -4
- package/dist/schemas/onchain_operations_contact.schema.json +3 -3
- package/dist/schemas/onchain_operations_demand.schema.json +3 -3
- package/dist/schemas/onchain_operations_gen_passport.schema.json +1 -1
- package/dist/schemas/onchain_operations_gen_proof.schema.json +1 -1
- package/dist/schemas/onchain_operations_guard.schema.json +2 -2
- package/dist/schemas/onchain_operations_machine.schema.json +5 -5
- package/dist/schemas/onchain_operations_order.schema.json +3 -3
- package/dist/schemas/onchain_operations_payment.schema.json +3 -3
- package/dist/schemas/onchain_operations_permission.schema.json +3 -3
- package/dist/schemas/onchain_operations_personal.schema.json +1 -1
- package/dist/schemas/onchain_operations_progress.schema.json +3 -3
- package/dist/schemas/onchain_operations_proof.schema.json +1 -1
- package/dist/schemas/onchain_operations_repository.schema.json +3 -3
- package/dist/schemas/onchain_operations_reward.schema.json +7 -7
- package/dist/schemas/onchain_operations_service.schema.json +12 -14
- package/dist/schemas/onchain_operations_treasury.schema.json +9 -9
- package/dist/schemas/onchain_table_data.output.json +17 -13
- package/dist/schemas/query_toolkit.output.json +50 -52
- package/dist/schemas/query_toolkit.schema.json +6 -2
- package/dist/strategy/collectors.js +1 -1
- package/dist/task/playbook.js +1 -1
- package/dist/tools/handlers/config.js +1 -1
- package/dist/tools/handlers/evaluation.spec.js +1 -1
- package/dist/tools/handlers/onchain.js +1 -1
- package/dist/tools/handlers/query.js +1 -1
- package/dist/tools/index.js +1 -1
- package/dist/tools/registry/monitor.js +1 -1
- package/dist/tools/registry/query.js +1 -1
- package/dist/tools/shared.js +1 -1
- package/dist/tools/wrap.js +1 -1
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
import{MAX_SHARING_COUNT,MAX_ALLOCATOR_COUNT}from'@wowok/wowok';export{MAX_ALLOCATOR_COUNT};export const ALLOCATION_MAX_SHARING_COUNT=MAX_SHARING_COUNT;export const ALLOCATION_MODE_AMOUNT=0x0;export const ALLOCATION_MODE_RATE=0x1;export const ALLOCATION_MODE_SURPLUS=0x2;export const RATE_TOTAL_FULL=0x2710;export const ALLOCATION_ERROR_CODES={'ERECIPIENT_IDENTIFIER_NOT_ADDRESS':0x1,'EALLOCATOR_COUNT_EXCEEDED':0x2,'ENO_ALLOCATOR':0x3,'ERATE_NOT_10000':0x4,'EMULTIPLE_SURPLUS':0x5,'ERATE_EXCEEDS_10000':0x6,'EINSUFFICIENT_BALANCE':0x7,'EALLOCATORS_EMPTY':0x8,'ENO_PAYMENT_INFO':0x9,'ESHARING_COUNT_EXCEEDED':0xa,'ESHARING_MODE_INVALID':0xb,'EAMOUNT_BELOW_THRESHOLD':0xc,'EAMOUNT_EXCEEDS_MAX':0xd};export const ORDER_ALLOCATION_ALREADY_SPECIFIED='E_ALLOCATION_ALREADY_SPECIFIED';export const ALLOCATION_SCENES=[{'id':'allocation_standard_three_way_split','name':'Standard\x20three-way\x20split\x20(merchant\x20/\x20platform\x20/\x20logistics)','trigger_source':'service_order_allocators','distribution_strategy':'pure_rate','coin_type_note':'All\x20three\x20Treasury\x20objects\x20must\x20use\x20the\x20same\x20Coin<T>\x20type\x20as\x20the\x20Allocation','typical_allocator_count':0x1,'sharing_who_types':['Entity'],'modes_used':['Rate'],'guard_requirement':'required','non_zero_threshold':![],'uses_max':![],'common_patterns':['Single\x20Allocator,\x203\x20Rate\x20sharing\x20items,\x20sum(rates)\x20===\x2010000','Each\x20sharing.who=Entity\x20points\x20to\x20a\x20Treasury\x20address','Guard\x20verifies\x20order.service\x20binding\x20(query\x201563)\x20to\x20prevent\x20cross-project\x20bypass','Guard\x20verifies\x20progress.current_node\x20===\x20\x27Complete\x27'],'dependencies':['Service','Treasury','Guard','Order','Progress','Machine','Payment'],'key_constraints':['F-A-05:\x20sum(rates)\x20===\x2010000\x20(pure\x20Rate\x20mode)','Treasury\x20Permission\x20should\x20match\x20Service\x20Permission\x20(R-A-12)','order_allocators\x20immutable\x20after\x20Service\x20publish\x20(R-A-10)'],'recommended_templates':['T-A-02']},{'id':'allocation_merchant_full_payment','name':'Merchant\x20full\x20payment\x20(single\x20recipient,\x20100%)','trigger_source':'service_order_allocators','distribution_strategy':'pure_rate','coin_type_note':'Simplest\x20configuration\x20—\x20single\x20Treasury\x20or\x20personal\x20address','typical_allocator_count':0x1,'sharing_who_types':['Entity'],'modes_used':['Rate'],'guard_requirement':'single_relaxed','non_zero_threshold':![],'uses_max':![],'common_patterns':['Single\x20Allocator,\x201\x20Rate\x20sharing\x20=\x2010000','Guard\x20only\x20verifies\x20order\x20status\x20(no\x20complex\x20conditions)','who=Entity\x20can\x20be\x20either\x20Treasury\x20or\x20personal\x20wallet'],'dependencies':['Service','Guard','Order','Payment'],'key_constraints':['Simplest\x20allocation\x20configuration','No\x20multi-party\x20coordination\x20required'],'recommended_templates':['T-A-01']},{'id':'allocation_refund_first_surplus_to_merchant','name':'Refund\x20first\x20+\x20surplus\x20to\x20merchant\x20(Amount\x20+\x20Surplus\x20hybrid)','trigger_source':'service_order_allocators','distribution_strategy':'amount_plus_surplus','coin_type_note':'Refund\x20amount\x20must\x20match\x20Coin<T>\x20precision','typical_allocator_count':0x1,'sharing_who_types':['Entity'],'modes_used':['Amount','Surplus'],'guard_requirement':'required','non_zero_threshold':!![],'uses_max':![],'common_patterns':['Single\x20Allocator,\x202\x20sharing\x20items','sharing[0]:\x20Amount=refund_value,\x20who=Entity(customer_address)','sharing[1]:\x20Surplus,\x20who=Entity(merchant_treasury)','fix\x20=\x20refund_value\x20(cached\x20Amount\x20sum)','threshold\x20=\x20refund_value\x20(ensure\x20sufficient\x20balance\x20for\x20Amount)'],'dependencies':['Service','Treasury','Guard','Order','Payment'],'key_constraints':['F-A-04:\x20at\x20most\x201\x20Surplus\x20per\x20Allocator','F-A-07:\x20fix\x20>=\x20threshold\x20(Amount\x20sum\x20must\x20cover\x20threshold)','fix\x20must\x20precisely\x20match\x20the\x20refund\x20amount'],'recommended_templates':['T-A-03']},{'id':'allocation_treasury_personal_alternatives','name':'Treasury\x20+\x20Personal\x20alternative\x20strategies\x20(caller-specified\x20guard)','trigger_source':'service_order_allocators','distribution_strategy':'first_match_alternatives','coin_type_note':'Both\x20target\x20addresses\x20must\x20accept\x20the\x20same\x20Coin<T>','typical_allocator_count':0x2,'sharing_who_types':['Entity'],'modes_used':['Rate'],'guard_requirement':'multiple_unique','non_zero_threshold':![],'uses_max':![],'common_patterns':['2\x20Allocators,\x20each\x20with\x201\x20Rate=10000\x20sharing','Allocator[0]:\x20guard=guard_treasury,\x20who=Entity(treasury_address)','Allocator[1]:\x20guard=guard_personal,\x20who=Entity(personal_address)','Two\x20Guard\x20objects\x20must\x20be\x20different\x20addresses\x20(R-A-11)','caller-specified\x20guard:\x20caller\x20selects\x20Treasury\x20or\x20Personal\x20path\x20via\x20alloc_by_guard;\x20passport::result_for_guard\x20hard-validates\x20(failure\x20aborts\x20with\x20E_VERIFY_FAILED;\x20caller\x20must\x20switch\x20guard\x20and\x20retry)'],'dependencies':['Service','Treasury','Guard','Order','Payment'],'key_constraints':['F-A-14:\x20allocators[].guard\x20must\x20be\x20unique','Treasury\x20Permission\x20should\x20match\x20Service\x20Permission\x20(R-A-12)','Guard\x20A\x20and\x20Guard\x20B\x20may\x20share\x20root/table\x20but\x20must\x20differ\x20in\x20description'],'recommended_templates':['T-A-04']},{'id':'allocation_tiered_by_order_amount','name':'Tiered\x20split\x20by\x20order\x20amount\x20(multi-Allocator\x20amount-threshold\x20switch)','trigger_source':'service_order_allocators','distribution_strategy':'tiered_by_amount','coin_type_note':'Amount\x20threshold\x20uses\x20Coin<T>\x20smallest\x20unit\x20(e.g.\x20MIST\x20for\x20WOW)','typical_allocator_count':0x2,'sharing_who_types':['Entity'],'modes_used':['Rate'],'guard_requirement':'multiple_unique','non_zero_threshold':![],'uses_max':![],'common_patterns':['2\x20Allocators\x20triggered\x20by\x20mutually\x20exclusive\x20Guard\x20conditions','Allocator[0]:\x20guard\x20verifies\x20order.amount\x20<\x20threshold,\x20Rate=10000\x20to\x20merchant','Allocator[1]:\x20guard\x20verifies\x20order.amount\x20>=\x20threshold,\x20Rate=8000/2000\x20split','caller-specified\x20guard:\x20caller\x20selects\x20the\x20matching\x20Allocator\x20based\x20on\x20order\x20amount;\x20allocator\x20order\x20is\x20irrelevant','Guard\x20queries\x20order.amount\x20(query\x201561)'],'dependencies':['Service','Treasury','Guard','Order','Payment'],'key_constraints':['Guard\x20conditions\x20must\x20be\x20mutually\x20exclusive\x20(R-A-4-02\x20design\x20clarity)','Caller\x20must\x20select\x20correct\x20guard\x20based\x20on\x20order.amount\x20(no\x20auto-fallback)'],'recommended_templates':['T-A-05']},{'id':'allocation_dynamic_recipient','name':'Multi-role\x20split\x20with\x20dynamic\x20recipient\x20(GuardIdentifier)','trigger_source':'service_order_allocators','distribution_strategy':'dynamic_recipient','coin_type_note':'Passport\x20table\x20must\x20contain\x20address-typed\x20entry\x20at\x20the\x20referenced\x20identifier','typical_allocator_count':0x1,'sharing_who_types':['Entity','GuardIdentifier'],'modes_used':['Rate'],'guard_requirement':'required','non_zero_threshold':![],'uses_max':![],'common_patterns':['Single\x20Allocator,\x203\x20Rate\x20sharing\x20items','sharing[0]:\x20Rate=8000,\x20who=Entity(merchant_treasury)','sharing[1]:\x20Rate=1000,\x20who=Entity(platform_treasury)','sharing[2]:\x20Rate=1000,\x20who=GuardIdentifier(0)\x20—\x20resolves\x20from\x20Passport\x20table','Customer\x20submits\x20Passport\x20with\x20referrer\x20address\x20at\x20identifier=0'],'dependencies':['Service','Treasury','Guard','Passport','Order','Payment'],'key_constraints':['F-A-13:\x20Passport\x20table[identifier]\x20must\x20be\x20address\x20type\x20(else\x20ERECIPIENT_IDENTIFIER_NOT_ADDRESS)','Guard\x20must\x20verify\x20Passport\x20completeness','Customer\x20order\x20must\x20include\x20Passport\x20with\x20referrer\x20address'],'recommended_templates':['T-A-06']},{'id':'allocation_arbitration_fees','name':'Arbitration\x20fees\x20split\x20(arbitrator\x20/\x20platform)','trigger_source':'arbitration_fees','distribution_strategy':'pure_rate','coin_type_note':'Coin<T>\x20must\x20match\x20Arbitration\x27s\x20fee\x20Coin\x20type','typical_allocator_count':0x1,'sharing_who_types':['Entity'],'modes_used':['Rate'],'guard_requirement':'required','non_zero_threshold':![],'uses_max':![],'common_patterns':['Triggered\x20by\x20Arbitration.fees_alloc\x20(permission\x20365)\x20or\x20fees_alloc_with_passport','Single\x20Allocator,\x202\x20Rate\x20sharing\x20items:\x208000\x20arbitrator\x20/\x202000\x20platform','payment_info\x20reuses\x20Arbitration\x27s\x20payment_info','Caller\x20must\x20hold\x20ARBITRATION_FEES_ALLOC=365\x20permission'],'dependencies':['Arbitration','Treasury','Guard','Payment'],'key_constraints':['Independent\x20from\x20Service-order\x20Allocation','Requires\x20ARBITRATION_FEES_ALLOC=365\x20permission'],'recommended_templates':['T-A-08']},{'id':'allocation_refund_to_order','name':'Refund\x20Allocator\x20(100%\x20to\x20Order\x20object)','trigger_source':'service_order_allocators','distribution_strategy':'refund_to_order','coin_type_note':'who=Entity\x20must\x20be\x20the\x20Order\x20object\x20address\x20(NOT\x20a\x20personal\x20wallet)','typical_allocator_count':0x1,'sharing_who_types':['Entity'],'modes_used':['Rate'],'guard_requirement':'required','non_zero_threshold':![],'uses_max':![],'common_patterns':['Single\x20Allocator,\x201\x20Rate=10000\x20sharing','who=Entity(order_address)\x20—\x20funds\x20flow\x20back\x20to\x20Order,\x20not\x20personal\x20wallet','Guard\x20verifies\x20customer\x20refund\x20request\x20and\x20eligibility','Customer-side\x20risk\x20assessment\x20adds\x208-point\x20weight\x20(customer/risk-assessment.ts)'],'dependencies':['Service','Guard','Order','Payment'],'key_constraints':['who=Entity\x20MUST\x20be\x20Order\x20object\x20address\x20(not\x20personal\x20address)','Customer\x20due-diligence\x20rewards\x20this\x20configuration\x20(8-point\x20weight)','Refund\x20funds\x20return\x20to\x20Order\x20for\x20downstream\x20handling'],'recommended_templates':['T-A-07']},{'id':'allocation_max_capped_retain','name':'Max-capped\x20allocation\x20(retain\x20residual\x20balance)','trigger_source':'service_order_allocators','distribution_strategy':'max_capped','coin_type_note':'max\x20field\x20uses\x20Coin<T>\x20smallest\x20unit','typical_allocator_count':0x1,'sharing_who_types':['Entity'],'modes_used':['Amount','Rate'],'guard_requirement':'required','non_zero_threshold':!![],'uses_max':!![],'common_patterns':['Single\x20Allocator\x20with\x20max\x20field\x20set','max\x20triple\x20role:\x20Amount\x20cap\x20+\x20Rate\x20base\x20+\x20Surplus\x20cap','Amount\x20sharing\x20consumes\x20fix;\x20Rate\x20sharing\x20uses\x20(max\x20-\x20fix)\x20as\x20base','Residual\x20balance\x20remains\x20in\x20Allocation\x20for\x20subsequent\x20alloc()\x20calls'],'dependencies':['Service','Treasury','Guard','Order','Payment'],'key_constraints':['F-A-08:\x20Amount\x20sum\x20<=\x20max\x20(EAMOUNT_EXCEEDS_MAX)','max\x20-\x20fix\x20becomes\x20Rate\x20base\x20(NOT\x20balance\x20-\x20fix)','Residual\x20balance\x20may\x20be\x20claimed\x20by\x20re-triggering\x20alloc()'],'recommended_templates':[]},{'id':'allocation_multi_node_trigger','name':'Multi-Machine-node\x20triggered\x20allocation\x20(Complete\x20/\x20Refund\x20/\x20Lost)','trigger_source':'service_order_allocators','distribution_strategy':'multi_node_trigger','coin_type_note':'All\x20Allocators\x20share\x20the\x20same\x20Allocation\x27s\x20Coin<T>','typical_allocator_count':0x3,'sharing_who_types':['Entity'],'modes_used':['Rate'],'guard_requirement':'multiple_unique','non_zero_threshold':![],'uses_max':![],'common_patterns':['3\x20Allocators\x20mapped\x20to\x20Machine\x20terminal\x20nodes\x20(Complete/Refund/Lost)','Each\x20Allocator\x27s\x20Guard\x20verifies\x20progress.current_node\x20==\x20<node_name>','Mutually\x20exclusive\x20Guard\x20conditions\x20(only\x20one\x20terminal\x20node\x20active\x20at\x20a\x20time)','Machine.required_allocators[]\x20describes\x20each\x20trigger_node\x20mapping'],'dependencies':['Service','Treasury','Guard','Order','Progress','Machine','Payment'],'key_constraints':['Guard\x20conditions\x20must\x20be\x20mutually\x20exclusive','Sequence-sensitive:\x20business-flow\x20order','Machine.required_allocators[trigger_node]\x20must\x20map\x20to\x20Allocator\x20indices'],'recommended_templates':[]},{'id':'allocation_standalone_periodic_split','name':'Standalone\x20periodic\x20split\x20(investment\x20dividends\x20/\x20shared\x20income)','trigger_source':'standalone','distribution_strategy':'periodic_split','coin_type_note':'Coin<T>\x20must\x20match\x20the\x20asset\x20being\x20distributed\x20(e.g.\x20profit\x20token)','typical_allocator_count':0x1,'sharing_who_types':['Entity'],'modes_used':['Rate'],'guard_requirement':'required','non_zero_threshold':![],'uses_max':![],'common_patterns':['Single\x20Allocator,\x20N\x20Rate\x20sharing\x20items,\x20sum(rates)\x20===\x2010000','Each\x20sharing.who=Entity\x20points\x20to\x20a\x20beneficiary\x20wallet\x20(not\x20Treasury)','Guard\x20verifies\x20time-based\x20trigger\x20(e.g.\x20context(Clock).timestamp\x20>=\x20next_release)\x20or\x20signer\x20authorization','User\x20calls\x20receive()\x20to\x20deposit\x20funds,\x20then\x20alloc()\x20to\x20trigger\x20distribution','No\x20Service/Order/Progress/Machine\x20context\x20required'],'dependencies':['Treasury','Guard','Payment'],'key_constraints':['F-A-05:\x20sum(rates)\x20===\x2010000\x20(pure\x20Rate\x20mode)','R-A-3-04:\x20standalone\x20mode\x20has\x20no\x20Service-layer\x20access\x20control\x20—\x20Guard\x20+\x20Passport\x20MUST\x20be\x20sufficient','Caller\x20is\x20fully\x20responsible\x20for\x20receive\x20→\x20alloc\x20lifecycle\x20(no\x20auto-trigger)','Guard\x20should\x20bind\x20Signer\x20to\x20prevent\x20unauthorized\x20alloc()\x20calls'],'recommended_templates':['T-A-09']},{'id':'allocation_standalone_vesting','name':'Standalone\x20vesting\x20release\x20(time-locked\x20multi-stage\x20unlock)','trigger_source':'standalone','distribution_strategy':'time_locked_vesting','coin_type_note':'Coin<T>\x20must\x20match\x20the\x20vested\x20asset\x20(e.g.\x20locked\x20team\x20tokens)','typical_allocator_count':0x3,'sharing_who_types':['Entity'],'modes_used':['Amount','Rate','Surplus'],'guard_requirement':'multiple_unique','non_zero_threshold':!![],'uses_max':!![],'common_patterns':['N\x20Allocators,\x20each\x20mapped\x20to\x20a\x20vesting\x20stage\x20(e.g.\x2025%\x20at\x20month\x2012,\x2025%\x20at\x20month\x2024,\x2050%\x20surplus\x20at\x20month\x2036)','Each\x20Allocator\x27s\x20Guard\x20verifies\x20context(Clock).timestamp\x20>=\x20stage_unlock_time','Amount\x20sharing\x20per\x20stage\x20with\x20max\x20field\x20capping\x20the\x20cumulative\x20release','Final\x20Allocator\x20uses\x20Surplus\x20to\x20drain\x20remaining\x20balance\x20after\x20last\x20vesting\x20stage','Mutually\x20exclusive\x20Guard\x20conditions\x20(only\x20one\x20stage\x20active\x20at\x20a\x20time,\x20based\x20on\x20timestamp)','User\x20calls\x20receive()\x20to\x20deposit\x20locked\x20tokens,\x20then\x20alloc()\x20at\x20each\x20vesting\x20milestone'],'dependencies':['Treasury','Guard','Passport','Payment'],'key_constraints':['F-A-04:\x20at\x20most\x201\x20Surplus\x20per\x20Allocator\x20(final\x20stage\x20uses\x20Surplus\x20to\x20drain\x20remainder)','F-A-08:\x20Amount\x20sum\x20<=\x20max\x20(EAMOUNT_EXCEEDS_MAX)','R-A-3-04:\x20standalone\x20mode\x20has\x20no\x20Service-layer\x20access\x20control\x20—\x20Guard\x20time-lock\x20MUST\x20be\x20enforced','Guard\x20conditions\x20must\x20be\x20mutually\x20exclusive\x20by\x20timestamp\x20(R-A-4-02)','Caller\x20must\x20wait\x20for\x20time-lock\x20expiry\x20before\x20alloc()\x20succeeds;\x20otherwise\x20alloc()\x20silently\x20returns\x20(R-A-4-01)'],'recommended_templates':['T-A-10']}];export const ALLOCATION_LEDGER_VERSION='1.0.0';export function getScenesByTriggerSource(a){return ALLOCATION_SCENES['filter'](b=>b['trigger_source']===a);}export function getScenesByMode(a){return ALLOCATION_SCENES['filter'](b=>b['modes_used']['includes'](a));}export function getScenesByStrategy(a){return ALLOCATION_SCENES['filter'](b=>b['distribution_strategy']===a);}export function findSceneById(a){return ALLOCATION_SCENES['find'](b=>b['id']===a);}export function inferSceneFromIntent(a){const b=a['toLowerCase']();if(b['includes']('arbitration')||b['includes']('fees_alloc'))return findSceneById('allocation_arbitration_fees');if(b['includes']('standalone')||b['includes']('periodic\x20split')||b['includes']('investment\x20dividend')||b['includes']('shared\x20income')||b['includes']('dividend'))return findSceneById('allocation_standalone_periodic_split');if(b['includes']('vesting')||b['includes']('time-lock')||b['includes']('unlock\x20period')||b['includes']('locked\x20release')||b['includes']('token\x20unlock'))return findSceneById('allocation_standalone_vesting');if(b['includes']('refund')){if(b['includes']('order')||b['includes']('100%'))return findSceneById('allocation_refund_to_order');if(b['includes']('surplus')||b['includes']('merchant'))return findSceneById('allocation_refund_first_surplus_to_merchant');}if(b['includes']('alternative')||b['includes']('priority')||b['includes']('treasury')&&b['includes']('personal'))return findSceneById('allocation_treasury_personal_alternatives');if(b['includes']('tiered')||b['includes']('threshold\x20switch'))return findSceneById('allocation_tiered_by_order_amount');if(b['includes']('dynamic\x20recipient')||b['includes']('referrer')||b['includes']('guardidentifier'))return findSceneById('allocation_dynamic_recipient');if(b['includes']('retain')||b['includes']('max'))return findSceneById('allocation_max_capped_retain');if(b['includes']('multi-node')||b['includes']('multi\x20machine')||b['includes']('multi_node'))return findSceneById('allocation_multi_node_trigger');const c=(a['match'](/%/g)||[])['length'];if(c<=0x1)return findSceneById('allocation_merchant_full_payment');if(c>=0x2)return findSceneById('allocation_standard_three_way_split');return undefined;}export function getAllScenes(){return[...ALLOCATION_SCENES];}export function getScenesCount(){return ALLOCATION_SCENES['length'];}export function allocationModeToNumber(a){switch(a){case'Amount':return ALLOCATION_MODE_AMOUNT;case'Rate':return ALLOCATION_MODE_RATE;case'Surplus':return ALLOCATION_MODE_SURPLUS;}}export function allocationModeFromNumber(a){switch(a){case ALLOCATION_MODE_AMOUNT:return'Amount';case ALLOCATION_MODE_RATE:return'Rate';case ALLOCATION_MODE_SURPLUS:return'Surplus';default:throw new Error('Invalid\x20AllocationMode\x20number:\x20'+a);}}export function getRecipientType(a){if('GuardIdentifier'in a)return'GuardIdentifier';if('Entity'in a)return'Entity';return'Signer';}export function isSignerRecipient(a){return'Signer'in a;}export function isEntityRecipient(a){return'Entity'in a;}export function isGuardIdentifierRecipient(a){return'GuardIdentifier'in a;}export function getErrorName(a){for(const [b,d]of Object['entries'](ALLOCATION_ERROR_CODES)){if(d===a)return b;}return undefined;}export function getErrorDescription(a){const b={0x1:'GuardIdentifier\x20resolved\x20value\x20is\x20not\x20an\x20address\x20type',0x2:'Allocator\x20count\x20exceeds\x20MAX_ALLOCATOR_COUNT\x20(100)',0x3:'No\x20Allocator\x20in\x20the\x20allocators\x20vector',0x4:'Pure\x20Rate\x20mode\x20sum\x20!=\x2010000\x20(no\x20Surplus\x20to\x20absorb\x20remainder)',0x5:'Multiple\x20Surplus\x20sharing\x20in\x20a\x20single\x20Allocator',0x6:'Rate\x20+\x20Surplus\x20sum\x20>\x2010000',0x7:'balance\x20<\x20threshold\x20(insufficient\x20balance\x20to\x20trigger\x20alloc)',0x8:'allocators.allocators\x20is\x20empty',0x9:'payment_info\x20is\x20None\x20when\x20alloc()\x20is\x20called',0xa:'sharing\x20count\x20exceeds\x20MAX_SHARING_COUNT\x20(100)',0xb:'sharing\x20mode\x20is\x20not\x200\x20(Amount)\x20/\x201\x20(Rate)\x20/\x202\x20(Surplus)',0xc:'Amount\x20sum\x20(fix)\x20<\x20threshold',0xd:'Amount\x20sum\x20(fix)\x20>\x20max'};return b[a];}
|
|
1
|
+
import{MAX_SHARING_COUNT,MAX_ALLOCATOR_COUNT}from'@wowok/wowok';export{MAX_ALLOCATOR_COUNT};export const ALLOCATION_MAX_SHARING_COUNT=MAX_SHARING_COUNT;export const ALLOCATION_MODE_AMOUNT=0x0;export const ALLOCATION_MODE_RATE=0x1;export const ALLOCATION_MODE_SURPLUS=0x2;export const RATE_TOTAL_FULL=0x2710;export const ALLOCATION_ERROR_CODES={'ERECIPIENT_IDENTIFIER_NOT_ADDRESS':0x1,'EALLOCATOR_COUNT_EXCEEDED':0x2,'ENO_ALLOCATOR':0x3,'ERATE_NOT_10000':0x4,'EMULTIPLE_SURPLUS':0x5,'ERATE_EXCEEDS_10000':0x6,'EINSUFFICIENT_BALANCE':0x7,'EALLOCATORS_EMPTY':0x8,'ENO_PAYMENT_INFO':0x9,'ESHARING_COUNT_EXCEEDED':0xa,'ESHARING_MODE_INVALID':0xb,'EAMOUNT_BELOW_THRESHOLD':0xc,'EAMOUNT_EXCEEDS_MAX':0xd,'EZERO_DISTRIBUTION':0xe,'ERECIPIENT_NOT_FOR_OBJECT':0xf};export const ORDER_ALLOCATION_ALREADY_SPECIFIED='E_ALLOCATION_ALREADY_SPECIFIED';export const ALLOCATION_SCENES=[{'id':'allocation_standard_three_way_split','name':'Standard\x20three-way\x20split\x20(merchant\x20/\x20platform\x20/\x20logistics)','trigger_source':'service_order_allocators','distribution_strategy':'pure_rate','coin_type_note':'All\x20three\x20Treasury\x20objects\x20must\x20use\x20the\x20same\x20Coin<T>\x20type\x20as\x20the\x20Allocation','typical_allocator_count':0x1,'sharing_who_types':['Entity'],'modes_used':['Rate'],'guard_requirement':'required','non_zero_threshold':![],'uses_max':![],'common_patterns':['Single\x20Allocator,\x203\x20Rate\x20sharing\x20items,\x20sum(rates)\x20===\x2010000','Each\x20sharing.who=Entity\x20points\x20to\x20a\x20Treasury\x20address','Guard\x20verifies\x20order.service\x20binding\x20(query\x201563)\x20to\x20prevent\x20cross-project\x20bypass','Guard\x20verifies\x20progress.current_node\x20===\x20\x27Complete\x27'],'dependencies':['Service','Treasury','Guard','Order','Progress','Machine','Payment'],'key_constraints':['F-A-05:\x20sum(rates)\x20===\x2010000\x20(pure\x20Rate\x20mode)','Treasury\x20Permission\x20should\x20match\x20Service\x20Permission\x20(R-A-12)','order_allocators\x20immutable\x20after\x20Service\x20publish\x20(R-A-10)'],'recommended_templates':['T-A-02']},{'id':'allocation_merchant_full_payment','name':'Merchant\x20full\x20payment\x20(single\x20recipient,\x20100%)','trigger_source':'service_order_allocators','distribution_strategy':'pure_rate','coin_type_note':'Simplest\x20configuration\x20—\x20single\x20Treasury\x20or\x20personal\x20address','typical_allocator_count':0x1,'sharing_who_types':['Entity'],'modes_used':['Rate'],'guard_requirement':'single_relaxed','non_zero_threshold':![],'uses_max':![],'common_patterns':['Single\x20Allocator,\x201\x20Rate\x20sharing\x20=\x2010000','Guard\x20only\x20verifies\x20order\x20status\x20(no\x20complex\x20conditions)','who=Entity\x20can\x20be\x20either\x20Treasury\x20or\x20personal\x20wallet'],'dependencies':['Service','Guard','Order','Payment'],'key_constraints':['Simplest\x20allocation\x20configuration','No\x20multi-party\x20coordination\x20required'],'recommended_templates':['T-A-01']},{'id':'allocation_refund_first_surplus_to_merchant','name':'Refund\x20first\x20+\x20surplus\x20to\x20merchant\x20(Amount\x20+\x20Surplus\x20hybrid)','trigger_source':'service_order_allocators','distribution_strategy':'amount_plus_surplus','coin_type_note':'Refund\x20amount\x20must\x20match\x20Coin<T>\x20precision','typical_allocator_count':0x1,'sharing_who_types':['Entity'],'modes_used':['Amount','Surplus'],'guard_requirement':'required','non_zero_threshold':!![],'uses_max':![],'common_patterns':['Single\x20Allocator,\x202\x20sharing\x20items','sharing[0]:\x20Amount=refund_value,\x20who=Entity(customer_address)','sharing[1]:\x20Surplus,\x20who=Entity(merchant_treasury)','fix\x20=\x20refund_value\x20(cached\x20Amount\x20sum)','threshold\x20=\x20refund_value\x20(ensure\x20sufficient\x20balance\x20for\x20Amount)'],'dependencies':['Service','Treasury','Guard','Order','Payment'],'key_constraints':['F-A-04:\x20at\x20most\x201\x20Surplus\x20per\x20Allocator','F-A-07:\x20fix\x20>=\x20threshold\x20(Amount\x20sum\x20must\x20cover\x20threshold)','fix\x20must\x20precisely\x20match\x20the\x20refund\x20amount'],'recommended_templates':['T-A-03']},{'id':'allocation_treasury_personal_alternatives','name':'Treasury\x20+\x20Personal\x20alternative\x20strategies\x20(caller-specified\x20guard)','trigger_source':'service_order_allocators','distribution_strategy':'first_match_alternatives','coin_type_note':'Both\x20target\x20addresses\x20must\x20accept\x20the\x20same\x20Coin<T>','typical_allocator_count':0x2,'sharing_who_types':['Entity'],'modes_used':['Rate'],'guard_requirement':'multiple_unique','non_zero_threshold':![],'uses_max':![],'common_patterns':['2\x20Allocators,\x20each\x20with\x201\x20Rate=10000\x20sharing','Allocator[0]:\x20guard=guard_treasury,\x20who=Entity(treasury_address)','Allocator[1]:\x20guard=guard_personal,\x20who=Entity(personal_address)','Two\x20Guard\x20objects\x20must\x20be\x20different\x20addresses\x20(R-A-11)','caller-specified\x20guard:\x20caller\x20selects\x20Treasury\x20or\x20Personal\x20path\x20via\x20alloc_by_guard;\x20passport::result_for_guard\x20hard-validates\x20(failure\x20aborts\x20with\x20E_VERIFY_FAILED;\x20caller\x20must\x20switch\x20guard\x20and\x20retry)'],'dependencies':['Service','Treasury','Guard','Order','Payment'],'key_constraints':['F-A-14:\x20allocators[].guard\x20must\x20be\x20unique','Treasury\x20Permission\x20should\x20match\x20Service\x20Permission\x20(R-A-12)','Guard\x20A\x20and\x20Guard\x20B\x20may\x20share\x20root/table\x20but\x20must\x20differ\x20in\x20description'],'recommended_templates':['T-A-04']},{'id':'allocation_tiered_by_order_amount','name':'Tiered\x20split\x20by\x20order\x20amount\x20(multi-Allocator\x20amount-threshold\x20switch)','trigger_source':'service_order_allocators','distribution_strategy':'tiered_by_amount','coin_type_note':'Amount\x20threshold\x20uses\x20Coin<T>\x20smallest\x20unit\x20(e.g.\x20MIST\x20for\x20WOW)','typical_allocator_count':0x2,'sharing_who_types':['Entity'],'modes_used':['Rate'],'guard_requirement':'multiple_unique','non_zero_threshold':![],'uses_max':![],'common_patterns':['2\x20Allocators\x20triggered\x20by\x20mutually\x20exclusive\x20Guard\x20conditions','Allocator[0]:\x20guard\x20verifies\x20order.amount\x20<\x20threshold,\x20Rate=10000\x20to\x20merchant','Allocator[1]:\x20guard\x20verifies\x20order.amount\x20>=\x20threshold,\x20Rate=8000/2000\x20split','caller-specified\x20guard:\x20caller\x20selects\x20the\x20matching\x20Allocator\x20based\x20on\x20order\x20amount;\x20allocator\x20order\x20is\x20irrelevant','Guard\x20queries\x20order.amount\x20(query\x201561)'],'dependencies':['Service','Treasury','Guard','Order','Payment'],'key_constraints':['Guard\x20conditions\x20must\x20be\x20mutually\x20exclusive\x20(R-A-4-02\x20design\x20clarity)','Caller\x20must\x20select\x20correct\x20guard\x20based\x20on\x20order.amount\x20(no\x20auto-fallback)'],'recommended_templates':['T-A-05']},{'id':'allocation_dynamic_recipient','name':'Multi-role\x20split\x20with\x20dynamic\x20recipient\x20(GuardIdentifier)','trigger_source':'service_order_allocators','distribution_strategy':'dynamic_recipient','coin_type_note':'Passport\x20table\x20must\x20contain\x20address-typed\x20entry\x20at\x20the\x20referenced\x20identifier','typical_allocator_count':0x1,'sharing_who_types':['Entity','GuardIdentifier'],'modes_used':['Rate'],'guard_requirement':'required','non_zero_threshold':![],'uses_max':![],'common_patterns':['Single\x20Allocator,\x203\x20Rate\x20sharing\x20items','sharing[0]:\x20Rate=8000,\x20who=Entity(merchant_treasury)','sharing[1]:\x20Rate=1000,\x20who=Entity(platform_treasury)','sharing[2]:\x20Rate=1000,\x20who=GuardIdentifier(0)\x20—\x20resolves\x20from\x20Passport\x20table','Customer\x20submits\x20Passport\x20with\x20referrer\x20address\x20at\x20identifier=0'],'dependencies':['Service','Treasury','Guard','Passport','Order','Payment'],'key_constraints':['F-A-13:\x20Passport\x20table[identifier]\x20must\x20be\x20address\x20type\x20(else\x20ERECIPIENT_IDENTIFIER_NOT_ADDRESS)','Guard\x20must\x20verify\x20Passport\x20completeness','Customer\x20order\x20must\x20include\x20Passport\x20with\x20referrer\x20address'],'recommended_templates':['T-A-06']},{'id':'allocation_arbitration_fees','name':'Arbitration\x20fees\x20split\x20(arbitrator\x20/\x20platform)','trigger_source':'arbitration_fees','distribution_strategy':'pure_rate','coin_type_note':'Coin<T>\x20must\x20match\x20Arbitration\x27s\x20fee\x20Coin\x20type','typical_allocator_count':0x1,'sharing_who_types':['Entity'],'modes_used':['Rate'],'guard_requirement':'required','non_zero_threshold':![],'uses_max':![],'common_patterns':['Triggered\x20by\x20Arbitration.fees_alloc\x20(permission\x20365)\x20or\x20fees_alloc_with_passport','Single\x20Allocator,\x202\x20Rate\x20sharing\x20items:\x208000\x20arbitrator\x20/\x202000\x20platform','payment_info\x20reuses\x20Arbitration\x27s\x20payment_info','Caller\x20must\x20hold\x20ARBITRATION_FEES_ALLOC=365\x20permission'],'dependencies':['Arbitration','Treasury','Guard','Payment'],'key_constraints':['Independent\x20from\x20Service-order\x20Allocation','Requires\x20ARBITRATION_FEES_ALLOC=365\x20permission'],'recommended_templates':['T-A-08']},{'id':'allocation_refund_to_order','name':'Refund\x20Allocator\x20(100%\x20to\x20Order\x20object)','trigger_source':'service_order_allocators','distribution_strategy':'refund_to_order','coin_type_note':'who=Entity\x20must\x20be\x20the\x20Order\x20object\x20address\x20(NOT\x20a\x20personal\x20wallet)','typical_allocator_count':0x1,'sharing_who_types':['Entity'],'modes_used':['Rate'],'guard_requirement':'required','non_zero_threshold':![],'uses_max':![],'common_patterns':['Single\x20Allocator,\x201\x20Rate=10000\x20sharing','who=Entity(order_address)\x20—\x20funds\x20flow\x20back\x20to\x20Order,\x20not\x20personal\x20wallet','Guard\x20verifies\x20customer\x20refund\x20request\x20and\x20eligibility','Customer-side\x20risk\x20assessment\x20adds\x208-point\x20weight\x20(customer/risk-assessment.ts)'],'dependencies':['Service','Guard','Order','Payment'],'key_constraints':['who=Entity\x20MUST\x20be\x20Order\x20object\x20address\x20(not\x20personal\x20address)','Customer\x20due-diligence\x20rewards\x20this\x20configuration\x20(8-point\x20weight)','Refund\x20funds\x20return\x20to\x20Order\x20for\x20downstream\x20handling'],'recommended_templates':['T-A-07']},{'id':'allocation_max_capped_retain','name':'Max-capped\x20allocation\x20(retain\x20residual\x20balance)','trigger_source':'service_order_allocators','distribution_strategy':'max_capped','coin_type_note':'max\x20field\x20uses\x20Coin<T>\x20smallest\x20unit','typical_allocator_count':0x1,'sharing_who_types':['Entity'],'modes_used':['Amount','Rate'],'guard_requirement':'required','non_zero_threshold':!![],'uses_max':!![],'common_patterns':['Single\x20Allocator\x20with\x20max\x20field\x20set','max\x20triple\x20role:\x20Amount\x20cap\x20+\x20Rate\x20base\x20+\x20Surplus\x20cap','Amount\x20sharing\x20consumes\x20fix;\x20Rate\x20sharing\x20uses\x20(max\x20-\x20fix)\x20as\x20base','Residual\x20balance\x20remains\x20in\x20Allocation\x20for\x20subsequent\x20alloc()\x20calls'],'dependencies':['Service','Treasury','Guard','Order','Payment'],'key_constraints':['F-A-08:\x20Amount\x20sum\x20<=\x20max\x20(EAMOUNT_EXCEEDS_MAX)','max\x20-\x20fix\x20becomes\x20Rate\x20base\x20(NOT\x20balance\x20-\x20fix)','Residual\x20balance\x20may\x20be\x20claimed\x20by\x20re-triggering\x20alloc()'],'recommended_templates':[]},{'id':'allocation_multi_node_trigger','name':'Multi-Machine-node\x20triggered\x20allocation\x20(Complete\x20/\x20Refund\x20/\x20Lost)','trigger_source':'service_order_allocators','distribution_strategy':'multi_node_trigger','coin_type_note':'All\x20Allocators\x20share\x20the\x20same\x20Allocation\x27s\x20Coin<T>','typical_allocator_count':0x3,'sharing_who_types':['Entity'],'modes_used':['Rate'],'guard_requirement':'multiple_unique','non_zero_threshold':![],'uses_max':![],'common_patterns':['3\x20Allocators\x20mapped\x20to\x20Machine\x20terminal\x20nodes\x20(Complete/Refund/Lost)','Each\x20Allocator\x27s\x20Guard\x20verifies\x20progress.current_node\x20==\x20<node_name>','Mutually\x20exclusive\x20Guard\x20conditions\x20(only\x20one\x20terminal\x20node\x20active\x20at\x20a\x20time)','Machine.required_allocators[]\x20describes\x20each\x20trigger_node\x20mapping'],'dependencies':['Service','Treasury','Guard','Order','Progress','Machine','Payment'],'key_constraints':['Guard\x20conditions\x20must\x20be\x20mutually\x20exclusive','Sequence-sensitive:\x20business-flow\x20order','Machine.required_allocators[trigger_node]\x20must\x20map\x20to\x20Allocator\x20indices'],'recommended_templates':[]},{'id':'allocation_standalone_periodic_split','name':'Standalone\x20periodic\x20split\x20(investment\x20dividends\x20/\x20shared\x20income)','trigger_source':'standalone','distribution_strategy':'periodic_split','coin_type_note':'Coin<T>\x20must\x20match\x20the\x20asset\x20being\x20distributed\x20(e.g.\x20profit\x20token)','typical_allocator_count':0x1,'sharing_who_types':['Entity'],'modes_used':['Rate'],'guard_requirement':'required','non_zero_threshold':![],'uses_max':![],'common_patterns':['Single\x20Allocator,\x20N\x20Rate\x20sharing\x20items,\x20sum(rates)\x20===\x2010000','Each\x20sharing.who=Entity\x20points\x20to\x20a\x20beneficiary\x20wallet\x20(not\x20Treasury)','Guard\x20verifies\x20time-based\x20trigger\x20(e.g.\x20context(Clock).timestamp\x20>=\x20next_release)\x20or\x20signer\x20authorization','User\x20calls\x20receive()\x20to\x20deposit\x20funds,\x20then\x20alloc()\x20to\x20trigger\x20distribution','No\x20Service/Order/Progress/Machine\x20context\x20required'],'dependencies':['Treasury','Guard','Payment'],'key_constraints':['F-A-05:\x20sum(rates)\x20===\x2010000\x20(pure\x20Rate\x20mode)','R-A-3-04:\x20standalone\x20mode\x20has\x20no\x20Service-layer\x20access\x20control\x20—\x20Guard\x20+\x20Passport\x20MUST\x20be\x20sufficient','Caller\x20is\x20fully\x20responsible\x20for\x20receive\x20→\x20alloc\x20lifecycle\x20(no\x20auto-trigger)','Guard\x20should\x20bind\x20Signer\x20to\x20prevent\x20unauthorized\x20alloc()\x20calls'],'recommended_templates':['T-A-09']},{'id':'allocation_standalone_vesting','name':'Standalone\x20vesting\x20release\x20(time-locked\x20multi-stage\x20unlock)','trigger_source':'standalone','distribution_strategy':'time_locked_vesting','coin_type_note':'Coin<T>\x20must\x20match\x20the\x20vested\x20asset\x20(e.g.\x20locked\x20team\x20tokens)','typical_allocator_count':0x3,'sharing_who_types':['Entity'],'modes_used':['Amount','Rate','Surplus'],'guard_requirement':'multiple_unique','non_zero_threshold':!![],'uses_max':!![],'common_patterns':['N\x20Allocators,\x20each\x20mapped\x20to\x20a\x20vesting\x20stage\x20(e.g.\x2025%\x20at\x20month\x2012,\x2025%\x20at\x20month\x2024,\x2050%\x20surplus\x20at\x20month\x2036)','Each\x20Allocator\x27s\x20Guard\x20verifies\x20context(Clock).timestamp\x20>=\x20stage_unlock_time','Amount\x20sharing\x20per\x20stage\x20with\x20max\x20field\x20capping\x20the\x20cumulative\x20release','Final\x20Allocator\x20uses\x20Surplus\x20to\x20drain\x20remaining\x20balance\x20after\x20last\x20vesting\x20stage','Mutually\x20exclusive\x20Guard\x20conditions\x20(only\x20one\x20stage\x20active\x20at\x20a\x20time,\x20based\x20on\x20timestamp)','User\x20calls\x20receive()\x20to\x20deposit\x20locked\x20tokens,\x20then\x20alloc()\x20at\x20each\x20vesting\x20milestone'],'dependencies':['Treasury','Guard','Passport','Payment'],'key_constraints':['F-A-04:\x20at\x20most\x201\x20Surplus\x20per\x20Allocator\x20(final\x20stage\x20uses\x20Surplus\x20to\x20drain\x20remainder)','F-A-08:\x20Amount\x20sum\x20<=\x20max\x20(EAMOUNT_EXCEEDS_MAX)','R-A-3-04:\x20standalone\x20mode\x20has\x20no\x20Service-layer\x20access\x20control\x20—\x20Guard\x20time-lock\x20MUST\x20be\x20enforced','Guard\x20conditions\x20must\x20be\x20mutually\x20exclusive\x20by\x20timestamp\x20(R-A-4-02)','Caller\x20must\x20wait\x20for\x20time-lock\x20expiry\x20before\x20alloc()\x20succeeds;\x20otherwise\x20alloc()\x20silently\x20returns\x20(R-A-4-01)'],'recommended_templates':['T-A-10']}];export const ALLOCATION_LEDGER_VERSION='1.0.0';export function getScenesByTriggerSource(a){return ALLOCATION_SCENES['filter'](b=>b['trigger_source']===a);}export function getScenesByMode(a){return ALLOCATION_SCENES['filter'](b=>b['modes_used']['includes'](a));}export function getScenesByStrategy(a){return ALLOCATION_SCENES['filter'](b=>b['distribution_strategy']===a);}export function findSceneById(a){return ALLOCATION_SCENES['find'](b=>b['id']===a);}export function inferSceneFromIntent(a){const b=a['toLowerCase']();if(b['includes']('arbitration')||b['includes']('fees_alloc'))return findSceneById('allocation_arbitration_fees');if(b['includes']('standalone')||b['includes']('periodic\x20split')||b['includes']('investment\x20dividend')||b['includes']('shared\x20income')||b['includes']('dividend'))return findSceneById('allocation_standalone_periodic_split');if(b['includes']('vesting')||b['includes']('time-lock')||b['includes']('unlock\x20period')||b['includes']('locked\x20release')||b['includes']('token\x20unlock'))return findSceneById('allocation_standalone_vesting');if(b['includes']('refund')){if(b['includes']('order')||b['includes']('100%'))return findSceneById('allocation_refund_to_order');if(b['includes']('surplus')||b['includes']('merchant'))return findSceneById('allocation_refund_first_surplus_to_merchant');}if(b['includes']('alternative')||b['includes']('priority')||b['includes']('treasury')&&b['includes']('personal'))return findSceneById('allocation_treasury_personal_alternatives');if(b['includes']('tiered')||b['includes']('threshold\x20switch'))return findSceneById('allocation_tiered_by_order_amount');if(b['includes']('dynamic\x20recipient')||b['includes']('referrer')||b['includes']('guardidentifier'))return findSceneById('allocation_dynamic_recipient');if(b['includes']('retain')||b['includes']('max'))return findSceneById('allocation_max_capped_retain');if(b['includes']('multi-node')||b['includes']('multi\x20machine')||b['includes']('multi_node'))return findSceneById('allocation_multi_node_trigger');const c=(a['match'](/%/g)||[])['length'];if(c<=0x1)return findSceneById('allocation_merchant_full_payment');if(c>=0x2)return findSceneById('allocation_standard_three_way_split');return undefined;}export function getAllScenes(){return[...ALLOCATION_SCENES];}export function getScenesCount(){return ALLOCATION_SCENES['length'];}export function allocationModeToNumber(a){switch(a){case'Amount':return ALLOCATION_MODE_AMOUNT;case'Rate':return ALLOCATION_MODE_RATE;case'Surplus':return ALLOCATION_MODE_SURPLUS;}}export function allocationModeFromNumber(a){switch(a){case ALLOCATION_MODE_AMOUNT:return'Amount';case ALLOCATION_MODE_RATE:return'Rate';case ALLOCATION_MODE_SURPLUS:return'Surplus';default:throw new Error('Invalid\x20AllocationMode\x20number:\x20'+a);}}export function getRecipientType(a){if('GuardIdentifier'in a)return'GuardIdentifier';if('Entity'in a)return'Entity';return'Signer';}export function isSignerRecipient(a){return'Signer'in a;}export function isEntityRecipient(a){return'Entity'in a;}export function isGuardIdentifierRecipient(a){return'GuardIdentifier'in a;}export function getErrorName(a){for(const [b,d]of Object['entries'](ALLOCATION_ERROR_CODES)){if(d===a)return b;}return undefined;}export function getErrorDescription(a){const b={0x1:'GuardIdentifier\x20resolved\x20value\x20is\x20not\x20an\x20address\x20type',0x2:'Allocator\x20count\x20exceeds\x20MAX_ALLOCATOR_COUNT\x20(100)',0x3:'No\x20Allocator\x20in\x20the\x20allocators\x20vector',0x4:'Pure\x20Rate\x20mode\x20sum\x20!=\x2010000\x20(no\x20Surplus\x20to\x20absorb\x20remainder)',0x5:'Multiple\x20Surplus\x20sharing\x20in\x20a\x20single\x20Allocator',0x6:'Rate\x20+\x20Surplus\x20sum\x20>\x2010000',0x7:'balance\x20<\x20threshold\x20(insufficient\x20balance\x20to\x20trigger\x20alloc)',0x8:'allocators.allocators\x20is\x20empty',0x9:'payment_info\x20is\x20None\x20when\x20alloc()\x20is\x20called',0xa:'sharing\x20count\x20exceeds\x20MAX_SHARING_COUNT\x20(100)',0xb:'sharing\x20mode\x20is\x20not\x200\x20(Amount)\x20/\x201\x20(Rate)\x20/\x202\x20(Surplus)',0xc:'Amount\x20sum\x20(fix)\x20<\x20threshold',0xd:'Amount\x20sum\x20(fix)\x20>\x20max',0xe:'distribution\x20computes\x20to\x20zero\x20while\x20the\x20pool\x20still\x20holds\x20funds\x20(or\x20balance\x20is\x200)',0xf:'GuardIdentifier\x20recipient\x20address\x20!=\x20payment_info.for_object\x20anchor\x20(abort\x20fires\x20only\x20when\x20a\x20for_object\x20binding\x20is\x20declared)'};return b[a];}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{MAX_ALLOCATOR_COUNT,ALLOCATION_MAX_SHARING_COUNT,RATE_TOTAL_FULL}from'./allocation-ledger.js';export function initPuzzleFromIntent(a){const b={};return(a['action']||a['distribution_goal']||a['trigger_condition'])&&(b['intent']={'action':a['action']??'create','host_context':a['host_context']??'service_order_allocators','trigger_condition':a['trigger_condition']??'','distribution_goal':a['distribution_goal']??'','failure_conditions':a['failure_conditions']??[]}),b['constraints']={'F_A_01_allocator_count_le_100':!![],'F_A_02_sharing_count_le_100':!![],'F_A_03_sharing_mode_valid':!![],'F_A_04_at_most_1_surplus_per_allocator':!![],'F_A_05_pure_rate_sum_eq_10000':!![],'F_A_06_rate_plus_surplus_sum_le_10000':!![],'F_A_07_amount_sum_ge_threshold':!![],'F_A_08_amount_sum_le_max':!![],'F_A_09_balance_ge_threshold_at_alloc':!![],'F_A_10_payment_info_present':!![],'F_A_11_allocators_not_empty':!![],'F_A_12_order_at_most_1_allocation':!![],'F_A_13_guard_identifier_is_address':!![],'F_A_14_guard_addresses_unique':!![],'F_A_15_order_allocators_immutable_after_publish':!![]},b;}export function checkPuzzleCompleteness(a){const b=[],c=[];if(!a['intent'])b['push']('A'),c['push']({'dimension':'A','reason':'Intent\x20not\x20specified\x20(action\x20+\x20distribution_goal)'});else{if(!a['intent']['distribution_goal'])b['push']('A'),c['push']({'dimension':'A','reason':'distribution_goal\x20is\x20empty'});else!a['intent']['host_context']&&(b['push']('A'),c['push']({'dimension':'A','reason':'host_context\x20(trigger\x20source)\x20must\x20be\x20specified'}));}if(!a['binding'])b['push']('B'),c['push']({'dimension':'B','reason':'Binding\x20not\x20specified\x20(coin_type\x20+\x20guard_objects)'});else{if(!a['binding']['coin_type'])b['push']('B'),c['push']({'dimension':'B','reason':'coin_type\x20is\x20missing'});else a['binding']['guard_objects']['length']===0x0&&(b['push']('B'),c['push']({'dimension':'B','reason':'guard_objects\x20list\x20is\x20empty\x20—\x20at\x20least\x201\x20Guard\x20required'}));}if(!a['data_source']&&a['intent']?.['action']==='create')b['push']('C'),c['push']({'dimension':'C','reason':'Data\x20source\x20not\x20specified\x20(allocators_config\x20+\x20payment_info)'});else a['data_source']&&a['data_source']['allocators_config']['allocators']['length']===0x0&&(b['push']('C'),c['push']({'dimension':'C','reason':'allocators_config.allocators\x20is\x20empty'}));return!a['operations']&&(b['push']('D'),c['push']({'dimension':'D','reason':'Operations\x20not\x20enumerated'})),!a['logic']&&(b['push']('E'),c['push']({'dimension':'E','reason':'Logic\x20flow\x20(7-step\x20alloc)\x20not\x20defined'})),!a['constraints']&&(b['push']('F'),c['push']({'dimension':'F','reason':'Constraints\x20not\x20checked'})),{'dimensions':['A','B','C','D','E','F'],'missing':b,'missing_details':c,'complete':b['length']===0x0,'next_step':b['length']===0x0?'Puzzle\x20complete\x20—\x20ready\x20for\x20confirmation\x20text\x20generation':'Next:\x20complete\x20dimension\x20'+b[0x0]+'\x20—\x20'+c[0x0]['reason']};}export function validateConstraints(a){const b=[];if(!a['data_source'])return b;const c=a['data_source']['allocators_config'];c['allocators']['length']>MAX_ALLOCATOR_COUNT&&b['push']({'constraint_id':'F-A-01','severity':'CRITICAL','message':'Allocator\x20count\x20'+c['allocators']['length']+'\x20exceeds\x20MAX_ALLOCATOR_COUNT\x20'+MAX_ALLOCATOR_COUNT,'current_value':c['allocators']['length'],'limit':MAX_ALLOCATOR_COUNT,'related_move_error':'EALLOCATOR_COUNT_EXCEEDED\x20(2)'});c['allocators']['length']===0x0&&b['push']({'constraint_id':'F-A-11','severity':'CRITICAL','message':'allocators.allocators\x20is\x20empty\x20—\x20at\x20least\x201\x20Allocator\x20required','related_move_error':'EALLOCATORS_EMPTY\x20(8)\x20/\x20ENO_ALLOCATOR\x20(3)'});const d=c['allocators']['map'](f=>f['guard']),e=new Set(d);e['size']!==d['length']&&b['push']({'constraint_id':'F-A-14','severity':'MEDIUM','message':'Duplicate\x20Guard\x20addresses\x20in\x20allocators\x20('+d['length']+'\x20entries,\x20'+e['size']+'\x20unique)\x20—\x20alloc_by_guard\x20address\x20match\x20only\x20hits\x20the\x20first,\x20subsequent\x20duplicate\x20Allocators\x20are\x20never\x20reachable'});for(const f of c['allocators']){f['sharing']['length']>ALLOCATION_MAX_SHARING_COUNT&&b['push']({'constraint_id':'F-A-02','severity':'CRITICAL','message':'Allocator\x20'+f['guard']+'\x20has\x20'+f['sharing']['length']+'\x20sharing\x20entries,\x20exceeds\x20MAX_SHARING_COUNT\x20'+ALLOCATION_MAX_SHARING_COUNT,'current_value':f['sharing']['length'],'limit':ALLOCATION_MAX_SHARING_COUNT,'related_move_error':'ESHARING_COUNT_EXCEEDED\x20(10)'});for(const m of f['sharing']){!['Amount','Rate','Surplus']['includes'](m['mode'])&&b['push']({'constraint_id':'F-A-03','severity':'CRITICAL','message':'Invalid\x20sharing\x20mode:\x20'+m['mode'],'related_move_error':'ESHARING_MODE_INVALID\x20(11)'});}const g=f['sharing']['filter'](n=>n['mode']==='Surplus')['length'];g>0x1&&b['push']({'constraint_id':'F-A-04','severity':'HIGH','message':'Allocator\x20'+f['guard']+'\x20has\x20'+g+'\x20Surplus\x20sharing\x20—\x20at\x20most\x201\x20allowed','current_value':g,'limit':0x1,'related_move_error':'EMULTIPLE_SURPLUS\x20(5)'});const h=f['sharing']['filter'](n=>n['mode']==='Rate')['reduce']((n,o)=>n+Number(o['sharing']),0x0),i=g>0x0;!i&&h>0x0&&h!==RATE_TOTAL_FULL&&b['push']({'constraint_id':'F-A-05','severity':'HIGH','message':'Pure\x20Rate\x20mode\x20(no\x20Surplus)\x20sum\x20'+h+'\x20!=\x20'+RATE_TOTAL_FULL,'current_value':h,'limit':RATE_TOTAL_FULL,'related_move_error':'ERATE_NOT_10000\x20(4)'});i&&h>RATE_TOTAL_FULL&&b['push']({'constraint_id':'F-A-06','severity':'HIGH','message':'Rate\x20+\x20Surplus\x20mode\x20sum\x20'+h+'\x20>\x20'+RATE_TOTAL_FULL,'current_value':h,'limit':RATE_TOTAL_FULL,'related_move_error':'ERATE_EXCEEDS_10000\x20(6)'});const j=f['sharing']['filter'](n=>n['mode']==='Amount')['reduce']((n,o)=>n+Number(o['sharing']),0x0),k=Number(c['threshold']);j>0x0&&j<k&&b['push']({'constraint_id':'F-A-07','severity':'HIGH','message':'Amount\x20sum\x20'+j+'\x20<\x20threshold\x20'+k,'current_value':j,'limit':k,'related_move_error':'EAMOUNT_BELOW_THRESHOLD\x20(12)'});f['max']!=null&&j>Number(f['max'])&&b['push']({'constraint_id':'F-A-08','severity':'MEDIUM','message':'Amount\x20sum\x20'+j+'\x20>\x20max\x20'+Number(f['max']),'current_value':j,'limit':Number(f['max']),'related_move_error':'EAMOUNT_EXCEEDS_MAX\x20(13)'});const l=f['sharing']['find'](n=>typeof n['who']==='object'&&'GuardIdentifier'in n['who']);if(l){}}return b;}export function generateConfirmationText(a){const b=[];b['push']('═══\x20Allocation\x20Confirmation\x20═══'),b['push']('');if(a['intent']){b['push']('Action:\x20'+a['intent']['action']),b['push']('Host\x20context:\x20'+a['intent']['host_context']),b['push']('Trigger:\x20'+a['intent']['trigger_condition']),b['push']('Distribution\x20goal:\x20'+a['intent']['distribution_goal']);if(a['intent']['failure_conditions']['length']>0x0){b['push']('Failure\x20conditions:');for(const d of a['intent']['failure_conditions'])b['push']('\x20\x20-\x20'+d);}b['push']('');}if(a['binding']){b['push']('─\x20Binding\x20──────────────'),b['push']('Coin\x20type:\x20'+a['binding']['coin_type']);if(a['binding']['host_service'])b['push']('Host\x20Service:\x20'+a['binding']['host_service']);if(a['binding']['host_arbitration'])b['push']('Host\x20Arbitration:\x20'+a['binding']['host_arbitration']);if(a['binding']['bound_order'])b['push']('Bound\x20Order:\x20'+a['binding']['bound_order']);if(a['binding']['trigger_node'])b['push']('Trigger\x20node:\x20'+a['binding']['trigger_node']);b['push']('Guard\x20objects\x20('+a['binding']['guard_objects']['length']+'):\x20'+a['binding']['guard_objects']['join'](',\x20')),b['push']('Payment\x20info\x20source:\x20'+a['binding']['payment_info_source']),b['push']('');}if(a['data_source']){const e=a['data_source']['allocators_config'];b['push']('─\x20Data\x20Source\x20──────────────'),b['push']('Description:\x20'+e['description']),b['push']('Threshold:\x20'+e['threshold']),b['push']('Allocators:\x20'+e['allocators']['length']),e['allocators']['forEach']((f,g)=>{b['push']('\x20\x20['+g+']\x20guard='+f['guard']+',\x20sharing='+f['sharing']['length']+'\x20items,\x20fix='+(f['fix']??'0')+',\x20max='+(f['max']??'null')),f['sharing']['forEach']((h,k)=>{b['push']('\x20\x20\x20\x20\x20\x20('+k+')\x20who='+JSON['stringify'](h['who'])+',\x20sharing='+h['sharing']+',\x20mode='+h['mode']);});}),b['push']('Payment\x20info\x20for_object:\x20'+a['data_source']['payment_info']['for_object']),b['push']('Coin\x20source:\x20'+a['data_source']['coin_source']),b['push']('');}if(a['logic']){b['push']('─\x20Logic\x20──────────────'),b['push']('Guard\x20matching:\x20'+a['logic']['guard_matching_strategy']),b['push']('alloc()\x20flow\x20('+a['logic']['alloc_flow']['length']+'\x20steps):');for(const f of a['logic']['alloc_flow']){b['push']('\x20\x20'+f['step']+'.\x20'+f['action']+':\x20'+f['description']);}b['push']('');}const c=validateConstraints(a);if(c['length']>0x0){b['push']('─\x20Constraint\x20Violations\x20──────────────');for(const g of c){b['push']('\x20\x20['+g['severity']+']\x20'+g['constraint_id']+':\x20'+g['message']);}b['push']('');}return b['join']('\x0a');}export function buildDefaultAllocFlow(){return[{'step':0x1,'action':'pre_check','description':'assert\x20balance\x20>=\x20threshold,\x20payment_info.is_some(),\x20allocators\x20not\x20empty'},{'step':0x2,'action':'guard_lookup','description':'iterate\x20allocators[],\x20locate\x20alloc.guard\x20==\x20alloc_by_guard\x20address;\x20on\x20hit\x20call\x20passport::result_for_guard\x20hard\x20verification\x20(failure\x20aborts\x20E_VERIFY_FAILED)'},{'step':0x3,'action':'rate_base_calc','description':'total_rates\x20=\x20max\x20-\x20fix\x20(if\x20max)\x20else\x20balance\x20-\x20fix'},{'step':0x4,'action':'sharing_distribution','description':'iterate\x20sharing[],\x20split\x20by\x20mode\x20(Amount/Rate/Surplus\x20placeholder)'},{'step':0x5,'action':'surplus_distribution','description':'withdraw_all\x20to\x20surplus_recipient\x20(if\x20any)'},{'step':0x6,'action':'recipient_resolution','description':'resolve\x20address\x20from\x20GuardIdentifier(passport)\x20/\x20Entity(static)\x20/\x20Signer(tx\x20sender)'},{'step':0x7,'action':'payment_creation','description':'create\x20Payment\x20object,\x20push\x20to\x20self.payment\x20vector'}];}export function buildDefaultRecipientRules(){return[{'recipient_type':'GuardIdentifier','resolution_source':'passport_table','safety_level':'safe'},{'recipient_type':'Entity','resolution_source':'static_address','safety_level':'safe'},{'recipient_type':'Signer','resolution_source':'tx_sender','safety_level':'dangerous'}];}export function buildDefaultLogicPuzzle(){return{'alloc_flow':buildDefaultAllocFlow(),'guard_matching_strategy':'caller_specified_guard','recipient_resolution_rules':buildDefaultRecipientRules()};}export const ALLOCATION_PUZZLE_VERSION='1.0.0';
|
|
1
|
+
import{MAX_ALLOCATOR_COUNT,ALLOCATION_MAX_SHARING_COUNT,RATE_TOTAL_FULL}from'./allocation-ledger.js';export function initPuzzleFromIntent(a){const b={};return(a['action']||a['distribution_goal']||a['trigger_condition'])&&(b['intent']={'action':a['action']??'create','host_context':a['host_context']??'service_order_allocators','trigger_condition':a['trigger_condition']??'','distribution_goal':a['distribution_goal']??'','failure_conditions':a['failure_conditions']??[]}),b['constraints']={'F_A_01_allocator_count_le_100':!![],'F_A_02_sharing_count_le_100':!![],'F_A_03_sharing_mode_valid':!![],'F_A_04_at_most_1_surplus_per_allocator':!![],'F_A_05_pure_rate_sum_eq_10000':!![],'F_A_06_rate_plus_surplus_sum_le_10000':!![],'F_A_07_amount_sum_ge_threshold':!![],'F_A_08_amount_sum_le_max':!![],'F_A_09_balance_ge_threshold_at_alloc':!![],'F_A_10_payment_info_present':!![],'F_A_11_allocators_not_empty':!![],'F_A_12_order_at_most_1_allocation':!![],'F_A_13_guard_identifier_is_address':!![],'F_A_14_guard_addresses_unique':!![],'F_A_15_order_allocators_immutable_after_publish':!![]},b;}export function checkPuzzleCompleteness(a){const b=[],c=[];if(!a['intent'])b['push']('A'),c['push']({'dimension':'A','reason':'Intent\x20not\x20specified\x20(action\x20+\x20distribution_goal)'});else{if(!a['intent']['distribution_goal'])b['push']('A'),c['push']({'dimension':'A','reason':'distribution_goal\x20is\x20empty'});else!a['intent']['host_context']&&(b['push']('A'),c['push']({'dimension':'A','reason':'host_context\x20(trigger\x20source)\x20must\x20be\x20specified'}));}if(!a['binding'])b['push']('B'),c['push']({'dimension':'B','reason':'Binding\x20not\x20specified\x20(coin_type\x20+\x20guard_objects)'});else{if(!a['binding']['coin_type'])b['push']('B'),c['push']({'dimension':'B','reason':'coin_type\x20is\x20missing'});else a['binding']['guard_objects']['length']===0x0&&(b['push']('B'),c['push']({'dimension':'B','reason':'guard_objects\x20list\x20is\x20empty\x20—\x20at\x20least\x201\x20Guard\x20required'}));}if(!a['data_source']&&a['intent']?.['action']==='create')b['push']('C'),c['push']({'dimension':'C','reason':'Data\x20source\x20not\x20specified\x20(allocators_config\x20+\x20payment_info)'});else a['data_source']&&a['data_source']['allocators_config']['allocators']['length']===0x0&&(b['push']('C'),c['push']({'dimension':'C','reason':'allocators_config.allocators\x20is\x20empty'}));return!a['operations']&&(b['push']('D'),c['push']({'dimension':'D','reason':'Operations\x20not\x20enumerated'})),!a['logic']&&(b['push']('E'),c['push']({'dimension':'E','reason':'Logic\x20flow\x20(7-step\x20alloc)\x20not\x20defined'})),!a['constraints']&&(b['push']('F'),c['push']({'dimension':'F','reason':'Constraints\x20not\x20checked'})),{'dimensions':['A','B','C','D','E','F'],'missing':b,'missing_details':c,'complete':b['length']===0x0,'next_step':b['length']===0x0?'Puzzle\x20complete\x20—\x20ready\x20for\x20confirmation\x20text\x20generation':'Next:\x20complete\x20dimension\x20'+b[0x0]+'\x20—\x20'+c[0x0]['reason']};}export function validateConstraints(a){const b=[];if(!a['data_source'])return b;const c=a['data_source']['allocators_config'];c['allocators']['length']>MAX_ALLOCATOR_COUNT&&b['push']({'constraint_id':'F-A-01','severity':'CRITICAL','message':'Allocator\x20count\x20'+c['allocators']['length']+'\x20exceeds\x20MAX_ALLOCATOR_COUNT\x20'+MAX_ALLOCATOR_COUNT,'current_value':c['allocators']['length'],'limit':MAX_ALLOCATOR_COUNT,'related_move_error':'EALLOCATOR_COUNT_EXCEEDED\x20(2)'});c['allocators']['length']===0x0&&b['push']({'constraint_id':'F-A-11','severity':'CRITICAL','message':'allocators.allocators\x20is\x20empty\x20—\x20at\x20least\x201\x20Allocator\x20required','related_move_error':'EALLOCATORS_EMPTY\x20(8)\x20/\x20ENO_ALLOCATOR\x20(3)'});const d=c['allocators']['map'](f=>f['guard']),e=new Set(d);e['size']!==d['length']&&b['push']({'constraint_id':'F-A-14','severity':'MEDIUM','message':'Duplicate\x20Guard\x20addresses\x20in\x20allocators\x20('+d['length']+'\x20entries,\x20'+e['size']+'\x20unique)\x20—\x20alloc_by_guard\x20address\x20match\x20only\x20hits\x20the\x20first,\x20subsequent\x20duplicate\x20Allocators\x20are\x20never\x20reachable'});for(const f of c['allocators']){f['sharing']['length']>ALLOCATION_MAX_SHARING_COUNT&&b['push']({'constraint_id':'F-A-02','severity':'CRITICAL','message':'Allocator\x20'+f['guard']+'\x20has\x20'+f['sharing']['length']+'\x20sharing\x20entries,\x20exceeds\x20MAX_SHARING_COUNT\x20'+ALLOCATION_MAX_SHARING_COUNT,'current_value':f['sharing']['length'],'limit':ALLOCATION_MAX_SHARING_COUNT,'related_move_error':'ESHARING_COUNT_EXCEEDED\x20(10)'});for(const m of f['sharing']){!['Amount','Rate','Surplus']['includes'](m['mode'])&&b['push']({'constraint_id':'F-A-03','severity':'CRITICAL','message':'Invalid\x20sharing\x20mode:\x20'+m['mode'],'related_move_error':'ESHARING_MODE_INVALID\x20(11)'});}const g=f['sharing']['filter'](n=>n['mode']==='Surplus')['length'];g>0x1&&b['push']({'constraint_id':'F-A-04','severity':'HIGH','message':'Allocator\x20'+f['guard']+'\x20has\x20'+g+'\x20Surplus\x20sharing\x20—\x20at\x20most\x201\x20allowed','current_value':g,'limit':0x1,'related_move_error':'EMULTIPLE_SURPLUS\x20(5)'});const h=f['sharing']['filter'](n=>n['mode']==='Rate')['reduce']((n,o)=>n+Number(o['sharing']),0x0),i=g>0x0;!i&&h>0x0&&h!==RATE_TOTAL_FULL&&b['push']({'constraint_id':'F-A-05','severity':'HIGH','message':'Pure\x20Rate\x20mode\x20(no\x20Surplus)\x20sum\x20'+h+'\x20!=\x20'+RATE_TOTAL_FULL,'current_value':h,'limit':RATE_TOTAL_FULL,'related_move_error':'ERATE_NOT_10000\x20(4)'});i&&h>RATE_TOTAL_FULL&&b['push']({'constraint_id':'F-A-06','severity':'HIGH','message':'Rate\x20+\x20Surplus\x20mode\x20sum\x20'+h+'\x20>\x20'+RATE_TOTAL_FULL,'current_value':h,'limit':RATE_TOTAL_FULL,'related_move_error':'ERATE_EXCEEDS_10000\x20(6)'});const j=f['sharing']['filter'](n=>n['mode']==='Amount')['reduce']((n,o)=>n+Number(o['sharing']),0x0),k=Number(c['threshold']);j>0x0&&j<k&&b['push']({'constraint_id':'F-A-07','severity':'HIGH','message':'Amount\x20sum\x20'+j+'\x20<\x20threshold\x20'+k,'current_value':j,'limit':k,'related_move_error':'EAMOUNT_BELOW_THRESHOLD\x20(12)'});f['max']!=null&&j>Number(f['max'])&&b['push']({'constraint_id':'F-A-08','severity':'MEDIUM','message':'Amount\x20sum\x20'+j+'\x20>\x20max\x20'+Number(f['max']),'current_value':j,'limit':Number(f['max']),'related_move_error':'EAMOUNT_EXCEEDS_MAX\x20(13)'});const l=f['sharing']['find'](n=>typeof n['who']==='object'&&'GuardIdentifier'in n['who']);if(l){}}return b;}export function generateConfirmationText(a){const b=[];b['push']('═══\x20Allocation\x20Confirmation\x20═══'),b['push']('');if(a['intent']){b['push']('Action:\x20'+a['intent']['action']),b['push']('Host\x20context:\x20'+a['intent']['host_context']),b['push']('Trigger:\x20'+a['intent']['trigger_condition']),b['push']('Distribution\x20goal:\x20'+a['intent']['distribution_goal']);if(a['intent']['failure_conditions']['length']>0x0){b['push']('Failure\x20conditions:');for(const d of a['intent']['failure_conditions'])b['push']('\x20\x20-\x20'+d);}b['push']('');}if(a['binding']){b['push']('─\x20Binding\x20──────────────'),b['push']('Coin\x20type:\x20'+a['binding']['coin_type']);if(a['binding']['host_service'])b['push']('Host\x20Service:\x20'+a['binding']['host_service']);if(a['binding']['host_arbitration'])b['push']('Host\x20Arbitration:\x20'+a['binding']['host_arbitration']);if(a['binding']['bound_order'])b['push']('Bound\x20Order:\x20'+a['binding']['bound_order']);if(a['binding']['trigger_node'])b['push']('Trigger\x20node:\x20'+a['binding']['trigger_node']);b['push']('Guard\x20objects\x20('+a['binding']['guard_objects']['length']+'):\x20'+a['binding']['guard_objects']['join'](',\x20')),b['push']('Payment\x20info\x20source:\x20'+a['binding']['payment_info_source']),b['push']('');}if(a['data_source']){const e=a['data_source']['allocators_config'];b['push']('─\x20Data\x20Source\x20──────────────'),b['push']('Description:\x20'+e['description']),b['push']('Threshold:\x20'+e['threshold']),b['push']('Allocators:\x20'+e['allocators']['length']),e['allocators']['forEach']((f,g)=>{b['push']('\x20\x20['+g+']\x20guard='+f['guard']+',\x20sharing='+f['sharing']['length']+'\x20items,\x20fix='+(f['fix']??'0')+',\x20max='+(f['max']??'null')),f['sharing']['forEach']((h,k)=>{b['push']('\x20\x20\x20\x20\x20\x20('+k+')\x20who='+JSON['stringify'](h['who'])+',\x20sharing='+h['sharing']+',\x20mode='+h['mode']);});}),b['push']('Payment\x20info\x20for_object:\x20'+a['data_source']['payment_info']['for_object']+(a['data_source']['payment_info']['for_object']?'\x20(ENFORCED\x20at\x20alloc:\x20GuardIdentifier\x20submissions\x20must\x20equal\x20this\x20address,\x20abort\x2015\x20on\x20mismatch)':'\x20(no\x20anchor:\x20nothing\x20enforced\x20on-chain,\x20recipient\x20routing\x20is\x20the\x20creator\x27s\x20business)')),b['push']('Coin\x20source:\x20'+a['data_source']['coin_source']),b['push']('');}if(a['logic']){b['push']('─\x20Logic\x20──────────────'),b['push']('Guard\x20matching:\x20'+a['logic']['guard_matching_strategy']),b['push']('alloc()\x20flow\x20('+a['logic']['alloc_flow']['length']+'\x20steps):');for(const f of a['logic']['alloc_flow']){b['push']('\x20\x20'+f['step']+'.\x20'+f['action']+':\x20'+f['description']);}b['push']('');}const c=validateConstraints(a);if(c['length']>0x0){b['push']('─\x20Constraint\x20Violations\x20──────────────');for(const g of c){b['push']('\x20\x20['+g['severity']+']\x20'+g['constraint_id']+':\x20'+g['message']);}b['push']('');}return b['join']('\x0a');}export function buildDefaultAllocFlow(){return[{'step':0x1,'action':'pre_check','description':'assert\x20balance\x20>=\x20threshold,\x20payment_info.is_some(),\x20allocators\x20not\x20empty'},{'step':0x2,'action':'guard_lookup','description':'iterate\x20allocators[],\x20locate\x20alloc.guard\x20==\x20alloc_by_guard\x20address;\x20on\x20hit\x20call\x20passport::result_for_guard\x20hard\x20verification\x20(failure\x20aborts\x20E_VERIFY_FAILED)'},{'step':0x3,'action':'rate_base_calc','description':'total_rates\x20=\x20max\x20-\x20fix\x20(if\x20max)\x20else\x20balance\x20-\x20fix'},{'step':0x4,'action':'sharing_distribution','description':'iterate\x20sharing[],\x20split\x20by\x20mode\x20(Amount/Rate/Surplus\x20placeholder)'},{'step':0x5,'action':'surplus_distribution','description':'withdraw_all\x20to\x20surplus_recipient\x20(if\x20any)'},{'step':0x6,'action':'recipient_resolution','description':'resolve\x20address\x20from\x20GuardIdentifier(passport)\x20/\x20Entity(static)\x20/\x20Signer(tx\x20sender);\x20GuardIdentifier\x20submissions\x20are\x20additionally\x20checked\x20against\x20payment_info.for_object\x20when\x20it\x20is\x20Some\x20(mismatch\x20aborts\x20ERECIPIENT_NOT_FOR_OBJECT\x2015;\x20None\x20=\x20no\x20anchor,\x20nothing\x20enforced)'},{'step':0x7,'action':'payment_creation','description':'create\x20Payment\x20object,\x20push\x20to\x20self.payment\x20vector'}];}export function buildDefaultRecipientRules(){return[{'recipient_type':'GuardIdentifier','resolution_source':'passport_table','safety_level':'safe'},{'recipient_type':'Entity','resolution_source':'static_address','safety_level':'safe'},{'recipient_type':'Signer','resolution_source':'tx_sender','safety_level':'dangerous'}];}export function buildDefaultLogicPuzzle(){return{'alloc_flow':buildDefaultAllocFlow(),'guard_matching_strategy':'caller_specified_guard','recipient_resolution_rules':buildDefaultRecipientRules()};}export const ALLOCATION_PUZZLE_VERSION='1.0.0';
|
|
@@ -47,6 +47,7 @@ export interface AllocationRiskCheckContext {
|
|
|
47
47
|
operation_type?: "create" | "receive" | "alloc_by_guard" | "query";
|
|
48
48
|
coin_type?: string;
|
|
49
49
|
has_payment_info?: boolean;
|
|
50
|
+
payment_info_for_object?: string | null;
|
|
50
51
|
trigger_source?: "service_order_allocators" | "arbitration_fees" | "standalone";
|
|
51
52
|
host_service_published?: boolean;
|
|
52
53
|
host_service_permission?: string;
|
|
@@ -59,7 +60,7 @@ export interface AllocationRiskCheckContext {
|
|
|
59
60
|
bound_order?: string;
|
|
60
61
|
order_already_has_allocation?: boolean;
|
|
61
62
|
}
|
|
62
|
-
export declare const ALLOCATION_RISK_VERSION = "1.
|
|
63
|
+
export declare const ALLOCATION_RISK_VERSION = "1.1.0";
|
|
63
64
|
export declare function getAllRiskRules(): AllocationRiskRule[];
|
|
64
65
|
export declare function getRiskRulesCount(): number;
|
|
65
66
|
export declare function getRiskRulesByCategory(category: AllocationRiskCategory): AllocationRiskRule[];
|
|
@@ -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_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_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.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 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 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 +1 @@
|
|
|
1
|
-
export const GUARD_DESIGN_PATTERNS=[{'id':'pattern.identity_check_single','business_requirement':'Only\x20the\x20author\x20can\x20purchase\x20this\x20service\x20(strict\x20single-identity)','data_source':'SystemContext','host':'service_buy_guard','verifier_level':'level1_strict_single','logic_summary':'logic_equal[context(Signer),\x20identifier[N](fixed_address)]','key_queries':[],'mitigated_risks':['R-C4-04'],'notes':['Maximally\x20secure\x20but\x20maximally\x20inconvenient','If\x20address\x20is\x20unavailable\x20(key\x20loss,\x20rotation),\x20Guard\x20permanently\x20blocks','Avoid\x20unless\x20role\x20is\x20permanently\x20tied\x20to\x20one\x20address']},{'id':'pattern.identity_check_allowlist','business_requirement':'Customer\x20must\x20be\x20in\x20an\x20allowlist\x20to\x20purchase','data_source':'SystemContext','host':'service_buy_guard','verifier_level':'level2_identity_set','logic_summary':'vec_contains_address[identifier[N](allowlist_vec),\x20context(Signer)]','key_queries':[],'mitigated_risks':['R-C4-04'],'notes':['Allowlist\x20stored\x20as\x20Address\x20vector\x20in\x20table\x20constant']},{'id':'pattern.identity_check_order_holder','business_requirement':'Only\x20order\x20owner\x20or\x20agent\x20can\x20perform\x20operation','data_source':'OnChainConstant','host':'machine_forward','verifier_level':'level2_identity_set','logic_summary':'logic_or[logic_equal[query(1562\x20order.owner),\x20context(Signer)],\x20query(1567\x20order.agent\x20has,\x20Signer)]','key_queries':['order.owner','order.agent\x20has'],'mitigated_risks':['R-C4-04','R-C3-06'],'notes':['1562\x20returns\x20Address\x20→\x20wrap\x20in\x20logic_equal','1567\x20returns\x20Bool\x20→\x20use\x20directly\x20as\x20logic_or\x20child','Recommended\x20Level\x202\x20alternative\x20to\x20Level\x201\x20strict\x20binding']},{'id':'pattern.identity_check_service_provider_dynamic','business_requirement':'Verify\x20caller\x20is\x20service\x27s\x20current\x20permission\x20owner\x20(survives\x20permission\x20rotation)','data_source':'SubmittedObject','host':'machine_forward','verifier_level':'level2_identity_set','logic_summary':'logic_and[logic_equal[query(1488\x20service.permission),\x20identifier[N](submitted_perm)],\x20logic_or[logic_equal[query(1002\x20permission.owner),\x20context(Signer)],\x20query(1004\x20permission.admin\x20has,\x20Signer)]]','key_queries':['service.permission','permission.owner','permission.admin\x20has'],'mitigated_risks':['R-C4-04','R-C3-05'],'notes':['Dynamic\x20permission\x20address\x20(RECOMMENDED)\x20—\x20survives\x20Service\x20permission\x20rotation','Caller\x20submits\x20permission\x20address;\x20Guard\x20verifies\x20match\x20then\x20checks\x20identity','More\x20complex\x20than\x20static\x20but\x20far\x20more\x20robust']},{'id':'pattern.time_lock_progress','business_requirement':'Customer\x20must\x20wait\x20N\x20hours\x20before\x20completing\x20(time-lock)','data_source':'WitnessDerived','host':'machine_forward','verifier_level':'none','logic_summary':'logic_as_u256_ge[context(Clock),\x20calc_number_add[query(1272\x20progress.current_time,\x20witness=OrderProgress),\x20identifier[N](duration_ms)]]','key_queries':['progress.current_time'],'witness_types':['OrderProgress'],'mitigated_risks':[],'notes':['Use\x20convert_witness=100\x20(OrderProgress)\x20to\x20derive\x20Progress\x20from\x20submitted\x20Order\x20ID','Duration\x20in\x20milliseconds\x20—\x20test\x20with\x20small\x20values\x20first']},{'id':'pattern.time_lock_absolute','business_requirement':'Operation\x20allowed\x20only\x20after\x20a\x20fixed\x20timestamp','data_source':'SystemContext','host':'service_buy_guard','verifier_level':'none','logic_summary':'logic_as_u256_ge[context(Clock),\x20identifier[N](release_timestamp)]','key_queries':[],'mitigated_risks':[],'notes':['Useful\x20for\x20pre-sale\x20windows,\x20embargo\x20periods']},{'id':'pattern.repository_data_check','business_requirement':'External\x20data\x20must\x20match\x20expected\x20value\x20(e.g.,\x20weather,\x20price\x20feed)','data_source':'OnChainConstant','host':'machine_forward','verifier_level':'none','logic_summary':'logic_equal[query(1167\x20repository.data,\x20policy,\x20key),\x20identifier[N](expected_value)]','key_queries':['repository.data'],'mitigated_risks':[],'notes':['Repository\x20address\x20declared\x20as\x20table\x20constant','Timestamp\x20keys\x20may\x20need\x20convert_number_address','quote_guard\x20context:\x20fails\x20in\x20gen_passport\x20(impack_list\x20empty),\x20works\x20in\x20on-chain\x20business\x20operations\x20(see\x20R-X1-10)']},{'id':'pattern.repository_quote_guard_subscription','business_requirement':'Repository\x20data\x20access\x20requires\x20payment\x20proof\x20(subscription\x20revenue\x20model)','data_source':'SubmittedObject','host':'repository_write','verifier_level':'level3_scene_combined','logic_summary':'Repository\x20policy\x20sets\x20quote_guard\x20(is_depended:\x20immutable\x20+\x20rep=true).\x20'+'When\x20a\x20Guard\x20queries\x20this\x20Repository\x27s\x20data\x20(query\x201167),\x20check_repository_quote_guard\x20verifies\x20'+'the\x20quote_guard\x20is\x20in\x20impack_list.\x20The\x20quote_guard\x20itself\x20verifies\x20a\x20submitted\x20Payment\x20'+'(payment.info.for\x20matches\x20Repository,\x20payment.amount\x20meets\x20subscription\x20price).\x20'+'User\x20submits\x20Payment\x20via\x20Passport\x20→\x20quote_guard\x20verified\x20→\x20added\x20to\x20impack_list\x20→\x20query\x201167\x20passes.','key_queries':['repository.data','payment.info.for','payment.amount'],'mitigated_risks':['R-X1-10'],'applicable_industries':['subscription','travel','rental','education'],'notes':['VERIFIED:\x20passport.rs#L545-612\x20(check_repository_quote_guard),\x20passport.rs#L758-769\x20(trigger\x20at\x20query_id==1167)','Repository.owner_receive<T>\x20accepts\x20Payment\x20as\x20subscription\x20revenue\x20(repository.move#L714-717)','quote_guard\x20must\x20be\x20is_depended:\x20immutable=true,\x20relies\x20empty,\x20rep=true\x20(guard.move#L133-135)','VERIFIER-EVIDENCE\x20DESIGN:\x20user\x20submits\x20valid\x20Payment,\x20quote_guard\x20verifies\x20Payment\x20fields\x20—\x20no\x20object-linker\x20binding\x20needed','gen_passport\x20context:\x20quote_guard\x20fails\x20(impack_list\x20empty)\x20—\x20only\x20use\x20for\x20on-chain\x20business\x20operations','Business\x20model:\x20data\x20provider\x20publishes\x20weather/market/oracle\x20data\x20to\x20Repository,\x20'+'users\x20pay\x20subscription\x20to\x20access\x20data\x20in\x20their\x20Machine\x20flows','MODE\x20A\x20(direct\x20payment\x20verify)\x20—\x20four\x20verifiable\x20elements\x20on\x20the\x20submitted\x20Payment:\x20'+'1)\x20amount:\x20logic_as_u256_ge[payment.amount,\x20N]\x20(>=\x20subscription\x20price);\x20'+'2)\x20subscription\x20type:\x20payment.info.remark\x20/\x20payment.info.index\x20encodes\x20the\x20tier/plan;\x20'+'3)\x20fixed\x20recipient:\x20payment.record.recipient\x20must\x20equal\x20the\x20designated\x20payee\x20(Treasury/owner\x20address);\x20'+'4)\x20occurrence\x20time:\x20payment.time\x20within\x20the\x20validity\x20window\x20(logic_as_u256_ge/le\x20vs\x20context(Clock))','Payment\x20is\x20freeze_object\x20after\x20creation\x20—\x20all\x20four\x20elements\x20are\x20tamper-proof\x20evidence','For\x20a\x20LOWER\x20user-cost\x20variant\x20(no\x20per-user\x20payment\x20submission),\x20see\x20pattern.repository_whitelist_sync\x20(Mode\x20B)']},{'id':'pattern.repository_whitelist_sync','business_requirement':'Entitlement\x20check\x20via\x20a\x20synced\x20allowlist\x20Repository\x20instead\x20of\x20per-user\x20payment\x20submission\x20(low-friction\x20entitlements:\x20memberships,\x20authorizations,\x20paid-user\x20lists)','data_source':'OnChainConstant','host':'machine_forward','verifier_level':'none','logic_summary':'Off-chain\x20collector\x20gathers\x20eligible\x20users\x20(transfers\x20/\x20Payments\x20to\x20the\x20designated\x20receiving\x20address\x20or\x20object,\x20'+'Service\x20orders,\x20or\x20any\x20off-chain\x20record)\x20and\x20syncs\x20the\x20list\x20into\x20a\x20dedicated\x20Repository\x20object\x20'+'(entries\x20may\x20carry\x20a\x20validity\x20window,\x20e.g.\x20authorized\x20time\x20period).\x20'+'The\x20consuming\x20Guard\x20checks\x20membership\x20via\x20query\x201166/1167\x20(repository.data)\x20keyed\x20by\x20the\x20caller:\x20'+'vec_contains_address-style\x20logic_or\x20over\x20[repository.data(key=Signer)]\x20or\x20logic_equal[repository.data(...),\x20identifier[N](expected)].\x20'+'Repository\x20writes\x20go\x20through\x20id_data\x20/\x20id_data_add\x20/\x20id_data_remove\x20(batch\x20up\x20to\x20100\x20entries\x20per\x20tx).','key_queries':['repository.data'],'mitigated_risks':['R-X1-10'],'applicable_industries':['subscription','travel','rental','education'],'notes':['MODE\x20B\x20(whitelist\x20sync)\x20—\x20user-cost\x20optimization\x20of\x20Mode\x20A\x20(pattern.repository_quote_guard_subscription):\x20'+'users\x20do\x20NOT\x20submit\x20a\x20Payment\x20at\x20verification\x20time;\x20the\x20operator\x20proves\x20eligibility\x20off-chain\x20and\x20syncs\x20the\x20roster','TRADE-OFF:\x20eventual\x20consistency\x20—\x20the\x20roster\x20updates\x20at\x20the\x20collector\x27s\x20sync\x20frequency\x20(slight\x20delay),\x20'+'vs\x20Mode\x20A\x27s\x20instant\x20per-payment\x20proof.\x20Choose\x20by\x20business:\x20high-frequency\x20low-value\x20→\x20Mode\x20B;\x20'+'high-value\x20instant\x20entitlement\x20→\x20Mode\x20A','Entry\x20shape:\x20key\x20=\x20user\x20address\x20(or\x20derived\x20id),\x20value\x20=\x20expiry\x20timestamp\x20/\x20tier\x20/\x20scope;\x20'+'time-window\x20enforcement\x20compares\x20entry\x20value\x20against\x20context(Clock)\x20in\x20the\x20Guard','VERIFIED:\x20repository.move\x20id_data*\x20(batch\x20≤100),\x20guard-ins.ts\x201166/1167\x20(repository.data\x20queries),\x20'+'guard.move\x20is_depended\x20(1167\x20marks\x20query-only\x20repositories)','The\x20collector\x20can\x20source\x20eligibility\x20from:\x20transfers\x20or\x20Payments\x20to\x20a\x20fixed\x20receiving\x20address/object,\x20'+'Service\x20orders\x20(order.service\x20==\x20designated\x20service),\x20or\x20external\x20off-chain\x20records','Repository\x20access\x20economics\x20stay\x20OUT\x20of\x20this\x20pattern\x20(K3\x2010\x20§5\x20D5\x20ruling:\x20reuse\x20Reward/Allocation\x20'+'outside\x20the\x20Repository\x20for\x20payment;\x20the\x20Repository\x20here\x20is\x20the\x20roster,\x20not\x20the\x20payment\x20rail)']},{'id':'pattern.supply_chain_suborder_verification','business_requirement':'Sub-service\x20purchase\x20requires\x20ownership\x20of\x20main\x20service\x20order\x20(supply\x20chain\x20milestone\x20unlock)','data_source':'SubmittedObject','host':'service_buy_guard','verifier_level':'level2_identity_set','logic_summary':'Sub-service\x20buy_guard\x20verifies\x20submitted\x20main\x20Order:\x20'+'logic_and[logic_equal[query(order.owner),\x20context(Signer)],\x20logic_equal[query(order.service),\x20identifier[N](main_service_address)]].\x20'+'User\x20submits\x20main\x20Order\x20via\x20Passport\x20(b_submission=true),\x20buy_guard\x20verifies\x20ownership\x20+\x20service\x20match.','key_queries':['order.owner','order.service'],'mitigated_risks':['R-C3-05'],'applicable_industries':['travel','rental','education','freelance'],'notes':['VERIFIER-EVIDENCE\x20DESIGN:\x20user\x20submits\x20main\x20Order\x20as\x20evidence,\x20buy_guard\x20verifies\x20order.owner==Signer\x20AND\x20order.service==main_service','Each\x20milestone\x20=\x20one\x20sub-order\x20with\x20its\x20own\x20Service\x20+\x20buy_guard\x20referencing\x20the\x20main\x20order','Main\x20flow\x20can\x20branch\x20to\x20different\x20sub-services\x20based\x20on\x20Machine\x20node\x20progression','No\x20parent_order\x20field\x20needed\x20—\x20relationship\x20verified\x20via\x20buy_guard\x20querying\x20submitted\x20Order\x20fields','Enables\x20supply\x20chain\x20composition:\x20main\x20service\x20→\x20multiple\x20sub-services\x20with\x20conditional\x20access']},{'id':'pattern.payment_exception_compensation','business_requirement':'Exception\x20branch\x20triggers\x20compensation\x20Payment\x20(e.g.,\x20delivery\x20delay\x20>\x2030min\x20auto-compensates\x20customer)','data_source':'SubmittedObject','host':'machine_forward','verifier_level':'level3_scene_combined','logic_summary':'Exception\x20forward\x20guard\x20verifies\x204-dimensional\x20anti-reuse\x20binding:\x20logic_and['+'logic_equal[query(payment.info.for),\x20identifier[N](order_address)],\x20'+'logic_equal[query(payment.info.guard),\x20identifier[N](this_guard_address)],\x20'+'logic_as_u256_ge[query(payment.amount),\x20identifier[N](compensation_amount)],\x20'+'logic_as_u256_equal[query(payment.info.index),\x20query(progress.history\x20count)],\x20'+'logic_string_nocase_equal[query(payment.info.remark),\x20query(progress.current)]].\x20'+'Treasury\x20withdraws\x20to\x20customer\x20with\x20PaymentInfo(for_object=order,\x20for_guard=this,\x20index=history_count_at_creation,\x20remark=node_name).\x20'+'Customer\x20submits\x20Payment\x20via\x20Passport;\x20guard\x20verifies\x20index\x20matches\x20current\x20unique\x20step\x20(progress.history\x20count,\x20U64,\x20monotonically\x20increasing\x20—\x20unique\x20even\x20in\x20cycles)\x20AND\x20remark\x20matches\x20current\x20node\x20name\x20(progress.current,\x20String\x20—\x20may\x20repeat\x20across\x20cycles\x20but\x20bound\x20to\x20this\x20step\x20by\x20index).','key_queries':['payment.info.for','payment.info.guard','payment.info.index','payment.info.remark','payment.amount','progress.history\x20count','progress.current'],'mitigated_risks':[],'applicable_industries':['rental','travel','general','freelance'],'notes':['VERIFIED:\x20payment.move#L66-71\x20(PaymentInfo:\x20for_object,\x20for_guard,\x20remark,\x20index),\x20payment.move#L82-86\x20(payment_info_with_guard)','VERIFIED:\x20treasury.move#L249-264\x20(withdraw\x20creates\x20Payment\x20via\x20payment::new_singleton\x20+\x20from_object_set)','Payment\x20is\x20freeze_object\x20(immutable,\x20payment.move#L160)\x20—\x20cannot\x20be\x20modified\x20after\x20creation','VERIFIED\x20INDEX\x20QUERY:\x20progress.history\x20count\x20(id\x201273,\x20U64)\x20—\x20guard-ins.ts#L1228-1237.\x20From\x20progress.move\x20L440-441\x20(session_accomplish\x20pushes\x20a\x20new\x20History\x20entry)\x20+\x20L475/L482\x20(parent_table_vec::length\x20returns\x20current\x20session\x20id).\x20This\x20count\x20is\x20the\x20unique\x20monotonically\x20increasing\x20step\x20index\x20—\x20even\x20in\x20cycles,\x20each\x20entry\x20has\x20a\x20different\x20count.','VERIFIED\x20NODE\x20NAME\x20QUERY:\x20progress.current\x20(id\x201253,\x20String)\x20—\x20guard-ins.ts#L1025-1032.\x20Returns\x20the\x20current\x20node\x20name.\x20A\x20node\x20CAN\x20be\x20entered\x20multiple\x20times\x20in\x20cycles,\x20so\x20node\x20name\x20alone\x20is\x20NOT\x20unique\x20—\x20it\x20MUST\x20be\x20paired\x20with\x20progress.history\x20count\x20for\x20uniqueness.','DESIGN\x20INTENT\x20(USER):\x20to\x20validate\x20index\x20(U64\x20type),\x20use\x20progress.history\x20count\x20(unique,\x20non-repeating);\x20to\x20validate\x20node\x20name\x20(may\x20repeat\x20in\x20cycles),\x20store\x20it\x20in\x20PaymentInfo.remark\x20and\x20do\x20string\x20comparison\x20with\x20progress.current.','ANTI-REUSE\x204-DIMENSIONAL\x20BINDING:\x20for_object\x20(Order)\x20+\x20for_guard\x20(Guard)\x20+\x20index\x20(unique\x20step\x20via\x20progress.history\x20count)\x20+\x20remark\x20(node\x20name\x20via\x20progress.current).\x20Same\x20Payment\x20cannot\x20be\x20reused\x20in\x20other\x20contexts\x20—\x20at\x20least\x20one\x20field\x20will\x20mismatch.','VERIFIER-EVIDENCE\x20DESIGN:\x20customer\x20submits\x20Payment,\x20guard\x20verifies\x20binding\x20fields\x20match\x20current\x20context','Enables\x20user-friendly\x20exception\x20handling:\x20delay\x20→\x20auto-compensation\x20→\x20friendly\x20branch\x20flow','No\x20object-linker\x20binding\x20registration\x20needed\x20—\x20guard\x20only\x20verifies\x20submitted\x20Payment\x27s\x20field\x20accuracy']},{'id':'pattern.verifier_evidence_philosophy','business_requirement':'Guard\x20design\x20philosophy:\x20verifier\x20provides\x20evidence,\x20guard\x20verifies\x20logic\x20+\x20data\x20accuracy\x20(NOT\x20data\x20discovery)','data_source':'SubmittedObject','host':'gen_passport','verifier_level':'none','logic_summary':'Guard\x20is\x20a\x20PURE\x20VERIFICATION\x20engine.\x20Participants\x20submit\x20evidence\x20(Payment,\x20Order,\x20Proof,\x20etc.)\x20'+'via\x20Passport\x20submissions\x20(b_submission=true).\x20Guard\x20verifies:\x20(1)\x20logic\x20completeness,\x20(2)\x20data\x20usage\x20accuracy.\x20'+'Guard\x20does\x20NOT\x20discover/fetch\x20objects\x20via\x20object-linker\x20binding.\x20object-linker\x20binding\x20is\x20for\x20object\x20lifecycle\x20bookkeeping,\x20'+'NOT\x20for\x20guard\x20data\x20discovery.','key_queries':[],'mitigated_risks':['R-C3-05','R-C3-06'],'notes':['CORE\x20PRINCIPLE:\x20Guard\x20only\x20validates\x20submitted\x20evidence\x20—\x20it\x20never\x20fetches\x20data\x20on\x20its\x20own','For\x20Payment\x20verification:\x20user\x20submits\x20valid\x20Payment\x20→\x20guard\x20checks\x20for_object/for_guard/index\x20match','For\x20multi-order\x20verification:\x20verifier\x20submits\x20Order\x20data\x20→\x20guard\x20checks\x20service/owner\x20relationships','For\x20Repository\x20access:\x20user\x20submits\x20Payment\x20→\x20quote_guard\x20verifies\x20→\x20impack_list\x20updated\x20→\x20data\x20query\x20passes','Type\x203\x20(SubmittedObject)\x20data\x20source\x20class\x20embodies\x20this\x20philosophy\x20—\x20b_submission=true\x20entries','This\x20pattern\x20is\x20foundational\x20for\x20all\x20guard\x20designs\x20—\x20always\x20prefer\x20verifier-evidence\x20over\x20complex\x20object\x20discovery']},{'id':'pattern.progress_state_check','business_requirement':'Specific\x20forward\x20has\x20been\x20accomplished\x20(customer\x20confirms\x20delivery)','data_source':'WitnessDerived','host':'reward_claim','verifier_level':'none','logic_summary':'logic_equal[query_progress_history_find(...).accomplished,\x20identifier[N](true)]','key_queries':['progress.current','progress.current_time'],'witness_types':['OrderProgress'],'mitigated_risks':[],'notes':['Chain\x20query_progress_history_find\x20→\x20query_progress_history_session_forward_find']},{'id':'pattern.reward_one_time_claim','business_requirement':'User\x20can\x20only\x20claim\x20reward\x20once\x20(no\x20prior\x20claims)','data_source':'OnChainConstant','host':'reward_claim','verifier_level':'none','logic_summary':'logic_equal[query_reward_record_count(recipient=Signer),\x20identifier[N](0)]','key_queries':['reward.record_count'],'mitigated_risks':[],'notes':['Record\x20count\x20check\x20prevents\x20double-claim']},{'id':'pattern.reward_multi_condition','business_requirement':'Order\x20payment\x20>\x20threshold\x20AND\x20reached\x20\x27complete\x27\x20to\x20claim\x20reward','data_source':'WitnessDerived','host':'reward_claim','verifier_level':'none','logic_summary':'logic_and[logic_as_u256_gt[query(order.amount),\x20threshold],\x20logic_equal[query(progress.current),\x20\x27complete\x27],\x20logic_equal[query(order.service),\x20identifier[N](expected_service)]]','key_queries':['order.amount','progress.current','order.service'],'witness_types':['OrderProgress'],'mitigated_risks':['R-C3-05'],'notes':['Multi-condition:\x20amount\x20+\x20progress\x20state\x20+\x20service\x20match']},{'id':'pattern.arbitration_voting_weight','business_requirement':'Vote\x20weight\x20equals\x20reputation\x20score\x20(dynamic\x20weight\x20from\x20Passport)','data_source':'SubmittedObject','host':'arbitration_voting','verifier_level':'none','logic_summary':'GuardIdentifier\x20extracts\x20numeric\x20value\x20from\x20Passport\x20submission','key_queries':[],'mitigated_risks':['R-C3-02'],'notes':['Table\x20needs\x20numeric\x20submission\x20entry\x20at\x20referenced\x20index','Weight\x20must\x20come\x20from\x20on-chain\x20EntityRegistrar,\x20not\x20submission','BINDING_01:\x20voting_guard\x20GuardIdentifier\x20must\x20be\x20numeric\x20(U8-U256)','C-9\x20VERIFIED:\x20voting\x20is\x20OPTIONAL\x20—\x20arb.move\x20voting_deadline\x20is\x20Option\x20'+'(None\x20=\x20open-ended\x20voting;\x20arbitration\x20can\x20proceed\x20whenever\x20the\x20arbiter\x20decides).\x20'+'NO\x20minimum\x20voter\x20quorum\x20is\x20required\x20on-chain:\x20the\x20arbiter\x20may\x20rule\x20with\x20any\x20number\x20'+'of\x20votes\x20(including\x20zero).\x20MAX_ARBITRATOR_VOTING=520\x20is\x20only\x20an\x20upper\x20bound.\x20'+'Open\x20voting\x20(empty\x20voting_guard)\x20gives\x20every\x20vote\x20weight\x201\x20(vote_imp\x20asserts\x20empty\x20guard).']},{'id':'pattern.arbitration_membership_check','business_requirement':'Only\x20premium\x20members\x20can\x20file\x20disputes','data_source':'OnChainConstant','host':'arbitration_usage','verifier_level':'none','logic_summary':'logic_and[query(entity\x20exists),\x20logic_as_u256_ge[query(entity\x20tier),\x20identifier[N](premium_tier)]]','key_queries':['entity.registrar','entity.linker'],'mitigated_risks':[],'notes':['ENTITY_REGISTRAR_ADDRESS\x20(0xaab)\x20/\x20ENTITY_LINKER_ADDRESS\x20(0xaaa)\x20must\x20be\x20in\x20table']},{'id':'pattern.scene_allocator_entity_recipient','business_requirement':'Service\x20allocator\x20with\x20sharing.who=Entity\x20—\x20no\x20Signer\x20binding\x20needed','data_source':'OnChainConstant','host':'service_allocator_guard','verifier_level':'level3_scene_combined','logic_summary':'Scene\x20verifies\x20fund\x20flow\x20safety\x20—\x20Guard\x20only\x20validates\x20allocation\x20rules','key_queries':['service.permission','order.amount'],'mitigated_risks':['R-C3-06'],'notes':['Funds\x20flow\x20to\x20fixed\x20Treasury/address\x20regardless\x20of\x20caller','sharing.who=Entity\x20already\x20guarantees\x20recipient\x20safety','No\x20Signer\x20binding\x20required\x20—\x20R-C3-06\x20safe']},{'id':'pattern.scene_machine_forward_operator','business_requirement':'Machine\x20forward\x20with\x20permissionIndex/namedOperator\x20already\x20verifies\x20operator','data_source':'OnChainConstant','host':'machine_forward','verifier_level':'level3_scene_combined','logic_summary':'Forward\x27s\x20permissionIndex/namedOperator\x20verifies\x20operator\x20—\x20Guard\x20only\x20validates\x20submitted\x20data','key_queries':[],'mitigated_risks':[],'notes':['Scene\x20verifies\x20operator\x20permission\x20via\x20permissionIndex/namedOperator','Signer\x20binding\x20only\x20needed\x20if\x20submitted\x20data\x20must\x20belong\x20to\x20operator','Evaluate\x20scene\x20before\x20adding\x20Signer\x20binding']},{'id':'pattern.fund_flow_refund_freeform','business_requirement':'Refund\x20/\x20cancellation\x20fund-release\x20defined\x20purely\x20by\x20game\x20conditions\x20—\x20NOT\x20bound\x20to\x20any\x20Machine\x20node','data_source':'SubmittedObject','host':'service_allocator_guard','verifier_level':'level2_identity_set','logic_summary':'An\x20allocator\x20Guard\x20whose\x20root\x20encodes\x20refund\x20conditions\x20ARBITRARILY:\x20'+'buyer\x20signature\x20(logic_equal[Signer,\x20buyer]),\x20timeout\x20(logic_as_u256_ge[Clock,\x20deadline]),\x20'+'evidence\x20state\x20(query\x20any\x20on-chain\x20object:\x20order\x20fields,\x20repository\x20data,\x20payment\x20proofs),\x20'+'arbitration\x20outcome,\x20or\x20any\x20logic_and/or\x20combination.\x20No\x20progress/current-node\x20query\x20required.','key_queries':['order.owner','order.service','order.amount'],'mitigated_risks':['R-C3-06'],'notes':['C-2\x20RESOLUTION:\x20Machine-node-triggered\x20refund\x20(\x27at\x20cancelled\x20node\x20→\x20release\x27)\x20is\x20only\x20ONE\x20application\x20pattern.\x20'+'Guard+Allocator\x20is\x20a\x20GENERAL\x20game\x20primitive:\x20the\x20refund\x20condition\x20tree\x20is\x20fully\x20free-form.\x20'+'Move\x20layer\x20needs\x20NO\x20change\x20—\x20guard.move\x20roots\x20accept\x20arbitrary\x20logic\x20over\x20any\x20queryable\x20state.','GAME-THEORETIC\x20READING:\x20both\x20parties\x20should\x20evaluate\x20the\x20refund\x20Guard\x20BEFORE\x20transacting\x20—\x20'+'who\x20can\x20trigger\x20it,\x20under\x20which\x20conditions,\x20with\x20what\x20evidence.\x20Use\x20the\x20analyze_guard_semantics\x20'+'query\x20action\x20to\x20render\x20+\x20lint\x20any\x20Guard\x20and\x20reason\x20about\x20each\x20party\x27s\x20leverage.','Condition\x20dimensions\x20freely\x20composable:\x20identity\x20(Signer/Entity),\x20time\x20(Clock),\x20'+'counterparty\x20evidence\x20(submitted\x20Payment/Order/Proof),\x20shared\x20data\x20(Repository),\x20'+'workflow\x20state\x20(Progress\x20—\x20optional,\x20only\x20when\x20a\x20Machine\x20exists)','Multi-tier\x20refund:\x20multiple\x20allocators\x20with\x20first-match-wins\x20order\x20encode\x20graduated\x20policies\x20'+'(full\x20refund\x20pre-delivery,\x20partial\x20refund\x20post-milestone,\x20no\x20refund\x20post-acceptance)\x20as\x20SEPARATE\x20Guards']},{'id':'pattern.fund_flow_profit_share_freeform','business_requirement':'Revenue/profit\x20sharing\x20among\x20partners\x20triggered\x20by\x20verifiable\x20contribution\x20conditions\x20—\x20not\x20by\x20workflow\x20nodes','data_source':'OnChainConstant','host':'service_allocator_guard','verifier_level':'level3_scene_combined','logic_summary':'Allocator\x20sharing\x20(who+ratio)\x20defines\x20the\x20SPLIT;\x20the\x20Guard\x20defines\x20WHEN\x20the\x20split\x20executes.\x20'+'The\x20WHEN\x20is\x20free-form:\x20period\x20boundary\x20(Clock\x20vs\x20interval),\x20contribution\x20proof\x20(submitted\x20evidence),\x20'+'performance\x20threshold\x20(Repository\x20metric),\x20or\x20counterparty\x20co-signature.','key_queries':['repository.data','payment.amount'],'mitigated_risks':['R-C3-06'],'applicable_industries':['freelance','subscription','education'],'notes':['C-2\x20RESOLUTION:\x20profit-sharing\x20is\x20an\x20application\x20pattern\x20of\x20the\x20same\x20Guard+Allocator\x20primitive\x20—\x20'+'the\x20trigger\x20condition\x20tree\x20is\x20arbitrary\x20game\x20logic,\x20not\x20a\x20workflow\x20artifact.','sharing.who=Entity\x20recipients\x20make\x20the\x20split\x20caller-safe\x20(funds\x20flow\x20to\x20fixed\x20addresses)\x20—\x20'+'Guard\x20then\x20only\x20gates\x20TIMING/CONDITIONS,\x20not\x20identity\x20(R-C3-06\x20safe\x20by\x20scene)','Periodic\x20settlement:\x20logic_as_u256_ge[Clock,\x20identifier[N](period_start)]\x20+\x20'+'logic_as_u256_equal[calc_number_mod[Clock,\x20interval],\x200]-style\x20windows,\x20'+'or\x20a\x20Repository-held\x20settlement\x20cursor\x20updated\x20after\x20each\x20allocation\x20run']},{'id':'pattern.permission_guard_entity_time_window','business_requirement':'Delegate\x20a\x20permission\x20index\x20to\x20a\x20Guard\x20object\x20address\x20—\x20authorization\x20that\x20self-enforces\x20and\x20self-expires\x20(time-windowed\x20delegation)','data_source':'SystemContext','host':'machine_forward','verifier_level':'none','logic_summary':'permission.move\x20entity\x20table\x20accepts\x20\x27user/guard\x20address\x20&\x20permission_index\x20list\x27\x20—\x20'+'a\x20Guard\x27s\x20OWN\x20ADDRESS\x20can\x20hold\x20a\x20permission\x20index.\x20The\x20delegated\x20Guard\x20then\x20encodes\x20'+'temporal\x20+\x20contextual\x20conditions:\x20logic_and[logic_as_u256_ge[Clock,\x20valid_from],\x20'+'logic_as_u256_le[Clock,\x20valid_until],\x20<scene\x20conditions>].\x20'+'Callers\x20satisfying\x20the\x20Guard\x20act\x20with\x20the\x20delegated\x20permission\x20index.','key_queries':[],'mitigated_risks':[],'notes':['C-8\x20VERIFIED:\x20permission.move\x20entity\x20table\x20comment\x20—\x20\x27user/guard\x20address\x20&\x20permission_index\x20list\x27\x20'+'(guard\x20addresses\x20are\x20first-class\x20permission\x20entities,\x20same\x20as\x20user\x20addresses)','TIME\x20WINDOW:\x20Guard\x20roots\x20compose\x20context(Clock)\x20freely\x20—\x20valid_from/valid_until\x20bounds,\x20'+'recurring\x20windows\x20(mod\x20arithmetic),\x20or\x20deadline-before\x20(authorize\x20only\x20until\x20expiry)','SELF-EXPIRING\x20DELEGATION:\x20after\x20valid_until\x20the\x20Guard\x20fails\x20for\x20everyone\x20—\x20no\x20on-chain\x20'+'revocation\x20transaction\x20needed,\x20no\x20trust\x20in\x20the\x20delegate\x20to\x20stop\x20acting','SCENARIO\x20COMBINATION\x20(情景层):\x20temporary\x20operator\x20(holiday\x20cover),\x20seasonal\x20service\x20window,\x20'+'trial-period\x20customer\x20privileges,\x20contractor\x20time-boxed\x20access,\x20emergency-break-glass\x20with\x20auto-expiry','Design\x20tip:\x20combine\x20with\x20scene\x20conditions\x20(order\x20state,\x20submitted\x20evidence)\x20—\x20'+'time\x20bounds\x20rarely\x20stand\x20alone']}];export const VERIFIER_LEVEL_GUIDANCE=[{'level':'level1_strict_single','pattern':'logic_equal[context(Signer),\x20identifier[N](fixed_address)]','when_to_use':'Role\x20permanently\x20tied\x20to\x20one\x20address\x20AND\x20designer\x20accepts\x20lock-in\x20risk','risk_rules':['R-C4-04'],'recommendation':'avoid'},{'level':'level2_identity_set','pattern':'logic_or\x20of\x20multiple\x20identity\x20checks','when_to_use':'Role-based\x20access\x20—\x20multiple\x20authorized\x20identities','risk_rules':['R-C4-04\x20(suppressed)'],'recommendation':'recommended'},{'level':'level3_scene_combined','pattern':'Scene\x20itself\x20verifies\x20identity\x20—\x20no\x20Signer\x20binding\x20needed','when_to_use':'Scene\x27s\x20host\x20object\x20already\x20verifies\x20operator\x20(e.g.,\x20Machine\x20forward,\x20sharing.who=Entity)','risk_rules':[],'recommendation':'default'},{'level':'none','pattern':'No\x20Signer\x20binding\x20required','when_to_use':'Resource\x20flow\x20matters\x20more\x20than\x20caller\x20identity','risk_rules':[],'recommendation':'default'}];export function getGuardDesignPattern(a){return GUARD_DESIGN_PATTERNS['find'](b=>b['id']===a);}export function searchGuardDesignPatterns(a){const b=a['toLowerCase']();return GUARD_DESIGN_PATTERNS['filter'](c=>{if(c['business_requirement']['toLowerCase']()['includes'](b))return!![];if(c['logic_summary']['toLowerCase']()['includes'](b))return!![];if(c['key_queries']['some'](d=>d['toLowerCase']()['includes'](b)))return!![];return![];});}export function getPatternsByHost(a){return GUARD_DESIGN_PATTERNS['filter'](b=>b['host']===a);}export function getPatternsByIndustry(a){return GUARD_DESIGN_PATTERNS['filter'](b=>b['applicable_industries']?.['includes'](a));}export function getPatternsByDataSourceClass(a){return GUARD_DESIGN_PATTERNS['filter'](b=>b['data_source']===a);}export function getVerifierLevelGuidance(a){return VERIFIER_LEVEL_GUIDANCE['find'](b=>b['level']===a);}export function suggestPatternForRequirement(a){const b=searchGuardDesignPatterns(a);if(b['length']===0x0){const e=GUARD_DESIGN_PATTERNS[0x0];return{'best':e,'alternatives':[]};}const [c,...d]=b;return{'best':c,'alternatives':d};}export const GUARD_DESIGN_PATTERNS_VERSION=0x2;
|
|
1
|
+
export const GUARD_DESIGN_PATTERNS=[{'id':'pattern.identity_check_single','business_requirement':'Only\x20the\x20author\x20can\x20purchase\x20this\x20service\x20(strict\x20single-identity)','data_source':'SystemContext','host':'service_buy_guard','verifier_level':'level1_strict_single','logic_summary':'logic_equal[context(Signer),\x20identifier[N](fixed_address)]','key_queries':[],'mitigated_risks':['R-C4-04'],'notes':['Maximally\x20secure\x20but\x20maximally\x20inconvenient','If\x20address\x20is\x20unavailable\x20(key\x20loss,\x20rotation),\x20Guard\x20permanently\x20blocks','Avoid\x20unless\x20role\x20is\x20permanently\x20tied\x20to\x20one\x20address']},{'id':'pattern.identity_check_allowlist','business_requirement':'Customer\x20must\x20be\x20in\x20an\x20allowlist\x20to\x20purchase','data_source':'SystemContext','host':'service_buy_guard','verifier_level':'level2_identity_set','logic_summary':'vec_contains_address[identifier[N](allowlist_vec),\x20context(Signer)]','key_queries':[],'mitigated_risks':['R-C4-04'],'notes':['Allowlist\x20stored\x20as\x20Address\x20vector\x20in\x20table\x20constant']},{'id':'pattern.identity_check_order_holder','business_requirement':'Only\x20order\x20owner\x20or\x20agent\x20can\x20perform\x20operation','data_source':'OnChainConstant','host':'machine_forward','verifier_level':'level2_identity_set','logic_summary':'logic_or[logic_equal[query(1562\x20order.owner),\x20context(Signer)],\x20query(1567\x20order.agent\x20has,\x20Signer)]','key_queries':['order.owner','order.agent\x20has'],'mitigated_risks':['R-C4-04','R-C3-06'],'notes':['1562\x20returns\x20Address\x20→\x20wrap\x20in\x20logic_equal','1567\x20returns\x20Bool\x20→\x20use\x20directly\x20as\x20logic_or\x20child','Recommended\x20Level\x202\x20alternative\x20to\x20Level\x201\x20strict\x20binding']},{'id':'pattern.identity_check_service_provider_dynamic','business_requirement':'Verify\x20caller\x20is\x20service\x27s\x20current\x20permission\x20owner\x20(survives\x20permission\x20rotation)','data_source':'SubmittedObject','host':'machine_forward','verifier_level':'level2_identity_set','logic_summary':'logic_and[logic_equal[query(1488\x20service.permission),\x20identifier[N](submitted_perm)],\x20logic_or[logic_equal[query(1002\x20permission.owner),\x20context(Signer)],\x20query(1004\x20permission.admin\x20has,\x20Signer)]]','key_queries':['service.permission','permission.owner','permission.admin\x20has'],'mitigated_risks':['R-C4-04','R-C3-05'],'notes':['Dynamic\x20permission\x20address\x20(RECOMMENDED)\x20—\x20survives\x20Service\x20permission\x20rotation','Caller\x20submits\x20permission\x20address;\x20Guard\x20verifies\x20match\x20then\x20checks\x20identity','More\x20complex\x20than\x20static\x20but\x20far\x20more\x20robust']},{'id':'pattern.time_lock_progress','business_requirement':'Customer\x20must\x20wait\x20N\x20hours\x20before\x20completing\x20(time-lock)','data_source':'WitnessDerived','host':'machine_forward','verifier_level':'none','logic_summary':'logic_as_u256_ge[context(Clock),\x20calc_number_add[query(1272\x20progress.current_time,\x20witness=OrderProgress),\x20identifier[N](duration_ms)]]','key_queries':['progress.current_time'],'witness_types':['OrderProgress'],'mitigated_risks':[],'notes':['Use\x20convert_witness=100\x20(OrderProgress)\x20to\x20derive\x20Progress\x20from\x20submitted\x20Order\x20ID','Duration\x20in\x20milliseconds\x20—\x20test\x20with\x20small\x20values\x20first']},{'id':'pattern.time_lock_absolute','business_requirement':'Operation\x20allowed\x20only\x20after\x20a\x20fixed\x20timestamp','data_source':'SystemContext','host':'service_buy_guard','verifier_level':'none','logic_summary':'logic_as_u256_ge[context(Clock),\x20identifier[N](release_timestamp)]','key_queries':[],'mitigated_risks':[],'notes':['Useful\x20for\x20pre-sale\x20windows,\x20embargo\x20periods']},{'id':'pattern.repository_data_check','business_requirement':'External\x20data\x20must\x20match\x20expected\x20value\x20(e.g.,\x20weather,\x20price\x20feed)','data_source':'OnChainConstant','host':'machine_forward','verifier_level':'none','logic_summary':'logic_equal[query(1167\x20repository.data,\x20policy,\x20key),\x20identifier[N](expected_value)]','key_queries':['repository.data'],'mitigated_risks':[],'notes':['Repository\x20address\x20declared\x20as\x20table\x20constant','Timestamp\x20keys\x20may\x20need\x20convert_number_address','quote_guard\x20context:\x20fails\x20in\x20gen_passport\x20(impack_list\x20empty),\x20works\x20in\x20on-chain\x20business\x20operations\x20(see\x20R-X1-10)']},{'id':'pattern.repository_quote_guard_subscription','business_requirement':'Repository\x20data\x20access\x20requires\x20payment\x20proof\x20(subscription\x20revenue\x20model)','data_source':'SubmittedObject','host':'repository_write','verifier_level':'level3_scene_combined','logic_summary':'Repository\x20policy\x20sets\x20quote_guard\x20(is_depended:\x20immutable\x20+\x20rep=true).\x20'+'When\x20a\x20Guard\x20queries\x20this\x20Repository\x27s\x20data\x20(query\x201167),\x20check_repository_quote_guard\x20verifies\x20'+'the\x20quote_guard\x20is\x20in\x20impack_list.\x20The\x20quote_guard\x20itself\x20verifies\x20a\x20submitted\x20Payment\x20'+'(payment.info.for\x20matches\x20Repository,\x20payment.amount\x20meets\x20subscription\x20price).\x20'+'User\x20submits\x20Payment\x20via\x20Passport\x20→\x20quote_guard\x20verified\x20→\x20added\x20to\x20impack_list\x20→\x20query\x201167\x20passes.','key_queries':['repository.data','payment.info.for','payment.amount'],'mitigated_risks':['R-X1-10'],'applicable_industries':['subscription','travel','rental','education'],'notes':['VERIFIED:\x20passport.rs#L545-612\x20(check_repository_quote_guard),\x20passport.rs#L758-769\x20(trigger\x20at\x20query_id==1167)','Repository.owner_receive<T>\x20accepts\x20Payment\x20as\x20subscription\x20revenue\x20(repository.move#L714-717)','quote_guard\x20must\x20be\x20is_depended:\x20immutable=true,\x20relies\x20empty,\x20rep=true\x20(guard.move#L133-135)','VERIFIER-EVIDENCE\x20DESIGN:\x20user\x20submits\x20valid\x20Payment,\x20quote_guard\x20verifies\x20Payment\x20fields\x20—\x20no\x20object-linker\x20binding\x20needed','gen_passport\x20context:\x20quote_guard\x20fails\x20(impack_list\x20empty)\x20—\x20only\x20use\x20for\x20on-chain\x20business\x20operations','Business\x20model:\x20data\x20provider\x20publishes\x20weather/market/oracle\x20data\x20to\x20Repository,\x20'+'users\x20pay\x20subscription\x20to\x20access\x20data\x20in\x20their\x20Machine\x20flows','MODE\x20A\x20(direct\x20payment\x20verify)\x20—\x20four\x20verifiable\x20elements\x20on\x20the\x20submitted\x20Payment:\x20'+'1)\x20amount:\x20logic_as_u256_ge[payment.amount,\x20N]\x20(>=\x20subscription\x20price);\x20'+'2)\x20subscription\x20type:\x20payment.info.remark\x20/\x20payment.info.index\x20encodes\x20the\x20tier/plan;\x20'+'3)\x20fixed\x20recipient:\x20payment.record.recipient\x20must\x20equal\x20the\x20designated\x20payee\x20(Treasury/owner\x20address);\x20'+'4)\x20occurrence\x20time:\x20payment.time\x20within\x20the\x20validity\x20window\x20(logic_as_u256_ge/le\x20vs\x20context(Clock))','Payment\x20is\x20freeze_object\x20after\x20creation\x20—\x20all\x20four\x20elements\x20are\x20tamper-proof\x20evidence','For\x20a\x20LOWER\x20user-cost\x20variant\x20(no\x20per-user\x20payment\x20submission),\x20see\x20pattern.repository_whitelist_sync\x20(Mode\x20B)']},{'id':'pattern.repository_whitelist_sync','business_requirement':'Entitlement\x20check\x20via\x20a\x20synced\x20allowlist\x20Repository\x20instead\x20of\x20per-user\x20payment\x20submission\x20(low-friction\x20entitlements:\x20memberships,\x20authorizations,\x20paid-user\x20lists)','data_source':'OnChainConstant','host':'machine_forward','verifier_level':'none','logic_summary':'Off-chain\x20collector\x20gathers\x20eligible\x20users\x20(transfers\x20/\x20Payments\x20to\x20the\x20designated\x20receiving\x20address\x20or\x20object,\x20'+'Service\x20orders,\x20or\x20any\x20off-chain\x20record)\x20and\x20syncs\x20the\x20list\x20into\x20a\x20dedicated\x20Repository\x20object\x20'+'(entries\x20may\x20carry\x20a\x20validity\x20window,\x20e.g.\x20authorized\x20time\x20period).\x20'+'The\x20consuming\x20Guard\x20checks\x20membership\x20via\x20query\x201166/1167\x20(repository.data)\x20keyed\x20by\x20the\x20caller:\x20'+'vec_contains_address-style\x20logic_or\x20over\x20[repository.data(key=Signer)]\x20or\x20logic_equal[repository.data(...),\x20identifier[N](expected)].\x20'+'Repository\x20writes\x20go\x20through\x20id_data\x20/\x20id_data_add\x20/\x20id_data_remove\x20(batch\x20up\x20to\x20100\x20entries\x20per\x20tx).','key_queries':['repository.data'],'mitigated_risks':['R-X1-10'],'applicable_industries':['subscription','travel','rental','education'],'notes':['MODE\x20B\x20(whitelist\x20sync)\x20—\x20user-cost\x20optimization\x20of\x20Mode\x20A\x20(pattern.repository_quote_guard_subscription):\x20'+'users\x20do\x20NOT\x20submit\x20a\x20Payment\x20at\x20verification\x20time;\x20the\x20operator\x20proves\x20eligibility\x20off-chain\x20and\x20syncs\x20the\x20roster','TRADE-OFF:\x20eventual\x20consistency\x20—\x20the\x20roster\x20updates\x20at\x20the\x20collector\x27s\x20sync\x20frequency\x20(slight\x20delay),\x20'+'vs\x20Mode\x20A\x27s\x20instant\x20per-payment\x20proof.\x20Choose\x20by\x20business:\x20high-frequency\x20low-value\x20→\x20Mode\x20B;\x20'+'high-value\x20instant\x20entitlement\x20→\x20Mode\x20A','Entry\x20shape:\x20key\x20=\x20user\x20address\x20(or\x20derived\x20id),\x20value\x20=\x20expiry\x20timestamp\x20/\x20tier\x20/\x20scope;\x20'+'time-window\x20enforcement\x20compares\x20entry\x20value\x20against\x20context(Clock)\x20in\x20the\x20Guard','VERIFIED:\x20repository.move\x20id_data*\x20(batch\x20≤100),\x20guard-ins.ts\x201166/1167\x20(repository.data\x20queries),\x20'+'guard.move\x20is_depended\x20(1167\x20marks\x20query-only\x20repositories)','The\x20collector\x20can\x20source\x20eligibility\x20from:\x20transfers\x20or\x20Payments\x20to\x20a\x20fixed\x20receiving\x20address/object,\x20'+'Service\x20orders\x20(order.service\x20==\x20designated\x20service),\x20or\x20external\x20off-chain\x20records','Repository\x20access\x20economics\x20stay\x20OUT\x20of\x20this\x20pattern\x20(K3\x2010\x20§5\x20D5\x20ruling:\x20reuse\x20Reward/Allocation\x20'+'outside\x20the\x20Repository\x20for\x20payment;\x20the\x20Repository\x20here\x20is\x20the\x20roster,\x20not\x20the\x20payment\x20rail)']},{'id':'pattern.supply_chain_suborder_verification','business_requirement':'Sub-service\x20purchase\x20requires\x20ownership\x20of\x20main\x20service\x20order\x20(supply\x20chain\x20milestone\x20unlock)','data_source':'SubmittedObject','host':'service_buy_guard','verifier_level':'level2_identity_set','logic_summary':'Sub-service\x20buy_guard\x20verifies\x20submitted\x20main\x20Order:\x20'+'logic_and[logic_equal[query(order.owner),\x20context(Signer)],\x20logic_equal[query(order.service),\x20identifier[N](main_service_address)]].\x20'+'User\x20submits\x20main\x20Order\x20via\x20Passport\x20(b_submission=true),\x20buy_guard\x20verifies\x20ownership\x20+\x20service\x20match.','key_queries':['order.owner','order.service'],'mitigated_risks':['R-C3-05'],'applicable_industries':['travel','rental','education','freelance'],'notes':['VERIFIER-EVIDENCE\x20DESIGN:\x20user\x20submits\x20main\x20Order\x20as\x20evidence,\x20buy_guard\x20verifies\x20order.owner==Signer\x20AND\x20order.service==main_service','Each\x20milestone\x20=\x20one\x20sub-order\x20with\x20its\x20own\x20Service\x20+\x20buy_guard\x20referencing\x20the\x20main\x20order','Main\x20flow\x20can\x20branch\x20to\x20different\x20sub-services\x20based\x20on\x20Machine\x20node\x20progression','No\x20parent_order\x20field\x20needed\x20—\x20relationship\x20verified\x20via\x20buy_guard\x20querying\x20submitted\x20Order\x20fields','Enables\x20supply\x20chain\x20composition:\x20main\x20service\x20→\x20multiple\x20sub-services\x20with\x20conditional\x20access']},{'id':'pattern.payment_exception_compensation','business_requirement':'Exception\x20branch\x20triggers\x20compensation\x20Payment\x20(e.g.,\x20delivery\x20delay\x20>\x2030min\x20auto-compensates\x20customer)','data_source':'SubmittedObject','host':'machine_forward','verifier_level':'level3_scene_combined','logic_summary':'Exception\x20forward\x20guard\x20verifies\x204-dimensional\x20anti-reuse\x20binding:\x20logic_and['+'logic_equal[query(payment.info.for),\x20identifier[N](order_address)],\x20'+'logic_equal[query(payment.info.guard),\x20identifier[N](this_guard_address)],\x20'+'logic_as_u256_ge[query(payment.amount),\x20identifier[N](compensation_amount)],\x20'+'logic_as_u256_equal[query(payment.info.index),\x20query(progress.history\x20count)],\x20'+'logic_string_nocase_equal[query(payment.info.remark),\x20query(progress.current)]].\x20'+'Treasury\x20withdraws\x20to\x20customer\x20with\x20PaymentInfo(for_object=order,\x20for_guard=this,\x20index=history_count_at_creation,\x20remark=node_name).\x20'+'Customer\x20submits\x20Payment\x20via\x20Passport;\x20guard\x20verifies\x20index\x20matches\x20current\x20unique\x20step\x20(progress.history\x20count,\x20U64,\x20monotonically\x20increasing\x20—\x20unique\x20even\x20in\x20cycles)\x20AND\x20remark\x20matches\x20current\x20node\x20name\x20(progress.current,\x20String\x20—\x20may\x20repeat\x20across\x20cycles\x20but\x20bound\x20to\x20this\x20step\x20by\x20index).','key_queries':['payment.info.for','payment.info.guard','payment.info.index','payment.info.remark','payment.amount','progress.history\x20count','progress.current'],'mitigated_risks':[],'applicable_industries':['rental','travel','general','freelance'],'notes':['VERIFIED:\x20payment.move#L66-71\x20(PaymentInfo:\x20for_object,\x20for_guard,\x20remark,\x20index),\x20payment.move#L82-86\x20(payment_info_with_guard)','VERIFIED:\x20treasury.move#L249-264\x20(withdraw\x20creates\x20Payment\x20via\x20payment::new_singleton\x20+\x20from_object_set)','Payment\x20is\x20freeze_object\x20(immutable,\x20payment.move#L160)\x20—\x20cannot\x20be\x20modified\x20after\x20creation','VERIFIED\x20INDEX\x20QUERY:\x20progress.history\x20count\x20(id\x201273,\x20U64)\x20—\x20guard-ins.ts#L1228-1237.\x20From\x20progress.move\x20L440-441\x20(session_accomplish\x20pushes\x20a\x20new\x20History\x20entry)\x20+\x20L475/L482\x20(parent_table_vec::length\x20returns\x20current\x20session\x20id).\x20This\x20count\x20is\x20the\x20unique\x20monotonically\x20increasing\x20step\x20index\x20—\x20even\x20in\x20cycles,\x20each\x20entry\x20has\x20a\x20different\x20count.','VERIFIED\x20NODE\x20NAME\x20QUERY:\x20progress.current\x20(id\x201253,\x20String)\x20—\x20guard-ins.ts#L1025-1032.\x20Returns\x20the\x20current\x20node\x20name.\x20A\x20node\x20CAN\x20be\x20entered\x20multiple\x20times\x20in\x20cycles,\x20so\x20node\x20name\x20alone\x20is\x20NOT\x20unique\x20—\x20it\x20MUST\x20be\x20paired\x20with\x20progress.history\x20count\x20for\x20uniqueness.','DESIGN\x20INTENT\x20(USER):\x20to\x20validate\x20index\x20(U64\x20type),\x20use\x20progress.history\x20count\x20(unique,\x20non-repeating);\x20to\x20validate\x20node\x20name\x20(may\x20repeat\x20in\x20cycles),\x20store\x20it\x20in\x20PaymentInfo.remark\x20and\x20do\x20string\x20comparison\x20with\x20progress.current.','ANTI-REUSE\x204-DIMENSIONAL\x20BINDING:\x20for_object\x20(Order)\x20+\x20for_guard\x20(Guard)\x20+\x20index\x20(unique\x20step\x20via\x20progress.history\x20count)\x20+\x20remark\x20(node\x20name\x20via\x20progress.current).\x20Same\x20Payment\x20cannot\x20be\x20reused\x20in\x20other\x20contexts\x20—\x20at\x20least\x20one\x20field\x20will\x20mismatch.','VERIFIER-EVIDENCE\x20DESIGN:\x20customer\x20submits\x20Payment,\x20guard\x20verifies\x20binding\x20fields\x20match\x20current\x20context','Enables\x20user-friendly\x20exception\x20handling:\x20delay\x20→\x20auto-compensation\x20→\x20friendly\x20branch\x20flow','No\x20object-linker\x20binding\x20registration\x20needed\x20—\x20guard\x20only\x20verifies\x20submitted\x20Payment\x27s\x20field\x20accuracy']},{'id':'pattern.verifier_evidence_philosophy','business_requirement':'Guard\x20design\x20philosophy:\x20verifier\x20provides\x20evidence,\x20guard\x20verifies\x20logic\x20+\x20data\x20accuracy\x20(NOT\x20data\x20discovery)','data_source':'SubmittedObject','host':'gen_passport','verifier_level':'none','logic_summary':'Guard\x20is\x20a\x20PURE\x20VERIFICATION\x20engine.\x20Participants\x20submit\x20evidence\x20(Payment,\x20Order,\x20Proof,\x20etc.)\x20'+'via\x20Passport\x20submissions\x20(b_submission=true).\x20Guard\x20verifies:\x20(1)\x20logic\x20completeness,\x20(2)\x20data\x20usage\x20accuracy.\x20'+'Guard\x20does\x20NOT\x20discover/fetch\x20objects\x20via\x20object-linker\x20binding.\x20object-linker\x20binding\x20is\x20for\x20object\x20lifecycle\x20bookkeeping,\x20'+'NOT\x20for\x20guard\x20data\x20discovery.','key_queries':[],'mitigated_risks':['R-C3-05','R-C3-06'],'notes':['CORE\x20PRINCIPLE:\x20Guard\x20only\x20validates\x20submitted\x20evidence\x20—\x20it\x20never\x20fetches\x20data\x20on\x20its\x20own','For\x20Payment\x20verification:\x20user\x20submits\x20valid\x20Payment\x20→\x20guard\x20checks\x20for_object/for_guard/index\x20match','For\x20multi-order\x20verification:\x20verifier\x20submits\x20Order\x20data\x20→\x20guard\x20checks\x20service/owner\x20relationships','For\x20Repository\x20access:\x20user\x20submits\x20Payment\x20→\x20quote_guard\x20verifies\x20→\x20impack_list\x20updated\x20→\x20data\x20query\x20passes','Type\x203\x20(SubmittedObject)\x20data\x20source\x20class\x20embodies\x20this\x20philosophy\x20—\x20b_submission=true\x20entries','This\x20pattern\x20is\x20foundational\x20for\x20all\x20guard\x20designs\x20—\x20always\x20prefer\x20verifier-evidence\x20over\x20complex\x20object\x20discovery']},{'id':'pattern.progress_state_check','business_requirement':'Specific\x20forward\x20has\x20been\x20accomplished\x20(customer\x20confirms\x20delivery)','data_source':'WitnessDerived','host':'reward_claim','verifier_level':'none','logic_summary':'logic_equal[query_progress_history_find(...).accomplished,\x20identifier[N](true)]','key_queries':['progress.current','progress.current_time'],'witness_types':['OrderProgress'],'mitigated_risks':[],'notes':['Chain\x20query_progress_history_find\x20→\x20query_progress_history_session_forward_find']},{'id':'pattern.reward_one_time_claim','business_requirement':'User\x20can\x20only\x20claim\x20reward\x20once\x20(no\x20prior\x20claims)','data_source':'OnChainConstant','host':'reward_claim','verifier_level':'none','logic_summary':'logic_equal[query_reward_record_count(recipient=Signer),\x20identifier[N](0)]','key_queries':['reward.record_count'],'mitigated_risks':[],'notes':['Record\x20count\x20check\x20prevents\x20double-claim']},{'id':'pattern.reward_multi_condition','business_requirement':'Order\x20payment\x20>\x20threshold\x20AND\x20reached\x20\x27complete\x27\x20to\x20claim\x20reward','data_source':'WitnessDerived','host':'reward_claim','verifier_level':'none','logic_summary':'logic_and[logic_as_u256_gt[query(order.amount),\x20threshold],\x20logic_equal[query(progress.current),\x20\x27complete\x27],\x20logic_equal[query(order.service),\x20identifier[N](expected_service)]]','key_queries':['order.amount','progress.current','order.service'],'witness_types':['OrderProgress'],'mitigated_risks':['R-C3-05'],'notes':['Multi-condition:\x20amount\x20+\x20progress\x20state\x20+\x20service\x20match']},{'id':'pattern.arbitration_voting_weight','business_requirement':'Vote\x20weight\x20equals\x20reputation\x20score\x20(dynamic\x20weight\x20from\x20Passport)','data_source':'SubmittedObject','host':'arbitration_voting','verifier_level':'none','logic_summary':'GuardIdentifier\x20extracts\x20numeric\x20value\x20from\x20Passport\x20submission','key_queries':[],'mitigated_risks':['R-C3-02'],'notes':['Table\x20needs\x20numeric\x20submission\x20entry\x20at\x20referenced\x20index','Weight\x20must\x20come\x20from\x20on-chain\x20EntityRegistrar,\x20not\x20submission','BINDING_01:\x20voting_guard\x20GuardIdentifier\x20must\x20be\x20numeric\x20(U8-U256)','C-9\x20VERIFIED:\x20voting\x20is\x20OPTIONAL\x20—\x20arb.move\x20voting_deadline\x20is\x20Option\x20'+'(None\x20=\x20open-ended\x20voting;\x20arbitration\x20can\x20proceed\x20whenever\x20the\x20arbiter\x20decides).\x20'+'NO\x20minimum\x20voter\x20quorum\x20is\x20required\x20on-chain:\x20the\x20arbiter\x20may\x20rule\x20with\x20any\x20number\x20'+'of\x20votes\x20(including\x20zero).\x20MAX_ARBITRATOR_VOTING=520\x20is\x20only\x20an\x20upper\x20bound.\x20'+'Open\x20voting\x20(empty\x20voting_guard)\x20gives\x20every\x20vote\x20weight\x201\x20(vote_imp\x20asserts\x20empty\x20guard).']},{'id':'pattern.arbitration_membership_check','business_requirement':'Only\x20premium\x20members\x20can\x20file\x20disputes','data_source':'OnChainConstant','host':'arbitration_usage','verifier_level':'none','logic_summary':'logic_and[query(entity\x20exists),\x20logic_as_u256_ge[query(entity\x20tier),\x20identifier[N](premium_tier)]]','key_queries':['entity.registrar','entity.linker'],'mitigated_risks':[],'notes':['ENTITY_REGISTRAR_ADDRESS\x20(0xaab)\x20/\x20ENTITY_LINKER_ADDRESS\x20(0xaaa)\x20must\x20be\x20in\x20table']},{'id':'pattern.scene_allocator_entity_recipient','business_requirement':'Service\x20allocator\x20with\x20sharing.who=Entity\x20—\x20no\x20Signer\x20binding\x20needed','data_source':'OnChainConstant','host':'service_allocator_guard','verifier_level':'level3_scene_combined','logic_summary':'Scene\x20verifies\x20fund\x20flow\x20safety\x20—\x20Guard\x20only\x20validates\x20allocation\x20rules','key_queries':['service.permission','order.amount'],'mitigated_risks':['R-C3-06'],'notes':['Funds\x20flow\x20to\x20fixed\x20Treasury/address\x20regardless\x20of\x20caller','sharing.who=Entity\x20already\x20guarantees\x20recipient\x20safety','No\x20Signer\x20binding\x20required\x20—\x20R-C3-06\x20safe']},{'id':'pattern.scene_machine_forward_operator','business_requirement':'Machine\x20forward\x20with\x20permissionIndex/namedOperator\x20already\x20verifies\x20operator','data_source':'OnChainConstant','host':'machine_forward','verifier_level':'level3_scene_combined','logic_summary':'Forward\x27s\x20permissionIndex/namedOperator\x20verifies\x20operator\x20—\x20Guard\x20only\x20validates\x20submitted\x20data','key_queries':[],'mitigated_risks':[],'notes':['Scene\x20verifies\x20operator\x20permission\x20via\x20permissionIndex/namedOperator','Signer\x20binding\x20only\x20needed\x20if\x20submitted\x20data\x20must\x20belong\x20to\x20operator','Evaluate\x20scene\x20before\x20adding\x20Signer\x20binding']},{'id':'pattern.fund_flow_refund_freeform','business_requirement':'Refund\x20/\x20cancellation\x20fund-release\x20defined\x20purely\x20by\x20game\x20conditions\x20—\x20NOT\x20bound\x20to\x20any\x20Machine\x20node','data_source':'SubmittedObject','host':'service_allocator_guard','verifier_level':'level2_identity_set','logic_summary':'An\x20allocator\x20Guard\x20whose\x20root\x20encodes\x20refund\x20conditions\x20ARBITRARILY:\x20'+'buyer\x20signature\x20(logic_equal[Signer,\x20buyer]),\x20timeout\x20(logic_as_u256_ge[Clock,\x20deadline]),\x20'+'evidence\x20state\x20(query\x20any\x20on-chain\x20object:\x20order\x20fields,\x20repository\x20data,\x20payment\x20proofs),\x20'+'arbitration\x20outcome,\x20or\x20any\x20logic_and/or\x20combination.\x20No\x20progress/current-node\x20query\x20required.','key_queries':['order.owner','order.service','order.amount'],'mitigated_risks':['R-C3-06'],'notes':['C-2\x20RESOLUTION:\x20Machine-node-triggered\x20refund\x20(\x27at\x20cancelled\x20node\x20→\x20release\x27)\x20is\x20only\x20ONE\x20application\x20pattern.\x20'+'Guard+Allocator\x20is\x20a\x20GENERAL\x20game\x20primitive:\x20the\x20refund\x20condition\x20tree\x20is\x20fully\x20free-form.\x20'+'Move\x20layer\x20needs\x20NO\x20change\x20—\x20guard.move\x20roots\x20accept\x20arbitrary\x20logic\x20over\x20any\x20queryable\x20state.','GAME-THEORETIC\x20READING:\x20both\x20parties\x20should\x20evaluate\x20the\x20refund\x20Guard\x20BEFORE\x20transacting\x20—\x20'+'who\x20can\x20trigger\x20it,\x20under\x20which\x20conditions,\x20with\x20what\x20evidence.\x20Use\x20the\x20analyze_guard_semantics\x20'+'query\x20action\x20to\x20render\x20+\x20lint\x20any\x20Guard\x20and\x20reason\x20about\x20each\x20party\x27s\x20leverage.','Condition\x20dimensions\x20freely\x20composable:\x20identity\x20(Signer/Entity),\x20time\x20(Clock),\x20'+'counterparty\x20evidence\x20(submitted\x20Payment/Order/Proof),\x20shared\x20data\x20(Repository),\x20'+'workflow\x20state\x20(Progress\x20—\x20optional,\x20only\x20when\x20a\x20Machine\x20exists)','Multi-tier\x20refund:\x20multiple\x20allocators\x20with\x20first-match-wins\x20order\x20encode\x20graduated\x20policies\x20'+'(full\x20refund\x20pre-delivery,\x20partial\x20refund\x20post-milestone,\x20no\x20refund\x20post-acceptance)\x20as\x20SEPARATE\x20Guards']},{'id':'pattern.fund_flow_profit_share_freeform','business_requirement':'Revenue/profit\x20sharing\x20among\x20partners\x20triggered\x20by\x20verifiable\x20contribution\x20conditions\x20—\x20not\x20by\x20workflow\x20nodes','data_source':'OnChainConstant','host':'service_allocator_guard','verifier_level':'level3_scene_combined','logic_summary':'Allocator\x20sharing\x20(who+ratio)\x20defines\x20the\x20SPLIT;\x20the\x20Guard\x20defines\x20WHEN\x20the\x20split\x20executes.\x20'+'The\x20WHEN\x20is\x20free-form:\x20period\x20boundary\x20(Clock\x20vs\x20interval),\x20contribution\x20proof\x20(submitted\x20evidence),\x20'+'performance\x20threshold\x20(Repository\x20metric),\x20or\x20counterparty\x20co-signature.','key_queries':['repository.data','payment.amount'],'mitigated_risks':['R-C3-06'],'applicable_industries':['freelance','subscription','education'],'notes':['C-2\x20RESOLUTION:\x20profit-sharing\x20is\x20an\x20application\x20pattern\x20of\x20the\x20same\x20Guard+Allocator\x20primitive\x20—\x20'+'the\x20trigger\x20condition\x20tree\x20is\x20arbitrary\x20game\x20logic,\x20not\x20a\x20workflow\x20artifact.','sharing.who=Entity\x20recipients\x20make\x20the\x20split\x20caller-safe\x20(funds\x20flow\x20to\x20fixed\x20addresses)\x20—\x20'+'Guard\x20then\x20only\x20gates\x20TIMING/CONDITIONS,\x20not\x20identity\x20(R-C3-06\x20safe\x20by\x20scene)','Periodic\x20settlement:\x20logic_as_u256_ge[Clock,\x20identifier[N](period_start)]\x20+\x20'+'logic_as_u256_equal[calc_number_mod[Clock,\x20interval],\x200]-style\x20windows,\x20'+'or\x20a\x20Repository-held\x20settlement\x20cursor\x20updated\x20after\x20each\x20allocation\x20run']},{'id':'pattern.permission_guard_entity_time_window','business_requirement':'Delegate\x20a\x20permission\x20index\x20to\x20a\x20Guard\x20object\x20address\x20—\x20authorization\x20that\x20self-enforces\x20and\x20self-expires\x20(time-windowed\x20delegation)','data_source':'SystemContext','host':'machine_forward','verifier_level':'none','logic_summary':'permission.move\x20entity\x20table\x20accepts\x20\x27user/guard\x20address\x20&\x20permission_index\x20list\x27\x20—\x20'+'a\x20Guard\x27s\x20OWN\x20ADDRESS\x20can\x20hold\x20a\x20permission\x20index.\x20The\x20delegated\x20Guard\x20then\x20encodes\x20'+'temporal\x20+\x20contextual\x20conditions:\x20logic_and[logic_as_u256_ge[Clock,\x20valid_from],\x20'+'logic_as_u256_le[Clock,\x20valid_until],\x20<scene\x20conditions>].\x20'+'Callers\x20satisfying\x20the\x20Guard\x20act\x20with\x20the\x20delegated\x20permission\x20index.','key_queries':[],'mitigated_risks':[],'notes':['C-8\x20VERIFIED:\x20permission.move\x20entity\x20table\x20comment\x20—\x20\x27user/guard\x20address\x20&\x20permission_index\x20list\x27\x20'+'(guard\x20addresses\x20are\x20first-class\x20permission\x20entities,\x20same\x20as\x20user\x20addresses)','TIME\x20WINDOW:\x20Guard\x20roots\x20compose\x20context(Clock)\x20freely\x20—\x20valid_from/valid_until\x20bounds,\x20'+'recurring\x20windows\x20(mod\x20arithmetic),\x20or\x20deadline-before\x20(authorize\x20only\x20until\x20expiry)','SELF-EXPIRING\x20DELEGATION:\x20after\x20valid_until\x20the\x20Guard\x20fails\x20for\x20everyone\x20—\x20no\x20on-chain\x20'+'revocation\x20transaction\x20needed,\x20no\x20trust\x20in\x20the\x20delegate\x20to\x20stop\x20acting','SCENARIO\x20COMBINATION\x20(scenario\x20layer):\x20temporary\x20operator\x20(holiday\x20cover),\x20seasonal\x20service\x20window,\x20'+'trial-period\x20customer\x20privileges,\x20contractor\x20time-boxed\x20access,\x20emergency-break-glass\x20with\x20auto-expiry','Design\x20tip:\x20combine\x20with\x20scene\x20conditions\x20(order\x20state,\x20submitted\x20evidence)\x20—\x20'+'time\x20bounds\x20rarely\x20stand\x20alone']}];export const VERIFIER_LEVEL_GUIDANCE=[{'level':'level1_strict_single','pattern':'logic_equal[context(Signer),\x20identifier[N](fixed_address)]','when_to_use':'Role\x20permanently\x20tied\x20to\x20one\x20address\x20AND\x20designer\x20accepts\x20lock-in\x20risk','risk_rules':['R-C4-04'],'recommendation':'avoid'},{'level':'level2_identity_set','pattern':'logic_or\x20of\x20multiple\x20identity\x20checks','when_to_use':'Role-based\x20access\x20—\x20multiple\x20authorized\x20identities','risk_rules':['R-C4-04\x20(suppressed)'],'recommendation':'recommended'},{'level':'level3_scene_combined','pattern':'Scene\x20itself\x20verifies\x20identity\x20—\x20no\x20Signer\x20binding\x20needed','when_to_use':'Scene\x27s\x20host\x20object\x20already\x20verifies\x20operator\x20(e.g.,\x20Machine\x20forward,\x20sharing.who=Entity)','risk_rules':[],'recommendation':'default'},{'level':'none','pattern':'No\x20Signer\x20binding\x20required','when_to_use':'Resource\x20flow\x20matters\x20more\x20than\x20caller\x20identity','risk_rules':[],'recommendation':'default'}];export function getGuardDesignPattern(a){return GUARD_DESIGN_PATTERNS['find'](b=>b['id']===a);}export function searchGuardDesignPatterns(a){const b=a['toLowerCase']();return GUARD_DESIGN_PATTERNS['filter'](c=>{if(c['business_requirement']['toLowerCase']()['includes'](b))return!![];if(c['logic_summary']['toLowerCase']()['includes'](b))return!![];if(c['key_queries']['some'](d=>d['toLowerCase']()['includes'](b)))return!![];return![];});}export function getPatternsByHost(a){return GUARD_DESIGN_PATTERNS['filter'](b=>b['host']===a);}export function getPatternsByIndustry(a){return GUARD_DESIGN_PATTERNS['filter'](b=>b['applicable_industries']?.['includes'](a));}export function getPatternsByDataSourceClass(a){return GUARD_DESIGN_PATTERNS['filter'](b=>b['data_source']===a);}export function getVerifierLevelGuidance(a){return VERIFIER_LEVEL_GUIDANCE['find'](b=>b['level']===a);}export function suggestPatternForRequirement(a){const b=searchGuardDesignPatterns(a);if(b['length']===0x0){const e=GUARD_DESIGN_PATTERNS[0x0];return{'best':e,'alternatives':[]};}const [c,...d]=b;return{'best':c,'alternatives':d};}export const GUARD_DESIGN_PATTERNS_VERSION=0x2;
|