@wowok/agent-mcp 3.3.0 → 3.3.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/chain-semantics/field-capability.js +1 -1
- package/dist/chain-semantics/freeze-map.js +1 -1
- package/dist/chain-semantics/fund-flow.js +1 -1
- package/dist/chain-semantics/guard-verbs.js +1 -1
- package/dist/chain-semantics/object-graph.js +1 -1
- package/dist/composition/audit.d.ts +5 -0
- package/dist/composition/audit.js +1 -1
- package/dist/composition/blueprint-view.d.ts +0 -1
- package/dist/composition/blueprint-view.js +1 -1
- package/dist/composition/compile.d.ts +4 -2
- package/dist/composition/compile.js +1 -1
- package/dist/composition/inflight.d.ts +8 -4
- package/dist/composition/inflight.js +1 -1
- package/dist/customer/industry-risks.js +1 -1
- package/dist/customer/user-preferences.js +1 -1
- package/dist/extensions/business-modules.d.ts +7 -2
- package/dist/extensions/business-modules.js +1 -1
- package/dist/extensions/industry-audit.spec.js +1 -1
- package/dist/extensions/industry-pack.d.ts +3 -2
- package/dist/extensions/industry-pack.js +1 -1
- package/dist/extensions/modes.js +1 -1
- package/dist/graph/onchain/project-relationship.js +1 -1
- package/dist/knowledge/acquisition-flywheel.js +1 -1
- package/dist/knowledge/allocation-ledger.d.ts +4 -1
- package/dist/knowledge/allocation-ledger.js +1 -1
- package/dist/knowledge/allocation-puzzle.d.ts +1 -0
- package/dist/knowledge/allocation-puzzle.js +1 -1
- package/dist/knowledge/allocation-risk.d.ts +1 -1
- package/dist/knowledge/allocation-risk.js +1 -1
- package/dist/knowledge/arb-fund-facts.d.ts +5 -0
- package/dist/knowledge/arb-fund-facts.js +1 -1
- package/dist/knowledge/audit-rules.d.ts +4 -3
- package/dist/knowledge/audit-rules.js +1 -1
- package/dist/knowledge/baselines/rules/plan.json +48 -2
- package/dist/knowledge/baselines/rules/reward.json +1 -1
- package/dist/knowledge/builtin-templates.d.ts +9 -1
- package/dist/knowledge/builtin-templates.js +1 -1
- package/dist/knowledge/discount-threshold.js +1 -1
- package/dist/knowledge/guard-bindings.js +1 -1
- package/dist/knowledge/guard-design-patterns.js +1 -1
- package/dist/knowledge/guard-field-cognition.js +1 -1
- package/dist/knowledge/guard-lint.js +1 -1
- package/dist/knowledge/guard-submission-brief.d.ts +5 -0
- package/dist/knowledge/guard-submission-brief.js +1 -1
- package/dist/knowledge/guard-submission-prompt.d.ts +2 -1
- package/dist/knowledge/guard-submission-prompt.js +1 -1
- package/dist/knowledge/guard-templates.d.ts +1 -1
- package/dist/knowledge/guard-templates.js +1 -1
- package/dist/knowledge/industry-generalizer.js +1 -1
- package/dist/knowledge/industry-registry.js +1 -1
- package/dist/knowledge/industry-strategy.js +1 -1
- package/dist/knowledge/reward-ledger.js +1 -1
- package/dist/knowledge/reward-puzzle.d.ts +1 -1
- package/dist/knowledge/reward-risk.d.ts +1 -1
- package/dist/knowledge/scenario-modes.d.ts +2 -2
- package/dist/knowledge/scenario-modes.js +1 -1
- package/dist/knowledge/scenario-topology.js +1 -1
- package/dist/knowledge/strategy-manuals.js +1 -1
- package/dist/knowledge/template-index.d.ts +19 -0
- package/dist/knowledge/template-index.js +1 -0
- package/dist/knowledge/template-loader.d.ts +36 -0
- package/dist/knowledge/template-loader.js +1 -1
- package/dist/knowledge/template-registry.js +1 -1
- package/dist/knowledge/template-scanner.d.ts +7 -0
- package/dist/knowledge/template-scanner.js +1 -1
- package/dist/knowledge/tool-constraints.js +1 -1
- package/dist/knowledge/workflow-guidance.js +1 -1
- package/dist/monitor/MonitorLoop.js +1 -1
- package/dist/participation/radar-core.d.ts +1 -0
- package/dist/participation/radar-core.js +1 -1
- package/dist/persona/defaults.js +1 -1
- package/dist/persona/topology-focus.js +1 -1
- package/dist/playbooks/service-build/business-puzzle.js +1 -1
- package/dist/playbooks/service-build/game-theory.d.ts +4 -1
- package/dist/playbooks/service-build/game-theory.js +1 -1
- package/dist/playbooks/service-build/machine-panorama.js +1 -1
- package/dist/playbooks/service-build/merchant-guide.d.ts +25 -1
- package/dist/playbooks/service-build/merchant-guide.js +1 -1
- package/dist/playbooks/service-build/migration-planner.js +1 -1
- package/dist/playbooks/service-build/object-panorama.js +1 -1
- package/dist/playbooks/service-build/participation-radar.js +1 -1
- package/dist/playbooks/service-build/pipeline-actions.d.ts +4 -1
- package/dist/playbooks/service-build/pipeline-actions.js +1 -1
- package/dist/playbooks/service-build/relationship-profile.js +1 -1
- package/dist/playbooks/service-build/service-panorama.d.ts +4 -0
- package/dist/playbooks/service-build/service-panorama.js +1 -1
- package/dist/playbooks/service-build/service-quote.js +1 -1
- package/dist/relationship/derivation.d.ts +1 -1
- package/dist/review/index.js +1 -1
- package/dist/rules.js +1 -1
- package/dist/safety/confirm-gate.js +1 -1
- package/dist/schema/benchmark-migration/index.d.ts +35 -0
- package/dist/schema/benchmark-migration/index.js +1 -1
- package/dist/schema/call/allocation.d.ts +46 -3
- package/dist/schema/call/allocation.js +1 -1
- package/dist/schema/call/contact.js +1 -1
- package/dist/schema/call/guard.js +1 -1
- package/dist/schema/call/handler.js +1 -1
- package/dist/schema/call/order.js +1 -1
- package/dist/schema/call/progress.d.ts +6 -3
- package/dist/schema/call/progress.js +1 -1
- package/dist/schema/call/repository.js +1 -1
- package/dist/schema/call/reward.d.ts +2 -2
- package/dist/schema/call/reward.js +1 -1
- package/dist/schema/call/semantic.js +1 -1
- package/dist/schema/call/service.d.ts +8 -4
- package/dist/schema/call/service.js +1 -1
- package/dist/schema/common/index.js +1 -1
- package/dist/schema/goal/index.d.ts +54 -0
- package/dist/schema/goal/planning.d.ts +86 -0
- package/dist/schema/goal/planning.js +1 -1
- package/dist/schema/local/index.d.ts +39 -0
- package/dist/schema/local/index.js +1 -1
- package/dist/schema/operations.d.ts +20 -5
- package/dist/schema/operations.js +1 -1
- package/dist/schema/query/bi.d.ts +2 -0
- package/dist/schema/query/bi.js +1 -1
- package/dist/schema/query/index.d.ts +24 -12
- package/dist/schema/query/index.js +1 -1
- package/dist/schema/schema-version.d.ts +1 -1
- package/dist/schema/schema-version.js +1 -1
- package/dist/schema/workspace/index.d.ts +9 -0
- package/dist/schema/workspace/index.js +1 -1
- package/dist/schema-query-impl/index.js +1 -1
- package/dist/schemas/account_operation.output.json +28 -3
- package/dist/schemas/benchmark_migration_operation.schema.json +87 -0
- package/dist/schemas/goal_operation.schema.json +94 -0
- package/dist/schemas/index.json +1 -1
- package/dist/schemas/onchain_operations.output.json +1 -1
- package/dist/schemas/onchain_operations.schema.json +409 -119
- package/dist/schemas/onchain_operations_allocation.schema.json +290 -6
- package/dist/schemas/onchain_operations_arbitration.schema.json +2 -2
- package/dist/schemas/onchain_operations_contact.schema.json +2 -2
- 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_guard.schema.json +63 -63
- package/dist/schemas/onchain_operations_machine.schema.json +1 -1
- package/dist/schemas/onchain_operations_order.schema.json +2 -2
- package/dist/schemas/onchain_operations_progress.schema.json +7 -3
- package/dist/schemas/onchain_operations_proof.schema.json +1 -1
- package/dist/schemas/onchain_operations_repository.schema.json +2 -2
- package/dist/schemas/onchain_operations_reward.schema.json +8 -8
- package/dist/schemas/onchain_operations_service.schema.json +20 -18
- package/dist/schemas/onchain_operations_treasury.schema.json +7 -7
- package/dist/schemas/query_toolkit.output.json +67 -53
- package/dist/schemas/workflow_operation.schema.json +1 -1
- package/dist/schemas/workspace_operation.output.json +23 -3
- package/dist/schemas/workspace_operation.schema.json +3 -3
- package/dist/tools/handlers/benchmark-migration.js +1 -1
- package/dist/tools/handlers/config.js +1 -1
- package/dist/tools/handlers/file-export.js +1 -1
- package/dist/tools/handlers/industry-pack.d.ts +1 -0
- package/dist/tools/handlers/industry-pack.js +1 -1
- package/dist/tools/handlers/local.js +1 -1
- package/dist/tools/handlers/onchain.d.ts +24 -0
- package/dist/tools/handlers/onchain.js +1 -1
- package/dist/tools/handlers/query.js +1 -1
- package/dist/tools/handlers/review-chain.d.ts +1 -1
- package/dist/tools/handlers/review-chain.js +1 -1
- package/dist/tools/handlers/schema-query.js +1 -1
- package/dist/tools/handlers/workflow.js +1 -1
- package/dist/tools/handlers/workspace.js +1 -1
- package/dist/tools/registry/agent.js +1 -1
- package/dist/tools/registry/local.js +1 -1
- package/dist/tools/wip-deploy-assist.js +1 -1
- package/dist/tools/wrap.js +1 -1
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
import{ENTRYPOINT}from'@wowok/wowok';import{buildViewport,runNodeAnalyzers}from'../graph/onchain/index.js';import{makeProposalNode}from'../graph/onchain/proposal-graph.js';import{machineRuleNodeAnalyzer,allocationRuleNodeAnalyzer}from'./rule-node-analyzers.js';import{GUARD_TEMPLATES}from'./guard-templates.js';import{GUARD_DESIGN_PATTERNS}from'./guard-design-patterns.js';import{unannotatedBuyerActionNodes}from'./scenario-modes.js';import{findLoopCycles}from'./machine-topology.js';import{DIRECT_SALES_INVARIANT,ENTITY_RECIPIENT_RULE_ID}from'./entity-recipient-guard.js';import{DISPUTE_FAMILY_NODE_REGEX,FUND_TERMINAL_NODE_REGEX,classifyLoopCycle}from'./audit-rules.js';import{platformShareBps,validateAllocatorRows}from'./template-loader.js';const PLATFORM_TAKE_KEY=/^(?:platform_(?:share|commission|take)_bps|platform_fee_rate_bps|commission_rate_bps|(?:base_)?commission_rate_bps|offsite_ads_rate_bps|service_fee_rate_bps|payment_fee_bps)$/,MERCHANT_OWN_PRICE_KEY=/^(?:merchant_service_fee_bps|contract_fee_(?:small|large)_usd|contract_fee_tier_boundary_usd|digital_product_fee_(?:bps|min_usd|max_usd)|arbitration_fee.*|escrow_.*|min_.*|max_.*)$/,MERCHANT_SHARE_KEY=/^(?:host|property|partner|institution|landlord|freelancer|creator|seller|instructor)_rate_bps$/;function directSalesEconomyChecks(a){const b=[],c=a['fee_params'],d=Object['keys'](c)['filter'](y=>PLATFORM_TAKE_KEY['test'](y)&&typeof c[y]==='number'&&c[y]!==0x0);d['length']>0x0&&b['push']({'rule_id':'R-ECON-01','severity':'critical','title':'Template\x20mandates\x20a\x20platform\x20commission\x20('+d['map'](y=>y+'='+c[y])['join'](',\x20')+')','detail':'WoWok\x20is\x20DIRECT\x20SALES:\x20the\x20protocol\x20never\x20extracts\x20and\x20a\x20merchant\x20pays\x20only\x20gas,\x20so\x20the\x20merchant-side\x20share\x20must\x20default\x20to\x20the\x20whole\x20sale.\x20A\x20non-zero\x20platform\x20take\x20is\x20(a)\x20an\x20extraction\x20the\x20platform\x20has\x20no\x20right\x20to,\x20and\x20(b)\x20an\x20UNALLOCATED\x20liability\x20—\x20no\x20template\x20declares\x20a\x20platform\x20address,\x20so\x20at\x20build\x20time\x20it\x20resolves\x20to\x20the\x20deploying\x20merchant\x20itself\x20(blank\x20→\x20Account.Instance(),\x20ts-sdk/packages/wowok/src/w/local/index.ts:89-91),\x20to\x20the\x20keeper\x20(Recipient::Signer\x20→\x20tx_context::sender,\x20allocation.move:531-533),\x20or\x20back\x20to\x20the\x20buyer\x20(Recipient::GuardIdentifier,\x20allocation.move:501-527).\x20None\x20of\x20those\x20is\x20revenue.','suggestion':'Set\x20'+d['join'](',\x20')+'\x20to\x200\x20and\x20give\x20the\x20merchant\x20the\x20whole\x20sale\x20(single\x20Rate\x2010000\x20leg).\x20If\x20the\x20merchant\x20IS\x20the\x20aggregator\x20and\x20genuinely\x20charges\x20a\x20fee,\x20declare\x20it\x20via\x20merchant_service_fee_bps\x20with\x20an\x20EXPLICIT\x20non-empty\x20recipient\x20Entity.'});const e=a['allocator']['description'],f=/(?:commission|take|platform|remainder|share)\s*(?:=|:)\s*order\s*total\s*-\s*(?:segment|sum)/i['test'](e),g=(a['allocator']['rows']??[])['some'](y=>y['mode']==='surplus')||a['allocator']['mode']==='surplus',h=g&&/(?:platform|commission|fee|take)[^.;]{0,120}\bsurplus\b|\bsurplus\b[^.;]{0,120}(?:platform|commission|fee|take)/i['test'](e);f&&b['push']({'rule_id':'R-ECON-02','severity':'critical','title':'Take\x20is\x20an\x20implicit\x20remainder\x20(not\x20computable\x20before\x20ordering)','detail':'The\x20allocator\x20describes\x20the\x20platform\x20share\x20as\x20\x22order\x20total\x20-\x20segment\x20sums\x22,\x20so\x20the\x20amount\x20taken\x20depends\x20on\x20the\x20segment\x20configuration\x20rather\x20than\x20a\x20declared\x20rate.\x20A\x20buyer\x20(or\x20their\x20AI)\x20cannot\x20compute\x20the\x20take\x20BEFORE\x20ordering,\x20which\x20defeats\x20pre-order\x20evaluation\x20—\x20and\x20an\x20unbounded\x20remainder\x20off\x20a\x20transit\x20pool\x20is\x20unbounded\x20extraction.','suggestion':'Pin\x20every\x20share\x20to\x20an\x20EXPLICIT\x20Rate\x20(or\x20an\x20Amount\x20derived\x20from\x20a\x20declared\x20rate).\x20A\x20supplier\x20fee\x20belongs\x20in\x20its\x20own\x20explicitly-priced\x20segment\x20order,\x20never\x20as\x20a\x20residual\x20share.'});h&&b['push']({'rule_id':'R-ECON-02','severity':'high','title':'Fee\x20appears\x20to\x20be\x20taken\x20by\x20a\x20Surplus\x20leg','detail':'A\x20Surplus\x20sharing\x20entry\x20allocates\x20the\x20WHOLE\x20remaining\x20balance\x20(allocation.move:427\x20withdraw_all\x20semantics),\x20so\x20it\x20cannot\x20express\x20\x22take\x2015%\x22:\x20it\x20doubles\x20as\x20draining\x20the\x20pool.','suggestion':'Use\x20Rate\x20(or\x20RateGross)\x20for\x20any\x20proportional\x20share.\x20Reserve\x20Surplus\x20for\x20an\x20explicitly-bounded\x20residual\x20whose\x20recipient\x20and\x20cap\x20are\x20stated.'});const j=/\{\s*(?:who|Entity|Signer|GuardIdentifier)\s*:/['test'](e)||/recipient\s*[:=]/i['test'](e),k=/^(?:merchant_service_fee_bps|digital_product_fee_bps|logistics_rate_bps|service_fee_rate_bps)$/,l=Object['keys'](c)['some'](y=>k['test'](y)&&typeof c[y]==='number'&&c[y]!==0x0);if(l&&!j&&d['length']===0x0){const y=collectFeeParamLandings(a),z=Object['keys'](c)['filter'](C=>k['test'](C)&&typeof c[C]==='number'&&c[C]!==0x0),A=z['some'](C=>(y['get'](C)??[])['some'](D=>D['surface']==='guard'||D['surface']==='allocator_row'&&D['recipient_blank']!==!![])),B=!A&&z['some'](C=>(y['get'](C)??[])['some'](D=>D['surface']==='directive'));!A?b['push']({'rule_id':'R-ECON-03','severity':'high','title':B?'Fee-bearing\x20template\x20is\x20a\x20DIRECTIVE\x20only\x20—\x20the\x20share\x20has\x20no\x20on-chain\x20carrier':'Fee-bearing\x20template\x20names\x20no\x20recipient\x20slot\x20for\x20the\x20non-merchant\x20share','detail':B?'fee_params\x20carry\x20fee-shaped\x20keys\x20('+z['join'](',\x20')+')\x20whose\x20only\x20landing\x20is\x20directive\x20prose\x20—\x20no\x20allocator\x20row\x20or\x20guard\x20consumes\x20them.\x20On-chain\x20NOTHING\x20carries\x20the\x20fee:\x20whoever\x20materializes\x20the\x20template\x20computes\x20the\x20cut\x20themselves\x20(and\x20the\x20promised\x20clamps\x20live\x20only\x20in\x20text),\x20so\x20two\x20builders\x20can\x20take\x20different\x20shares\x20with\x20nothing\x20to\x20verify\x20against.':'fee_params\x20carry\x20fee-shaped\x20keys\x20but\x20the\x20allocator\x20names\x20no\x20recipient\x20for\x20them.\x20On-chain\x20each\x20Rate\x20lands\x20in\x20ITS\x20OWN\x20recipient\x20slot;\x20an\x20unnamed\x20one\x20resolves\x20to\x20the\x20deploying\x20account\x20(ts-sdk/packages/wowok/src/w/local/index.ts:89-91),\x20to\x20the\x20keeper\x20(allocation.move:531-533),\x20or\x20back\x20to\x20the\x20buyer.\x20The\x20share\x20is\x20then\x20an\x20unallocated\x20liability\x20rather\x20than\x20revenue.','suggestion':'State\x20the\x20recipient\x20per\x20share\x20in\x20the\x20allocator\x20description\x20and\x20bind\x20it\x20to\x20an\x20explicit\x20NON-EMPTY\x20Entity\x20the\x20buyer\x20can\x20see\x20before\x20ordering.\x20Never\x20leave\x20it\x20blank.'}):b['push']({'rule_id':'R-ECON-03','severity':'low','title':'Fee\x20share\x20has\x20a\x20declared\x20landing\x20—\x20keep\x20its\x20recipient\x20explicit\x20and\x20visible\x20pre-order','detail':'The\x20fee-shaped\x20keys\x20('+z['join'](',\x20')+')\x20land\x20in\x20allocator\x20rows/guards;\x20the\x20allocator\x20prose\x20names\x20no\x20recipient\x20slot,\x20so\x20the\x20binding\x20relies\x20on\x20the\x20row\x20declarations.\x20Keep\x20every\x20recipient\x20an\x20explicit\x20NON-EMPTY\x20Entity\x20the\x20buyer\x20can\x20see\x20before\x20ordering.','suggestion':'Re-check\x20at\x20template_scan\x20after\x20edits\x20that\x20the\x20fee\x20keys\x20still\x20land\x20in\x20rows\x20whose\x20recipient\x20is\x20explicit.'});}const m=/(?:layer-?1|service-?level|pool)[^.]*settles? the full amount|full amount to the (?:platform|organizer) pool/i['test'](e);m&&b['push']({'rule_id':'R-ECON-04','severity':'medium','title':'Escrow\x20transits\x20an\x20organizer\x20pool\x20before\x20reaching\x20the\x20merchant','detail':'The\x20full\x20order\x20amount\x20settles\x20into\x20a\x20platform/organizer\x20pool\x20first\x20and\x20is\x20then\x20redistributed.\x20That\x20contradicts\x20the\x20direct-sales\x20promise\x20(\x22money\x20moves\x20only\x20between\x20the\x20two\x20parties\x22)\x20and\x20makes\x20the\x20organizer\x20a\x20waypoint\x20on\x20every\x20payout,\x20including\x20every\x20refund.','suggestion':'Release\x20supplier\x20segments\x20directly\x20from\x20the\x20order\x27s\x20own\x20Allocation,\x20and\x20make\x20the\x20organizer\x20a\x20named\x20party\x20rather\x20than\x20a\x20transit\x20node.'});const n=Object['keys'](c)['find'](C=>/^attributed_.*_bps$/['test'](C)&&typeof c[C]==='number'),o=Object['keys'](c)['find'](C=>/^(?:base_)?commission_rate_bps$/['test'](C)&&typeof c[C]==='number');n&&o&&c[n]>c[o]&&b['push']({'rule_id':'R-ECON-05','severity':'medium','title':'Attribution-priced\x20take:\x20a\x20cheaper\x20acquisition\x20channel\x20is\x20charged\x20MORE','detail':n+'='+c[n]+'\x20exceeds\x20'+o+'='+c[o]+'.\x20Charging\x20more\x20for\x20attributed\x20orders\x20means\x20the\x20merchant\x27s\x20cheap\x20channels\x20(KOC,\x20social,\x20repeat\x20buyers)\x20are\x20penalised\x20—\x20the\x20opposite\x20of\x20what\x20direct\x20sales\x20should\x20reward.','suggestion':'Price\x20every\x20channel\x20identically.\x20Attribution\x20may\x20change\x20RANKING,\x20never\x20the\x20take.'});if(a['allocator']['mode']==='rate'){const C=Object['keys'](c)['filter'](F=>MERCHANT_SHARE_KEY['test'](F)&&typeof c[F]==='number'),D=Object['keys'](c)['filter'](F=>PLATFORM_TAKE_KEY['test'](F)&&typeof c[F]==='number'),E=[...C,...D];if(C['length']>0x0&&D['length']>0x0){const F=E['map'](I=>c[I])['filter'](I=>typeof I==='number'),G=F['reduce']((I,J)=>I+J,0x0),H=/surplus/i['test'](e);G!==0x2710&&!H&&b['push']({'rule_id':'R-ECON-06','severity':'critical','title':'Rate\x20shares\x20sum\x20to\x20'+G+',\x20not\x2010000','detail':'Declared\x20rate\x20shares\x20('+E['map']((I,J)=>I+'='+F[J])['join']('\x20+\x20')+')\x20total\x20'+G+'.\x20With\x20no\x20Surplus\x20recipient\x20the\x20remainder\x20is\x20not\x20protected:\x20the\x20chain\x20records\x20no\x20\x22already\x20triggered\x22\x20flag,\x20so\x20a\x20balance\x20left\x20behind\x20after\x20a\x20partial\x20split\x20can\x20be\x20claimed\x20REPEATEDLY\x20by\x20anyone\x20passing\x20the\x20same\x20Guard.\x20This\x20is\x20exactly\x20what\x20happens\x20when\x20a\x20platform\x20leg\x20is\x20zeroed\x20without\x20recomputing\x20the\x20merchant\x20leg.','suggestion':'Make\x20the\x20shares\x20sum\x20to\x20exactly\x2010000,\x20or\x20declare\x20an\x20explicit\x20Surplus\x20recipient\x20for\x20the\x20residual.'});}}const p=(a['allocator']['rows']??[])['map']((I,J)=>({'r':I,'i':J})),q=p['filter'](({r:I})=>I['recipient']==='entity'&&!(I['recipient_key']??'')['trim']());q['length']>0x0&&b['push']({'rule_id':ENTITY_RECIPIENT_RULE_ID,'severity':'critical','title':'Allocator\x20row(s)\x20'+q['map'](({i:I})=>'#'+I)['join'](',\x20')+'\x20name\x20no\x20Entity\x20recipient\x20—\x20the\x20share\x20silently\x20pays\x20the\x20deploying\x20merchant','detail':q['map'](({i:I})=>'rows['+I+']')['join'](',\x20')+'\x20declare\x20recipient=\x27entity\x27\x20with\x20no\x20recipient_key,\x20which\x20builds\x20as\x20'+'{\x20who:\x20{\x20Entity:\x20{\x20name_or_address:\x20\x22\x22\x20}\x20}\x20}.\x20That\x20is\x20NOT\x20a\x20no-op:\x20the\x20SDK\x20resolver\x20substitutes\x20the\x20DEFAULT\x20LOCAL\x20ACCOUNT\x20before\x20the\x20'+'address\x20reaches\x20Move,\x20so\x20the\x20order\x20escrow\x20pays\x20whoever\x20ran\x20the\x20deploy\x20—\x20the\x20\x27platform\x27\x20share\x20the\x20template\x20left\x20unnamed\x20becomes\x20the\x20merchant\x27s\x20'+('own\x20take.\x20'+DIRECT_SALES_INVARIANT),'suggestion':'Give\x20the\x20row\x20an\x20explicit\x20`recipient_key`\x20naming\x20the\x20party\x20(a\x20mark\x20name\x20or\x20a\x200x\x20address\x20the\x20buyer\x20can\x20see\x20BEFORE\x20ordering).\x20If\x20the\x20whole\x20sale\x20goes\x20'+'to\x20the\x20merchant,\x20do\x20not\x20declare\x20an\x20entity\x20row\x20at\x20all:\x20use\x20ONE\x20{\x20who:\x20{\x20GuardIdentifier:\x200\x20},\x20sharing:\x2010000,\x20mode:\x20\x22Rate\x22\x20}\x20leg.\x20The\x20scalar\x20'+'`allocator.recipient:\x20\x22entity\x22`\x20form\x20is\x20auditable\x20too:\x20it\x20must\x20carry\x20a\x20`recipient_key`\x20(or\x20a\x20`rows[]`\x20array)\x20when\x20no\x20rows\x20narrow\x20it.'});!a['allocator']['rows']&&a['allocator']['recipient']==='entity'&&!(a['allocator']['recipient_key']??'')['trim']()&&b['push']({'rule_id':ENTITY_RECIPIENT_RULE_ID,'severity':'critical','title':'Allocator\x20names\x20no\x20Entity\x20recipient\x20(scalar\x20form,\x20no\x20rows)\x20—\x20the\x20share\x20silently\x20pays\x20the\x20deploying\x20merchant','detail':'The\x20allocator\x20declares\x20scalar\x20recipient=\x27entity\x27\x20with\x20no\x20recipient_key\x20and\x20no\x20rows[],\x20which\x20builds\x20as\x20'+'{\x20who:\x20{\x20Entity:\x20{\x20name_or_address:\x20\x22\x22\x20}\x20}\x20}.\x20That\x20is\x20NOT\x20a\x20no-op:\x20the\x20SDK\x20resolver\x20substitutes\x20the\x20DEFAULT\x20LOCAL\x20ACCOUNT\x20before\x20the\x20'+'address\x20reaches\x20Move,\x20so\x20the\x20order\x20escrow\x20pays\x20whoever\x20ran\x20the\x20deploy\x20—\x20the\x20share\x20the\x20template\x20left\x20unnamed\x20becomes\x20the\x20merchant\x27s\x20'+('own\x20take.\x20'+DIRECT_SALES_INVARIANT),'suggestion':'Declare\x20the\x20destination\x20machine-checkably:\x20set\x20`recipient_key`\x20on\x20the\x20allocator\x20(a\x20mark\x20name\x20or\x20a\x200x\x20address\x20the\x20buyer\x20can\x20see\x20BEFORE\x20ordering),\x20'+'or\x20add\x20a\x20`rows[]`\x20array\x20carrying\x20the\x20on-chain\x20`who`\x20shape.\x20If\x20the\x20whole\x20sale\x20goes\x20to\x20the\x20merchant,\x20use\x20ONE\x20'+'{\x20recipient:\x20\x27guard_identifier\x27,\x20recipient_key:\x20\x270\x27\x20}\x20row\x20instead\x20of\x20an\x20entity\x20scalar.'});const s=p['filter'](({r:I})=>I['recipient']==='entity'&&/^0x0*$/i['test']((I['recipient_key']??'')['trim']()));s['length']>0x0&&b['push']({'rule_id':ENTITY_RECIPIENT_RULE_ID,'severity':'high','title':'Allocator\x20row(s)\x20'+s['map'](({i:I})=>'#'+I)['join'](',\x20')+'\x20name\x20the\x20zero\x20address\x20as\x20Entity\x20recipient','detail':s['map'](({i:I})=>'rows['+I+']')['join'](',\x20')+'\x20carry\x20recipient_key=\x270x0\x27\x20(or\x20an\x20all-zero\x20literal).\x20The\x20chain\x20does\x20NOT\x20reject\x20it:\x20'+'allocation.move:250-255\x20swallows\x20Recipient::Entity\x20in\x20a\x20(_)\x20catch-all\x20at\x20declaration\x20time,\x20and\x20allocation.move:451-453\x20/\x20:514\x20forward\x20the\x20raw\x20'+'address\x20straight\x20to\x20the\x20payout\x20constructor.\x20The\x20allocation\x20is\x20accepted\x20and\x20the\x20share\x20is\x20silently\x20transferred\x20to\x200x0\x20and\x20permanently\x20burned\x20—\x20'+'this\x20scan\x20is\x20the\x20only\x20defence.','suggestion':'Replace\x20the\x20zero\x20literal\x20with\x20the\x20real\x20recipient\x20address\x20(a\x20mark\x20name\x20or\x20a\x200x\x20address),\x20or\x20drop\x20the\x20row\x20if\x20the\x20share\x20is\x20not\x20owed.'});const u=I=>I['recipient']+':'+(I['recipient_key']??'')['trim']()['toLowerCase'](),v=/^(recover_gate|awarded_recover|terminal_settlement_recover)$/,w=new Set((a['allocator']['rows']??[])['filter'](I=>I['mode']==='rate'&&!v['test'](I['guard_key']??''))['map'](u)),x=p['filter'](({r:I})=>I['mode']==='surplus'&&w['has'](u(I)));return x['length']>0x0&&b['push']({'rule_id':'R-RECIPIENT-04','severity':'critical','title':'Surplus\x20row(s)\x20'+x['map'](({i:I})=>'#'+I)['join'](',\x20')+'\x20pay\x20a\x20recipient\x20a\x20Rate\x20leg\x20already\x20pays\x20—\x20the\x20remainder\x20swallows\x20an\x20undeclared\x20share','detail':x['map'](({i:I})=>'rows['+I+']')['join'](',\x20')+'\x20duplicate\x20a\x20Rate\x20leg\x27s\x20recipient.\x20The\x20chain\x20pays\x20every\x20Rate\x20leg\x20its\x20declared\x20basis\x20points\x20'+'and\x20then\x20pays\x20the\x20ENTIRE\x20remainder\x20to\x20the\x20Surplus\x20recipient,\x20so\x20this\x20party\x20quietly\x20receives\x20rate%\x20+\x20100%\x20of\x20the\x20residual\x20and\x20any\x20leg\x20the\x20'+'author\x20intended\x20but\x20omitted\x20(commission,\x20payment\x20fee,\x20platform\x20take)\x20is\x20never\x20created.\x20The\x20Rate-sum\x20rule\x20passes\x20because\x20the\x20sum\x20is\x20legal\x20—\x20'+'the\x20misroute\x20is\x20invisible\x20there,\x20and\x20order_allocators\x20freezes\x20permanently\x20at\x20publish.\x20Mainnet\x20precedent\x20(Booking\x20replica,\x202026-10-06):\x20the\x20'+'property\x20took\x20100%\x20(Rate\x208350\x20+\x20Surplus),\x20the\x2015%\x20commission\x20and\x201.5%\x20payment-fee\x20legs\x20never\x20existed,\x20and\x20the\x20published\x20Service\x20had\x20to\x20be\x20abandoned.','suggestion':'Point\x20the\x20Surplus\x20row\x20at\x20the\x20party\x20meant\x20to\x20absorb\x20the\x20remainder\x20(usually\x20the\x20merchant),\x20distinct\x20from\x20every\x20Rate\x20leg\x20—\x20or,\x20if\x20the\x20duplicated\x20'+'recipient\x20is\x20truly\x20intended\x20to\x20take\x20rate%\x20+\x20remainder,\x20collapse\x20the\x20two\x20rows\x20into\x20ONE\x20rate\x20row\x20so\x20the\x20declared\x20split\x20equals\x20the\x20actual\x20split.\x20'+'Every\x20intended\x20payee\x20must\x20be\x20its\x20own\x20explicit\x20row.'}),b;}const KNOWN_GUARD_REF_IDS=new Set([...GUARD_DESIGN_PATTERNS['map'](a=>a['id']),...GUARD_TEMPLATES['map'](a=>a['id'])]);function guardRefChecks(a){const b=[];for(const c of a['guards']){if(!/^(pattern\.[a-z0-9_]+|tpl_[a-z0-9_]+)$/['test'](c['template_id'])){b['push']({'rule_id':'R-REF-01','severity':'high','title':'Guard\x20reference\x20\x27'+c['template_id']+'\x27\x20is\x20not\x20a\x20resolvable\x20id','detail':'Guard\x20references\x20must\x20name\x20a\x20guard\x20design\x20pattern\x20(\x27pattern.*\x27,\x20'+GUARD_DESIGN_PATTERNS['length']+'\x20available)\x20or\x20a\x20guard\x20template\x20(\x27tpl_*\x27,\x20'+GUARD_TEMPLATES['length']+'\x20available).\x20Bare\x20prose\x20ids\x20dangle:\x20no\x20builder\x20can\x20resolve\x20them,\x20so\x20the\x20AI\x20invents\x20guard\x20logic\x20at\x20build\x20time.','suggestion':'Replace\x20with\x20the\x20semantically\x20nearest\x20pattern.*/tpl_*\x20id\x20(compose\x20multi-condition\x20logic\x20in\x20the\x20purpose\x20text).'});continue;}!KNOWN_GUARD_REF_IDS['has'](c['template_id'])&&b['push']({'rule_id':'R-REF-02','severity':'high','title':'Guard\x20reference\x20\x27'+c['template_id']+'\x27\x20does\x20not\x20exist\x20in\x20any\x20guard\x20catalog','detail':'The\x20id\x20is\x20namespaced\x20correctly\x20but\x20matches\x20no\x20guard\x20design\x20pattern\x20nor\x20guard\x20template\x20—\x20a\x20dangling\x20reference\x20the\x20AI\x20cannot\x20resolve.','suggestion':'Fix\x20the\x20id\x20(typo)\x20or\x20point\x20it\x20at\x20the\x20nearest\x20existing\x20pattern.*/tpl_*\x20entry.'});}return b;}function staticChecks(a){const b=[],c=j=>{const k=new RegExp('\x5cb'+j['replace'](/[.*+?^${}()|[\]\\]/g,'\x5c$&')+'\x5cb','i');for(const l of a['allocator']?.['rows']??[]){if(l['track']!=='refund'||!l['guard_key'])continue;const m=a['guards']['find'](n=>n['key']===l['guard_key']);if(m&&k['test']((m['key']??'')+'\x20'+m['purpose']))return!![];}return![];};for(const j of a['machine_shape']){const k=DISPUTE_FAMILY_NODE_REGEX['test'](j['name']),l=!k&&FUND_TERMINAL_NODE_REGEX['test'](j['name']);if(k||l&&!c(j['name']))b['push']({'rule_id':'R-M1-11','severity':'critical','title':'Machine\x20node\x20\x27'+j['name']+'\x27\x20models\x20dispute/refund\x20flow','detail':'Disputes\x20are\x20independent\x20of\x20the\x20Machine\x20workflow;\x20refunds\x20route\x20via\x20Allocators\x20triggered\x20by\x20business\x20states.','suggestion':'Remove\x20the\x20node;\x20route\x20refunds\x20via\x20Allocator\x20states\x20(closed_cancel/cancel_requested)\x20and\x20disputes\x20via\x20the\x20Arbitration\x20object.'});else l&&b['push']({'rule_id':'R-M1-11','severity':'low','title':'Machine\x20node\x20\x27'+j['name']+'\x27\x20reuses\x20a\x20fund-terminal\x20name\x20(guard-anchored,\x20exempt)','detail':'The\x20refund-track\x20allocator\x20consumes\x20a\x20guard\x20anchored\x20to\x20\x27'+j['name']+'\x27\x20—\x20the\x20guard\x20moves\x20the\x20funds,\x20so\x20the\x20node\x20is\x20a\x20routing\x20state,\x20not\x20a\x20money\x20move.','suggestion':'Prefer\x20a\x20routing-state\x20name\x20(closed_cancel/cancel_requested)\x20so\x20the\x20intent\x20is\x20self-evident\x20without\x20the\x20guard\x20chain.'});}const d=new Map();for(const m of a['guards']){if(/time_lock|order_holder|progress_state/['test'](m['template_id'])&&!/order\.service|project bind|service binding/i['test'](m['purpose'])){const n=d['get'](m['template_id'])??[];n['push'](m['key']??'(no\x20key)'),d['set'](m['template_id'],n);}}for(const [o,p]of d){b['push']({'rule_id':'R-C3-05','severity':'low','title':'Guard\x20\x27'+o+'\x27\x20consumes\x20a\x20submitted\x20Order\x20without\x20project\x20binding\x20('+p['length']+'x:\x20'+p['join'](',\x20')+')\x20—\x20advisory\x20(v148\x20backstop)','detail':'Passport\x20submissions\x20are\x20caller-built;\x20without\x20logic_equal[order.service,\x20<service>]\x20a\x20stale\x20order\x20from\x20another\x20project\x20could\x20satisfy\x20the\x20guard\x20for\x20a\x20fresh\x20order.\x20Since\x20protocol\x20v148\x20the\x20Progress\x20layer\x20itself\x20rejects\x20cross-order\x20submissions\x20(the\x20chain-side\x20task-binding\x20check),\x20so\x20this\x20is\x20now\x20defense-in-depth:\x20the\x20window\x20is\x20closed\x20at\x20the\x20chain,\x20the\x20template\x20binding\x20only\x20shortens\x20the\x20failure\x20distance.','suggestion':'Optionally\x20state\x20the\x20project\x20binding\x20in\x20the\x20guard\x20purpose\x20AND\x20include\x20it\x20in\x20the\x20guard\x20root\x20at\x20build\x20time\x20(fails\x20earlier,\x20closer\x20to\x20the\x20cause).\x20No\x20longer\x20a\x20publish\x20blocker.'});}a['machine_shape']['length']===0x0&&b['push']({'rule_id':'R-M1-01','severity':'critical','title':'machine_shape\x20is\x20empty','detail':'No\x20entry\x20node\x20—\x20the\x20Machine\x20cannot\x20start.','suggestion':'Add\x20at\x20least\x20one\x20entry\x20node\x20representing\x20the\x20escrowed\x20state.'});const e=a['guards']['some'](q=>/refund|cancel/i['test'](q['template_id'])||/refund|cancel/i['test'](q['purpose']))||/refund/i['test'](a['allocator']['description']);!e&&b['push']({'rule_id':'R1','severity':'high','title':'No\x20refund\x20path\x20detected','detail':'No\x20refund/cancel\x20guard\x20and\x20no\x20refund\x20route\x20in\x20the\x20allocator\x20description.','suggestion':'Add\x20a\x20refund/cancel\x20guard\x20or\x20an\x20allocator\x20refund\x20route\x20before\x20publishing.'});const f=a['guards']['some'](q=>q['host']==='arbitration')||a['trust_mechanisms']['some'](q=>q['startsWith']('R2'));!f&&b['push']({'rule_id':'R2','severity':'high','title':'No\x20independent\x20Arbitration\x20reference\x20detected','detail':'The\x20template\x20carries\x20no\x20arbitration-hosted\x20guard\x20and\x20no\x20R2\x20trust\x20mechanism.','suggestion':'Mount\x20an\x20independent\x20Arbitration\x20object\x20with\x20its\x20own\x20Permission.'});a['keeper_dependencies']['length']===0x0&&b['push']({'rule_id':'R9','severity':'medium','title':'No\x20keeper\x20dependencies\x20declared','detail':'Time-driven\x20transitions\x20only\x20ALLOW\x20advancement\x20—\x20someone\x20must\x20run\x20the\x20keepers.','suggestion':'Declare\x20the\x20keeper\x20operations\x20(timeouts,\x20window\x20expiries,\x20settlement\x20triggers).'});b['push'](...directSalesEconomyChecks(a));const h=unannotatedBuyerActionNodes(a['machine_shape']);return h['length']>0x0&&b['push']({'rule_id':'R-OPER-01','severity':'medium','title':'Buyer-side\x20node(s)\x20without\x20an\x20operator\x20annotation','detail':'Node(s)\x20'+h['map'](q=>'\x27'+q+'\x27')['join'](',\x20')+'\x20look\x20like\x20order-payer\x20actions\x20but\x20carry\x20no\x20operator\x20field.\x20At\x20build\x20time\x20they\x20default\x20to\x20a\x20merchant\x20permission\x20slot,\x20and\x20the\x20order\x20payer\x20cannot\x20advance\x20them\x20(E_PERMISSION_DENIED).','suggestion':'Annotate\x20true\x20buyer\x20actions\x20with\x20operator:\x20\x22order_payer\x22\x20(an\x20EMPTY\x20namedOperator\x20—\x20the\x20on-chain\x20check\x20resolves\x20it\x20to\x20the\x20order\x20payer);\x20rename\x20merchant-side\x20states\x20(e.g.\x20\x27cancelled\x27\x20->\x20\x27merchant_cancelled\x27)\x20when\x20the\x20actor\x20is\x20NOT\x20the\x20buyer.'}),b;}const PERIOD_COUNT_KEY_REGEX=/^(monthly_allocators|term_count|session_count|segment_count|periods|cycles|installments)$/;function poolPeriodCount(a){for(const [b,c]of Object['entries'](a['fee_params'])){if(PERIOD_COUNT_KEY_REGEX['test'](b)&&typeof c==='number'&&c>=0x2)return c;}return undefined;}function periodicReleaseChecks(a){const b=poolPeriodCount(a);if(b===undefined)return[];const c=[a['allocator']['description'],...a['build_notes'],...a['trust_mechanisms'],...a['guards']['map'](h=>h['purpose'])]['join']('\x20\x0a\x20'),d=[];/surplus/i['test'](c)&&!/no surplus|surplus[^.\n]*(disabled|forbidden|disallowed)|amount mode only|single surplus/i['test'](c)&&d['push']({'rule_id':'R-PER-01','severity':'high','title':'Multi-period\x20pool\x20('+b+'\x20periods)\x20declares\x20Surplus\x20without\x20a\x20terminal-only\x20qualifier','detail':'A\x20Surplus\x20allocator\x20entry\x20runs\x20balance::withdraw_all\x20(allocation.move:288-298).\x20In\x20a\x20pool\x20pre-funded\x20for\x20'+b+'\x20periods\x20it\x20drains\x20every\x20future\x20release,\x20not\x20just\x20the\x20remainder.','suggestion':'Release\x20each\x20period\x20with\x20Amount;\x20if\x20the\x20pool\x20remainder\x20settles\x20in\x20one\x20entry,\x20declare\x20it\x20explicitly\x20as\x20the\x20SINGLE\x20terminal\x20Surplus\x20at\x20the\x20settlement\x20node,\x20or\x20disable\x20Surplus\x20outright.'});const e=a['guards']['map'](h=>[h['key'],h['template_id'],h['purpose']]['filter'](Boolean)['join']('\x20'))['join']('\x20\x0a\x20'),f=c+'\x20\x0a\x20'+e,g=/per[- ](month|period|term|session|cycle|segment)|one per (rent )?period|release-sequence lock/i['test'](f)||/(?:month|period|term|week|session)_\d+_(?:release|unlock|guard)|release_\d+/i['test'](e);return!g&&d['push']({'rule_id':'R-PER-02','severity':'high','title':'Multi-period\x20pool\x20('+b+'\x20periods)\x20declares\x20no\x20per-period\x20release\x20Guard','detail':'alloc()\x20has\x20no\x20consumed/nonce\x20flag\x20(allocation.move:204-321):\x20two\x20releases\x20bound\x20to\x20the\x20SAME\x20Guard\x20can\x20both\x20fire\x20the\x20same\x20day\x20and\x20drain\x20the\x20pool.\x20The\x20cadence\x20gate\x20must\x20be\x20one\x20Guard\x20per\x20period.','suggestion':'Declare\x20one\x20release\x20Guard\x20per\x20period\x20(per-month/per-term\x20time-lock\x20Guards,\x20each\x20keyed\x20to\x20its\x20own\x20period\x20window)\x20in\x20the\x20guard\x20set.'}),!/threshold[^.\n]*(one|single|per[- ]|month|period|term|session|=\s*0\b|\b0\b|must be 0)/i['test'](c)&&d['push']({'rule_id':'R-PER-03','severity':'medium','title':'Multi-period\x20pool\x20('+b+'\x20periods)\x20does\x20not\x20pin\x20threshold\x20to\x20one\x20period','detail':'alloc()\x20asserts\x20balance\x20>=\x20threshold\x20before\x20EVERY\x20release\x20(allocation.move:206).\x20A\x20threshold\x20sized\x20to\x20the\x20total\x20pool\x20passes\x20the\x20first\x20release\x20and\x20then\x20locks\x20all\x20remaining\x20periods.','suggestion':'State\x20in\x20the\x20allocator\x20description\x20or\x20build\x20notes\x20that\x20threshold\x20=\x20one\x20period\x27s\x20release\x20amount\x20(never\x20the\x20pre-funded\x20total).'}),d;}const MIN_PRICE_KEY_REGEX=/^(?:min_[a-z0-9_]*?(?:price|amount|usd|value)|price_floor)$/,FLOOR_TEXT_REGEX=/fixed (?:fee|charge)[^.\n]*(?:<|less than|below) [^.\n]*(?:lowest|minimum|min)|minimum (?:sku|order|item|unit) (?:price|amount)|(?:below|under|<=)\s*the\s+smallest[^.\n]*(?:order|escrow|booking|price)/i,FIXED_FEE_TEXT_REGEX=/\bamount mode\b|fixed (?:fee|fulfillment|fulfilment|per[- ]order) (?:fee|charge)|\bAmount\b[^.\n]*(?:fee|charge)/i;function fundAnchorChecks(a){const b=[],c=[a['allocator']['description'],...a['build_notes'],...a['trust_mechanisms'],...a['guards']['map'](h=>h['template_id']+'\x20'+h['purpose'])]['join']('\x20\x0a\x20'),d=a['allocator']['refund_track']==='order_anchored'||/allocator_order_anchor/['test'](c)||/guardidentifier\(0\)|order[- ]anchored|for_object/i['test'](c);!d&&b['push']({'rule_id':'R-ANCHOR-01','severity':'critical','title':'Allocator\x20has\x20no\x20order\x20anchor\x20—\x20its\x20Guard\x20cannot\x20bind\x20the\x20paying\x20Order','detail':'Every\x20recipient\x20of\x20this\x20allocator\x20is\x20a\x20fixed\x20party\x20(recipient=\x27'+a['allocator']['recipient']+'\x27,\x20no\x20GuardIdentifier\x20row),\x20so\x20nothing\x20in\x20the\x20Guard\x27s\x20verification\x20context\x20names\x20the\x20Order\x20being\x20settled:\x20Recipient::Entity/Signer\x20are\x20resolved\x20without\x20any\x20submission\x20check\x20(allocation.move:451-456)\x20and\x20the\x20Allocation\x20itself\x20never\x20enters\x20the\x20Guard\x20context.\x20Testnet\x20proved\x20the\x20consequence:\x20a\x20passport\x20built\x20from\x20an\x20ALREADY-SETTLED\x20order\x20of\x20the\x20same\x20Service\x20drained\x20a\x20different\x20order\x27s\x20escrow\x20(CR-01).\x20The\x20identifier-255\x20once-slot\x20does\x20not\x20help\x20—\x20it\x20is\x20stored\x20per\x20Allocation,\x20so\x20a\x20fresh\x20pool\x20has\x20no\x20record.','suggestion':'Adopt\x20pattern.allocator_order_anchor:\x20add\x20one\x20{GuardIdentifier:\x200}\x20row\x20with\x20Rate\x200\x20(pays\x20nothing,\x20makes\x20the\x20submitted\x20Order\x20the\x20Guard\x27s\x20binding\x20target),\x20declare\x20refund_track:\x20\x22order_anchored\x22,\x20and\x20pin\x20the\x20Guard\x20expression\x20to\x20that\x20identifier\x20plus\x20logic_equal[order.service,\x20<this\x20service>].'});const e=a['allocator']['mode']==='amount',f=e||FIXED_FEE_TEXT_REGEX['test'](c),g=Object['keys'](a['fee_params'])['some'](h=>MIN_PRICE_KEY_REGEX['test'](h))||FLOOR_TEXT_REGEX['test'](c);f&&!g&&b['push']({'rule_id':'R-FIXFEE-01','severity':e?'critical':'high','title':'Fixed\x20Amount\x20fee\x20with\x20no\x20minimum\x20order\x20value\x20—\x20sub-fee\x20orders\x20deadlock\x20permanently','detail':'alloc()\x20asserts\x20balance\x20>=\x20fix\x20before\x20distributing\x20(allocation.move:390):\x20an\x20order\x20escrowed\x20BELOW\x20the\x20fixed\x20fee\x20can\x20never\x20settle,\x20and\x20the\x20terminal\x20nodes\x20(completed/closed_cancel)\x20leave\x20no\x20refund\x20path\x20for\x20it,\x20so\x20buyer\x20funds\x20and\x20the\x20order\x20strand\x20forever\x20(testnet\x20CR-02,\x20reproduced\x20on\x20a\x200.001\x20WOW\x20SKU\x20against\x20a\x200.15\x20WOW\x20fee).','suggestion':'Declare\x20a\x20minimum\x20listing/order\x20value\x20above\x20every\x20fixed\x20leg\x20in\x20fee_params\x20(e.g.\x20min_sku_price)\x20and\x20state\x20it\x20in\x20the\x20allocator\x20description,\x20or\x20model\x20the\x20per-order\x20fee\x20as\x20Rate/RateGross\x20instead\x20of\x20a\x20fixed\x20Amount.'});a['allocator']['once_per_order']===!![]&&!/per[- ]allocation|per[- ]pool|not cross[- ]order|within (a|the) (pool|allocation)/i['test'](c)&&b['push']({'rule_id':'R-ONCE-SCOPE-01','severity':'medium','title':'once_per_order\x20claim\x20does\x20not\x20state\x20its\x20per-Allocation\x20scope','detail':'The\x20identifier-255\x20once-slot\x20is\x20keyed\x20(guard,\x20allocator,\x20submission)\x20ON\x20ONE\x20Allocation,\x20so\x20replay\x20immunity\x20holds\x20within\x20a\x20single\x20pool\x20only;\x20a\x20second\x20Allocation\x20of\x20the\x20same\x20Service\x20starts\x20with\x20no\x20record.\x20Presenting\x20ONCE\x20as\x20general\x20idempotency\x20is\x20what\x20let\x20testnet\x20CR-01\x20read\x20as\x20\x27already\x20protected\x27.','suggestion':'Say\x20explicitly\x20that\x20255\x20protects\x20one\x20pool,\x20and\x20pair\x20it\x20with\x20the\x20order\x20anchor\x20(R-ANCHOR-01)\x20for\x20cross-order\x20safety.'});if(a['allocator']['once_per_order']===!![]){const h=new Set((a['allocator']['rows']??[])['map'](n=>n['guard_key'])['filter'](n=>typeof n==='string'&&n['length']>0x0)),j=h['size']>0x0?a['guards']['filter'](n=>n['key']!=null&&h['has'](n['key'])):a['guards'],k=j['map'](n=>n['key']??n['template_id']),l=j['some'](n=>{if(!n['template_id']['startsWith']('tpl_'))return![];const o=GUARD_TEMPLATES['find'](p=>p['id']===n['template_id']);return Array['isArray'](o?.['example_table'])&&o['example_table']['some'](p=>p?.['identifier']===0xfe||p?.['identifier']===0xff);}),m=/\bidentifier[- ]?25[45]\b/['test'](c)||/\b25[45]\b[^.\n]{0,80}\bb_submission\b/i['test'](c)||/ONCE-FOR-OBJECT/['test'](c);!l&&!m&&b['push']({'rule_id':'R-ONCE-ARM','severity':'critical','title':'once-slot\x20NOT\x20armed\x20—\x20once_per_order\x20is\x20claimed\x20but\x20no\x20254/255\x20submission\x20slot\x20is\x20declared\x20anywhere','detail':'once_per_order\x20has\x20NO\x20automatic\x20on-chain\x20wiring:\x20the\x20chain\x20only\x20sees\x20a\x20replay\x20defense\x20if\x20the\x20BUILT\x20Guard\x20table\x20declares\x20the\x20ONCE\x20submission\x20slot\x20(identifier\x20254\x20ONCE-FOR-ORDER\x20/\x20255\x20byte-keyed)\x20and\x20the\x20trigger\x20passport\x20submits\x20it.\x20This\x20template\x20sets\x20once_per_order=true,\x20yet\x20neither\x20a\x20tpl_*\x20guard\x20table\x20nor\x20the\x20build\x20notes\x20declare\x20the\x20slot\x20for\x20any\x20allocator-bound\x20guard\x20—\x20the\x20advertised\x20replay\x20protection\x20does\x20not\x20exist\x20on-chain.','suggestion':'Arm\x20the\x20allocator-bound\x20guard\x20row(s)\x20['+(k['join'](',\x20')||'<none\x20—\x20template\x20declares\x20no\x20guards>')+']:\x20add\x20the\x20arming\x20build_note\x20\x27Generation\x20must\x20add\x20a\x20submission\x20entry\x20{identifier:254,\x20b_submission:true,\x20value_type:\x22Address\x22,\x20object_type:\x22Order\x22}\x20to\x20each\x20allocator\x20Guard\x20and\x20submit\x20identifier\x20254\x20in\x20the\x20trigger\x20Passport\x27\x20(255\x20with\x20a\x20per-period\x20key\x20instead,\x20for\x20rails\x20that\x20legitimately\x20repeat),\x20or\x20reference\x20a\x20tpl_*\x20guard\x20whose\x20example_table\x20already\x20declares\x20the\x20slot\x20—\x20or\x20set\x20once_per_order=false\x20if\x20replay\x20protection\x20is\x20not\x20intended.'});}return b;}function templateText(a,b=[]){return[a['allocator']['description'],...a['build_notes'],...a['trust_mechanisms'],...a['guards']['map'](c=>c['template_id']+'\x20'+c['purpose']),...a['machine_shape']['map'](c=>c['name']+'\x20'+c['role']),...Object['entries'](a['time_anchors']??{})['map'](([c,d])=>c+'\x20'+d),...b]['join']('\x20\x0a\x20');}const BUY_GATE_CLAIM_REGEX=/\b(buy[\s-]?gate|purchase[\s-]?gate|age[\s-]?verification|age[\s-]?gate|adult[\s-]?verification|kyc[\s-]?gate|identity[\s-]?gate)\b/i;function buyKeyDeclarationChecks(a){const b=[];if(a['guards']['some'](c=>c['host']==='service'&&c['key']==='buy'))return b;return BUY_GATE_CLAIM_REGEX['test'](templateText(a))&&b['push']({'rule_id':'R-BUYKEY-01','severity':'critical','title':'A\x20purchase/buy\x20gate\x20is\x20declared\x20but\x20no\x20service\x20guard\x20carries\x20key\x20\x22buy\x22\x20—\x20the\x20gate\x20never\x20mounts','detail':'The\x20template\x20prose\x20declares\x20a\x20buy/purchase\x20gate\x20(age\x20verification,\x20KYC,\x20identity\x20gate\x20or\x20similar),\x20but\x20the\x20compiler\x20mounts\x20the\x20Service\x20buy\x20guard\x20ONLY\x20from\x20a\x20guard\x20spec\x20with\x20host=\x27service\x27\x20AND\x20key=\x27buy\x27.\x20No\x20such\x20spec\x20exists,\x20so\x20the\x20service\x20would\x20publish\x20with\x20NO\x20purchase\x20gate\x20while\x20trust_mechanisms\x20still\x20claim\x20one.','suggestion':'Add\x20key:\x20\x22buy\x22\x20to\x20the\x20service-host\x20guard\x20spec\x20that\x20implements\x20the\x20gate\x20(host\x20stays\x20\x27service\x27),\x20or\x20drop\x20the\x20gate\x20claim\x20from\x20the\x20prose\x20if\x20no\x20gate\x20is\x20intended.'}),b;}const STAY_DATE_REGEX=/check[\s-]?in|check[\s-]?out|departure\s+date|arrival\s+date|booking\s+date|checkin|checkout|stay\s+date|stay_nights|\bstay\s+nights?\b|\bper\s+night\b|入住|退房|离店|到店日/i,CHAIN_CLOCK_REGEX=/order\.time|progress\.current_time|\border\s+time\b|witness/i,REPOSITORY_DATE_SOURCE_REGEX=/(?:write|writes|written|storing|store|stores|persist|persisted|record|records|read|reads)\b[^.\n]{0,90}repositor|repositor\w*\b[^.\n]{0,90}(?:stay|check[\s-]?in|check[\s-]?out|departure|arrival|date)/i;function timeWindowAnchorChecks(a){const b=templateText(a);if(!STAY_DATE_REGEX['test'](b))return[];if(CHAIN_CLOCK_REGEX['test'](b)||REPOSITORY_DATE_SOURCE_REGEX['test'](b))return[];const c=b['match'](new RegExp(STAY_DATE_REGEX['source'],'gi'))??[],d=/\d+\s*[-–]\s*\d+\s*h(?:ours?|rs?)?\s*(?:adjustable|tunable|configurable)|\badjustable\b|\btunable\b/i['test'](b);return[{'rule_id':'R-WIN-ANCHOR-01','severity':'high','title':'Per-order\x20time\x20window(s)\x20anchored\x20to\x20a\x20stay\x20date\x20that\x20does\x20not\x20exist\x20on\x20chain\x20('+Array['from'](new Set(c))['slice'](0x0,0x5)['join'](',\x20')+')','detail':'The\x20template\x27s\x20windows\x20are\x20relative\x20to\x20a\x20check-in\x20/\x20check-out\x20/\x20departure\x20/\x20night\x20date.\x20No\x20such\x20field\x20exists\x20on\x20chain:\x20'+'`Order.items`\x20is\x20`vector<SaleItem>`\x20with\x20`SaleItem\x20{\x20item,\x20price,\x20quantity,\x20wip_hash\x20}`\x20(order.move:28-33)\x20and\x20the\x20purchasable\x20'+'`Sale\x20{\x20name,\x20price,\x20stock,\x20suspension,\x20wip,\x20wip_hash\x20}`\x20(service.move:100-107)\x20carries\x20no\x20schedule;\x20the\x20only\x20per-order\x20clock\x20is\x20'+'`Order.time`\x20(order.move:74),\x20the\x20CREATION\x20timestamp.\x20`Progress.current_time`\x20(progress.move:85)\x20is\x20overwritten\x20on\x20every\x20forward\x20'+'(progress.move:458)\x20and\x20`Progress.history`\x20records\x20node\x20visits,\x20so\x20neither\x20is\x20a\x20business\x20date.\x20A\x20window\x20declared\x20relative\x20to\x20the\x20'+'stay\x20calendar\x20is\x20therefore\x20UNREACHABLE\x20—\x20every\x20published\x20Guard\x20silently\x20measures\x20from\x20booking\x20time\x20instead,\x20and\x20for\x20a\x20lead\x20time\x20of\x20'+'days-to-weeks\x20that\x20is\x20a\x20material\x20semantic\x20loss,\x20not\x20a\x20rounding\x20error.'+(d?'\x20The\x20window\x20is\x20also\x20advertised\x20as\x20adjustable,\x20which\x20is\x20doubly\x20unreachable:\x20a\x20Guard\x20is\x20frozen\x20at\x20creation\x20'+'(transfer::freeze_object,\x20guard.move:262)\x20and\x20Machine\x20forwards\x20are\x20immutable\x20after\x20publish\x20(the\x20not-published\x20guard,\x20'+'machine.move:316),\x20so\x20an\x20\x27N-Mh\x20adjustable\x27\x20window\x20means\x20one\x20separately\x20published\x20Guard\x20per\x20window\x20value,\x20never\x20a\x20tunable\x20one.':''),'suggestion':'Express\x20every\x20window\x20relative\x20to\x20`order.time`\x20(or\x20`order.time\x20+\x20<window>`),\x20and\x20if\x20the\x20business\x20promise\x20is\x20genuinely\x20a\x20stay-date\x20'+'deadline,\x20write\x20the\x20stay\x20dates\x20into\x20a\x20Repository\x20at\x20buy\x20time,\x20pin\x20that\x20Repository\x20address\x20as\x20a\x20table\x20constant,\x20and\x20read\x20them\x20in\x20the\x20'+'Guard\x20(`query\x20repository.data`).\x20State\x20the\x20residual\x20semantic\x20loss\x20in\x20build_notes\x20rather\x20than\x20declaring\x20a\x20calendar-relative\x20window.'}];}function signerRefundChecks(a){const b=[],c=a['allocator']['rows']??[],d=c['find'](j=>j['recipient']==='signer'),e=a['allocator']['recipient']==='signer';if(!d&&!e)return b;const f=templateText(a),g=/refund|chargeback|repay|退款|(?:pay(?:ment|out)?|release|send|transfer|settle)\w*[^.\n]{0,40}to the (?:buyer|order|customer)/i['test'](f);if(!g)return b;const h=d?'allocator\x20row\x20'+d['track']+'/'+(d['recipient_key']??'?'):'allocator.recipient=\x27signer\x27';return b['push']({'rule_id':'R-SIGNER-02','severity':'high','title':'Refund\x20leg\x20pays\x20Recipient::Signer\x20—\x20the\x20keeper,\x20not\x20the\x20buyer\x20('+h+')','detail':'`Recipient::Signer`\x20resolves\x20to\x20`tx_context::sender(ctx)`\x20(allocation.move:531-533),\x20i.e.\x20whoever\x20signed\x20the\x20transaction\x20that\x20triggered\x20'+'`alloc`.\x20Time-driven\x20refunds\x20are\x20keeper-triggered\x20by\x20construction,\x20so\x20this\x20leg\x20pays\x20the\x20KEEPER,\x20and\x20because\x20`alloc()`\x20records\x20no\x20'+'consumed\x20flag\x20for\x20the\x20recipient,\x20first-come-first-served.\x20Only\x20`Recipient::GuardIdentifier`\x20(resolved\x20through\x20the\x20Guard\x20submission,\x20'+'allocation.move:501-527)\x20or\x20an\x20explicit\x20`Entity`\x20is\x20safe\x20for\x20a\x20refund.','suggestion':'Replace\x20the\x20Signer\x20refund\x20row\x20with\x20a\x20`{GuardIdentifier:\x200}`\x20row\x20(the\x20submission\x20for\x20a\x20Service-created\x20Allocation\x20is\x20pinned\x20to\x20the\x20paying\x20'+'Order,\x20so\x20only\x20`order.owner`\x20can\x20receive\x20it)\x20and\x20bind\x20the\x20Guard\x20to\x20`order.owner`\x20+\x20`progress.current\x20==\x20<refund\x20node>`.'}),b;}function orderAnchorDeclarationChecks(a){const b=templateText(a),c=a['allocator']['refund_track']==='order_anchored'||/order[\s-]anchored|order anchor|refund recipient is the order|anchor row|guardidentifier\s*\(\s*0\s*\)|for_object|退款接收方为订单/i['test'](b);if(!c)return[];const d=(a['allocator']['rows']??[])['some'](g=>g['recipient']==='guard_identifier'||g['recipient']==='guard_identifier_to_order'),e=a['guards']['some'](h=>h['template_id']==='pattern.allocator_order_anchor');if(d||e)return[];const f=a['allocator']['recipient']??'?';return[{'rule_id':'R-RECIPIENT-02','severity':'high','title':'Order-anchored\x20refund\x20recipient\x20is\x20asserted\x20in\x20prose\x20but\x20declared\x20nowhere\x20machine-checkable','detail':'The\x20template\x20claims\x20an\x20order-anchored\x20escrow\x20/\x20refund\x20recipient\x20while\x20its\x20machine-readable\x20allocator\x20says\x20recipient=\x27'+f+'\x27\x20'+'with\x20no\x20`guard_identifier`\x20row\x20and\x20no\x20`pattern.allocator_order_anchor`\x20Guard\x20reference.\x20Two\x20on-chain\x20facts\x20make\x20the\x20claim\x20as\x20written\x20'+'unbuildable:\x20(1)\x20`Recipient`\x20has\x20only\x20`GuardIdentifier(u8)`\x20/\x20`Entity(address)`\x20/\x20`Signer`\x20(allocation.move:148-152)\x20—\x20there\x20is\x20NO\x20'+'`Order`\x20variant,\x20so\x20\x27the\x20refund\x20recipient\x20is\x20the\x20order\x20object\x27\x20can\x20only\x20be\x20written\x20as\x20a\x20`GuardIdentifier`\x20row;\x20(2)\x20recipients\x20that\x20are\x20'+'all\x20fixed\x20`Entity`\x20rows\x20resolve\x20without\x20the\x20passport\x20submission\x20(allocation.move:528-530)\x20and\x20the\x20Allocation\x20never\x20enters\x20the\x20Guard\x20'+'context,\x20so\x20the\x20Guard\x20has\x20no\x20order\x20to\x20bind\x20at\x20all\x20—\x20the\x20CR-01\x20drain\x20shape.\x20A\x20build\x20agent\x20reading\x20the\x20prose\x20instead\x20of\x20the\x20schema\x20will\x20'+'emit\x20an\x20Entity\x20refund\x20leg\x20to\x20the\x20merchant,\x20or\x20a\x20Signer\x20leg\x20to\x20the\x20keeper.','suggestion':'Declare\x20the\x20anchor\x20machine-checkably:\x20one\x20`{\x20recipient:\x20\x27guard_identifier\x27,\x20recipient_key:\x20\x270\x27,\x20mode:\x20\x27rate\x27,\x20value:\x200\x20}`\x20row\x20(the\x20'+'pattern.allocator_order_anchor\x20convention)\x20plus\x20`refund_track:\x20\x27order_anchored\x27`,\x20and\x20reference\x20`pattern.allocator_order_anchor`\x20in\x20the\x20'+'guard\x20set\x20with\x20the\x20`logic_equal[order.service,\x20<this\x20service>]`\x20binding\x20stated\x20in\x20its\x20purpose.'}];}const EDGE_DEPENDENCY_REGEX=/\b(?:incoming|outgoing|arb_refund)\s+edge\b|\bstop[\s-]node\b|\bedges?\b|\bpairs?\b|\bforwards?\b|one pair|two pairs/i;function topologyChecks(a){const b=[],c=templateText(a);if(a['machine_shape']['some'](j=>(j['from']??[])['length']>0x0))return b;EDGE_DEPENDENCY_REGEX['test'](c)&&b['push']({'rule_id':'R-TOPO-01','severity':'high','title':'machine_shape\x20ships\x20nodes\x20only\x20—\x20no\x20Pair/forward\x20list,\x20so\x20stop-node\x20fund-exit\x20coverage\x20is\x20unauditable','detail':'This\x20template\x27s\x20correctness\x20depends\x20on\x20Machine\x20edges\x20(its\x20own\x20notes\x20reason\x20about\x20incoming/outgoing\x20edges,\x20pairs\x20and\x20stop-node\x20'+'fund-exit\x20coverage),\x20but\x20`machine_shape`\x20carries\x20NO\x20edges:\x20an\x20edge\x20on\x20chain\x20is\x20`Node[target].pairs\x20=\x20{\x20prev_node,\x20threshold,\x20'+'forwards[]\x20}`,\x20which\x20this\x20schema\x20cannot\x20express.\x20The\x20scanner\x20therefore\x20has\x20to\x20invent\x20a\x20linear\x20chain,\x20and\x20the\x20mandatory\x20'+'stop-node\x20walk\x20(R-M5-03\x20/\x20R-M5-09:\x20every\x20rest\x20state\x20needs\x20a\x20defined\x20withdrawal\x20AND\x20refund\x20rule,\x20satisfiable\x20in\x20both\x20directions)\x20'+'cannot\x20be\x20performed\x20—\x20an\x20uncovered\x20stop\x20node\x20strands\x20escrow\x20permanently\x20once\x20Machine\x20+\x20Allocator\x20are\x20frozen\x20at\x20publish.','suggestion':'Either\x20state\x20the\x20edges\x20explicitly\x20in\x20build_notes\x20as\x20`prev\x20─forward(op,w)→\x20next`\x20with\x20the\x20Pair\x20grouping,\x20or\x20declare\x20a\x20machine-readable\x20'+'edge\x20list\x20so\x20the\x20scanner\x20can\x20audit\x20stop-node\x20coverage\x20and\x20prev_node\x20uniqueness\x20instead\x20of\x20guessing.'});const d=a['machine_shape']['map'](j=>j['name']);if(d['length']===0x0)return b;const e=d['filter'](j=>BRANCH_STATE_REGEX['test'](j));if(e['length']===0x0)return b;const f=d[0x0],g=!BRANCH_STATE_REGEX['test'](d[0x1]),h=(g?0x1:0x0)+e['length'];if(h<=0x1)return b;return b['push']({'rule_id':'R-TOPO-02','severity':'medium','title':'Node\x20\x27'+f+'\x27\x20has\x20'+h+'\x20outgoing\x20rails\x20—\x20declare\x20the\x20Pair\x20grouping\x20(E_DUPLICATE_NODE_PREV\x20is\x20per\x20TARGET\x20node,\x20not\x20per\x20source)','detail':'From\x20\x27'+f+'\x27\x20the\x20declared\x20node\x20set\x20requires\x20'+h+'\x20distinct\x20rails\x20'+('('+(g?'the\x20linear\x20rail\x20to\x20\x27'+d[0x1]+'\x27,\x20':''))+(e['map'](j=>'the\x20branch\x20to\x20\x27'+j+'\x27')['join'](',\x20')+').\x20These\x20are\x20LEGAL\x20and\x20must\x20NOT\x20be\x20merged:\x20an\x20edge\x20A→B\x20is\x20')+'stored\x20in\x20`Node[B].pairs\x20=\x20{\x20prev_node:\x20A,\x20threshold,\x20forwards[]\x20}`,\x20and\x20the\x20chain\x20rejects\x20only\x20the\x20SAME\x20`prev_node`\x20appearing\x20'+'twice\x20inside\x20ONE\x20node\x27s\x20pairs\x20(`assert!(!vector::contains(&res,\x20&pair.prev_node),\x20E_DUPLICATE_NODE_PREV)`,\x20machine.move:171\x20and\x20'+'machine.move:440).\x20Rails\x20into\x20different\x20targets\x20occupy\x20different\x20nodes,\x20so\x20each\x20`prev_node`\x20still\x20appears\x20exactly\x20once\x20per\x20node.\x20'+'THE\x20HAZARD\x20IS\x20THE\x20MIRROR\x20IMAGE:\x20two\x20forwards\x20from\x20the\x20SAME\x20source\x20into\x20the\x20SAME\x20target\x20must\x20be\x20ONE\x20Pair\x20carrying\x20both\x20forwards\x20—\x20'+'a\x20builder\x20that\x20emits\x20one\x20Pair\x20per\x20forward\x20duplicates\x20`prev_node`\x20and\x20ABORTS\x20at\x20publish,\x20after\x20Machine\x20+\x20Guard\x20are\x20frozen.\x20Note\x20'+'also\x20that\x20one\x20forward\x20cannot\x20satisfy\x20two\x20operators:\x20each\x20forward\x20contributes\x20its\x20weight\x20at\x20most\x20once\x20(locked\x20by\x20its\x20first\x20operator,\x20'+'progress.move:425-431),\x20so\x20a\x20dual-confirmation\x20step\x20needs\x20`threshold\x20=\x202`\x20with\x20two\x20DISTINCT\x20forwards.\x20A\x20node\x20list\x20cannot\x20distinguish\x20'+'these\x20cases,\x20which\x20is\x20why\x20this\x20is\x20advisory\x20and\x20not\x20a\x20proven\x20defect.','suggestion':'Do\x20NOT\x20merge\x20the\x20rails.\x20Instead\x20declare\x20the\x20grouping\x20explicitly\x20in\x20build_notes\x20as\x20'+'`prev\x20─forward(op,w)→\x20next`,\x20marking\x20which\x20forwards\x20SHARE\x20one\x20target\x20and\x20therefore\x20belong\x20in\x20ONE\x20Pair,\x20and\x20state\x20each\x20Pair\x27s\x20'+'`threshold`\x20(2\x20with\x20two\x20distinct\x20forwards\x20when\x20two\x20different\x20operators\x20must\x20act).\x20This\x20also\x20lets\x20the\x20scanner\x20audit\x20prev_node\x20'+'uniqueness\x20instead\x20of\x20guessing.\x20Related:\x20R-TOPO-01\x20(high)\x20is\x20the\x20finding\x20that\x20records\x20that\x20edges\x20are\x20unauditable\x20at\x20all.'}),b;}function reachabilityChecks(a){const b=a['machine_shape']??[];if(b['length']===0x0)return[];if(!b['some'](s=>(s['from']??[])['length']>0x0))return[];const c=new Map(b['map'](s=>[s['name'],s])),d=new Map(),f=[];for(const s of b){for(const u of s['from']??[]){const v=typeof u==='string'?u:u?.['prev'];if(v==='')f['push'](s['name']);else{if(!d['has'](v))d['set'](v,[]);d['get'](v)['push'](s['name']);}}}const g=[];if(f['length']===0x0)g['push']('no\x20entry\x20edge\x20(prev:\x20\x22\x22)\x20—\x20the\x20Machine\x20has\x20no\x20starting\x20Pair\x20and\x20orders\x20can\x20never\x20begin');else f['length']>0x1&&g['push'](f['length']+'\x20entry\x20edges\x20(prev:\x20\x22\x22)\x20into\x20'+f['map'](w=>'\x27'+w+'\x27')['join'](',\x20')+'\x20—\x20'+'exactly\x20one\x20starting\x20Pair\x20is\x20expressible\x20on\x20chain\x20(the\x20first\x20pair\x20with\x20prev_node\x20\x22\x22)');const h=new Set(f),j=[...f];while(j['length']>0x0){const w=j['pop']();for(const x of d['get'](w)??[]){!h['has'](x)&&(h['add'](x),j['push'](x));}}const k=b['filter'](y=>!h['has'](y['name']))['map'](y=>'\x27'+y['name']+'\x27');k['length']>0x0&&g['push']('unreachable\x20from\x20the\x20entry\x20(declared\x20but\x20dead):\x20'+k['join'](',\x20'));const l=y=>y['semantic_role']==='final'||y['semantic_role']==='cancelled',n=new Map();for(const [y,z]of d){for(const A of z){if(!n['has'](A))n['set'](A,[]);n['get'](A)['push'](y);}}const o=new Set(),p=b['filter'](l)['map'](B=>B['name']);p['forEach'](B=>o['add'](B));while(p['length']>0x0){const B=p['pop']();for(const C of n['get'](B)??[]){!o['has'](C)&&(o['add'](C),p['push'](C));}}const q=b['filter'](D=>!l(D)&&!o['has'](D['name'])&&(d['get'](D['name'])??[])['length']>0x0)['map'](D=>{const E='exits\x20lead\x20only\x20to\x20'+[...new Set(d['get'](D['name'])??[])]['map'](F=>'\x27'+F+'\x27')['join'](',\x20')+',\x20none\x20of\x20which\x20reaches\x20a\x20settlement\x20or\x20refund\x20endpoint';return'\x27'+D['name']+'\x27\x20('+(D['semantic_role']??'no\x20semantic_role')+')\x20—\x20'+E;});q['length']>0x0&&g['push']('no\x20path\x20to\x20a\x20terminal\x20(final/cancelled):\x20'+q['join'](';\x20'));if(g['length']===0x0)return[];return[{'rule_id':'R-TOPO-03','severity':'high','title':'Machine\x20edge\x20graph\x20breaks\x20reachability\x20—\x20declared\x20semantics\x20can\x20never\x20execute\x20or\x20never\x20end','detail':'Auditing\x20the\x20structured\x20from-edges:\x20'+g['join'](';\x20')+'.\x20Every\x20declared\x20node\x20must\x20be\x20'+'reachable\x20from\x20the\x20single\x20entry\x20Pair,\x20and\x20every\x20non-terminal\x20node\x20must\x20reach\x20a\x20final/cancelled\x20'+'endpoint\x20—\x20buy\x20escrows\x20ATOMICALLY,\x20so\x20a\x20node\x20from\x20which\x20the\x20world\x20cannot\x20end\x20strands\x20the\x20pool.\x20'+'Machine\x20topology\x20is\x20frozen\x20at\x20publish\x20(IMMUT-001),\x20so\x20these\x20defects\x20are\x20unfixable\x20after\x20the\x20fact;\x20'+'the\x20only\x20remedy\x20is\x20correcting\x20the\x20template\x20BEFORE\x20the\x20Machine\x20is\x20built.\x20Zero-exit\x20leaves\x20are\x20'+'reported\x20by\x20R-DEAD-END\x20(an\x20`optional:\x20true`\x20mark\x20does\x20not\x20rescue\x20them);\x20this\x20finding\x20covers\x20nodes\x20'+'WITH\x20exits\x20whose\x20exits\x20never\x20reach\x20an\x20endpoint.','suggestion':'Fix\x20the\x20edge\x20data:\x20give\x20every\x20non-entry\x20node\x20a\x20from-edge\x20chain\x20back\x20to\x20the\x20entry,\x20give\x20every\x20mandatory\x20'+'state\x20at\x20least\x20one\x20forward\x20path\x20into\x20a\x20final/cancelled\x20endpoint,\x20and\x20mark\x20genuinely\x20skippable\x20side\x20'+'actions\x20`optional:\x20true`\x20(which\x20exempts\x20them\x20from\x20THIS\x20audit\x27s\x20mandatory-flow\x20reading\x20only\x20—\x20a\x20'+'zero-exit\x20optional\x20leaf\x20is\x20still\x20an\x20R-DEAD-END\x20lockup).\x20One\x20entry\x20edge\x20(prev:\x20\x22\x22)\x20only\x20—\x20the\x20'+'on-chain\x20Machine\x20has\x20exactly\x20one\x20starting\x20Pair.'}];}function loopFundChecks(a){const b=a['machine_shape']??[];if(b['length']===0x0||!b['some'](q=>(q['from']??[])['length']>0x0))return[];const c=new Map();for(const q of b){for(const s of q['from']??[]){const u=typeof s==='string'?s:s?.['prev'];if(typeof u!=='string'||u==='')continue;if(!c['has'](u))c['set'](u,[]);c['get'](u)['push'](q['name']);}}const d=findLoopCycles(c);if(d['length']===0x0)return[];const f=[],g=d['filter'](v=>classifyLoopCycle(v['cycle'])==='remedy');g['length']>0x0&&f['push']({'rule_id':'R-LOOP-FUND','severity':'low','title':'Remedy\x20loop\x20cycle(s)\x20'+g['map'](v=>'['+v['cycle']['join']('\x20->\x20')+']')['join'](',\x20')+'\x20—\x20same-order\x20revisit,\x20no\x20new\x20charge\x20implied','detail':'A\x20revision/review/rework/refund/cancel/claim-family\x20cycle\x20re-enters\x20work\x20states\x20WITHIN\x20one\x20paid\x20order,\x20so\x20it\x20needs\x20'+'no\x20fund\x20gate\x20while\x20the\x20revisit\x20is\x20free\x20(crs\x20P2-3\x20visibility).\x20If\x20the\x20business\x20EVER\x20intends\x20a\x20revisit\x20'+'to\x20cost\x20money,\x20that\x20fee\x20IS\x20enforceable\x20via\x20the\x20allocation.balance\x20Guard\x20query\x20(1051,\x20witness\x20'+'OrderAllocation\x20109)\x20—\x20but\x20that\x20reshapes\x20the\x20cycle\x20into\x20the\x20charge\x20tier\x20below.','suggestion':'Keep\x20remedy\x20loops\x20single-charge\x20(one\x20paid\x20order,\x20revisions\x20included)\x20—\x20or,\x20if\x20each\x20revisit\x20'+'must\x20be\x20paid,\x20declare\x20the\x20guard-layer\x20fund\x20gate\x20convention\x20(see\x20the\x20charge\x20tier)\x20or\x20replace\x20the\x20loop\x20'+'with\x20per-period\x20NEW\x20Orders\x20(REUSE\x20pattern\x20—\x20a\x20fresh\x20order\x20per\x20period\x20instead\x20of\x20an\x20in-order\x20loop\x20that\x20replays\x20its\x20forwards\x20every\x20lap).'});const h=templateText(a),j=/order_renew/i['test'](h)&&/atomic|re-fund/i['test'](h),k=d['filter'](v=>classifyLoopCycle(v['cycle'])==='renewal'),l=j?[]:k,n=d['filter'](v=>classifyLoopCycle(v['cycle'])==='charge'),o=[...n,...l];if(o['length']===0x0)return f;const p=n['length']===0x0?'the\x20atomic\x20order_renew\x20funding\x20convention\x20is\x20not\x20declared\x20in\x20the\x20template\x20prose':l['length']===0x0?'a\x20cycle\x20implies\x20a\x20per-revisit\x20charge\x20(retake\x20/\x20session-card\x20shape)\x20whose\x20fund\x20gate\x20is\x20not\x20declared\x20in\x20the\x20template\x20prose':'a\x20cycle\x20implies\x20a\x20per-revisit\x20charge\x20with\x20no\x20declared\x20fund\x20gate,\x20AND\x20the\x20renewal-shaped\x20cycles\x20lack\x20the\x20declared\x20order_renew\x20convention';return f['push']({'rule_id':'R-LOOP-FUND','severity':'critical','title':'Loop\x20cycle(s)\x20'+o['map'](v=>'['+v['cycle']['join']('\x20->\x20')+']')['join'](',\x20')+'\x20—\x20revisit\x20funding\x20is\x20not\x20declared\x20at\x20the\x20template\x20layer','detail':'A\x20cycle\x20lets\x20an\x20order\x20revisit\x20nodes,\x20and\x20the\x20contract\x20never\x20verifies\x20that\x20a\x20revisit\x20re-funds\x20the\x20'+'Allocation\x20—\x20every\x20charge-bearing\x20loop\x20forward\x20MUST\x20carry\x20the\x20new-period\x20payment\x20atomically\x20or\x20the\x20loop\x20allows\x20'+'zero-value\x20re-delivery\x20cycles\x20(test/11\x20R2-F3,\x20crs\x20P2-3).\x20The\x20allocation.balance\x20Guard\x20query\x20(1051,\x20witness\x20'+'OrderAllocation\x20109)\x20makes\x20the\x20fee\x20enforceable\x20at\x20the\x20guard\x20layer,\x20but\x20this\x20template\x20does\x20not\x20DECLARE\x20that\x20'+('convention,\x20and\x20here\x20'+p+'.'),'suggestion':(l['length']>0x0?'For\x20the\x20renewal-shaped\x20cycle(s)\x20'+l['map'](v=>'['+v['cycle']['join']('\x20->\x20')+']')['join'](',\x20')+':\x20declare\x20the\x20'+'atomic\x20order_renew\x20convention\x20in\x20build_notes\x20—\x20\x27use\x20the\x20order\x20call\x27s\x20`order_renew`\x20field:\x20ONE\x20PTB\x20pays\x20'+'the\x20period\x20amount\x20into\x20the\x20Allocation\x20and\x20advances\x20the\x20renew\x20forward\x20atomically\x20(fund\x20+\x20record\x20+\x20'+'advance,\x20no\x20unfunded-advance\x20window)\x27.\x20':'')+'For\x20charge-bearing\x20cycles\x20that\x20are\x20not\x20renewal-shaped,\x20declare\x20the\x20guard-layer\x20fund\x20gate\x20in\x20build_notes\x20—\x20'+'\x27the\x20revisit\x20forward\x20carries\x20a\x20Guard:\x20constant\x20=\x20order\x20address,\x20convert_witness\x20OrderAllocation(109),\x20'+'allocation.balance\x20(query\x201051)\x20>=\x20revisit\x20fee\x27\x20—\x20or\x20replace\x20the\x20loop\x20'+'with\x20per-period\x20NEW\x20Orders\x20(REUSE\x20pattern\x20—\x20a\x20fresh\x20order\x20per\x20period)\x20or\x20remove\x20the\x20back-edge\x20—\x20rework\x20the\x20business\x20'+'flow\x20so\x20re-entry\x20is\x20a\x20fresh\x20order,\x20not\x20a\x20node\x20revisit.'}),f;}function deadEndLockChecks(a){const b=a['machine_shape']??[];if(b['length']===0x0||!b['some'](k=>(k['from']??[])['length']>0x0))return[];const c=new Map(),d=[];for(const k of b){for(const l of k['from']??[]){const n=typeof l==='string'?l:l?.['prev'];if(n==='')d['push'](k['name']);else{if(!c['has'](n))c['set'](n,[]);c['get'](n)['push'](k['name']);}}}const f=new Set(d),g=[...d];while(g['length']>0x0){const o=g['pop']();for(const p of c['get'](o)??[]){!f['has'](p)&&(f['add'](p),g['push'](p));}}const h=q=>/pool is empty|pool drains?ed|drains? in full|already (?:released|paid)|escrow (?:is )?(?:empty|drained)/i['test'](q),j=b['filter'](q=>q['semantic_role']!=='final'&&q['semantic_role']!=='cancelled')['filter'](q=>f['has'](q['name'])&&(c['get'](q['name'])??[])['length']===0x0)['filter'](q=>!h(q['role']))['map'](q=>'\x27'+q['name']+'\x27\x20('+(q['semantic_role']??'no\x20semantic_role')+(q['optional']===!![]?',\x20optional':'')+')');if(j['length']===0x0)return[];return[{'rule_id':'R-DEAD-END','severity':'high','title':'Dead-end\x20node(s)\x20'+j['join'](',\x20')+'\x20—\x20taking\x20the\x20forward\x20locks\x20the\x20order\x20and\x20its\x20escrow\x20forever','detail':'A\x20reachable\x20node\x20with\x20no\x20outgoing\x20forward\x20strands\x20the\x20order\x20the\x20moment\x20someone\x20advances\x20into\x20it:\x20'+'Machine\x20topology\x20freezes\x20at\x20publish,\x20so\x20there\x20is\x20no\x20later\x20repair,\x20and\x20`optional:\x20true`\x20does\x20NOT\x20help\x20—\x20'+'the\x20buyer\x20can\x20still\x20take\x20the\x20optional\x20forward,\x20and\x20the\x20order\x20then\x20stands\x20at\x20a\x20node\x20from\x20which\x20no\x20Pair\x20'+'exists\x20(Etsy\x20mainnet\x20ets1_o2\x20stopped\x20exactly\x20there:\x20delivered\x20→\x20reviewed,\x20history\x20ends,\x20no\x20rail\x20can\x20'+'ever\x20anchor\x20that\x20state\x20again).\x20Buy\x20escrows\x20ATOMICALLY,\x20so\x20the\x20full\x20pool\x20rides\x20into\x20the\x20dead\x20end\x20'+'unless\x20a\x20rail\x20drained\x20it\x20upstream.\x20This\x20is\x20the\x20defect\x20class\x20the\x20old\x20optional-leaf\x20exemption\x20in\x20'+'R-TOPO-03\x20let\x20ship\x20into\x20two\x20builtin\x20templates.','suggestion':'Wire\x20an\x20exit\x20edge\x20back\x20into\x20the\x20live\x20flow\x20(review\x20re-joins\x20the\x20settlement\x20rail,\x20e.g.\x20reviewed\x20'+'─settle→\x20completed)\x20or\x20remove\x20the\x20node\x20from\x20machine_shape\x20and\x20keep\x20the\x20action\x20off-Machine\x20'+'(Repository\x20/\x20Reward).\x20If\x20the\x20node\x20is\x20genuinely\x20a\x20record\x20state\x20whose\x20pool\x20already\x20drained\x20upstream,\x20'+'say\x20so\x20in\x20its\x20role\x20(\x27pool\x20is\x20empty\x27)\x20so\x20this\x20rule\x20and\x20TERMINAL-NO-RAIL\x20exempt\x20it.'}];}function reviewNoRaceChecks(a){const b=a['machine_shape'];if(b['length']===0x0)return[];const c=[],d=h=>/review(ed|ing)?\b/i['test'](h)&&!/un|no |not |without |expire/i['test'](h),f=h=>/unreviewed|no[_ -]?review|not[_ -]?reviewed|without[_ -]?review|review[^.;]{0,40}expire|expire[^.;]{0,40}review|review[_ -]?timeout|auto[_ -]?accept[^.;]{0,30}review/i['test'](h),g=new Map();for(const h of b){const j=new Set();for(const k of h['from']??[]){const l=typeof k==='string'?{'prev':k}:k;if(!l['prev']||j['has'](l['prev']))continue;j['add'](l['prev']);const m=g['get'](l['prev'])??[];m['push']({'name':h['name'],'role':h['role']??''}),g['set'](l['prev'],m);}}for(const [o,p]of g){const q=p['find'](u=>d(u['name']+'\x20'+u['role'])),s=p['find'](u=>u['name']!==q?.['name']&&f(u['name']+'\x20'+u['role']));if(q===undefined||s===undefined)continue;c['push']({'rule_id':'R-REVIEW-NORACE','severity':'high','title':'Node\x20\x27'+o+'\x27\x20fans\x20out\x20\x27'+q['name']+'\x27\x20and\x20its\x20complement\x20\x27'+s['name']+'\x27\x20as\x20SIBLING\x20outgoing\x20edges\x20—\x20complementary\x20conditions\x20race\x20(F-REVIEW-BLOCK)','detail':'Sibling\x20forwards\x20on\x20one\x20NodePair\x20have\x20no\x20on-chain\x20mutual\x20exclusion.\x20Reviewed/unreviewed\x20as\x20parallel\x20edges\x20'+'race\x20on\x20their\x20time\x20conditions:\x20in\x20an\x20overlap\x20BOTH\x20fire\x20(double\x20movement),\x20in\x20a\x20gap\x20NEITHER\x20fires\x20—\x20and\x20with\x20'+'topology\x20frozen\x20at\x20publish\x20the\x20neither-gap\x20is\x20a\x20permanent\x20deadlock\x20that\x20no\x20later\x20repair\x20can\x20close.','suggestion':'Fold\x20the\x20complement\x20into\x20ONE\x20release\x20guard\x20as\x20a\x20logic_or\x20time\x20variant\x20(\x27reviewed\x20OR\x20unreviewed\x20after\x20T\x27)\x20on\x20a\x20'+'single\x20edge\x20—\x20REVIEW-GATED\x20RELEASE\x20in\x20guard-design-patterns\x20—\x20or\x20give\x20each\x20sibling\x20its\x20own\x20NodePair\x20so\x20the\x20'+'choice\x20is\x20a\x20build-time\x20topology\x20decision,\x20not\x20a\x20runtime\x20race.'});}return c;}export function rootHasRewardRecordGate(a){if(a===null||typeof a!=='object')return![];const b=a;if(b['type']==='query_reward_record_exists')return!![];if(b['type']==='query'&&typeof b['query']==='string'&&/^reward\.record[ .](has|count|find|exists_where)/i['test'](b['query']))return!![];if(b['type']==='query'&&typeof b['query']==='number'&&[0x64c,0x64d,0x65a,0x65d]['includes'](b['query']))return!![];for(const c of b['nodes']??[])if(rootHasRewardRecordGate(c))return!![];for(const d of b['and']??[])if(rootHasRewardRecordGate(d))return!![];for(const e of b['or']??[])if(rootHasRewardRecordGate(e))return!![];if(b['node']!==undefined&&rootHasRewardRecordGate(b['node']))return!![];return![];}function subtreeHasOrderAmount(a){if(Array['isArray'](a))return a['some'](subtreeHasOrderAmount);if(a===null||typeof a!=='object')return![];const b=a;if(b['type']==='query'&&b['query']==='order.amount')return!![];if(b['type']==='query'&&b['query']===0x619)return!![];return(b['nodes']??[])['some'](subtreeHasOrderAmount);}export function rootHasPositiveAmountLeg(a){if(a===null||typeof a!=='object')return![];const b=a;if(typeof b['type']==='string'&&/^logic_as_u256_greater/['test'](b['type'])&&subtreeHasOrderAmount(b))return!![];for(const c of b['nodes']??[])if(rootHasPositiveAmountLeg(c))return!![];for(const d of b['and']??[])if(rootHasPositiveAmountLeg(d))return!![];for(const e of b['or']??[])if(rootHasPositiveAmountLeg(e))return!![];if(b['node']!==undefined&&rootHasPositiveAmountLeg(b['node']))return!![];return![];}function rewardZeroOrderChecks(a){const b=(a['guards']??[])['filter'](h=>h['host']==='reward');if(b['length']===0x0)return[];const c=b['some'](h=>{if(!h['template_id']['startsWith']('tpl_'))return![];const j=GUARD_TEMPLATES['find'](k=>k['id']===h['template_id']);return rootHasPositiveAmountLeg(j?.['example_root']);}),d=templateText(a),e=/order\.amount/i['test'](d)&&/positive[- ]amount|zero[- ]?(total|value)|0[- ]?value/i['test'](d);if(c||e)return[];const f=b['map'](h=>h['key']??h['template_id']);return[{'rule_id':'R-REWARD-ZERO-ORDER','severity':'medium','title':'Reward-claim\x20guard(s)\x20['+f['join'](',\x20')+']\x20not\x20positive-amount\x20gated\x20—\x20a\x20zero-total\x20order\x20can\x20mint\x20a\x20reward\x20claim','detail':'A\x20coupon\x20that\x20zeroes\x20the\x20basket\x20(MINUS\x20value\x20>=\x20the\x20SKU\x20price,\x20RATES\x2010000)\x20creates\x20a\x20ZERO-VALUE\x20order:\x20'+'the\x20escrow\x20holds\x200\x20while\x20the\x20order\x20still\x20walks\x20the\x20machine\x20nodes.\x20A\x20claim\x20guard\x20without\x20a\x20positive-amount\x20'+'leg\x20lets\x20that\x20free\x20buy\x20clear\x20the\x20review\x20node\x20and\x20collect\x20the\x20bounty\x20—\x20zero-cost\x20incentive\x20arbitrage\x20'+'(bkmn\x20F-M39/T6).\x20Reward\x20guards\x20are\x20immutable\x20once\x20the\x20Reward\x20object\x20is\x20published,\x20so\x20the\x20leg\x20must\x20be\x20in\x20'+'the\x20design\x20BEFORE\x20publish.\x20The\x20coupon\x20side\x20is\x20floored\x20at\x20issuance\x20(zeroing\x20coupons\x20are\x20blocked\x20unless\x20the\x20'+'free\x20tier\x20is\x20declared\x20via\x20allow_zero_total);\x20this\x20leg\x20is\x20the\x20claim-side\x20half\x20of\x20the\x20pair.','suggestion':'Add\x20to\x20every\x20reward\x20claim\x20root,\x20wrapped\x20in\x20logic_and\x20with\x20the\x20identity\x20+\x20replay\x20legs:\x20'+'logic_as_u256_greater_or_equal[query(order.amount),\x20identifier[N](1)]\x20(declare\x20slot\x20N\x20as\x20a\x20static\x20U64\x20'+'value\x201\x20—\x20see\x20tpl_reward_one_time_claim\x20v55\x20notes);\x20or\x20reference\x20a\x20tpl_*\x20guard\x20whose\x20example_root\x20already\x20'+'carries\x20the\x20positive-amount\x20leg;\x20or\x20declare\x20the\x20requirement\x20verbatim\x20in\x20the\x20build\x20notes\x20'+'(order.amount\x20+\x20positive-amount\x20phrasing)\x20so\x20the\x20generated\x20root\x20includes\x20it.'}];}function rewardReplayChecks(a){const b=(a['guards']??[])['filter'](f=>f['host']==='reward');if(b['length']===0x0)return[];const c=b['some'](f=>{if(!f['template_id']['startsWith']('tpl_'))return![];const h=GUARD_TEMPLATES['find'](j=>j['id']===f['template_id']);return rootHasRewardRecordGate(h?.['example_root']);}),d=/query_reward_record_exists/i['test'](templateText(a))||/reward\.record[ .](has|count|find|exists_where)/i['test'](templateText(a))||/reward[ -]record[ -]gate/i['test'](templateText(a));if(c||d)return[];const e=b['map'](f=>f['key']??f['template_id']);return[{'rule_id':'R-REWARD-REPLAY','severity':'high','title':'Reward-claim\x20guard(s)\x20['+e['join'](',\x20')+']\x20not\x20record-gated\x20—\x20the\x20replay\x20defense\x20this\x20template\x20implies\x20does\x20not\x20exist\x20on-chain','detail':'Reward.claim\x20pays\x20Recipient::Signer\x20with\x20no\x20order\x20binding\x20of\x20its\x20own:\x20the\x20armed\x20rail\x20is\x20the\x20record\x20gate\x20—\x20'+'logic_not(query_reward_record_exists(...))\x20inside\x20the\x20claim\x20guard\x20root,\x20forced\x20together\x20with\x20an\x20identity\x20leg\x20'+'(Signer\x20==\x20order.owner).\x20The\x20PRIMARY\x20form\x20is\x20ORDER-SCOPED\x20(where.storeFromId\x20=\x20the\x20submitted\x20Order\x20address\x20slot,\x20'+'the\x20same\x20slot\x20the\x20guard_add\x20entry\x20stamps;\x20azx7-mn-261014\x20live\x20T8)\x20=\x20once\x20per\x20buyer\x20per\x20order;\x20the\x20EMPTY-where\x20'+'variant\x20is\x20the\x20deliberate\x20once-per-buyer-FOR-LIFE\x20choice\x20(upw\x20F-48:\x20it\x20silently\x20kills\x20the\x20buyer\x27s\x20second\x20order).\x20'+'The\x20ofn-mn-261012\x20F-01\x20\x27storeFromId\x20filter\x20is\x20a\x20silent\x20no-op\x27\x20verdict\x20described\x20UNSTAMPED/legacy\x20rewards\x20only\x20—\x20'+'records\x20written\x20without\x20the\x20guard_add\x20entry\x20stamp\x20carry\x20store_from\x20=\x20none\x20and\x20match\x20no\x20storeFromId\x20predicate;\x20the\x20'+'MCP\x20stamp\x20gate\x20(UPW-K7)\x20now\x20rejects\x20unstamped\x20record-consuming\x20entries.\x20This\x20template\x20'+'mounts\x20host:\x22reward\x22\x20claim\x20machinery\x20yet\x20arms\x20it\x20nowhere:\x20no\x20tpl_*\x20guard\x20whose\x20example_root\x20carries\x20the\x20record\x20gate,\x20'+'no\x20prose\x20declaring\x20the\x20idiom.\x20reward_claim_policy\x20is\x20a\x20documentation\x20field\x20with\x20no\x20compile\x20wiring\x20and\x20does\x20NOT\x20arm\x20'+'anything\x20(same\x20ruling\x20as\x20once_per_order\x20/\x20R-ONCE-ARM)\x20—\x20a\x20funded\x20pool\x20behind\x20an\x20un-armed\x20claim\x20guard\x20is\x20a\x20drainable\x20target.','suggestion':'Arm\x20the\x20claim\x20guard\x20root:\x20add,\x20wrapped\x20in\x20logic_and\x20with\x20the\x20identity\x20leg\x20(Signer\x20==\x20order.owner)\x20and\x20the\x20existing\x20'+'state\x20checks,\x20logic_not(query_reward_record_exists(object=<reward\x20object>,\x20where:{storeFromId:{identifier:<order\x20slot>}}))\x20'+'—\x20the\x20SV-2\x20ORDER-SCOPED\x20form\x20(once\x20per\x20buyer\x20per\x20order;\x20swap\x20to\x20an\x20EMPTY\x20where\x20ONLY\x20for\x20a\x20deliberate\x20'+'one-bounty-per-buyer\x20design).\x20The\x20reward.guard_add\x20store_from_id\x20STAMP\x20is\x20the\x20separate,\x20mandatory\x20field:\x20a\x20'+'record-consuming\x20guard\x20must\x20be\x20added\x20with\x20store_from_id\x20=\x20the\x20per-order\x20stamp\x20slot\x20(the\x20submitted\x20Order\x20address,\x20'+'conventionally\x20slot\x200)\x20or\x20the\x20MCP\x20stamp\x20gate\x20rejects\x20the\x20entry.\x20Reference\x20a\x20tpl_*\x20guard\x20whose\x20example_root\x20already\x20'+'carries\x20the\x20order-scoped\x20gate;\x20or\x20declare\x20the\x20idiom\x20verbatim\x20in\x20the\x20'+'build\x20notes\x20so\x20the\x20generated\x20guard\x20root\x20includes\x20it\x20(guard-risk\x20R-X1-14\x20then\x20audits\x20the\x20built\x20guard\x20and\x20flags\x20the\x20'+'un-wrapped\x20pseudo-protection\x20form).\x20Until\x20armed,\x20keep\x20the\x20Reward\x20pool\x20unfunded\x20—\x20an\x20unfunded\x20incentive\x20promise\x20is\x20'+'already\x20blocked\x20at\x20compile\x20(INV-4\x20reward_funding).'}];}function rewardFundedChecks(a){if(a['review_mode']!=='review_reward')return[];const b=Object['keys'](a['fee_params']??{}),c=b['some'](d=>/review_reward_pool|reward_pool/i['test'](d))||/review_reward_pool|reward_pool/i['test'](templateText(a))||a['reward_claim_policy']?.['max_total_per_recipient']!==undefined;if(c)return[];return[{'rule_id':'R-REWARD-FUNDED','severity':'high','title':'review_reward\x20template\x20declares\x20no\x20reward\x20pool\x20surface\x20—\x20an\x20unfunded\x20incentive\x20promise\x20must\x20not\x20publish\x20(INV-4)','detail':'review_mode\x20\x27review_reward\x27\x20promises\x20buyers\x20a\x20claim\x20reward,\x20but\x20the\x20template\x20declares\x20neither\x20a\x20pool\x20'+'fee_param\x20(review_reward_pool)\x20nor\x20a\x20pool-sizing\x20reward_claim_policy\x20cap.\x20At\x20compile\x20the\x20reward_funding\x20'+'input\x20hard-gates\x20the\x20build,\x20so\x20the\x20promise\x20dies\x20at\x20build\x20time\x20—\x20surface\x20the\x20pool\x20plan\x20in\x20the\x20template\x20'+'so\x20the\x20wizard\x20can\x20ask\x20the\x20funding\x20question\x20with\x20real\x20numbers.','suggestion':'Declare\x20a\x20review_reward_pool\x20fee_param\x20(>=\x20expected\x20orders\x20x\x20per-order\x20reward)\x20and\x20fund\x20it\x20at\x20build\x20time\x20'+'via\x20the\x20reward_funding\x20input\x20(sale-time\x20planning:\x20the\x20buyer\x20perceives\x20the\x20funded\x20reward\x20at\x20quote/buy),\x20'+'or\x20set\x20a\x20reward_claim_policy\x20max_total_per_recipient\x20that\x20sizes\x20the\x20pool.'}];}function compoundPayoutChecks(a){const b=templateText(a),c=a['allocator']['rows']??[],d=a['allocator']['refund_track']!==undefined||c['some'](f=>f['track']==='refund')||/refund|退款/i['test'](a['allocator']['description']);if(!d)return[];const e=a['guards']['some'](f=>f['host']==='arbitration')||a['trust_mechanisms']['some'](f=>/^R2\b/['test'](f))||/compensation[_ ]fund/i['test'](b);if(!e)return[];return[{'rule_id':'R-COMPOUND-01','severity':'low','title':'Dual\x20buyer-remedy\x20rails\x20(escrow\x20refund\x20+\x20compensation\x20fund)\x20—\x20the\x20arbitrator\x20nets\x20the\x20award','detail':'This\x20template\x20carries\x20BOTH\x20buyer-remedy\x20channels\x20by\x20design:\x20a\x20refund\x20Allocator\x20paying\x20out\x20of\x20the\x20order\x20escrow\x20AND\x20a\x20bound\x20'+'Arbitration\x20paying\x20out\x20of\x20the\x20Service\x27s\x20compensation\x20fund.\x20The\x20two\x20channels\x20are\x20independent\x20on-chain\x20and\x20the\x20platform\x20does\x20not\x20'+'hard-block\x20a\x20double\x20payout\x20at\x20the\x20protocol\x20level\x20—\x20that\x20is\x20an\x20intentional\x20commercial\x20game,\x20not\x20a\x20defect:\x20the\x20merchant\x20chose\x20the\x20'+'arbitrator,\x20and\x20the\x20arbitrator\x20rules\x20on\x20the\x20full\x20fund\x20picture.\x20Every\x20query\x20of\x20an\x20Arb\x20case\x20auto-attaches\x20the\x20order-side\x20fund\x20facts\x20'+'(_order_fund_facts:\x20amount,\x20escrow\x20balance,\x20withdraw\x20history,\x20claimed_by,\x20workflow\x20node),\x20and\x20every\x20case\x20operation\x20result\x20carries\x20'+'order_fund_facts,\x20so\x20a\x20refund-then-claim\x20ordering\x20is\x20visible\x20at\x20ruling\x20time\x20and\x20the\x20award\x20is\x20expected\x20to\x20net\x20out\x20the\x20already-refunded\x20principal.','suggestion':'No\x20structural\x20change\x20required.\x20Keep\x20the\x20operational\x20rule:\x20arbitrators\x20read\x20order_fund_facts\x20before\x20finalizing\x20the\x20indemnity\x20and\x20net\x20'+'any\x20positive\x20escrow_deficit\x20/\x20withdraw_history\x20payouts\x20against\x20the\x20award.\x20If\x20a\x20template\x20intends\x20a\x20non-monetary\x20remedy\x20instead,\x20say\x20so\x20'+'explicitly\x20in\x20the\x20arbitration\x20proposition\x20wording.'}];}function surplusTrackChecks(a){const b=a['allocator']['rows']??[],c=[],d=b['filter'](h=>h['track']==='refund'&&h['mode']==='surplus'),e=b['filter'](h=>h['track']==='settlement'&&h['mode']==='amount');d['length']>0x0&&e['length']>0x0&&c['push']({'rule_id':'R-SURPLUS-01','severity':'critical','title':'Refund-track\x20Surplus\x20sweeps\x20UNPAID\x20settlement\x20Amounts\x20out\x20of\x20the\x20shared\x20pool','detail':'An\x20order\x20funds\x20ONE\x20pool\x20—\x20`track`\x20is\x20a\x20build-time\x20grouping\x20the\x20chain\x20never\x20sees.\x20The\x20refund\x20row\x20'+'runs\x20Surplus\x20mode,\x20which\x20pays\x20the\x20ENTIRE\x20remaining\x20balance\x20(allocation.move:494-505;\x20template\x20rows\x20cannot\x20set\x20'+'`Allocator.max`,\x20so\x20the\x20sweep\x20is\x20uncapped),\x20while\x20the\x20settlement\x20track\x20still\x20carries\x20fixed\x20Amount\x20obligations\x20'+('('+e['map'](h=>h['recipient_key']??h['recipient'])['join'](',\x20')+').\x20Track\x20guards\x20are\x20independent\x20—\x20a\x20')+'time-locked\x20deposit\x20release\x20does\x20not\x20wait\x20for\x20month-gated\x20rent\x20—\x20so\x20when\x20the\x20refund\x20fires\x20first,\x20the\x20sweep\x20hands\x20'+'the\x20unpaid\x20Amounts\x20to\x20the\x20refund\x20recipient.\x20VERIFIED\x20LIVE\x20on\x20ziroom\x20mainnet\x20T-05:\x20the\x20deposit_back\x20Surplus\x20paid\x20'+'the\x20tenant\x20the\x20deposit\x20PLUS\x20the\x20unreleased\x20rent\x20(585/525\x20in\x20full);\x20the\x20landlord\x20received\x200.','suggestion':'Size\x20the\x20refund\x20leg\x20explicitly:\x20an\x20Amount\x20row\x20pinned\x20to\x20the\x20deposit\x20value\x20(value/value_from),\x20so\x20the\x20payout\x20can\x20'+'never\x20exceed\x20its\x20own\x20scope\x20—\x20or\x20split\x20the\x20two\x20fund\x20scopes\x20into\x20separate\x20Allocation\x20objects\x20so\x20a\x20sweep\x20can\x20only\x20'+'reach\x20its\x20own\x20pool.\x20If\x20an\x20uncapped\x20sweep\x20is\x20truly\x20intended,\x20gate\x20it\x20on\x20a\x20node\x20that\x20provably\x20follows\x20the\x20FINAL\x20'+'settlement\x20release,\x20and\x20state\x20in\x20the\x20template\x20that\x20any\x20obligation\x20unpaid\x20by\x20then\x20is\x20forfeit.'});const f=b['filter'](h=>h['track']==='settlement'&&h['mode']==='surplus'),g=b['filter'](h=>h['track']==='refund'&&h['mode']==='amount');return f['length']>0x0&&g['length']>0x0&&c['push']({'rule_id':'R-SURPLUS-02','severity':'high','title':'Settlement-track\x20Surplus\x20can\x20drain\x20the\x20pool\x20ahead\x20of\x20a\x20fixed-Amount\x20refund','detail':'The\x20settlement\x20sweep\x20(Surplus,\x20uncapped\x20—\x20allocation.move:494-505)\x20pays\x20the\x20merchant\x20the\x20entire\x20remainder\x20while\x20'+('the\x20refund\x20track\x20still\x20owes\x20fixed\x20Amounts\x20('+g['map'](h=>h['recipient_key']??h['recipient'])['join'](',\x20')+').\x20')+'If\x20the\x20settlement\x20guard\x20fires\x20while\x20a\x20refund\x20obligation\x20is\x20still\x20open\x20(the\x20tracks\x20are\x20gated\x20independently),\x20the\x20'+'pool\x20is\x20empty\x20when\x20the\x20refund\x20fires\x20and\x20alloc()\x20aborts\x20on\x20insufficient\x20balance\x20(allocation.move:390)\x20—\x20the\x20buyer\x20'+'remedy\x20is\x20bricked\x20and\x20the\x20merchant\x20keeps\x20money\x20the\x20template\x20declared\x20refundable.','suggestion':'Make\x20the\x20two\x20tracks\x20mutually\x20exclusive\x20by\x20construction\x20(refund\x20fires\x20only\x20from\x20cancel\x20nodes\x20the\x20settlement\x20'+'guard\x20can\x20never\x20reach,\x20and\x20vice\x20versa),\x20or\x20size\x20the\x20refund\x20as\x20a\x20Rate\x20so\x20it\x20degrades\x20to\x20a\x20share\x20instead\x20of\x20'+'aborting.\x20NOTE:\x20there\x20is\x20no\x20on-chain\x20holdback\x20(FACT-ALLOC-03)\x20—\x20do\x20NOT\x20try\x20to\x20\x27reserve\x27\x20the\x20refund\x20Amount\x20'+'via\x20a\x20fix\x20value;\x20split\x20the\x20two\x20fund\x20scopes\x20into\x20separate\x20Allocation\x20objects\x20if\x20isolation\x20is\x20required.'}),c;}const BRANCH_STATE_REGEX=/(cancel|return|withdraw|exit|expired)/i;function amountDeadlockChecks(a){const b=a['allocator']['rows']??[],c=b['filter'](f=>f['track']==='settlement');if(c['length']===0x0||!c['every'](f=>f['mode']==='amount'))return[];const d=[a['allocator']['description'],...a['build_notes'],...a['trust_mechanisms'],...a['guards']['map'](f=>f['template_id']+'\x20'+f['purpose'])]['join']('\x20\x0a\x20'),e=Object['keys'](a['fee_params'])['some'](f=>MIN_PRICE_KEY_REGEX['test'](f))||FLOOR_TEXT_REGEX['test'](d);if(e)return[];return[{'rule_id':'R-DEADLOCK-01','severity':'medium','title':'Settlement\x20track\x20is\x20ALL\x20fixed\x20Amount\x20—\x20an\x20under-funded\x20pool\x20deadlocks\x20permanently','detail':'Every\x20settlement\x20row\x20is\x20mode\x20\x27amount\x27\x20('+c['length']+'\x20row(s));\x20each\x20asserts\x20balance\x20>=\x20fix\x20at\x20release\x20'+'(allocation.move:390).\x20When\x20the\x20pool\x20is\x20smaller\x20than\x20the\x20pinned\x20leg\x20—\x20a\x20discount\x20code,\x20a\x20low-price\x20SKU,\x20a\x20'+'partially-funded\x20order\x20—\x20the\x20call\x20aborts\x20and\x20NO\x20later\x20call\x20can\x20settle\x20a\x20smaller\x20amount:\x20the\x20merchant\x27s\x20payout\x20'+'path\x20is\x20bricked\x20for\x20that\x20order\x20(ziroom\x20CR-02:\x20fixed\x20Amount\x20legs\x20+\x20a\x20cheap\x20SKU\x20=\x20permanent\x20settlement\x20abort).\x20'+'Rate\x20and\x20Surplus\x20legs\x20degrade\x20to\x20whatever\x20the\x20pool\x20actually\x20holds;\x20Amount\x20legs\x20cannot.','suggestion':'Carry\x20at\x20least\x20one\x20Rate/Surplus\x20leg\x20as\x20the\x20degradation\x20path\x20(e.g.\x20the\x20merchant\x20remainder\x20as\x20Rate).\x20'+'If\x20the\x20fixed\x20legs\x20are\x20the\x20design\x20(staged\x20tuition,\x20per-session\x20releases),\x20the\x20BUY\x20path\x20already\x20enforces\x20'+'order\x20>=\x20the\x20fixed-leg\x20SUM\x20per\x20order\x20(the\x20b6-11-family\x20fixed-leg\x20gate,\x20error\x20'+'order_below_fixed_leg_sum\x20—\x20a\x20discounted\x20order\x20is\x20rejected\x20before\x20any\x20money\x20moves),\x20so\x20the\x20template-side\x20'+'duty\x20narrows\x20to\x20pricing\x20every\x20SKU\x20at\x20or\x20above\x20the\x20fixed-leg\x20sum\x20(state\x20that\x20floor\x20in\x20fee_params)\x20—\x20a\x20SKU\x20'+'below\x20the\x20floor\x20could\x20never\x20complete\x20a\x20sale.'}];}const DISCOUNT_FIXED_KEY_REGEX=/(?:discount|coupon)[a-z0-9_]*(?:value|amount)/i,DISCOUNT_RATE_KEY_REGEX=/(?:discount|coupon)[a-z0-9_]*(?:rate_bps|bps|percent)/i,DISCOUNT_ISSUANCE_PROSE_REGEX=/create a discount|discount object|coupon handoff|run promotions|(?:mint|issue)\s+(?:a\s+|the\s+)?coupon|first-order discount/i,TIER_VARIANT_REGEX=/\btiers?\b|\bvariants?\b|\bpackages?\b|\bplans?\b/i;function numericFeeParam(a,b){const c=Object['keys'](a)['find'](d=>b['test'](d)&&typeof a[d]==='number');return c!==undefined?a[c]:undefined;}function railValue(a,b){if(typeof a['value']==='number')return a['value'];if(typeof a['value']==='string'&&/^\d+(\.\d+)?$/['test'](a['value']['trim']()))return Number(a['value']);if(a['value_from']!==undefined){const c=b[a['value_from']];if(typeof c==='number')return c;if(typeof c==='string'&&/^\d+(\.\d+)?$/['test'](c['trim']()))return Number(c);}return null;}function discountRailScaleChecks(a){const b=a['fee_params'],c=(a['allocator']['rows']??[])['filter'](n=>n['track']==='settlement'&&n['mode']==='amount');if(c['length']===0x0)return[];const d=numericFeeParam(b,DISCOUNT_FIXED_KEY_REGEX),e=numericFeeParam(b,DISCOUNT_RATE_KEY_REGEX),f=DISCOUNT_ISSUANCE_PROSE_REGEX['test'](templateText(a));if(d===undefined&&e===undefined&&!f)return[];const h=Object['keys'](b)['find'](n=>MIN_PRICE_KEY_REGEX['test'](n)&&typeof b[n]==='number'),j=h!==undefined?b[h]:undefined;let k;if(j!==undefined&&d!==undefined)k=Math['max'](0x0,j-d);else{if(j!==undefined&&e!==undefined)k=j*(0x2710-Math['min'](e,0x2710))/0x2710;}const l=n=>TIER_VARIANT_REGEX['test']((n['note']??'')+'\x20'+(n['guard_key']??'')),m=new Map();if(c['length']>=0x2&&c['every'](l))for(const n of c){const o=n['guard_key']??n['recipient_key']??'row/'+n['recipient'],p=m['get'](o)??{'label':o,'sum':0x0,'resolvable':!![]},q=railValue(n,b);if(q===null)p['resolvable']=![];else p['sum']+=q;m['set'](o,p);}else{let s=0x0,u=!![];for(const w of c){const x=railValue(w,b);if(x===null)u=![];else s+=x;}m['set']('settlement',{'label':'settlement','sum':s,'resolvable':u});}if(k!==undefined){const y=[...m['values']()]['filter'](z=>z['resolvable']&&z['sum']>k);if(y['length']>0x0)return[{'rule_id':'R-FAMT-SCALE','severity':'critical','title':'Absolute\x20Amount\x20rails\x20exceed\x20the\x20minimum\x20post-discount\x20payable\x20('+y['map'](z=>z['label']+':\x20'+z['sum']+'\x20>\x20'+k)['join'](';\x20')+')','detail':'This\x20template\x20combines\x20ABSOLUTE\x20Amount\x20rails\x20with\x20a\x20discount\x20configuration,\x20and\x20the\x20arithmetic\x20is\x20'+('resolvable\x20at\x20build\x20time:\x20minimum\x20order\x20value\x20'+j+'\x20('+h+')\x20minus\x20the\x20discount\x20leaves\x20'+k+',\x20')+'while\x20the\x20settlement\x20Amount\x20rail(s)\x20named\x20above\x20sum\x20to\x20more.\x20On\x20chain\x20the\x20order\x20escrows\x20the\x20POST-discount\x20'+'total\x20(the\x20discounted-quote\x20computation,\x20service.move:370-383)\x20and\x20every\x20Amount\x20leg\x20asserts\x20balance\x20>=\x20fix\x20at\x20release\x20'+'(allocation.move:390)\x20—\x20the\x20LAST\x20rail\x20to\x20fire\x20aborts\x20mid-workflow\x20and\x20the\x20order\x20strands\x20with\x20its\x20remaining\x20'+'pool.\x20Machines\x20and\x20allocators\x20are\x20immutable\x20after\x20publish:\x20no\x20late\x20repair\x20exists.\x20Offending\x20rail\x20'+('scope(s)\x20(each\x20tier\x20judged\x20on\x20its\x20own\x20selected\x20variant,\x20not\x20the\x20first\x20row):\x20'+y['map'](z=>z['label'])['join'](',\x20')+'.'),'suggestion':'Shrink\x20the\x20rails\x20to\x20fit\x20the\x20discounted\x20floor\x20('+y['map'](z=>z['label']+'\x20<=\x20'+k)['join'](',\x20')+'),\x20or\x20'+'express\x20the\x20rails\x20as\x20Rate/RateGross\x20legs\x20which\x20degrade\x20to\x20whatever\x20the\x20discounted\x20pool\x20actually\x20holds.\x20A\x20'+'percentage\x20discount\x20keeps\x20rails\x20payable\x20only\x20when\x20the\x20rails\x20are\x20percentage-based\x20too.'}];if([...m['values']()]['every'](z=>z['resolvable']))return[];}return[{'rule_id':'R-FAMT-SCALE','severity':'medium','title':'Absolute\x20Amount\x20rails\x20combined\x20with\x20a\x20discount\x20—\x20the\x20tail\x20rail\x20can\x20strand\x20when\x20the\x20discounted\x20total\x20undercuts\x20the\x20rails','detail':'This\x20template\x20directs\x20the\x20build\x20to\x20attach\x20a\x20Service-side\x20discount\x20(coupon)\x20while\x20its\x20settlement\x20track\x20carries\x20fixed\x20'+'Amount\x20rails.\x20The\x20order\x20escrows\x20the\x20POST-discount\x20total\x20(the\x20discounted-quote\x20computation,\x20service.move:370-383)\x20and\x20every\x20'+'Amount\x20leg\x20asserts\x20balance\x20>=\x20fix\x20at\x20release\x20(allocation.move:390),\x20so\x20whenever\x20the\x20discounted\x20payable\x20falls\x20below\x20'+'the\x20rail\x20sum\x20the\x20LAST\x20rail\x20aborts\x20and\x20the\x20order\x20strands\x20—\x20unrepairable\x20after\x20publish.\x20The\x20minimum\x20post-discount\x20'+'payable\x20cannot\x20be\x20resolved\x20at\x20build\x20time\x20here\x20(the\x20order\x20value\x20is\x20a\x20merchant\x20runtime\x20input\x20such\x20as\x20the\x20SKU\x20price,\x20'+'or\x20the\x20discount\x20magnitude\x20is\x20declared\x20only\x20in\x20prose),\x20so\x20the\x20scale\x20cannot\x20be\x20proven\x20safe\x20statically.','suggestion':'Prefer\x20percentage-based\x20rails:\x20express\x20the\x20settlement\x20legs\x20as\x20Rate/RateGross\x20(which\x20degrade\x20to\x20whatever\x20the\x20'+'discounted\x20pool\x20holds)\x20instead\x20of\x20fixed\x20Amounts\x20—\x20or\x20pin\x20BOTH\x20sides\x20machine-checkably\x20(a\x20numeric\x20min_*\x20'+'order-value\x20floor\x20in\x20fee_params\x20plus\x20a\x20numeric\x20discount\x20magnitude\x20key)\x20so\x20the\x20build-time\x20scale\x20check\x20can\x20run.\x20'+'Otherwise\x20keep\x20the\x20discount\x20budget\x20documented\x20so\x20the\x20merchant\x20prices\x20coupons\x20above\x20the\x20rail\x20sum.'}];}function cancelCoverageChecks(a){const b=a['allocator']['rows']??[];if(b['some'](d=>d['track']==='refund'))return[];if(a['allocator']['refund_track']!==undefined)return[];const c=a['machine_shape']['find'](d=>BRANCH_STATE_REGEX['test'](d['name']));if(!c)return[];return[{'rule_id':'R-CANCEL-01','severity':'high','title':'Machine\x20models\x20\x27'+c['name']+'\x27\x20but\x20the\x20allocator\x20has\x20NO\x20refund-track\x20rows\x20—\x20money\x20locks\x20on\x20that\x20path','detail':'The\x20machine\x20shape\x20carries\x20a\x20cancel/return/exit\x20state,\x20yet\x20no\x20allocator\x20row\x20pays\x20on\x20the\x20refund\x20track.\x20Text-level\x20'+'claims\x20(guard\x20purposes,\x20allocator\x20description)\x20may\x20still\x20say\x20\x27refund\x27,\x20but\x20on\x20chain\x20only\x20rows\x20move\x20money:\x20an\x20'+'order\x20that\x20reaches\x20this\x20state\x20keeps\x20its\x20escrow\x20with\x20no\x20rail\x20out\x20(ofn\x20#P-02:\x20the\x20subscription\x20template\x27s\x20refund\x20'+'rails\x20missed\x20closed_cancel\x20and\x200.5\x20WOW\x20locked\x20permanently;\x20verified\x20live).','suggestion':'Add\x20refund-track\x20rows\x20covering\x20EVERY\x20cancel-ish\x20terminal\x20(order-anchored\x20GuardIdentifier(0)\x20recipient,\x20'+'Rate-sized\x20with\x20the\x20group\x20summing\x2010000),\x20or\x20remove\x20the\x20state\x20from\x20the\x20machine\x20so\x20orders\x20can\x20never\x20enter\x20it.'}];}function redundGuardObjectMismatchChecks(a){const b=a['allocator']['rows']??[],c=b['filter'](h=>h['track']==='refund'&&h['recipient']==='guard_identifier');if(c['length']===0x0)return[];const d=new Set(c['map'](h=>h['guard_key'])['filter'](h=>typeof h==='string')),e=a['guards']['some'](h=>h['key']!==undefined&&d['has'](h['key'])&&(/arb|ruling|arbitration/i['test'](h['template_id'])||/arb|ruling|arbitration/i['test'](h['purpose'])));if(!e)return[];const f=templateText(a),g=/two[- ]slot|slot\s*0.*order|slot\s*1.*arb|arb\.order.*==|for_object.*binding/i['test'](f);if(g)return[{'rule_id':'REDUND-GUARD-OBJECT-MISMATCH','severity':'low','title':'Arb-refund\x20guard\x20uses\x20two-slot\x20design\x20(Order\x20+\x20Arb)\x20—\x20self-certifying\x20pair','detail':'The\x20template\x20carries\x20a\x20refund\x20allocator\x20row\x20with\x20a\x20GuardIdentifier\x20recipient\x20AND\x20an\x20arbitration-ruling\x20guard.\x20'+'The\x20two-slot\x20design\x20(slot\x200\x20=\x20Order\x20for\x20the\x20allocator\x20recipient,\x20slot\x201\x20=\x20Arb\x20for\x20the\x20ruling\x20state)\x20is\x20the\x20'+'correct\x20resolution\x20of\x20the\x20F-02\x20slot\x20conflict:\x20the\x20allocator\x20reads\x20slot\x200\x20(payment_info.for_object\x20binding),\x20'+'the\x20forward\x20reads\x20slot\x201\x20(arb.indemnity\x20state),\x20and\x20the\x20binding\x20assertion\x20query(\x22arb.order\x22,\x20slot1)\x20==\x20slot0\x20'+'makes\x20the\x20pair\x20self-certifying\x20against\x20redirect\x20attacks.','suggestion':'Verify\x20the\x20guard\x20is\x20tpl_forward_arb_ruling_won\x20(two-slot\x20form)\x20or\x20an\x20equivalent\x20custom\x20guard\x20with\x20the\x20same\x20'+'slot\x20layout\x20and\x20binding\x20assertion.\x20Single-slot\x20arb-refund\x20guards\x20are\x20unreachable\x20(F-02).'}];return[{'rule_id':'REDUND-GUARD-OBJECT-MISMATCH','severity':'high','title':'Arb-refund\x20guard\x20may\x20use\x20a\x20SINGLE\x20slot\x20—\x20unreachable\x20rail\x20(F-02)','detail':'The\x20template\x20carries\x20a\x20refund\x20allocator\x20row\x20with\x20a\x20GuardIdentifier\x20recipient\x20AND\x20an\x20arbitration-ruling\x20guard,\x20'+'but\x20the\x20template\x20text\x20does\x20not\x20mention\x20the\x20two-slot\x20design.\x20A\x20single-slot\x20guard\x20cannot\x20satisfy\x20both\x20consumers:\x20'+'the\x20forward\x20needs\x20the\x20Arb\x20object\x20(to\x20read\x20arb.indemnity),\x20while\x20the\x20allocator\x20recipient\x20GuardIdentifier(0)\x20needs\x20'+'the\x20Order\x20object\x20(payment_info.for_object\x20binding).\x20F-02\x20verified\x20live:\x20Order\x20address\x20→\x20forward\x20aborts;\x20Arb\x20address\x20'+'→\x20allocation\x20aborts\x2015\x20(ERECIPIENT_NOT_FOR_OBJECT).\x20The\x20escrow\x20strands\x20permanently\x20with\x20no\x20on-chain\x20exit.','suggestion':'Use\x20tpl_forward_arb_ruling_won\x20(two-slot\x20form:\x20slot\x200\x20=\x20Order,\x20slot\x201\x20=\x20Arb,\x20with\x20arb.order\x20==\x20order\x20binding),\x20'+'or\x20document\x20the\x20two-slot\x20design\x20explicitly\x20in\x20the\x20template\x20build_notes.\x20A\x20single-slot\x20arb-refund\x20guard\x20is\x20'+'unreachable\x20by\x20construction\x20(F-02).'}];}function zeroAmountGuardChecks(a){const b=templateText(a),c=/zero[- ]amount|0[ -]?amount|free[^a-z]|price\s*=\s*0|amount\s*>\s*0|min_booking_amount/i['test'](b)||/no[- ]charge|gratis|complimentary/i['test'](b);if(c)return[];const d=new Set((a['allocator']['rows']??[])['map'](f=>f['guard_key'])['filter'](f=>typeof f==='string')),e=a['guards']['some'](f=>f['host']==='machine'&&!(f['key']!==undefined&&d['has'](f['key']))&&(/claimed_by|allocation|payment\s|alloc\b/i['test'](f['template_id'])||/claimed_by|allocation|payment\s|alloc\b/i['test'](f['purpose']))&&!/refund|pro-?rata|staged[_ -]?release|recovery|polarity/i['test'](f['template_id']+'\x20'+f['purpose']));if(!e)return[];return[{'rule_id':'D7-ZERO-AMOUNT-GUARD','severity':'medium','title':'Machine\x20progress\x20guards\x20may\x20depend\x20on\x20allocator\x20events\x20—\x20zero-amount\x20orders\x20deadlock','detail':'The\x20protocol\x20does\x20NOT\x20create\x20an\x20Allocation\x20for\x20a\x20zero-amount\x20order\x20(amount\x20>\x200\x20is\x20required).\x20'+'A\x20zero-amount\x20order\x20therefore\x20has\x20NO\x20claimed_by,\x20NO\x20payment\x20history,\x20and\x20NO\x20allocation\x20balance.\x20'+'This\x20template\x20carries\x20machine\x20guards\x20that\x20reference\x20allocator-dependent\x20state\x20(claimed_by\x20/\x20allocation\x20/\x20payment),\x20'+'but\x20the\x20template\x20does\x20NOT\x20explicitly\x20exclude\x20zero-amount\x20items.\x20A\x20zero-amount\x20order\x20can\x20never\x20satisfy\x20such\x20a\x20guard\x20'+'and\x20deadlocks\x20at\x20the\x20node\x20with\x20no\x20exit.','suggestion':'Either\x20(a)\x20exclude\x20zero-amount\x20items\x20explicitly\x20(e.g.\x20min_booking_amount,\x20amount\x20>\x200\x20in\x20build_notes),\x20or\x20'+'(b)\x20redesign\x20progress\x20guards\x20to\x20use\x20order-native\x20signals\x20(order.time,\x20signer,\x20progress.current,\x20Repository\x20data)\x20'+'instead\x20of\x20allocator-derived\x20state,\x20so\x20zero-amount\x20orders\x20can\x20still\x20advance.'}];}function terminalRailCoverageChecks(a){const b=a['machine_shape'];if(b['length']===0x0||!b['some'](w=>(w['from']??[])['length']>0x0))return[];const c=a['allocator']['rows']??[];if(c['length']===0x0)return[];const d=[...a['guards']['map'](w=>w['purpose']),...c['map'](w=>w['note']??'')];if(!d['some'](w=>/current\s*==/i['test'](w)))return[];const f=a['allocator']['description']??'',g=new Set();for(const w of b){for(const x of w['from']??[]){const y=typeof x==='string'?x:x?.['prev'];if(y)g['add'](y);}}const h=b['filter'](z=>!g['has'](z['name']));if(h['length']===0x0)return[];const j=z=>z['replace'](/[.*+?^${}()|[\]\\]/g,'\x5c$&'),k=z=>{const A=new RegExp('current\x5cs*==\x5cs*[\x22\x27]?'+j(z)+'\x5cb','i');if(a['guards']['some'](C=>A['test'](C['purpose'])))return!![];if(c['some'](C=>C['note']!==undefined&&A['test'](C['note'])))return!![];const B=new RegExp('\x5cb'+j(z)+'\x5cb','i');if(a['guards']['some'](C=>B['test'](C['purpose'])))return!![];if(c['some'](C=>C['note']!==undefined&&B['test'](C['note'])))return!![];return B['test'](f);},l=z=>/pool is empty|pool drains?ed|drains? in full|already (?:released|paid)|escrow (?:is )?(?:empty|drained)/i['test'](z),n=h['filter'](z=>!k(z['name'])&&!l(z['role']))['map'](z=>'\x27'+z['name']+'\x27'),o=/cancel|refund|return|withdraw|compensat/i,p=/refund|repay|chargeback|compensat/i,q=z=>z['semantic_role']==='cancelled'||o['test'](z['name']),s=z=>{const A=new RegExp('current\x5cs*==\x5cs*[\x22\x27]?'+j(z)+'\x5cb','i'),B=new RegExp('\x5cb'+j(z)+'\x5cb','i');if(c['some'](C=>C['track']==='refund'&&(A['test'](C['note']??'')||B['test'](C['note']??''))))return!![];return a['guards']['some'](C=>(A['test'](C['purpose'])||B['test'](C['purpose']))&&p['test'](C['template_id']+'\x20'+C['purpose']));},u=h['filter'](z=>q(z)&&k(z['name'])&&!s(z['name'])&&!l(z['role']))['map'](z=>'\x27'+z['name']+'\x27'),v=[];return n['length']>0x0&&v['push']({'rule_id':'TERMINAL-NO-RAIL','severity':'critical','title':'Terminal\x20node(s)\x20'+n['join'](',\x20')+'\x20have\x20no\x20allocator\x20rail\x20—\x20escrow\x20strands\x20permanently\x20(publish\x20blocked)','detail':'An\x20order\x20that\x20reaches\x20a\x20terminal\x20node\x20moves\x20no\x20money\x20by\x20itself:\x20settlement\x20is\x20a\x20separate\x20keeper\x20'+'submit\x20against\x20an\x20allocator\x20whose\x20guard\x20anchors\x20that\x20node\x20(progress.current\x20==\x20<terminal>).\x20'+'A\x20terminal\x20without\x20a\x20rail\x20publishes\x20into\x20a\x20permanent\x20strand\x20—\x20the\x20escrow\x20of\x20every\x20order\x20that\x20stops\x20'+'there\x20is\x20unrecoverable\x20(mainnet\x20az-mn-261007:\x200.299\x20stranded;\x20ofshop:\x200.25\x20stranded\x20at\x20\x27expired\x27),\x20'+'and\x20topology\x20+\x20allocators\x20are\x20both\x20immutable\x20after\x20publish.\x20Either\x20this\x20terminal\x20needs\x20its\x20own\x20'+'settlement/refund\x20rail\x20(canonical\x20guard\x20designs:\x20tpl_allocator_node_gate_settle\x20/\x20'+'tpl_allocator_node_gate_refund,\x20M-T12),\x20or\x20the\x20pool\x20legitimately\x20drains\x20at\x20an\x20EARLIER\x20node\x20—\x20in\x20'+'which\x20case\x20document\x20that\x20in\x20the\x20terminal\x27s\x20role\x20(e.g.\x20\x27pool\x20is\x20empty\x27)\x20so\x20this\x20rule\x20can\x20exempt\x20it.','suggestion':'For\x20each\x20listed\x20terminal:\x20add\x20an\x20allocator\x20row\x20whose\x20guard\x20purpose\x20anchors\x20progress.current\x20==\x20<terminal>,\x20'+'or\x20state\x20in\x20the\x20node\x20role\x20that\x20the\x20pool\x20is\x20already\x20empty\x20when\x20the\x20terminal\x20is\x20reached.'}),u['length']>0x0&&v['push']({'rule_id':'TERMINAL-WRONG-RAIL','severity':'critical','title':'Refund\x20terminal(s)\x20'+u['join'](',\x20')+'\x20anchored\x20ONLY\x20by\x20the\x20settlement\x20track\x20—\x20the\x20refund\x20pays\x20the\x20merchant\x20(publish\x20blocked)','detail':'A\x20cancel-flavored\x20terminal\x20must\x20drain\x20through\x20the\x20REFUND\x20track\x20(order-anchored\x20GuardIdentifier\x20rows):\x20'+'the\x20only\x20anchor\x20that\x20currently\x20covers\x20it\x20lives\x20on\x20a\x20settlement\x20row\x20or\x20a\x20guard\x20with\x20no\x20refund\x20intent,\x20'+'and\x20a\x20settlement\x20rail\x20resolves\x20its\x20recipients\x20to\x20the\x20merchant\x20side.\x20Triggered\x20that\x20way,\x20the\x20buyer\x27s\x20'+'refund\x20is\x20paid\x20to\x20the\x20counterparty\x20—\x20same\x20irreversibility\x20class\x20as\x20a\x20missing\x20rail\x20(topology\x20and\x20'+'allocators\x20are\x20immutable\x20after\x20publish).','suggestion':'For\x20each\x20listed\x20terminal:\x20add\x20refund-track\x20rows\x20anchored\x20to\x20it\x20(progress.current\x20==\x20<terminal>\x20on\x20a\x20'+'track:\x22refund\x22\x20row\x20note,\x20or\x20a\x20guard\x20purpose\x20that\x20names\x20both\x20the\x20node\x20and\x20the\x20refund\x20intent),\x20or\x20state\x20'+'in\x20the\x20node\x20role\x20that\x20the\x20pool\x20is\x20already\x20empty\x20when\x20the\x20terminal\x20is\x20reached.'}),v;}function railNodeDriftChecks(a){const b=a['machine_shape'];if(b['length']===0x0)return[];const c=a['allocator']['rows']??[],d=[...a['guards']['map'](h=>h['purpose']),...c['map'](h=>h['note']??'')];if(!d['some'](h=>/current\s*==|current_time\s+of/i['test'](h)))return[];d['push'](a['allocator']['description']??'');const e=new Set(b['map'](h=>h['name']['toLowerCase']())),f=new Set(),g=h=>{const j=(h[0x1]??h[0x2]??'')['trim']();if(j===''||/^<.*>$/['test'](j))return;if(!/^[A-Za-z0-9_]+$/['test'](j))return;if(!e['has'](j['toLowerCase']()))f['add']('\x27'+j+'\x27');};for(const h of d){for(const j of h['matchAll'](/current\s*==\s*(?:"([^"]+)"|'([^']+)')/gi))g(j);for(const k of h['matchAll'](/current_time\s+of\s+(?:"([^"]+)"|'([^']+)')/gi))g(k);}if(f['size']===0x0)return[];return[{'rule_id':'RAIL-NODE-DRIFT','severity':'high','title':'Progress\x20anchor(s)\x20'+[...f]['join'](',\x20')+'\x20name\x20no\x20machine_shape\x20node\x20—\x20the\x20rail\x20can\x20never\x20fire','detail':'These\x20progress\x20anchors\x20(current\x20==\x20\x27X\x27\x20/\x20current_time\x20of\x20\x27X\x27)\x20reference\x20node\x20names\x20absent\x20from\x20'+'machine_shape,\x20so\x20the\x20guard\x20can\x20never\x20match\x20a\x20real\x20progress\x20state\x20and\x20whatever\x20the\x20rail\x20drains\x20'+'(settlement,\x20refund,\x20compensation)\x20strands\x20permanently.\x20The\x20usual\x20cause\x20is\x20a\x20node\x20rename\x20that\x20did\x20'+'not\x20propagate:\x20rails\x20pinned\x20\x27cancelled\x27\x20while\x20the\x20node\x20shipped\x20as\x20\x27guest_cancelled\x27\x20killed\x20every\x20'+'refund\x20path\x20on\x20a\x20live\x20store.\x20Chain\x20publishability\x20does\x20NOT\x20compare\x20anchor\x20literals\x20against\x20the\x20'+'node\x20set\x20—\x20this\x20prose-drift\x20is\x20only\x20visible\x20to\x20a\x20scan.','suggestion':'Align\x20each\x20listed\x20anchor\x20with\x20the\x20actual\x20machine_shape\x20node\x20name\x20(preferred:\x20update\x20the\x20guard\x20'+'purpose\x20/\x20allocator\x20note\x20to\x20the\x20current\x20node\x20name),\x20or\x20restore\x20the\x20node\x20name\x20in\x20machine_shape\x20'+'if\x20the\x20anchor\x20was\x20correct\x20and\x20the\x20shape\x20drifted.'}];}function siblingForwardExclusivityChecks(a){const b=a['machine_shape'];if(b['length']===0x0)return[];const d=new Map();for(const n of a['guards'])if(n['key'])d['set'](n['key'],n);const f=new Map();for(const o of a['conditional_guards']??[]){f['set'](o['param'],(f['get'](o['param'])??0x0)+0x1);}const h=new Set((a['conditional_guards']??[])['filter'](p=>(f['get'](p['param'])??0x0)>0x1)['map'](p=>p['guard_key'])),j=a['allocator']['rows']??[],k=p=>{const q=j['find'](s=>s['guard_key']===p||s['guard_key']===p+'_refund');return q?String(q['value']??q['value_from']??q['mode']):undefined;},l=p=>{if(!p)return![];const q=d['get'](p);if(!q)return![];return/time_lock/['test'](q['template_id'])||/until\b|within\b|\bdays?\b|\bhours?\b|\bwindow\b|deadline|before (?:check[- ]?in|delivery|deadline)/i['test'](q['purpose']);},m=[];for(const p of b){const q=new Map();for(const s of p['from']??[]){const u=typeof s==='string'?{'prev':s}:s;if(!u['prev'])continue;const v=u['operator']??(u['permission_index']!==undefined?'perm:'+u['permission_index']:p['operator']??'merchant'),w=q['get'](u['prev'])??[];w['push']({'guard_key':u['guard_key'],'actor':v}),q['set'](u['prev'],w);}for(const [x,y]of q){const z=y['filter'](F=>F['guard_key']!==undefined);if(z['length']<0x2)continue;const A=new Set(z['map'](F=>F['actor']));if(A['size']>0x1)continue;const B=z['filter'](F=>l(F['guard_key']));if(B['length']<0x2)continue;if(B['every'](F=>h['has'](F['guard_key'])))continue;const C=B['map'](F=>F['guard_key']),D=[...new Set(C['map'](F=>k(F))['filter'](F=>F!==undefined&&F!==''))],E=D['length']>0x1;m['push']({'rule_id':'SIBLING-FORWARD-EXCLUSIVITY','severity':E?'high':'medium','title':'Node\x20\x27'+p['name']+'\x27\x20(pair\x20from\x20\x27'+x+'\x27)\x20carries\x20'+B['length']+'\x20sibling\x20forwards\x20gated\x20by\x20'+('time-window\x20guards\x20under\x20one\x20actor\x20('+[...A]['join']('/')+')\x20—\x20no\x20on-chain\x20mutual\x20exclusion'),'detail':E?'Sibling\x20guards\x20resolve\x20to\x20DIFFERENT\x20settlement\x20amounts\x20('+D['join']('\x20vs\x20')+').\x20Sibling\x20forwards\x20on\x20one\x20'+'NodePair\x20have\x20no\x20on-chain\x20mutual\x20exclusion\x20and\x20Order.allocation\x20is\x20write-once\x20—\x20all\x20their\x20rails\x20share\x20'+'ONE\x20immutable\x20pool,\x20so\x20overlapping\x20windows\x20let\x20the\x20actor\x20fire\x20the\x20most\x20favourable\x20branch\x20(79678\x20audit\x20'+'F-01.1:\x20a\x20guest\x2040\x20days\x20out\x20can\x20satisfy\x20both\x20a\x20full-refund\x20and\x20a\x20partial-refund\x20tier).':'Sibling\x20forwards\x20on\x20one\x20NodePair\x20have\x20no\x20on-chain\x20mutual\x20exclusion;\x20if\x20their\x20time\x20windows\x20overlap,\x20the\x20'+'actor\x20picks\x20the\x20branch.\x20Verify\x20the\x20intervals\x20are\x20mutually\x20exclusive\x20by\x20construction.','suggestion':E?'Emit\x20ONE\x20forward\x20+\x20ONE\x20rail\x20per\x20selected\x20option\x20(M-T7\x20conditional\x20emission,\x20e.g.\x20user_inputs\x20cancellation_policy\x201..6),\x20'+'or\x20make\x20the\x20guards\x27\x20intervals\x20provably\x20disjoint\x20so\x20at\x20most\x20one\x20can\x20pass\x20at\x20any\x20moment.':'Make\x20the\x20sibling\x20guards\x27\x20time\x20intervals\x20provably\x20disjoint\x20(at\x20most\x20one\x20satisfiable\x20at\x20any\x20moment),\x20'+'or\x20split\x20each\x20option\x20onto\x20its\x20own\x20NodePair\x20so\x20mounting\x20is\x20a\x20build-time\x20choice.'});}}return m;}function serialClaimWindowChecks(a){const b=a['machine_shape']['some'](h=>/claim(?!ed_by)/i['test'](h['name']))||a['guards']['some'](h=>/claim/i['test'](h['key']??'')&&h['host']!=='reward');if(!b)return[];const c=a['allocator']['rows']??[],d=c['some'](h=>h['track']==='settlement'&&(h['mode']==='surplus'||h['mode']==='rate'&&h['value']===0x2710));if(!d)return[];const e=templateText(a),f=a['machine_shape']['some'](h=>/claim_window/i['test'](h['name'])),g=/serial claim[- ]window|claim_window.*serial|serial[- ]claim|claims? (is|are|always) adjudicated while the pool is intact|between checkout and payout|before (any )?release/i['test'](e);if(f&&g)return[{'rule_id':'D2-SERIAL-CLAIM-WINDOW','severity':'low','title':'Serial\x20claim\x20window\x20gates\x20the\x20full-drain\x20release\x20(ABNB2-validated\x20design)','detail':'The\x20template\x20carries\x20claim\x20machinery\x20AND\x20a\x20full-drain\x20settlement\x20group\x20(Rate\x2010000\x20/\x20Surplus),\x20'+'and\x20resolves\x20the\x20race\x20with\x20a\x20serial\x20claim_window\x20node\x20between\x20delivery\x20confirmation\x20and\x20payout:\x20'+'the\x20release\x20can\x20only\x20fire\x20after\x20the\x20window\x20closed\x20with\x20no\x20upheld\x20claim,\x20so\x20the\x20pool\x20is\x20intact\x20'+'whenever\x20money\x20moves.','suggestion':'Verify\x20the\x20release\x20guard\x20anchors\x20on\x20progress.current_time\x20of\x20the\x20claim_window\x20entry\x20'+'(witness-derived),\x20not\x20on\x20order.time\x20—\x20a\x20booking-time\x20delay\x20has\x20always\x20expired\x20before\x20'+'checkout\x20and\x20gives\x20no\x20post-delivery\x20protection.'}];return[{'rule_id':'D2-SERIAL-CLAIM-WINDOW','severity':'high','title':'Full-drain\x20release\x20can\x20fire\x20while\x20a\x20claim\x20is\x20still\x20openable\x20—\x20FCFS\x20race\x20on\x20one\x20pool\x20(FACT-ALLOC-03)','detail':'The\x20template\x20carries\x20claim\x20machinery\x20AND\x20a\x20full-drain\x20settlement\x20group\x20(Rate\x2010000\x20or\x20Surplus),\x20'+'but\x20no\x20serial\x20claim_window\x20node\x20orders\x20them:\x20the\x20payout\x20and\x20a\x20later\x20claim\x20race\x20first-come-first-served\x20'+'on\x20the\x20SAME\x20pool,\x20and\x20the\x20chain\x20has\x20no\x20holdback\x20primitive\x20(fix\x20is\x20the\x20PAID\x20sum\x20of\x20Amount\x20legs,\x20'+'allocation.move:399,540).\x20Once\x20the\x20release\x20fires,\x20a\x20claim\x20can\x20pay\x20nothing\x20from\x20the\x20pool.\x20'+'Airbnb\x20mainnet\x20audit\x202026-10-07:\x20the\x20parallel\x20payout/claim\x20design\x20paid\x20the\x20host\x20in\x20full\x20and\x20left\x20'+'the\x20claim\x20window\x20with\x20an\x20empty\x20pool.','suggestion':'Insert\x20a\x20SERIAL\x20claim_window\x20node\x20between\x20delivery\x20confirmation\x20and\x20payout\x20(ABNB2-validated):\x20'+'checkout\x20→\x20claim_window\x20→\x20payout,\x20with\x20exactly\x20two\x20exits\x20—\x20FileClaim\x20(inside\x20the\x20window,\x20'+'Clock\x20<=\x20current_time(claim_window)\x20+\x20claim_window_days)\x20and\x20ReleaseNoClaim\x20(window\x20elapsed).\x20'+'Gate\x20the\x20release\x20allocator\x20on\x20the\x20post-window\x20node,\x20and\x20give\x20a\x20denied\x20claim\x20its\x20own\x20release\x20'+'forward\x20so\x20no\x20stop\x20node\x20holds\x20funds.'}];}function dismissEdgeGuardChecks(a){const b=a['machine_shape']['some'](d=>/claim/i['test'](d['name']))||a['guards']['some'](d=>/claim/i['test'](d['purpose']));if(!b)return[];const c=[];for(const d of a['machine_shape']){for(const e of d['from']??[]){if(typeof e==='string')continue;if(!e['forward']||!/dismiss|denied|rejected/i['test'](e['forward']))continue;if(e['guard_key']&&e['guard_key']['trim']()!=='')continue;c['push']((e['prev']??'?')+'\x20─'+e['forward']+'→\x20'+d['name']);}}if(c['length']===0x0)return[];return[{'rule_id':'D2-DISMISS-EDGE-GUARD','severity':'high','title':'Claim-dismissal\x20edge\x20is\x20a\x20bare\x20permission\x20wire\x20—\x20the\x20platform\x20can\x20dismiss\x20and\x20release\x20with\x20no\x20ruling\x20evidence\x20(N-T2)','detail':'These\x20dismissal\x20edges\x20carry\x20permission_index\x20but\x20NO\x20guard:\x20'+c['join'](';\x20')+'.\x20The\x20holder\x20of\x20that\x20permission\x20can\x20dismiss\x20the\x20buyer\x27s\x20claim\x20and\x20fire\x20the\x20release/payout\x20in\x20one\x20'+'step,\x20with\x20nothing\x20on-chain\x20proving\x20a\x20ruling\x20ever\x20happened\x20—\x20the\x20serial\x20claim\x20window\x27s\x20time\x20'+'ordering\x20is\x20defeated\x20by\x20its\x20own\x20escape\x20hatch.','suggestion':'Gate\x20each\x20dismissal\x20edge\x20on\x20tpl_forward_arb_ruling_dismissed\x20(arb.order\x20==\x20order\x20AND\x20'+'arb.indemnity.amount\x20==\x200):\x20the\x20native\x20indemnity.amount\x20query\x20errors\x20on\x20a\x20None\x20field,\x20so\x20the\x20'+'leg\x20passes\x20ONLY\x20for\x20a\x20standing\x20Some(0)\x20ruling\x20—\x20never-ruled\x20and\x20reset/objection\x20states\x20(both\x20'+'None)\x20fail\x20closed,\x20and\x20a\x20buyer-favor\x20ruling\x20(Some(>0))\x20fails\x20the\x20equality.\x20ONE\x20INSTANCE\x20PER\x20'+'dismissal\x20edge\x20—\x20never\x20share\x20the\x20guard\x20between\x20two\x20forwards.\x20Never\x20express\x20the\x20gate\x20as\x20'+'\x27arb.indemnity\x20some\x20==\x20false\x27\x20or\x20arb.status\x20(R-X1-16).'}];}function noteNodeDriftChecks(a){const b=new Set(a['machine_shape']['map'](d=>d['name']['toLowerCase']())),c=[];for(const d of a['build_notes']??[]){for(const e of d['matchAll'](/must (?:create|add|declare|include)[^.;]*?'([a-z0-9_]+)'/gi)){const f=e[0x1]['toLowerCase']();if(!b['has'](f))c['push']('\x27'+f+'\x27');}}if(c['length']===0x0)return[];return[{'rule_id':'NOTE-NODE-DRIFT','severity':'medium','title':'A\x20build_note\x20mandates\x20a\x20node\x20the\x20machine_shape\x20does\x20not\x20contain\x20—\x20prose\x20running\x20ahead\x20of\x20structure\x20(N-T6)','detail':'These\x20node\x20names\x20appear\x20under\x20MUST-create\x20language\x20in\x20build_notes\x20but\x20are\x20absent\x20from\x20machine_shape:\x20'+c['join'](',\x20')+'.\x20The\x20generator\x20will\x20read\x20the\x20note\x20and\x20invent\x20a\x20topology\x20the\x20structural\x20audit\x20(edges,\x20reachability,\x20'+'fund-exit\x20coverage)\x20never\x20examined\x20—\x20exactly\x20how\x20unguarded\x20edges\x20and\x20orphan\x20nodes\x20escaped\x20earlier\x20audits.','suggestion':'Either\x20land\x20the\x20mandated\x20node\x20in\x20machine_shape\x20WITH\x20its\x20from-edges\x20in\x20the\x20same\x20edit\x20(a\x20spliced\x20node\x20'+'without\x20edges\x20is\x20a\x20compile\x20blocker\x20and\x20a\x20reachability\x20finding),\x20or\x20reword\x20the\x20note\x20to\x20guidance\x20'+'language\x20(\x27model\x20it\x20as\x27,\x20\x27e.g.\x27)\x20so\x20the\x20optional\x20extension\x20is\x20not\x20read\x20as\x20a\x20structural\x20mandate.'}];}function syntheticMachine(a){const b=a['machine_shape']['map'](e=>({'name':e['name'],'description':e['role'],'operator':e['operator']})),c=[],d=(e,f)=>[{'name':e,'weight':0x1,'named_operator':f==='order_payer'?'':'order_holder'}];b['length']>0x0&&c['push']({'prev_node':'','next_node':b[0x0]['name'],'threshold':0x1,'forwards':d('enter_'+b[0x0]['name'],b[0x0]['operator'])});for(let e=0x0;e<b['length']-0x1;e++){const f=b[e]['name'],g=b[e+0x1];if(BRANCH_STATE_REGEX['test'](g['name']))continue;c['push']({'prev_node':f,'next_node':g['name'],'threshold':0x1,'forwards':d(f+'_to_'+g['name'],g['operator'])});}if(b['length']>0x0)for(const h of b){BRANCH_STATE_REGEX['test'](h['name'])&&c['push']({'prev_node':b[0x0]['name'],'next_node':h['name'],'threshold':0x1,'forwards':d('to_'+h['name'],h['operator'])});}return{'nodes':b,'pairs':c};}function singleNodeGraph(a){return{'network':ENTRYPOINT['Testnet'],'seed':a['id'],'builtAt':Date['now'](),'nodes':new Map([[a['id'],a]]),'edges':[],'out':new Map(),'inc':new Map(),'gaps':[],'truncations':[],'rpcReport':{'batches':0x0,'byChannel':{'objects':0x0,'keyedFields':0x0,'tables':0x0,'events':0x0},'dedupHits':0x0},'budgetExhausted':{}};}function analyzerFindings(a){const b=makeProposalNode('machine',syntheticMachine(a)),c=singleNodeGraph(b),d=buildViewport(c,c['seed'],'neutral');return runNodeAnalyzers(d,[machineRuleNodeAnalyzer,allocationRuleNodeAnalyzer]);}const SEVERITY_ORDER={'low':0x0,'medium':0x1,'high':0x2,'critical':0x3},ONEWAY_GATE_REGEX=/dispute[a-z]*\s*(?:count|len(?:gth)?)?[^.;:\n]{0,24}===?\s*0\b/gi,ONEWAY_NEGATION_REGEX=/\b(?:never|do\s+not|don'?t|not|avoid|instead|substitute|one-way\s+door|welds?|append-only|rather\s+than)\b/i;function onewayDisputeChecks(a){const b=[...a['guards']['map'](d=>['guard\x20'+d['template_id'],d['purpose']]),...(a['allocator']['rows']??[])['map']((d,e)=>['allocator\x20row\x20'+e,d['note']??'']),['allocator\x20description',a['allocator']['description']],...a['build_notes']['map']((d,e)=>['build\x20note\x20'+e,d]),...a['trust_mechanisms']['map']((d,e)=>['trust\x20mechanism\x20'+e,d])],c=[];for(const [d,e]of b){if(!e)continue;ONEWAY_GATE_REGEX['lastIndex']=0x0;for(let f=ONEWAY_GATE_REGEX['exec'](e);f!==null;f=ONEWAY_GATE_REGEX['exec'](e)){const g=e['slice'](Math['max'](0x0,f['index']-0x5a),f['index']+f[0x0]['length']+0x5a);if(ONEWAY_NEGATION_REGEX['test'](g))continue;c['push'](d+':\x20\x22'+f[0x0]['trim']()+'\x22');}}if(c['length']===0x0)return[];return[{'rule_id':'R-ONEWAY-DISPUTE','severity':'critical','title':'Dispute-count\x20gate\x20on\x20an\x20append-only\x20vector\x20—\x20the\x20first\x20filing\x20welds\x20the\x20rail\x20shut','detail':'Order.dispute\x20only\x20grows\x20(the\x20filing\x20entry\x20appends;\x20nothing\x20ever\x20removes).\x20A\x20guard\x20gated\x20on\x20'+'\x22dispute\x20count\x20==\x200\x22\x20is\x20monotone-false\x20after\x20the\x20first\x20case,\x20so\x20one\x20filing\x20permanently\x20closes\x20the\x20'+'gated\x20rail\x20and\x20strands\x20the\x20escrow\x20—\x20verified\x20on\x20mainnet\x20(az-mn-261007\x20T5:\x20the\x20reviewed\x20order\x20walked\x20'+'case\x20->\x20ruling\x20->\x20payout\x20and\x20its\x202.38\x20principal\x20froze\x20with\x20no\x20exit).\x20Offending\x20surfaces:\x20'+c['join'](';\x20')+'.','suggestion':'Gate\x20on\x20the\x20PAYOUT\x20state\x20instead:\x20order.claimed_by\x20via\x20query\x201570\x20—\x20some\x20==\x20false\x20blocks\x20the\x20refund\x20'+'rail\x20only\x20after\x20an\x20award\x20ACTUALLY\x20paid,\x20and\x20the\x20paired\x20merchant-recovery\x20allocator\x20(some\x20==\x20true)\x20'+'keeps\x20the\x20awarded\x20order\x27s\x20escrow\x20exit.\x20Never\x20substitute\x20dispute\x20count\x20==\x200\x20(append-only\x20one-way\x20door).'}];}const ARB_REFERENCE_REGEX=/\barbitration\b|\barbitrator\b|compensation[ -]fund|\barb\.|\bruling\b/i;function noEscrowExitChecks(a){const b=a['allocator']['rows']??[];if(!b['some'](d=>d['track']==='refund'&&d['recipient']==='guard_identifier'))return[];const c=templateText(a,b['map'](d=>d['note']??''));if(!ARB_REFERENCE_REGEX['test'](c))return[];if(/claimed_by/i['test'](c))return[];return[{'rule_id':'R-NO-ESCROW-EXIT','severity':'high','title':'Refund\x20rail\x20never\x20reads\x20the\x20arbitration\x20payout\x20state\x20—\x20double-pay\x20and\x20stranded-escrow\x20hazards','detail':'The\x20template\x20declares\x20an\x20order-anchored\x20refund\x20rail\x20and\x20references\x20arbitration,\x20but\x20no\x20guard\x20design,\x20'+'row\x20note,\x20or\x20build\x20note\x20reads\x20order.claimed_by\x20(query\x201570)\x20—\x20the\x20payout\x20state.\x20After\x20a\x20compensation\x20'+'award\x20pays:\x20the\x20refund\x20rail\x20cannot\x20block\x20(the\x20compensated\x20order\x20still\x20drains\x20the\x20escrow\x20—\x20D-BUG-2\x20'+'double-pay),\x20and\x20no\x20merchant-recovery\x20allocator\x20is\x20declared,\x20so\x20the\x20awarded\x20order\x27s\x20escrow\x20principal\x20'+'has\x20no\x20exit\x20(mainnet\x20az-mn-261007\x20T5:\x202.38\x20stranded).','suggestion':'Gate\x20the\x20refund\x20guard\x20on\x20order.claimed_by\x20some\x20==\x20false\x20(query\x201570)\x20and\x20PAIR\x20a\x20merchant-recovery\x20'+'allocator\x20whose\x20guard\x20asserts\x20order.claimed_by\x20some\x20==\x20true\x20plus\x20order.service\x20binding\x20and\x20the\x20'+'qualifying\x20node\x20—\x20exactly\x20one\x20of\x20the\x20two\x20legs\x20can\x20ever\x20pass\x20(ESCROW\x20EXIT\x20INVARIANT).'}];}const CLAIMED_FALSE_RE=/claimed_by\s*(?:is\s+)?(?:none|some\s*==\s*false)/i,CLAIMED_TRUE_RE=/claimed_by\s*(?:is\s+)?some\s*==\s*true/i;function pairingProseOnlyChecks(a){const b=a['allocator']['rows']??[];if(!b['some'](j=>j['track']==='refund'&&j['recipient']==='guard_identifier'))return[];const c=templateText(a);if(!ARB_REFERENCE_REGEX['test'](c))return[];if(!/claimed_by/i['test'](c))return[];const d=b['some'](j=>j['track']==='refund'&&CLAIMED_FALSE_RE['test'](j['note']??'')),e=b['some'](j=>j['track']!=='refund'&&CLAIMED_TRUE_RE['test'](j['note']??''));if(d&&e)return[];const f=a['guards']['some'](j=>CLAIMED_FALSE_RE['test'](j['purpose']??'')),g=a['guards']['some'](j=>CLAIMED_TRUE_RE['test'](j['purpose']??'')),h=[!d?'refund\x20leg\x20(claimed_by\x20some\x20==\x20false\x20in\x20the\x20refund\x20row\x20note)':null,!e?'recovery\x20leg\x20(claimed_by\x20some\x20==\x20true\x20in\x20the\x20recovery\x20row\x20note)':null]['filter'](j=>j!==null)['join']('\x20and\x20');if(f&&g)return[{'rule_id':'R-PAIRING-PROSE-ONLY','severity':'low','title':'claimed_by\x20pairing\x20declared\x20in\x20the\x20guard\x20specs\x20but\x20not\x20bound\x20in\x20the\x20row\x20notes','detail':'The\x20claimed_by\x20none/some\x20pairing\x20is\x20declared\x20in\x20the\x20guard\x20specs\x27\x20purposes\x20—\x20accepted\x20as\x20an\x20'+'alternative\x20resolution\x20(ptrn2-ln-261011\x20A2:\x20guard-pair\x20polarity\x20is\x20a\x20chain-validated\x20closure).\x20'+('Missing\x20from\x20the\x20row\x20notes:\x20'+h+'.\x20Row\x20notes\x20are\x20the\x20payload\x20a\x20builder\x20assembles\x20the\x20')+'allocator\x20guards\x20from;\x20rails\x20built\x20from\x20row\x20notes\x20alone\x20would\x20carry\x20no\x20payout\x20polarity:\x20a\x20'+'compensated\x20order\x20double-pays\x20(D-BUG-2)\x20and\x20the\x20awarded\x20order\x20strands\x20its\x20escrow\x20(mainnet\x20'+'az-mn-261007\x20T5).','suggestion':'Mirror\x20the\x20pairing\x20into\x20the\x20row\x20notes\x20so\x20the\x20assembled\x20payload\x20carries\x20it\x20structurally:\x20the\x20'+'refund\x20row\x20note\x20asserts\x20order.claimed_by\x20some\x20==\x20false\x20(query\x201570),\x20the\x20recovery\x20row\x20note\x20'+'asserts\x20some\x20==\x20true\x20+\x20order.service\x20binding\x20+\x20the\x20qualifying\x20node\x20—\x20exactly\x20one\x20leg\x20can\x20ever\x20'+'pass\x20(ESCROW\x20EXIT\x20INVARIANT).\x20Canonical\x20shape:\x20subscription/direct-fan-subscription\x27s\x20'+'refund_*\x20+\x20awarded_recover\x20rails.'}];return[{'rule_id':'R-PAIRING-PROSE-ONLY','severity':'medium','title':'claimed_by\x20refund/recovery\x20pairing\x20promised\x20in\x20prose\x20but\x20missing\x20from\x20the\x20row\x20notes','detail':'The\x20template\x27s\x20prose\x20describes\x20the\x20claimed_by\x20none/some\x20pairing\x20(refund\x20blocked\x20once\x20an\x20award\x20'+'ACTUALLY\x20paid\x20+\x20paired\x20merchant-recovery\x20allocator),\x20but\x20the\x20allocator\x20row\x20notes\x20do\x20not\x20declare\x20it.\x20Missing:\x20'+(h+'.\x20Row\x20notes\x20are\x20the\x20payload\x20a\x20builder\x20assembles\x20the\x20guards\x20from\x20—\x20rails\x20built\x20without\x20the\x20')+'declared\x20polarity\x20have\x20none:\x20a\x20compensated\x20order\x20double-pays\x20(D-BUG-2)\x20and\x20the\x20awarded\x20order\x20strands\x20its\x20'+'escrow\x20(mainnet\x20az-mn-261007\x20T5).','suggestion':'Declare\x20the\x20pairing\x20in\x20the\x20row\x20notes:\x20the\x20refund\x20row\x20note\x20asserts\x20order.claimed_by\x20some\x20==\x20false\x20'+'(query\x201570\x20—\x20refund\x20precluded\x20once\x20an\x20award\x20paid),\x20and\x20the\x20recovery\x20row\x20note\x20asserts\x20some\x20==\x20true\x20+\x20'+'order.service\x20binding\x20+\x20the\x20qualifying\x20node\x20—\x20exactly\x20one\x20of\x20the\x20two\x20legs\x20can\x20ever\x20pass\x20(ESCROW\x20EXIT\x20'+'INVARIANT).\x20Canonical\x20shape:\x20subscription/direct-fan-subscription\x27s\x20refund_*\x20+\x20awarded_recover\x20rails.'}];}const TIER_PROMISE_RE=/\btiers?\b[^.!?\n]{0,120}?\b(earns?|earned|unlocks?|unlocked|receives?|received|gets?|claims?|claimed|grants?|granted)\b|\b(earns?|earned|unlocks?|unlocked|receives?|received|gets?|claims?|claimed|grants?|granted)\b[^.!?\n]{0,80}?\btiers?\b/i,REWARD_CONTEXT_RE=/\brewards?\b|\bbount(?:y|ies)\b|\bbonus(?:es)?\b|\bhonors?\b|\bperks?\b/i,PROHIBITION_RE=/\b(?:never promise|do not|don'?t|cannot|not constructible|unenforceable|unforced decoration|must be disclosed|MUST be disclosed|either add|drop the wording|word promises? to match|without a guard leg|no guard leg|impossible)\b/i,TIER_PREDICATE_RE=/\bhistor(?:y|ical)\b|\bperiod count\b|\bcount\s*>=|per-order repository|\brepository row\b|\btier predicate\b|\bstore_from_id\b/i;function disclosureEnforceabilityChecks(a){const b=[...a['build_notes'],...a['differences']??[],...a['guards']['map'](e=>e['purpose']??''),...(a['allocator']['rows']??[])['map'](e=>e['note']??'')],c=b['flatMap'](e=>e['split'](/(?<=[.!?])\s+/))['filter'](e=>TIER_PROMISE_RE['test'](e)&&REWARD_CONTEXT_RE['test'](e)&&!PROHIBITION_RE['test'](e)&&!TIER_PREDICATE_RE['test'](e));if(c['length']===0x0)return[];const d=a['guards']['some'](e=>TIER_PREDICATE_RE['test'](e['purpose']??''));if(d)return[];return[{'rule_id':'DISCLOSURE-ENFORCEABILITY','severity':'medium','title':'Tier-scoped\x20reward\x20promise\x20with\x20no\x20enforcement\x20leg\x20—\x20unenforceable\x20decoration','detail':'The\x20template\x27s\x20prose\x20promises\x20tier-scoped\x20rewards\x20('+c['slice'](0x0,0x2)['map'](e=>'\x22'+e['trim']()['slice'](0x0,0x8c)+'\x22')['join'](';\x20')+(c['length']>0x2?'\x20+'+(c['length']-0x2)+'\x20more':'')+'),\x20but\x20no\x20guard\x20design\x20reads\x20tier\x20evidence\x20(history\x20count,\x20per-order\x20repository\x20row).\x20Reward\x20objects\x20'+'are\x20Service-level\x20and\x20sales\x20rows\x20carry\x20no\x20reward\x20field,\x20so\x20the\x20claim\x20guard\x20gates\x20tier-agnostically:\x20'+'buyers\x20are\x20promised\x20a\x20tier\x20benefit\x20the\x20chain\x20cannot\x20verify\x20or\x20pay\x20selectively\x20(ptrn2-ln-261011\x20B3:\x20'+'\x27Co-Producer\x20earns\x20Veteran\x20rewards\x27\x20while\x20the\x20claim\x20guard\x20read\x20history\x20>=\x207\x20for\x20every\x20tier).','suggestion':'Either\x20add\x20the\x20predicate\x20—\x20a\x20claim-guard\x20leg\x20reading\x20per-order\x20repository\x20evidence\x20(or\x20history\x20'+'count)\x20so\x20each\x20tier\x27s\x20promise\x20is\x20actually\x20gated\x20—\x20or\x20reword\x20the\x20promise\x20to\x20match\x20what\x20the\x20guard\x20'+'leg\x20really\x20reads.\x20Never\x20ship\x20tier\x20wording\x20the\x20guard\x20cannot\x20enforce.'}];}function railUnboundChecks(a){const b=a['allocator']['rows']??[],c=b['map']((d,e)=>({'r':d,'i':e}))['filter'](({r:d})=>d['guard_key']===undefined);if(c['length']===0x0)return[];return[{'rule_id':'R-RAIL-UNBOUND','severity':'critical','title':c['length']+'\x20money\x20row(s)\x20bind\x20no\x20guard_key\x20—\x20the\x20rails\x20ship\x20uncovered\x20and\x20FUND-EXIT-01\x20goes\x20critical\x20at\x20generation','detail':'Allocator\x20rows\x20are\x20the\x20payload\x20compile\x20turns\x20into\x20order_allocators.\x20A\x20row\x20without\x20guard_key\x20emits\x20an\x20'+'allocator\x20carrying\x20no\x20guard\x20reference,\x20so\x20(a)\x20the\x20terminal\x20it\x20serves\x20has\x20no\x20resolved\x20allocator\x20guard\x20'+'(FUND-EXIT-01\x20critical),\x20and\x20(b)\x20no\x20pending-judgment\x20surface\x20exists\x20for\x20guard_resolutions\x20to\x20close\x20'+'(the\x20surface\x20is\x20keyed\x20by\x20row\x20guard_key\x20bindings)\x20—\x20the\x20build\x20is\x20deadlocked,\x20not\x20merely\x20warned\x20'+'(upw-ln-261011\x20TPL-01).\x20Unbound\x20rows:\x20'+c['map'](({r:d,i:e})=>'#'+e+'\x20('+d['track']+'/'+d['recipient']+')')['join'](',\x20')+'.','suggestion':'Declare\x20a\x20keyed\x20guard\x20spec\x20per\x20rail\x20and\x20bind\x20every\x20money\x20row\x20via\x20guard_key:\x20settlement\x20rides\x20'+'tpl_allocator_node_gate_settle\x20(the\x20kernel\x20auto-fills\x20it\x20—\x20service_name\x20is\x20seeded\x20from\x20the\x20plan,\x20'+'settle_node\x20defaults\x20to\x20\x27completed\x27)\x20plus\x20a\x20Rate-0\x20ORDER\x20anchor\x20row\x20sharing\x20the\x20key\x20(CR-01);\x20'+'refund/recovery\x20ride\x20pattern.progress_state_check\x20designs\x20with\x20the\x20claimed_by\x20polarity\x20declared\x20in\x20'+'the\x20spec\x20purpose.\x20Canonical\x20shapes:\x20freelance/catalog-tiers\x20(v48)\x20and\x20subscription/direct-fan-subscription.'}];}function counterpartyFundEvidenceChecks(a){const b=a['allocator']['rows']??[],c=a['guards']??[];if(b['length']===0x0||c['length']===0x0)return[];const d=k=>k==='pattern.repository_data_check'||k['startsWith']('tpl_repository_'),e=new Map();for(const k of c){if(k['key']&&d(k['template_id']))e['set'](k['key'],k);}if(e['size']===0x0)return[];const f=/order[- ]holder|order\.owner|co-?writ|co-?sign|both part(?:y|ies)|written by the (?:buyer|payer|order)|writer authorization|write[- ](?:authorization|policy|guard)|build[- ]time|pinned (?:at|to) (?:build|generation|publish)|value_from|fee_param|event evidence only|append[- ]only|a new row|re-?disclos/i,h=b['map']((l,m)=>({'r':l,'i':m}))['filter'](({r:l})=>{const m=l['guard_key']?e['get'](l['guard_key']):undefined;if(!m)return![];return!f['test'](m['purpose'])&&!(l['note']&&f['test'](l['note']));});if(h['length']===0x0)return[];const j=h['map'](({r:l,i:m})=>'#'+m+'\x20('+l['track']+'/'+(l['recipient_key']??l['recipient'])+'\x20->\x20\x27'+l['guard_key']+'\x27)')['join'](',\x20');return[{'rule_id':'R-COUNTERPARTY-FUND-EVIDENCE','severity':'high','title':h['length']+'\x20money\x20row(s)\x20gate\x20on\x20counterparty-mutable\x20repository\x20evidence\x20—\x20fund\x20terms\x20one\x20party\x20can\x20rewrite','detail':'Rows\x20'+j+'\x20bind\x20a\x20repository-data\x20gate,\x20and\x20repository.data\x20is\x20an\x20UPSERT\x20key-value\x20store:\x20'+'its\x20rows\x20stay\x20overwritable\x20by\x20their\x20author\x20(mainnet\x20A/B,\x20ofn-mn-261012\x20F-02)\x20and\x20an\x20overwrite\x20raises\x20'+'no\x20buyer-parseable\x20event\x20(the\x20overwrite\x20event\x20renders\x20\x27Unknown\x20event\x27).\x20Whoever\x20writes\x20the\x20evidence\x20'+'can\x20therefore\x20silently\x20re-decide\x20WHICH\x20rail\x20applies\x20or\x20WHETHER\x20the\x20gate\x20matches\x20at\x20all\x20—\x20the\x20audited\x20'+'airbnb\x20service\x20ran\x20its\x20refunds\x20through\x20gates\x20the\x20host\x20rewrote\x20AFTER\x20the\x20buyer\x20had\x20already\x20cancelled,\x20'+'down\x20to\x20zero\x20matching\x20rails\x20(abnb7-mn-261013\x20F25).\x20Neither\x20the\x20guard\x20purpose\x20nor\x20the\x20row\x20note\x20declares\x20'+'the\x20counterparty\x20discipline.','suggestion':'Pin\x20every\x20fund\x20TERM\x20at\x20build\x20time\x20—\x20amounts\x20and\x20tier\x20selection\x20ride\x20value_from\x20/\x20fee_params\x20and\x20freeze\x20'+'into\x20the\x20allocator\x20at\x20publish;\x20repository\x20rows\x20carry\x20EVENT\x20evidence\x20only\x20and\x20never\x20select\x20between\x20rails.\x20'+'If\x20a\x20repository\x20row\x20must\x20inform\x20money\x20at\x20all,\x20its\x20write\x20authorization\x20MUST\x20include\x20the\x20order\x20holder\x20'+'(co-write\x20/\x20proof\x20signed\x20by\x20the\x20order\x20holder)\x20and\x20changes\x20land\x20as\x20a\x20NEW\x20row\x20with\x20disclosure\x20visible\x20to\x20'+'the\x20counterparty\x20through\x20the\x20Messenger\x20channel\x20—\x20never\x20an\x20in-place\x20overwrite\x20(see\x20p2p-shortstay\x27s\x20'+'guest_claim_evidence\x20for\x20the\x20participation\x20form\x20and\x20its\x20FUND-TERMS\x20build\x20note\x20for\x20the\x20full\x20discipline).'}];}function allocReplayChecks(a){const b=a['allocator']['rows']??[];if(b['length']===0x0)return[];if(a['allocator']['once_per_order']===!![])return[];if(poolPeriodCount(a)!==undefined)return[];const c=new Map();for(const e of b){const f=e['guard_key']??'';c['set'](f,[...c['get'](f)??[],e]);}const d=[];for(const [h,j]of c){if(j['some'](n=>n['mode']==='surplus'))continue;const k=j['filter'](n=>n['mode']==='amount');let l=0x0;for(const n of j)if(n['mode']==='rate')l+=Number(n['value'])||0x0;if(k['length']===0x0&&l>=0x2710)continue;const m=h?'guard\x20\x27'+h+'\x27':'ungrouped\x20rows';k['length']>0x0&&d['push']('fixed-Amount\x20row(s)\x20under\x20'+m+':\x20'+k['map'](o=>o['track']+'/'+(o['recipient_key']??o['recipient']))['join'](',\x20')),l>0x0&&l<0x2710&&d['push']('Rate\x20leg\x20under\x20'+m+'\x20summing\x20'+l+'\x20<\x2010000');}if(d['length']===0x0)return[];return[{'rule_id':'R-ALLOC-REPLAY','severity':'high','title':'Residual-capable\x20rails\x20without\x20a\x20once-slot\x20—\x20replay\x20protection\x20is\x20only\x20the\x20drained-balance\x20side\x20effect','detail':'The\x20allocator\x20declares\x20'+d['join']('\x20and\x20')+'\x20but\x20sets\x20no\x20once_per_order\x20replay\x20slot.\x20The\x20trigger\x20'+'guard\x20can\x20be\x20satisfied\x20repeatedly,\x20and\x20each\x20run\x20pays\x20from\x20any\x20remaining\x20balance:\x20a\x20replayed\x20alloc\x20on\x20a\x20'+'drained\x20pool\x20aborts\x20\x27Insufficient\x20balance\x27\x20—\x20the\x20guard\x20clauses\x20themselves\x20PASS\x20(the\x20once-protection\x20is\x20'+'the\x20zero\x20balance,\x20not\x20a\x20consumed-once\x20flag).\x20Any\x20surplus\x20leg\x20that\x20leaves\x20balance,\x20or\x20a\x20later\x20re-deposit\x20'+'into\x20the\x20Allocation,\x20re-enables\x20payout\x20(mainnet\x20az-mn-261007\x20N5).','suggestion':'Declare\x20allocator.once_per_order=true\x20so\x20generation\x20registers\x20the\x20ONCE-FOR-OBJECT\x20submission\x20slot\x20'+'(identifier\x20254\x20—\x20the\x20chain\x20derives\x20the\x20slot\x20key\x20from\x20payment_info.for_object\x20and\x20a\x20replay\x20aborts\x20with\x20'+'code\x2016\x20regardless\x20of\x20submitted\x20bytes;\x20use\x20identifier\x20255\x20with\x20a\x20\x27period-<N>\x27\x20key\x20only\x20for\x20rails\x20that\x20'+'legitimately\x20run\x20once\x20per\x20period).\x20Alternatively\x20make\x20every\x20leg\x20exhaust\x20its\x20pool\x20(pure\x20Rate\x2010000\x20or\x20a\x20'+'Surplus\x20sweep)\x20so\x20no\x20residual\x20can\x20be\x20replayed.'}];}function draftVoidChecks(a){const b=a['machine_shape']??[];if(b['length']===0x0)return[];if(!b['some'](e=>(e['from']??[])['length']>0x0))return[];const c=f=>{const g=[];for(const h of b){for(const j of h['from']??[]){const k=typeof j==='string'?j:j?.['prev'];if(k!==f)continue;const l=typeof j==='object'&&j?.['operator']?j['operator']:h['operator']??'merchant';g['push']({'target':h,'op':l});}}return g;},d=[];for(const e of b){if(!/escrow/i['test'](e['role']??''))continue;if(/award|pays the (host|seller|creator|merchant|provider)/i['test'](e['role']??''))continue;if(/^(delivered|final|cancelled)$/['test'](e['semantic_role']??''))continue;const f=c(e['name']),g=f['some'](({target:h,op:j})=>j==='order_payer'&&h['semantic_role']==='cancelled');if(g)continue;d['push'](f['length']===0x0?'\x27'+e['name']+'\x27\x20has\x20NO\x20outgoing\x20forward\x20at\x20all\x20(entry\x20dead-end)':'\x27'+e['name']+'\x27\x20exits\x20only\x20via\x20'+f['map'](({target:h,op:j})=>h['name']+'['+j+']')['join'](',\x20'));}if(d['length']===0x0)return[];return[{'rule_id':'R-DRAFT-VOID','severity':'high','title':'Escrowed\x20node\x20without\x20a\x20buyer-side\x20void\x20hop\x20—\x20abandoned\x20orders\x20strand\x20the\x20escrow','detail':'Buy\x20escrows\x20atomically,\x20so\x20the\x20money\x20is\x20pooled\x20from\x20the\x20moment\x20the\x20order\x20exists.\x20'+d['join'](';\x20')+'\x20—\x20none\x20of\x20these\x20routes\x20is\x20an\x20order-payer\x20hop\x20into\x20a\x20cancelled\x20'+'endpoint,\x20so\x20a\x20buyer\x20who\x20abandons\x20or\x20fails\x20mid-order\x20(transport\x20error,\x20second\x20thoughts,\x20'+'a\x20ghost\x20order)\x20has\x20funds\x20locked\x20with\x20no\x20single-hop\x20exit\x20(mainnet\x20az-mn-261007\x20G2:\x20the\x20'+'deployed\x20machine\x27s\x20draft\x20node\x20had\x20only\x20the\x20entry\x20forward;\x20voiding\x20required\x20Enter\x20->\x20'+'CancelBeforePayment).','suggestion':'Add\x20an\x20order-payer\x20forward\x20from\x20every\x20escrowed\x20node\x20to\x20the\x20template\x27s\x20cancelled\x20endpoint\x20'+'(e.g.\x20\x27paid\x20->\x20closed_cancel\x27,\x20operator\x20\x27order_payer\x27)\x20gated\x20by\x20the\x20cancel\x20guard;\x20the\x20refund\x20'+'rail\x20must\x20stay\x20mounted\x20—\x20escrow\x20is\x20funded\x20at\x20order_new,\x20not\x20at\x20first\x20forward.'}];}const DELIVERY_SURFACE_REGEX=/\b(ship(?:s|ping|ped|ment)?|tracking|courier|parcel|pickup|check[- ]?in|hand[- ]?over|redeem(?:s|ed|ption)?)\b/i,REQINFO_SURFACE_REGEX=/required[_ ]?info|customer_required|\b1572\b|required_info_evidence_gate/i;function requiredInfoGateChecks(a){const b=a['machine_shape']['filter'](c=>DELIVERY_SURFACE_REGEX['test'](c['name']+'\x20'+c['role']))['map'](c=>'\x27'+c['name']+'\x27\x20('+c['role']+')');if(b['length']===0x0)return[];if(REQINFO_SURFACE_REGEX['test'](templateText(a)))return[];return[{'rule_id':'R-REQINFO-GATE','severity':'high','title':'Fulfilment\x20flow\x20never\x20enforces\x20buyer\x20required\x20info\x20—\x20Service.customer_required\x20is\x20declarative-only','detail':'The\x20on-chain\x20purchase\x20entry\x20never\x20reads\x20Service.customer_required,\x20so\x20an\x20order\x20that\x20skips\x20every\x20'+'required\x20field\x20still\x20creates.\x20Fulfilment\x20surfaces\x20that\x20physically\x20hand\x20over\x20goods\x20or\x20need\x20to\x20reach\x20'+'the\x20buyer\x20—\x20'+b['join'](';\x20')+'\x20—\x20are\x20the\x20only\x20points\x20where\x20that\x20obligation\x20can\x20be\x20'+'enforced\x20on\x20chain,\x20yet\x20the\x20template\x20declares\x20no\x20required_info\x20surface\x20anywhere\x20(no\x20'+'pattern.required_info_evidence_gate,\x20no\x20order.required_info\x201572\x20reference\x20in\x20any\x20guard\x20purpose\x20'+'or\x20build\x20note).','suggestion':'Mount\x20pattern.required_info_evidence_gate\x20on\x20the\x20fulfilment\x20forward:\x20gate\x20order.required_info\x20some\x20'+'(1572)\x20presence\x20FIRST\x20—\x20a\x20bare\x201573\x20value\x20read\x20aborts\x20while\x20the\x20Option\x20is\x20empty.\x20Presence-only\x20is\x20'+'the\x20right\x20default:\x20the\x20recorded\x20value\x20is\x20unvalidated\x20buyer\x20input\x20and\x20carries\x20no\x20on-chain\x20meaning,\x20'+'so\x20treat\x20the\x20merchant\x27s\x20confirming\x20forward\x20(not\x20the\x20recorded\x20address)\x20as\x20the\x20acceptance\x20basis.'}];}function planReadinessChecks(a){const b=[],c=a['allocator']['rows']??[],d=c['some'](h=>h['track']==='refund'),e=a['allocator']['refund_track']!==undefined||/refund/i['test'](a['allocator']['description']),f=validateAllocatorRows(a);f['length']>0x0&&b['push']({'rule_id':'R-PLAN-01','severity':'critical','title':'Allocator\x20rows\x20are\x20internally\x20inconsistent\x20—\x20the\x20money\x20plan\x20cannot\x20be\x20built','detail':'Template\x20allocator\x20rows\x20are\x20internally\x20inconsistent:\x20'+f['join'](';\x20')+'.','suggestion':'Fix\x20the\x20template\x27s\x20allocator.rows\x20(they\x20are\x20the\x20authoritative\x20money\x20plan;\x20order_allocators\x20is\x20L1-frozen\x20at\x20publish).'});a['allocator']['refund_track']&&!d&&b['push']({'rule_id':'R-PLAN-02','severity':'critical','title':'Declared\x20refund\x20track\x20has\x20no\x20refund\x20row\x20—\x20the\x20plan\x20cannot\x20carry\x20the\x20promised\x20refund\x20rail','detail':'Template\x20declares\x20a\x20\x27'+a['allocator']['refund_track']+'\x27\x20refund\x20track\x20but\x20declares\x20no\x20allocator\x20row\x20with\x20'+'track=\x27refund\x27;\x20the\x20generated\x20plan\x20cannot\x20carry\x20the\x20promised\x20refund\x20rail.','suggestion':'Declare\x20a\x20refund\x20row\x20in\x20allocator.rows\x20(recipient\x20guard_identifier,\x20recipient_key\x20\x270\x27,\x20mode\x20rate,\x20value\x2010000)\x20so\x20the\x20order-anchored\x20full-refund\x20rail\x20rides\x20with\x20the\x20plan.'});if(!e)b['push']({'rule_id':'R-PLAN-03','severity':'high','title':'No\x20refund\x20track\x20declared\x20—\x20returns/refunds\x20have\x20no\x20funded\x20path\x20in\x20the\x20money\x20plan','detail':'The\x20template\x27s\x20allocator\x20declares\x20no\x20refund\x20track\x20—\x20returns/refunds\x20have\x20no\x20funded\x20path\x20in\x20the\x20money\x20plan.','suggestion':'Add\x20the\x20second\x20Allocator\x20(Rate\x2010000\x20to\x20the\x20buyer)\x20bound\x20to\x20the\x20refund\x20Guard,\x20or\x20confirm\x20with\x20the\x20merchant\x20that\x20refunds\x20are\x20out\x20of\x20scope.'});else!a['allocator']['refund_track']&&b['push']({'rule_id':'R-PLAN-04','severity':'medium','title':'Refund\x20intent\x20declared\x20in\x20prose\x20only\x20—\x20the\x20refund\x20recipient\x20is\x20not\x20order-anchored','detail':'A\x20refund\x20track\x20is\x20declared\x20but\x20not\x20order-anchored,\x20so\x20the\x20refund\x20recipient\x20is\x20resolved\x20from\x20the\x20signer/Entity\x20rather\x20than\x20the\x20paying\x20Order.','suggestion':'Gate\x20the\x20refund\x20track\x20with\x20AND[signer\x20==\x20order.owner,\x20progress.node\x20==\x20X]\x20or\x20move\x20it\x20to\x20an\x20order-anchored\x20GuardIdentifier(0)\x20recipient.'});if(c['length']===0x0){a['allocator']['mode']!=='rate'&&b['push']({'rule_id':'R-PLAN-05','severity':'critical','title':'Allocator\x20mode\x20is\x20not\x20expressible\x20as\x20a\x20percentage\x20split','detail':'Template\x20allocator\x20mode\x20is\x20\x27'+a['allocator']['mode']+'\x27,\x20which\x20a\x20percentage\x20pair\x20cannot\x20represent\x20—\x20'+'no\x20percentage\x20hint\x20can\x20be\x20emitted\x20for\x20it.','suggestion':'Declare\x20allocator.rows\x20in\x20the\x20template\x20(per-row\x20amount\x20/\x20rate\x20/\x20surplus);\x20the\x20pipeline\x20will\x20then\x20carry\x20the\x20real\x20split\x20instead\x20of\x20a\x20hint.'});if(a['allocator']['mode']==='rate'){const h=platformShareBps(a['fee_params']),j=h!==undefined&&h>0x0?0x2:0x0;a['allocator']['count']!==0x0&&a['allocator']['count']!==0x2&&b['push']({'rule_id':'R-PLAN-06','severity':'critical','title':'Declared\x20sharing\x20row\x20count\x20can\x20never\x20match\x20the\x20generated\x20percentage\x20hint','detail':'Template\x20declares\x20'+a['allocator']['count']+'\x20sharing\x20row(s)\x20but\x20the\x20generated\x20percentage\x20hint\x20can\x20'+('only\x20ever\x20carry\x20'+j+'\x20row(s)\x20(platform\x20take\x20'+(h??'none')+'\x20bps).'),'suggestion':'Build\x20the\x20Allocation\x20with\x20the\x20template\x27s\x20own\x20row\x20set\x20(order_allocators\x20is\x20L1\x20—\x20frozen\x20at\x20Service\x20publish),\x20or\x20declare\x20allocator.rows\x20in\x20the\x20template.'});}}const g=Object['keys'](a['fee_params'])['filter'](l=>/_(?:days|hours)$/['test'](l));return g['length']>0x0&&!a['time_anchors']&&b['push']({'rule_id':'R-PLAN-07','severity':'medium','title':'Business\x20windows\x20declared\x20without\x20time\x20anchors\x20—\x20release/timeout\x20steps\x20stay\x20unbuildable','detail':'fee_params\x20declares\x20business\x20windows\x20('+g['join'](',\x20')+')\x20but\x20the\x20template\x20declares\x20no\x20time_anchors.','suggestion':'Add\x20time_anchors\x20(or\x20name\x20the\x20window\x20in\x20the\x20Guard\x20set)\x20so\x20the\x20plan\x20emits\x20the\x20release/timeout\x20build\x20steps.'}),b;}const TASK_BINDING_SLOT=0xfe;function declaresAddressSubmissionSlot(a,b){const c=a;return c['identifier']===b&&c['b_submission']===!![]&&c['value_type']==='Address';}function tplSpecByKey(a,b){const c=a['guards']['find'](e=>e['key']===b);if(!c||!c['template_id']['startsWith']('tpl_'))return undefined;const d=GUARD_TEMPLATES['find'](e=>e['id']===c['template_id']);return d?{'templateId':d['id'],'exampleTable':d['example_table']}:undefined;}function taskBindingChecks(a){const b=[],c=new Set();for(const d of a['machine_shape']){for(const f of d['from']??[]){typeof f==='object'&&f!==null&&typeof f['guard_key']==='string'&&c['add'](f['guard_key']);}}for(const g of c){const h=tplSpecByKey(a,g);if(!h)continue;!h['exampleTable']['some'](j=>declaresAddressSubmissionSlot(j,TASK_BINDING_SLOT))&&b['push']({'rule_id':'TASKBIND-01','severity':'critical','title':'Guard\x20template\x20'+h['templateId']+'\x20(edge\x20key\x20\x27'+g+'\x27)\x20lacks\x20the\x20protocol\x20task-binding\x20slot\x20(254)','detail':'Every\x20guarded\x20forward\x20of\x20a\x20machine\x20running\x20on\x20an\x20order\x20Progress\x20requires\x20a\x20slot-254\x20passport\x20submission;\x20the\x20guard\x20table\x20declares\x20none,\x20so\x20the\x20forward\x20aborts\x20(code\x2011)\x20on\x20first\x20order\x20traversal.\x20Tables\x20and\x20machines\x20freeze\x20at\x20publish\x20—\x20shipping\x20now\x20strands\x20the\x20path\x20permanently.','suggestion':'Declare\x20{\x20identifier:\x20254,\x20b_submission:\x20true,\x20value_type:\x20\x27Address\x27\x20}\x20in\x20'+h['templateId']+'.example_table\x20(protocol\x20slot\x20254;\x20the\x20order\x20address\x20is\x20written\x20by\x20order\x20creation).'});}return b;}function allocLegSlotChecks(a){const b=[];for(const c of a['allocator']?.['rows']??[]){if(c['recipient']!=='guard_identifier'||!c['guard_key'])continue;const d=Number(c['recipient_key']??0x0);if(!Number['isInteger'](d)||d<0x0)continue;const e=tplSpecByKey(a,c['guard_key']);if(!e)continue;const f=e['exampleTable']['some'](h=>declaresAddressSubmissionSlot(h,d));if(f)continue;const g=e['exampleTable']['some'](h=>{const j=h;return j['identifier']===d&&j['value_type']==='Address';});b['push']({'rule_id':'TASKBIND-02','severity':'critical','title':g?'Guard\x20template\x20'+e['templateId']+'\x20slot\x20'+d+'\x20is\x20a\x20STATIC\x20Address\x20—\x20allocator\x20leg\x20\x27'+c['guard_key']+'\x27\x20needs\x20a\x20b_submission\x20declaration':'Guard\x20template\x20'+e['templateId']+'\x20never\x20declares\x20slot\x20'+d+'\x20—\x20allocator\x20leg\x20\x27'+c['guard_key']+'\x27\x20will\x20strand\x20escrow','detail':g?'A\x20static\x20Address\x20slot\x20passes\x20creation\x20but\x20fails\x20the\x20allocation\x20assertion\x20(passport\x20submission\x20==\x20payment_info.for_object):\x20the\x20distribution\x20aborts\x20and\x20escrowed\x20funds\x20stay\x20stranded,\x20because\x20the\x20table\x20froze\x20at\x20creation\x20and\x20cannot\x20gain\x20the\x20declaration\x20later\x20(N-11).':'The\x20allocation\x20assert\x20reads\x20a\x20passport\x20submission\x20at\x20this\x20slot;\x20with\x20no\x20declaration\x20the\x20assert\x20fails\x20and\x20the\x20distribution\x20aborts\x20with\x20funds\x20already\x20escrowed.','suggestion':'Declare\x20{\x20identifier:\x20'+d+',\x20b_submission:\x20true,\x20value_type:\x20\x27Address\x27,\x20object_type:\x20\x27Order\x27\x20}\x20in\x20'+e['templateId']+'.example_table\x20so\x20the\x20passing\x20order\x20address\x20is\x20captured.'});}return b;}export function isSplitFamilyFeeParam(a){return/(?:platform|commission|service_fee)[a-z_]*_bps$/['test'](a)||/^attributed_.*_bps$/['test'](a);}function isLandingRequired(a,b){return typeof a['fee_params'][b]==='number';}function feeParamLandingRegex(a){return new RegExp('\x5cb'+a['replace'](/[.*+?^${}()|[\]\\]/g,'\x5c$&')+'\x5cb');}function directiveLanding(a,b){const c=[['build_notes',a['build_notes']],['user_inputs',a['user_inputs']],['allocator.description',[a['allocator']['description']]],['trust_mechanisms',a['trust_mechanisms']],['machine_shape',a['machine_shape']['map'](d=>d['name']+'\x20'+d['role'])]];for(const [d,e]of c){const f=e['find'](g=>b['test'](g));if(f!==undefined)return{'surface':'directive','site':d,'excerpt':f};}return undefined;}export function collectFeeParamLandings(a){const b=new Map();for(const c of Object['keys'](a['fee_params']??{})){const d=[],e=feeParamLandingRegex(c);for(const f of a['guards']){if(e['test'](f['purpose']))d['push']({'surface':'guard','site':f['key']??f['template_id'],'excerpt':f['purpose']});}for(const h of a['allocator']['rows']??[]){const j=h['note']??'';if(e['test'](j)||h['value_from']===c){const k=h['recipient_key'];d['push']({'surface':'allocator_row','site':h['track']+'/'+(k??h['recipient']),'excerpt':j||'value_from:\x20'+String(h['value_from']),'recipient_blank':k===undefined||String(k)['trim']()===''});}}for(const [l,m]of Object['entries'](a['time_anchors']??{})){if(e['test'](m))d['push']({'surface':'time_anchor','site':l,'excerpt':m});}if(d['length']===0x0){const n=directiveLanding(a,e);if(n)d['push'](n);}b['set'](c,d);}return b;}export function buildFeeParamLandingTable(a,b){const c=collectFeeParamLandings(a);return Object['entries'](b)['map'](([d,e])=>({'param':d,'value':e,'split_family':isSplitFamilyFeeParam(d),'landings':c['get'](d)??[]}));}function feeParamLandingChecks(a){const b=[];for(const [c,d]of collectFeeParamLandings(a)){if(d['length']>0x0||isSplitFamilyFeeParam(c)||!isLandingRequired(a,c))continue;b['push']({'rule_id':'R-FEEPARAM-LANDING','severity':'medium','title':'fee_param\x20\x27'+c+'\x27\x20is\x20declared\x20but\x20lands\x20nowhere','detail':'template_generate\x20will\x20print\x20'+c+'='+String(a['fee_params'][c])+',\x20but\x20no\x20guard\x20purpose,\x20allocator\x20row\x20note\x20or\x20time\x20anchor\x20names\x20it\x20—\x20the\x20value\x20has\x20no\x20chain\x20landing,\x20so\x20whoever\x20materializes\x20the\x20template\x20hand-fills\x20the\x20constant\x20and\x20the\x20two\x20drift\x20(the\x20measured\x205-minute\x20/\x2030-day\x20window\x20mismatch\x20class).\x20Dead\x20parameters\x20also\x20mislead\x20the\x20migration\x20questionnaire,\x20which\x20presents\x20them\x20as\x20tunable.','suggestion':'Name\x20\x27'+c+'\x27\x20verbatim\x20at\x20its\x20landing\x20rung\x20—\x20the\x20purpose\x20of\x20the\x20guard\x20that\x20compiles\x20it\x20into\x20a\x20constant\x20(strongest),\x20an\x20allocator\x20row\x20note,\x20a\x20time\x20anchor,\x20or\x20at\x20minimum\x20its\x20directive\x20entry\x20(build_notes\x20/\x20user_inputs).\x20E.g.\x20\x27window\x20=\x20'+c+'\x27.\x20If\x20the\x20parameter\x20has\x20no\x20consumer\x20at\x20all,\x20delete\x20it\x20from\x20fee_params.'});}return b;}export function scanTemplate(a){const b=[...staticChecks(a),...guardRefChecks(a),...buyKeyDeclarationChecks(a),...taskBindingChecks(a),...allocLegSlotChecks(a),...fundAnchorChecks(a),...periodicReleaseChecks(a),...timeWindowAnchorChecks(a),...signerRefundChecks(a),...orderAnchorDeclarationChecks(a),...topologyChecks(a),...reachabilityChecks(a),...deadEndLockChecks(a),...reviewNoRaceChecks(a),...rewardReplayChecks(a),...rewardZeroOrderChecks(a),...rewardFundedChecks(a),...loopFundChecks(a),...terminalRailCoverageChecks(a),...railNodeDriftChecks(a),...siblingForwardExclusivityChecks(a),...compoundPayoutChecks(a),...surplusTrackChecks(a),...amountDeadlockChecks(a),...discountRailScaleChecks(a),...cancelCoverageChecks(a),...redundGuardObjectMismatchChecks(a),...zeroAmountGuardChecks(a),...serialClaimWindowChecks(a),...dismissEdgeGuardChecks(a),...noteNodeDriftChecks(a),...onewayDisputeChecks(a),...noEscrowExitChecks(a),...pairingProseOnlyChecks(a),...railUnboundChecks(a),...counterpartyFundEvidenceChecks(a),...disclosureEnforceabilityChecks(a),...allocReplayChecks(a),...draftVoidChecks(a),...requiredInfoGateChecks(a),...planReadinessChecks(a),...feeParamLandingChecks(a)];for(const e of analyzerFindings(a)){const g=e['severity']==='info'?'low':e['severity'];b['push']({'rule_id':e['ruleId'],'severity':g,'title':e['title'],'detail':e['detail'],'suggestion':e['suggestion']});}b['sort']((h,j)=>SEVERITY_ORDER[j['severity']]-SEVERITY_ORDER[h['severity']]);const c=b['length']>0x0?b[0x0]['severity']:'low',d=b['filter'](h=>h['severity']==='critical')['map'](h=>''+(h['rule_id']?h['rule_id']+':\x20':'')+h['title']);return{'template_id':a['id'],'risk_level':c,'passed':d['length']===0x0,'findings':b,'red_flags':d};}
|
|
1
|
+
import{ENTRYPOINT}from'@wowok/wowok';import{buildViewport,runNodeAnalyzers}from'../graph/onchain/index.js';import{makeProposalNode}from'../graph/onchain/proposal-graph.js';import{machineRuleNodeAnalyzer,allocationRuleNodeAnalyzer}from'./rule-node-analyzers.js';import{GUARD_TEMPLATES}from'./guard-templates.js';import{GUARD_DESIGN_PATTERNS}from'./guard-design-patterns.js';import{unannotatedBuyerActionNodes}from'./scenario-modes.js';import{findLoopCycles}from'./machine-topology.js';import{DIRECT_SALES_INVARIANT,ENTITY_RECIPIENT_RULE_ID}from'./entity-recipient-guard.js';import{DISPUTE_FAMILY_NODE_REGEX,FUND_TERMINAL_NODE_REGEX,classifyLoopCycle}from'./audit-rules.js';import{platformShareBps,validateAllocatorRows}from'./template-loader.js';const PLATFORM_TAKE_KEY=/^(?:platform_(?:share|commission|take)_bps|platform_fee_rate_bps|commission_rate_bps|(?:base_)?commission_rate_bps|offsite_ads_rate_bps|service_fee_rate_bps|payment_fee_bps)$/,MERCHANT_OWN_PRICE_KEY=/^(?:merchant_service_fee_bps|contract_fee_(?:small|large)_usd|contract_fee_tier_boundary_usd|digital_product_fee_(?:bps|min_usd|max_usd)|arbitration_fee.*|escrow_.*|min_.*|max_.*)$/,MERCHANT_SHARE_KEY=/^(?:host|property|partner|institution|landlord|freelancer|creator|seller|instructor)_rate_bps$/;function directSalesEconomyChecks(a){const b=[],c=a['fee_params'],d=Object['keys'](c)['filter'](y=>PLATFORM_TAKE_KEY['test'](y)&&typeof c[y]==='number'&&c[y]!==0x0);d['length']>0x0&&b['push']({'rule_id':'R-ECON-01','severity':'critical','title':'Template\x20mandates\x20a\x20platform\x20commission\x20('+d['map'](y=>y+'='+c[y])['join'](',\x20')+')','detail':'WoWok\x20is\x20DIRECT\x20SALES:\x20the\x20protocol\x20never\x20extracts\x20and\x20a\x20merchant\x20pays\x20only\x20gas,\x20so\x20the\x20merchant-side\x20share\x20must\x20default\x20to\x20the\x20whole\x20sale.\x20A\x20non-zero\x20platform\x20take\x20is\x20(a)\x20an\x20extraction\x20the\x20platform\x20has\x20no\x20right\x20to,\x20and\x20(b)\x20an\x20UNALLOCATED\x20liability\x20—\x20no\x20template\x20declares\x20a\x20platform\x20address,\x20so\x20at\x20build\x20time\x20it\x20resolves\x20to\x20the\x20deploying\x20merchant\x20itself\x20(blank\x20→\x20Account.Instance(),\x20ts-sdk/packages/wowok/src/w/local/index.ts:89-91),\x20to\x20the\x20keeper\x20(Recipient::Signer\x20→\x20tx_context::sender,\x20allocation.move:531-533),\x20or\x20back\x20to\x20the\x20buyer\x20(Recipient::GuardIdentifier,\x20allocation.move:501-527).\x20None\x20of\x20those\x20is\x20revenue.','suggestion':'Set\x20'+d['join'](',\x20')+'\x20to\x200\x20and\x20give\x20the\x20merchant\x20the\x20whole\x20sale\x20(single\x20Rate\x2010000\x20leg).\x20If\x20the\x20merchant\x20IS\x20the\x20aggregator\x20and\x20genuinely\x20charges\x20a\x20fee,\x20declare\x20it\x20via\x20merchant_service_fee_bps\x20with\x20an\x20EXPLICIT\x20non-empty\x20recipient\x20Entity.'});const e=a['allocator']['description'],f=/(?:commission|take|platform|remainder|share)\s*(?:=|:)\s*order\s*total\s*-\s*(?:segment|sum)/i['test'](e),g=(a['allocator']['rows']??[])['some'](y=>y['mode']==='surplus')||a['allocator']['mode']==='surplus',h=g&&/(?:platform|commission|fee|take)[^.;]{0,120}\bsurplus\b|\bsurplus\b[^.;]{0,120}(?:platform|commission|fee|take)/i['test'](e);f&&b['push']({'rule_id':'R-ECON-02','severity':'critical','title':'Take\x20is\x20an\x20implicit\x20remainder\x20(not\x20computable\x20before\x20ordering)','detail':'The\x20allocator\x20describes\x20the\x20platform\x20share\x20as\x20\x22order\x20total\x20-\x20segment\x20sums\x22,\x20so\x20the\x20amount\x20taken\x20depends\x20on\x20the\x20segment\x20configuration\x20rather\x20than\x20a\x20declared\x20rate.\x20A\x20buyer\x20(or\x20their\x20AI)\x20cannot\x20compute\x20the\x20take\x20BEFORE\x20ordering,\x20which\x20defeats\x20pre-order\x20evaluation\x20—\x20and\x20an\x20unbounded\x20remainder\x20off\x20a\x20transit\x20pool\x20is\x20unbounded\x20extraction.','suggestion':'Pin\x20every\x20share\x20to\x20an\x20EXPLICIT\x20Rate\x20(or\x20an\x20Amount\x20derived\x20from\x20a\x20declared\x20rate).\x20A\x20supplier\x20fee\x20belongs\x20in\x20its\x20own\x20explicitly-priced\x20segment\x20order,\x20never\x20as\x20a\x20residual\x20share.'});h&&b['push']({'rule_id':'R-ECON-02','severity':'high','title':'Fee\x20appears\x20to\x20be\x20taken\x20by\x20a\x20Surplus\x20leg','detail':'A\x20Surplus\x20sharing\x20entry\x20allocates\x20the\x20WHOLE\x20remaining\x20balance\x20(allocation.move:427\x20withdraw_all\x20semantics),\x20so\x20it\x20cannot\x20express\x20\x22take\x2015%\x22:\x20it\x20doubles\x20as\x20draining\x20the\x20pool.','suggestion':'Use\x20Rate\x20(or\x20RateGross)\x20for\x20any\x20proportional\x20share.\x20Reserve\x20Surplus\x20for\x20an\x20explicitly-bounded\x20residual\x20whose\x20recipient\x20and\x20cap\x20are\x20stated.'});const j=/\{\s*(?:who|Entity|Signer|GuardIdentifier)\s*:/['test'](e)||/recipient\s*[:=]/i['test'](e),k=/^(?:merchant_service_fee_bps|digital_product_fee_bps|logistics_rate_bps|service_fee_rate_bps)$/,l=Object['keys'](c)['some'](y=>k['test'](y)&&typeof c[y]==='number'&&c[y]!==0x0);if(l&&!j&&d['length']===0x0){const y=collectFeeParamLandings(a),z=Object['keys'](c)['filter'](C=>k['test'](C)&&typeof c[C]==='number'&&c[C]!==0x0),A=z['some'](C=>(y['get'](C)??[])['some'](D=>D['surface']==='guard'||D['surface']==='allocator_row'&&D['recipient_blank']!==!![])),B=!A&&z['some'](C=>(y['get'](C)??[])['some'](D=>D['surface']==='directive'));!A?b['push']({'rule_id':'R-ECON-03','severity':'high','title':B?'Fee-bearing\x20template\x20is\x20a\x20DIRECTIVE\x20only\x20—\x20the\x20share\x20has\x20no\x20on-chain\x20carrier':'Fee-bearing\x20template\x20names\x20no\x20recipient\x20slot\x20for\x20the\x20non-merchant\x20share','detail':B?'fee_params\x20carry\x20fee-shaped\x20keys\x20('+z['join'](',\x20')+')\x20whose\x20only\x20landing\x20is\x20directive\x20prose\x20—\x20no\x20allocator\x20row\x20or\x20guard\x20consumes\x20them.\x20On-chain\x20NOTHING\x20carries\x20the\x20fee:\x20whoever\x20materializes\x20the\x20template\x20computes\x20the\x20cut\x20themselves\x20(and\x20the\x20promised\x20clamps\x20live\x20only\x20in\x20text),\x20so\x20two\x20builders\x20can\x20take\x20different\x20shares\x20with\x20nothing\x20to\x20verify\x20against.':'fee_params\x20carry\x20fee-shaped\x20keys\x20but\x20the\x20allocator\x20names\x20no\x20recipient\x20for\x20them.\x20On-chain\x20each\x20Rate\x20lands\x20in\x20ITS\x20OWN\x20recipient\x20slot;\x20an\x20unnamed\x20one\x20resolves\x20to\x20the\x20deploying\x20account\x20(ts-sdk/packages/wowok/src/w/local/index.ts:89-91),\x20to\x20the\x20keeper\x20(allocation.move:615-617),\x20or\x20back\x20to\x20the\x20buyer.\x20The\x20share\x20is\x20then\x20an\x20unallocated\x20liability\x20rather\x20than\x20revenue.','suggestion':'State\x20the\x20recipient\x20per\x20share\x20in\x20the\x20allocator\x20description\x20and\x20bind\x20it\x20to\x20an\x20explicit\x20NON-EMPTY\x20Entity\x20the\x20buyer\x20can\x20see\x20before\x20ordering.\x20Never\x20leave\x20it\x20blank.'}):b['push']({'rule_id':'R-ECON-03','severity':'low','title':'Fee\x20share\x20has\x20a\x20declared\x20landing\x20—\x20keep\x20its\x20recipient\x20explicit\x20and\x20visible\x20pre-order','detail':'The\x20fee-shaped\x20keys\x20('+z['join'](',\x20')+')\x20land\x20in\x20allocator\x20rows/guards;\x20the\x20allocator\x20prose\x20names\x20no\x20recipient\x20slot,\x20so\x20the\x20binding\x20relies\x20on\x20the\x20row\x20declarations.\x20Keep\x20every\x20recipient\x20an\x20explicit\x20NON-EMPTY\x20Entity\x20the\x20buyer\x20can\x20see\x20before\x20ordering.','suggestion':'Re-check\x20at\x20template_scan\x20after\x20edits\x20that\x20the\x20fee\x20keys\x20still\x20land\x20in\x20rows\x20whose\x20recipient\x20is\x20explicit.'});}const m=/(?:layer-?1|service-?level|pool)[^.]*settles? the full amount|full amount to the (?:platform|organizer) pool/i['test'](e);m&&b['push']({'rule_id':'R-ECON-04','severity':'medium','title':'Escrow\x20transits\x20an\x20organizer\x20pool\x20before\x20reaching\x20the\x20merchant','detail':'The\x20full\x20order\x20amount\x20settles\x20into\x20a\x20platform/organizer\x20pool\x20first\x20and\x20is\x20then\x20redistributed.\x20That\x20contradicts\x20the\x20direct-sales\x20promise\x20(\x22money\x20moves\x20only\x20between\x20the\x20two\x20parties\x22)\x20and\x20makes\x20the\x20organizer\x20a\x20waypoint\x20on\x20every\x20payout,\x20including\x20every\x20refund.','suggestion':'Release\x20supplier\x20segments\x20directly\x20from\x20the\x20order\x27s\x20own\x20Allocation,\x20and\x20make\x20the\x20organizer\x20a\x20named\x20party\x20rather\x20than\x20a\x20transit\x20node.'});const n=Object['keys'](c)['find'](C=>/^attributed_.*_bps$/['test'](C)&&typeof c[C]==='number'),o=Object['keys'](c)['find'](C=>/^(?:base_)?commission_rate_bps$/['test'](C)&&typeof c[C]==='number');n&&o&&c[n]>c[o]&&b['push']({'rule_id':'R-ECON-05','severity':'medium','title':'Attribution-priced\x20take:\x20a\x20cheaper\x20acquisition\x20channel\x20is\x20charged\x20MORE','detail':n+'='+c[n]+'\x20exceeds\x20'+o+'='+c[o]+'.\x20Charging\x20more\x20for\x20attributed\x20orders\x20means\x20the\x20merchant\x27s\x20cheap\x20channels\x20(KOC,\x20social,\x20repeat\x20buyers)\x20are\x20penalised\x20—\x20the\x20opposite\x20of\x20what\x20direct\x20sales\x20should\x20reward.','suggestion':'Price\x20every\x20channel\x20identically.\x20Attribution\x20may\x20change\x20RANKING,\x20never\x20the\x20take.'});if(a['allocator']['mode']==='rate'){const C=Object['keys'](c)['filter'](F=>MERCHANT_SHARE_KEY['test'](F)&&typeof c[F]==='number'),D=Object['keys'](c)['filter'](F=>PLATFORM_TAKE_KEY['test'](F)&&typeof c[F]==='number'),E=[...C,...D];if(C['length']>0x0&&D['length']>0x0){const F=E['map'](I=>c[I])['filter'](I=>typeof I==='number'),G=F['reduce']((I,J)=>I+J,0x0),H=/surplus/i['test'](e);G!==0x2710&&!H&&b['push']({'rule_id':'R-ECON-06','severity':'critical','title':'Rate\x20shares\x20sum\x20to\x20'+G+',\x20not\x2010000','detail':'Declared\x20rate\x20shares\x20('+E['map']((I,J)=>I+'='+F[J])['join']('\x20+\x20')+')\x20total\x20'+G+'.\x20With\x20no\x20Surplus\x20recipient\x20the\x20remainder\x20is\x20not\x20protected:\x20the\x20chain\x20records\x20no\x20\x22already\x20triggered\x22\x20flag,\x20so\x20a\x20balance\x20left\x20behind\x20after\x20a\x20partial\x20split\x20can\x20be\x20claimed\x20REPEATEDLY\x20by\x20anyone\x20passing\x20the\x20same\x20Guard.\x20This\x20is\x20exactly\x20what\x20happens\x20when\x20a\x20platform\x20leg\x20is\x20zeroed\x20without\x20recomputing\x20the\x20merchant\x20leg.','suggestion':'Make\x20the\x20shares\x20sum\x20to\x20exactly\x2010000,\x20or\x20declare\x20an\x20explicit\x20Surplus\x20recipient\x20for\x20the\x20residual.'});}}const p=(a['allocator']['rows']??[])['map']((I,J)=>({'r':I,'i':J})),q=p['filter'](({r:I})=>I['recipient']==='entity'&&!(I['recipient_key']??'')['trim']());q['length']>0x0&&b['push']({'rule_id':ENTITY_RECIPIENT_RULE_ID,'severity':'critical','title':'Allocator\x20row(s)\x20'+q['map'](({i:I})=>'#'+I)['join'](',\x20')+'\x20name\x20no\x20Entity\x20recipient\x20—\x20the\x20share\x20silently\x20pays\x20the\x20deploying\x20merchant','detail':q['map'](({i:I})=>'rows['+I+']')['join'](',\x20')+'\x20declare\x20recipient=\x27entity\x27\x20with\x20no\x20recipient_key,\x20which\x20builds\x20as\x20'+'{\x20who:\x20{\x20Entity:\x20{\x20name_or_address:\x20\x22\x22\x20}\x20}\x20}.\x20That\x20is\x20NOT\x20a\x20no-op:\x20the\x20SDK\x20resolver\x20substitutes\x20the\x20DEFAULT\x20LOCAL\x20ACCOUNT\x20before\x20the\x20'+'address\x20reaches\x20Move,\x20so\x20the\x20order\x20escrow\x20pays\x20whoever\x20ran\x20the\x20deploy\x20—\x20the\x20\x27platform\x27\x20share\x20the\x20template\x20left\x20unnamed\x20becomes\x20the\x20merchant\x27s\x20'+('own\x20take.\x20'+DIRECT_SALES_INVARIANT),'suggestion':'Give\x20the\x20row\x20an\x20explicit\x20`recipient_key`\x20naming\x20the\x20party\x20(a\x20mark\x20name\x20or\x20a\x200x\x20address\x20the\x20buyer\x20can\x20see\x20BEFORE\x20ordering).\x20If\x20the\x20whole\x20sale\x20goes\x20'+'to\x20the\x20merchant,\x20do\x20not\x20declare\x20an\x20entity\x20row\x20at\x20all:\x20use\x20ONE\x20{\x20who:\x20{\x20GuardIdentifier:\x200\x20},\x20sharing:\x2010000,\x20mode:\x20\x22Rate\x22\x20}\x20leg.\x20The\x20scalar\x20'+'`allocator.recipient:\x20\x22entity\x22`\x20form\x20is\x20auditable\x20too:\x20it\x20must\x20carry\x20a\x20`recipient_key`\x20(or\x20a\x20`rows[]`\x20array)\x20when\x20no\x20rows\x20narrow\x20it.'});!a['allocator']['rows']&&a['allocator']['recipient']==='entity'&&!(a['allocator']['recipient_key']??'')['trim']()&&b['push']({'rule_id':ENTITY_RECIPIENT_RULE_ID,'severity':'critical','title':'Allocator\x20names\x20no\x20Entity\x20recipient\x20(scalar\x20form,\x20no\x20rows)\x20—\x20the\x20share\x20silently\x20pays\x20the\x20deploying\x20merchant','detail':'The\x20allocator\x20declares\x20scalar\x20recipient=\x27entity\x27\x20with\x20no\x20recipient_key\x20and\x20no\x20rows[],\x20which\x20builds\x20as\x20'+'{\x20who:\x20{\x20Entity:\x20{\x20name_or_address:\x20\x22\x22\x20}\x20}\x20}.\x20That\x20is\x20NOT\x20a\x20no-op:\x20the\x20SDK\x20resolver\x20substitutes\x20the\x20DEFAULT\x20LOCAL\x20ACCOUNT\x20before\x20the\x20'+'address\x20reaches\x20Move,\x20so\x20the\x20order\x20escrow\x20pays\x20whoever\x20ran\x20the\x20deploy\x20—\x20the\x20share\x20the\x20template\x20left\x20unnamed\x20becomes\x20the\x20merchant\x27s\x20'+('own\x20take.\x20'+DIRECT_SALES_INVARIANT),'suggestion':'Declare\x20the\x20destination\x20machine-checkably:\x20set\x20`recipient_key`\x20on\x20the\x20allocator\x20(a\x20mark\x20name\x20or\x20a\x200x\x20address\x20the\x20buyer\x20can\x20see\x20BEFORE\x20ordering),\x20'+'or\x20add\x20a\x20`rows[]`\x20array\x20carrying\x20the\x20on-chain\x20`who`\x20shape.\x20If\x20the\x20whole\x20sale\x20goes\x20to\x20the\x20merchant,\x20use\x20ONE\x20'+'{\x20recipient:\x20\x27guard_identifier\x27,\x20recipient_key:\x20\x270\x27\x20}\x20row\x20instead\x20of\x20an\x20entity\x20scalar.'});const s=p['filter'](({r:I})=>I['recipient']==='entity'&&/^0x0*$/i['test']((I['recipient_key']??'')['trim']()));s['length']>0x0&&b['push']({'rule_id':ENTITY_RECIPIENT_RULE_ID,'severity':'high','title':'Allocator\x20row(s)\x20'+s['map'](({i:I})=>'#'+I)['join'](',\x20')+'\x20name\x20the\x20zero\x20address\x20as\x20Entity\x20recipient','detail':s['map'](({i:I})=>'rows['+I+']')['join'](',\x20')+'\x20carry\x20recipient_key=\x270x0\x27\x20(or\x20an\x20all-zero\x20literal).\x20The\x20chain\x20does\x20NOT\x20reject\x20it:\x20'+'allocation.move:250-255\x20swallows\x20Recipient::Entity\x20in\x20a\x20(_)\x20catch-all\x20at\x20declaration\x20time,\x20and\x20allocation.move:451-453\x20/\x20:514\x20forward\x20the\x20raw\x20'+'address\x20straight\x20to\x20the\x20payout\x20constructor.\x20The\x20allocation\x20is\x20accepted\x20and\x20the\x20share\x20is\x20silently\x20transferred\x20to\x200x0\x20and\x20permanently\x20burned\x20—\x20'+'this\x20scan\x20is\x20the\x20only\x20defence.','suggestion':'Replace\x20the\x20zero\x20literal\x20with\x20the\x20real\x20recipient\x20address\x20(a\x20mark\x20name\x20or\x20a\x200x\x20address),\x20or\x20drop\x20the\x20row\x20if\x20the\x20share\x20is\x20not\x20owed.'});const u=I=>I['recipient']+':'+(I['recipient_key']??'')['trim']()['toLowerCase'](),v=/^(recover_gate|awarded_recover|terminal_settlement_recover)$/,w=new Set((a['allocator']['rows']??[])['filter'](I=>I['mode']==='rate'&&!v['test'](I['guard_key']??''))['map'](u)),x=p['filter'](({r:I})=>I['mode']==='surplus'&&w['has'](u(I)));return x['length']>0x0&&b['push']({'rule_id':'R-RECIPIENT-04','severity':'critical','title':'Surplus\x20row(s)\x20'+x['map'](({i:I})=>'#'+I)['join'](',\x20')+'\x20pay\x20a\x20recipient\x20a\x20Rate\x20leg\x20already\x20pays\x20—\x20the\x20remainder\x20swallows\x20an\x20undeclared\x20share','detail':x['map'](({i:I})=>'rows['+I+']')['join'](',\x20')+'\x20duplicate\x20a\x20Rate\x20leg\x27s\x20recipient.\x20The\x20chain\x20pays\x20every\x20Rate\x20leg\x20its\x20declared\x20basis\x20points\x20'+'and\x20then\x20pays\x20the\x20ENTIRE\x20remainder\x20to\x20the\x20Surplus\x20recipient,\x20so\x20this\x20party\x20quietly\x20receives\x20rate%\x20+\x20100%\x20of\x20the\x20residual\x20and\x20any\x20leg\x20the\x20'+'author\x20intended\x20but\x20omitted\x20(commission,\x20payment\x20fee,\x20platform\x20take)\x20is\x20never\x20created.\x20The\x20Rate-sum\x20rule\x20passes\x20because\x20the\x20sum\x20is\x20legal\x20—\x20'+'the\x20misroute\x20is\x20invisible\x20there,\x20and\x20order_allocators\x20freezes\x20permanently\x20at\x20publish.\x20Mainnet\x20precedent\x20(Booking\x20replica,\x202026-10-06):\x20the\x20'+'property\x20took\x20100%\x20(Rate\x208350\x20+\x20Surplus),\x20the\x2015%\x20commission\x20and\x201.5%\x20payment-fee\x20legs\x20never\x20existed,\x20and\x20the\x20published\x20Service\x20had\x20to\x20be\x20abandoned.','suggestion':'Point\x20the\x20Surplus\x20row\x20at\x20the\x20party\x20meant\x20to\x20absorb\x20the\x20remainder\x20(usually\x20the\x20merchant),\x20distinct\x20from\x20every\x20Rate\x20leg\x20—\x20or,\x20if\x20the\x20duplicated\x20'+'recipient\x20is\x20truly\x20intended\x20to\x20take\x20rate%\x20+\x20remainder,\x20collapse\x20the\x20two\x20rows\x20into\x20ONE\x20rate\x20row\x20so\x20the\x20declared\x20split\x20equals\x20the\x20actual\x20split.\x20'+'Every\x20intended\x20payee\x20must\x20be\x20its\x20own\x20explicit\x20row.'}),b;}const KNOWN_GUARD_REF_IDS=new Set([...GUARD_DESIGN_PATTERNS['map'](a=>a['id']),...GUARD_TEMPLATES['map'](a=>a['id'])]);function guardRefChecks(a){const b=[];for(const c of a['guards']){if(!/^(pattern\.[a-z0-9_]+|tpl_[a-z0-9_]+)$/['test'](c['template_id'])){b['push']({'rule_id':'R-REF-01','severity':'high','title':'Guard\x20reference\x20\x27'+c['template_id']+'\x27\x20is\x20not\x20a\x20resolvable\x20id','detail':'Guard\x20references\x20must\x20name\x20a\x20guard\x20design\x20pattern\x20(\x27pattern.*\x27,\x20'+GUARD_DESIGN_PATTERNS['length']+'\x20available)\x20or\x20a\x20guard\x20template\x20(\x27tpl_*\x27,\x20'+GUARD_TEMPLATES['length']+'\x20available).\x20Bare\x20prose\x20ids\x20dangle:\x20no\x20builder\x20can\x20resolve\x20them,\x20so\x20the\x20AI\x20invents\x20guard\x20logic\x20at\x20build\x20time.','suggestion':'Replace\x20with\x20the\x20semantically\x20nearest\x20pattern.*/tpl_*\x20id\x20(compose\x20multi-condition\x20logic\x20in\x20the\x20purpose\x20text).'});continue;}!KNOWN_GUARD_REF_IDS['has'](c['template_id'])&&b['push']({'rule_id':'R-REF-02','severity':'high','title':'Guard\x20reference\x20\x27'+c['template_id']+'\x27\x20does\x20not\x20exist\x20in\x20any\x20guard\x20catalog','detail':'The\x20id\x20is\x20namespaced\x20correctly\x20but\x20matches\x20no\x20guard\x20design\x20pattern\x20nor\x20guard\x20template\x20—\x20a\x20dangling\x20reference\x20the\x20AI\x20cannot\x20resolve.','suggestion':'Fix\x20the\x20id\x20(typo)\x20or\x20point\x20it\x20at\x20the\x20nearest\x20existing\x20pattern.*/tpl_*\x20entry.'});}return b;}function staticChecks(a){const b=[],c=j=>{const k=new RegExp('\x5cb'+j['replace'](/[.*+?^${}()|[\]\\]/g,'\x5c$&')+'\x5cb','i');for(const l of a['allocator']?.['rows']??[]){if(l['track']!=='refund'||!l['guard_key'])continue;const m=a['guards']['find'](n=>n['key']===l['guard_key']);if(m&&k['test']((m['key']??'')+'\x20'+m['purpose']))return!![];}return![];};for(const j of a['machine_shape']){const k=DISPUTE_FAMILY_NODE_REGEX['test'](j['name']),l=!k&&FUND_TERMINAL_NODE_REGEX['test'](j['name']);if(k||l&&!c(j['name']))b['push']({'rule_id':'R-M1-11','severity':'critical','title':'Machine\x20node\x20\x27'+j['name']+'\x27\x20models\x20dispute/refund\x20flow','detail':'Disputes\x20are\x20independent\x20of\x20the\x20Machine\x20workflow;\x20refunds\x20route\x20via\x20Allocators\x20triggered\x20by\x20business\x20states.','suggestion':'Remove\x20the\x20node;\x20route\x20refunds\x20via\x20Allocator\x20states\x20(closed_cancel/cancel_requested)\x20and\x20disputes\x20via\x20the\x20Arbitration\x20object.'});else l&&b['push']({'rule_id':'R-M1-11','severity':'low','title':'Machine\x20node\x20\x27'+j['name']+'\x27\x20reuses\x20a\x20fund-terminal\x20name\x20(guard-anchored,\x20exempt)','detail':'The\x20refund-track\x20allocator\x20consumes\x20a\x20guard\x20anchored\x20to\x20\x27'+j['name']+'\x27\x20—\x20the\x20guard\x20moves\x20the\x20funds,\x20so\x20the\x20node\x20is\x20a\x20routing\x20state,\x20not\x20a\x20money\x20move.','suggestion':'Prefer\x20a\x20routing-state\x20name\x20(closed_cancel/cancel_requested)\x20so\x20the\x20intent\x20is\x20self-evident\x20without\x20the\x20guard\x20chain.'});}const d=new Map();for(const m of a['guards']){if(/time_lock|order_holder|progress_state/['test'](m['template_id'])&&!/order\.service|project bind|service binding/i['test'](m['purpose'])){const n=d['get'](m['template_id'])??[];n['push'](m['key']??'(no\x20key)'),d['set'](m['template_id'],n);}}for(const [o,p]of d){b['push']({'rule_id':'R-C3-05','severity':'low','title':'Guard\x20\x27'+o+'\x27\x20consumes\x20a\x20submitted\x20Order\x20without\x20project\x20binding\x20('+p['length']+'x:\x20'+p['join'](',\x20')+')\x20—\x20advisory\x20(v148\x20backstop)','detail':'Passport\x20submissions\x20are\x20caller-built;\x20without\x20logic_equal[order.service,\x20<service>]\x20a\x20stale\x20order\x20from\x20another\x20project\x20could\x20satisfy\x20the\x20guard\x20for\x20a\x20fresh\x20order.\x20Since\x20protocol\x20v148\x20the\x20Progress\x20layer\x20itself\x20rejects\x20cross-order\x20submissions\x20(the\x20chain-side\x20task-binding\x20check),\x20so\x20this\x20is\x20now\x20defense-in-depth:\x20the\x20window\x20is\x20closed\x20at\x20the\x20chain,\x20the\x20template\x20binding\x20only\x20shortens\x20the\x20failure\x20distance.','suggestion':'Optionally\x20state\x20the\x20project\x20binding\x20in\x20the\x20guard\x20purpose\x20AND\x20include\x20it\x20in\x20the\x20guard\x20root\x20at\x20build\x20time\x20(fails\x20earlier,\x20closer\x20to\x20the\x20cause).\x20No\x20longer\x20a\x20publish\x20blocker.'});}a['machine_shape']['length']===0x0&&b['push']({'rule_id':'R-M1-01','severity':'critical','title':'machine_shape\x20is\x20empty','detail':'No\x20entry\x20node\x20—\x20the\x20Machine\x20cannot\x20start.','suggestion':'Add\x20at\x20least\x20one\x20entry\x20node\x20representing\x20the\x20escrowed\x20state.'});const e=a['guards']['some'](q=>/refund|cancel/i['test'](q['template_id'])||/refund|cancel/i['test'](q['purpose']))||/refund/i['test'](a['allocator']['description']);!e&&b['push']({'rule_id':'R1','severity':'high','title':'No\x20refund\x20path\x20detected','detail':'No\x20refund/cancel\x20guard\x20and\x20no\x20refund\x20route\x20in\x20the\x20allocator\x20description.','suggestion':'Add\x20a\x20refund/cancel\x20guard\x20or\x20an\x20allocator\x20refund\x20route\x20before\x20publishing.'});const f=a['guards']['some'](q=>q['host']==='arbitration')||a['trust_mechanisms']['some'](q=>q['startsWith']('R2'));!f&&b['push']({'rule_id':'R2','severity':'high','title':'No\x20independent\x20Arbitration\x20reference\x20detected','detail':'The\x20template\x20carries\x20no\x20arbitration-hosted\x20guard\x20and\x20no\x20R2\x20trust\x20mechanism.','suggestion':'Mount\x20an\x20independent\x20Arbitration\x20object\x20with\x20its\x20own\x20Permission.'});a['keeper_dependencies']['length']===0x0&&b['push']({'rule_id':'R9','severity':'medium','title':'No\x20keeper\x20dependencies\x20declared','detail':'Time-driven\x20transitions\x20only\x20ALLOW\x20advancement\x20—\x20someone\x20must\x20run\x20the\x20keepers.','suggestion':'Declare\x20the\x20keeper\x20operations\x20(timeouts,\x20window\x20expiries,\x20settlement\x20triggers).'});b['push'](...directSalesEconomyChecks(a));const h=unannotatedBuyerActionNodes(a['machine_shape']);return h['length']>0x0&&b['push']({'rule_id':'R-OPER-01','severity':'medium','title':'Buyer-side\x20node(s)\x20without\x20an\x20operator\x20annotation','detail':'Node(s)\x20'+h['map'](q=>'\x27'+q+'\x27')['join'](',\x20')+'\x20look\x20like\x20order-payer\x20actions\x20but\x20carry\x20no\x20operator\x20field.\x20At\x20build\x20time\x20they\x20default\x20to\x20a\x20merchant\x20permission\x20slot,\x20and\x20the\x20order\x20payer\x20cannot\x20advance\x20them\x20(E_PERMISSION_DENIED).','suggestion':'Annotate\x20true\x20buyer\x20actions\x20with\x20operator:\x20\x22order_payer\x22\x20(an\x20EMPTY\x20namedOperator\x20—\x20the\x20on-chain\x20check\x20resolves\x20it\x20to\x20the\x20order\x20payer);\x20rename\x20merchant-side\x20states\x20(e.g.\x20\x27cancelled\x27\x20->\x20\x27merchant_cancelled\x27)\x20when\x20the\x20actor\x20is\x20NOT\x20the\x20buyer.'}),b;}const PERIOD_COUNT_KEY_REGEX=/^(monthly_allocators|term_count|session_count|segment_count|periods|cycles|installments)$/;function poolPeriodCount(a){for(const [b,c]of Object['entries'](a['fee_params'])){if(PERIOD_COUNT_KEY_REGEX['test'](b)&&typeof c==='number'&&c>=0x2)return c;}return undefined;}function periodicReleaseChecks(a){const b=poolPeriodCount(a);if(b===undefined)return[];const c=[a['allocator']['description'],...a['build_notes'],...a['trust_mechanisms'],...a['guards']['map'](h=>h['purpose'])]['join']('\x20\x0a\x20'),d=[];/surplus/i['test'](c)&&!/no surplus|surplus[^.\n]*(disabled|forbidden|disallowed)|amount mode only|single surplus/i['test'](c)&&d['push']({'rule_id':'R-PER-01','severity':'high','title':'Multi-period\x20pool\x20('+b+'\x20periods)\x20declares\x20Surplus\x20without\x20a\x20terminal-only\x20qualifier','detail':'A\x20Surplus\x20allocator\x20entry\x20runs\x20balance::withdraw_all\x20(allocation.move:288-298).\x20In\x20a\x20pool\x20pre-funded\x20for\x20'+b+'\x20periods\x20it\x20drains\x20every\x20future\x20release,\x20not\x20just\x20the\x20remainder.','suggestion':'Release\x20each\x20period\x20with\x20Amount;\x20if\x20the\x20pool\x20remainder\x20settles\x20in\x20one\x20entry,\x20declare\x20it\x20explicitly\x20as\x20the\x20SINGLE\x20terminal\x20Surplus\x20at\x20the\x20settlement\x20node,\x20or\x20disable\x20Surplus\x20outright.'});const e=a['guards']['map'](h=>[h['key'],h['template_id'],h['purpose']]['filter'](Boolean)['join']('\x20'))['join']('\x20\x0a\x20'),f=c+'\x20\x0a\x20'+e,g=/per[- ](month|period|term|session|cycle|segment)|one per (rent )?period|release-sequence lock/i['test'](f)||/(?:month|period|term|week|session)_\d+_(?:release|unlock|guard)|release_\d+/i['test'](e);return!g&&d['push']({'rule_id':'R-PER-02','severity':'high','title':'Multi-period\x20pool\x20('+b+'\x20periods)\x20declares\x20no\x20per-period\x20release\x20Guard','detail':'alloc()\x20has\x20no\x20consumed/nonce\x20flag\x20(allocation.move:204-321):\x20two\x20releases\x20bound\x20to\x20the\x20SAME\x20Guard\x20can\x20both\x20fire\x20the\x20same\x20day\x20and\x20drain\x20the\x20pool.\x20The\x20cadence\x20gate\x20must\x20be\x20one\x20Guard\x20per\x20period.','suggestion':'Declare\x20one\x20release\x20Guard\x20per\x20period\x20(per-month/per-term\x20time-lock\x20Guards,\x20each\x20keyed\x20to\x20its\x20own\x20period\x20window)\x20in\x20the\x20guard\x20set.'}),!/threshold[^.\n]*(one|single|per[- ]|month|period|term|session|=\s*0\b|\b0\b|must be 0)/i['test'](c)&&d['push']({'rule_id':'R-PER-03','severity':'medium','title':'Multi-period\x20pool\x20('+b+'\x20periods)\x20does\x20not\x20pin\x20threshold\x20to\x20one\x20period','detail':'alloc()\x20asserts\x20balance\x20>=\x20threshold\x20before\x20EVERY\x20release\x20(allocation.move:206).\x20A\x20threshold\x20sized\x20to\x20the\x20total\x20pool\x20passes\x20the\x20first\x20release\x20and\x20then\x20locks\x20all\x20remaining\x20periods.','suggestion':'State\x20in\x20the\x20allocator\x20description\x20or\x20build\x20notes\x20that\x20threshold\x20=\x20one\x20period\x27s\x20release\x20amount\x20(never\x20the\x20pre-funded\x20total).'}),d;}const MIN_PRICE_KEY_REGEX=/^(?:min_[a-z0-9_]*?(?:price|amount|usd|value)|price_floor)$/,FLOOR_TEXT_REGEX=/fixed (?:fee|charge)[^.\n]*(?:<|less than|below) [^.\n]*(?:lowest|minimum|min)|minimum (?:sku|order|item|unit) (?:price|amount)|(?:below|under|<=)\s*the\s+smallest[^.\n]*(?:order|escrow|booking|price)/i,FIXED_FEE_TEXT_REGEX=/\bamount mode\b|fixed (?:fee|fulfillment|fulfilment|per[- ]order) (?:fee|charge)|\bAmount\b[^.\n]*(?:fee|charge)/i;function fundAnchorChecks(a){const b=[],c=[a['allocator']['description'],...a['build_notes'],...a['trust_mechanisms'],...a['guards']['map'](h=>h['template_id']+'\x20'+h['purpose'])]['join']('\x20\x0a\x20'),d=a['allocator']['refund_track']==='order_anchored'||/allocator_order_anchor/['test'](c)||/guardidentifier\(0\)|order[- ]anchored|for_object/i['test'](c);!d&&b['push']({'rule_id':'R-ANCHOR-01','severity':'critical','title':'Allocator\x20has\x20no\x20order\x20anchor\x20—\x20its\x20Guard\x20cannot\x20bind\x20the\x20paying\x20Order','detail':'Every\x20recipient\x20of\x20this\x20allocator\x20is\x20a\x20fixed\x20party\x20(recipient=\x27'+a['allocator']['recipient']+'\x27,\x20no\x20GuardIdentifier\x20row),\x20so\x20nothing\x20in\x20the\x20Guard\x27s\x20verification\x20context\x20names\x20the\x20Order\x20being\x20settled:\x20Recipient::Entity/Signer\x20are\x20resolved\x20without\x20any\x20submission\x20check\x20(allocation.move:451-456)\x20and\x20the\x20Allocation\x20itself\x20never\x20enters\x20the\x20Guard\x20context.\x20Testnet\x20proved\x20the\x20consequence:\x20a\x20passport\x20built\x20from\x20an\x20ALREADY-SETTLED\x20order\x20of\x20the\x20same\x20Service\x20drained\x20a\x20different\x20order\x27s\x20escrow\x20(CR-01).\x20The\x20identifier-255\x20once-slot\x20does\x20not\x20help\x20—\x20it\x20is\x20stored\x20per\x20Allocation,\x20so\x20a\x20fresh\x20pool\x20has\x20no\x20record.','suggestion':'Adopt\x20pattern.allocator_order_anchor:\x20add\x20one\x20{GuardIdentifier:\x200}\x20row\x20with\x20Rate\x200\x20(pays\x20nothing,\x20makes\x20the\x20submitted\x20Order\x20the\x20Guard\x27s\x20binding\x20target),\x20declare\x20refund_track:\x20\x22order_anchored\x22,\x20and\x20pin\x20the\x20Guard\x20expression\x20to\x20that\x20identifier\x20plus\x20logic_equal[order.service,\x20<this\x20service>].'});const e=a['allocator']['mode']==='amount',f=e||FIXED_FEE_TEXT_REGEX['test'](c),g=Object['keys'](a['fee_params'])['some'](h=>MIN_PRICE_KEY_REGEX['test'](h))||FLOOR_TEXT_REGEX['test'](c);f&&!g&&b['push']({'rule_id':'R-FIXFEE-01','severity':e?'critical':'high','title':'Fixed\x20Amount\x20fee\x20with\x20no\x20minimum\x20order\x20value\x20—\x20sub-fee\x20orders\x20deadlock\x20permanently','detail':'alloc()\x20asserts\x20balance\x20>=\x20fix\x20before\x20distributing\x20(allocation.move:390):\x20an\x20order\x20escrowed\x20BELOW\x20the\x20fixed\x20fee\x20can\x20never\x20settle,\x20and\x20the\x20terminal\x20nodes\x20(completed/closed_cancel)\x20leave\x20no\x20refund\x20path\x20for\x20it,\x20so\x20buyer\x20funds\x20and\x20the\x20order\x20strand\x20forever\x20(testnet\x20CR-02,\x20reproduced\x20on\x20a\x200.001\x20WOW\x20SKU\x20against\x20a\x200.15\x20WOW\x20fee).','suggestion':'Declare\x20a\x20minimum\x20listing/order\x20value\x20above\x20every\x20fixed\x20leg\x20in\x20fee_params\x20(e.g.\x20min_sku_price)\x20and\x20state\x20it\x20in\x20the\x20allocator\x20description,\x20or\x20model\x20the\x20per-order\x20fee\x20as\x20Rate/RateGross\x20instead\x20of\x20a\x20fixed\x20Amount.'});a['allocator']['once_per_order']===!![]&&!/per[- ]allocation|per[- ]pool|not cross[- ]order|within (a|the) (pool|allocation)/i['test'](c)&&b['push']({'rule_id':'R-ONCE-SCOPE-01','severity':'medium','title':'once_per_order\x20claim\x20does\x20not\x20state\x20its\x20per-Allocation\x20scope','detail':'The\x20identifier-255\x20once-slot\x20is\x20keyed\x20(guard,\x20allocator,\x20submission)\x20ON\x20ONE\x20Allocation,\x20so\x20replay\x20immunity\x20holds\x20within\x20a\x20single\x20pool\x20only;\x20a\x20second\x20Allocation\x20of\x20the\x20same\x20Service\x20starts\x20with\x20no\x20record.\x20Presenting\x20ONCE\x20as\x20general\x20idempotency\x20is\x20what\x20let\x20testnet\x20CR-01\x20read\x20as\x20\x27already\x20protected\x27.','suggestion':'Say\x20explicitly\x20that\x20255\x20protects\x20one\x20pool,\x20and\x20pair\x20it\x20with\x20the\x20order\x20anchor\x20(R-ANCHOR-01)\x20for\x20cross-order\x20safety.'});if(a['allocator']['once_per_order']===!![]){const h=new Set((a['allocator']['rows']??[])['map'](n=>n['guard_key'])['filter'](n=>typeof n==='string'&&n['length']>0x0)),j=h['size']>0x0?a['guards']['filter'](n=>n['key']!=null&&h['has'](n['key'])):a['guards'],k=j['map'](n=>n['key']??n['template_id']),l=j['some'](n=>{if(!n['template_id']['startsWith']('tpl_'))return![];const o=GUARD_TEMPLATES['find'](p=>p['id']===n['template_id']);return Array['isArray'](o?.['example_table'])&&o['example_table']['some'](p=>p?.['identifier']===0xfe||p?.['identifier']===0xff);}),m=/\bidentifier[- ]?25[45]\b/['test'](c)||/\b25[45]\b[^.\n]{0,80}\bb_submission\b/i['test'](c)||/ONCE-FOR-OBJECT/['test'](c);!l&&!m&&b['push']({'rule_id':'R-ONCE-ARM','severity':'critical','title':'once-slot\x20NOT\x20armed\x20—\x20once_per_order\x20is\x20claimed\x20but\x20no\x20254/255\x20submission\x20slot\x20is\x20declared\x20anywhere','detail':'once_per_order\x20has\x20NO\x20automatic\x20on-chain\x20wiring:\x20the\x20chain\x20only\x20sees\x20a\x20replay\x20defense\x20if\x20the\x20BUILT\x20Guard\x20table\x20declares\x20the\x20ONCE\x20submission\x20slot\x20(identifier\x20254\x20ONCE-FOR-ORDER\x20/\x20255\x20byte-keyed)\x20and\x20the\x20trigger\x20passport\x20submits\x20it.\x20This\x20template\x20sets\x20once_per_order=true,\x20yet\x20neither\x20a\x20tpl_*\x20guard\x20table\x20nor\x20the\x20build\x20notes\x20declare\x20the\x20slot\x20for\x20any\x20allocator-bound\x20guard\x20—\x20the\x20advertised\x20replay\x20protection\x20does\x20not\x20exist\x20on-chain.','suggestion':'Arm\x20the\x20allocator-bound\x20guard\x20row(s)\x20['+(k['join'](',\x20')||'<none\x20—\x20template\x20declares\x20no\x20guards>')+']:\x20add\x20the\x20arming\x20build_note\x20\x27Generation\x20must\x20add\x20a\x20submission\x20entry\x20{identifier:254,\x20b_submission:true,\x20value_type:\x22Address\x22,\x20object_type:\x22Order\x22}\x20to\x20each\x20allocator\x20Guard\x20and\x20submit\x20identifier\x20254\x20in\x20the\x20trigger\x20Passport\x27\x20(255\x20with\x20a\x20per-period\x20key\x20instead,\x20for\x20rails\x20that\x20legitimately\x20repeat),\x20or\x20reference\x20a\x20tpl_*\x20guard\x20whose\x20example_table\x20already\x20declares\x20the\x20slot\x20—\x20or\x20set\x20once_per_order=false\x20if\x20replay\x20protection\x20is\x20not\x20intended.'});}return b;}function templateText(a,b=[]){return[a['allocator']['description'],...a['build_notes'],...a['trust_mechanisms'],...a['guards']['map'](c=>c['template_id']+'\x20'+c['purpose']),...a['machine_shape']['map'](c=>c['name']+'\x20'+c['role']),...Object['entries'](a['time_anchors']??{})['map'](([c,d])=>c+'\x20'+d),...b]['join']('\x20\x0a\x20');}const BUY_GATE_CLAIM_REGEX=/\b(buy[\s-]?gate|purchase[\s-]?gate|age[\s-]?verification|age[\s-]?gate|adult[\s-]?verification|kyc[\s-]?gate|identity[\s-]?gate)\b/i;function buyKeyDeclarationChecks(a){const b=[];if(a['guards']['some'](c=>c['host']==='service'&&c['key']==='buy'))return b;return BUY_GATE_CLAIM_REGEX['test'](templateText(a))&&b['push']({'rule_id':'R-BUYKEY-01','severity':'critical','title':'A\x20purchase/buy\x20gate\x20is\x20declared\x20but\x20no\x20service\x20guard\x20carries\x20key\x20\x22buy\x22\x20—\x20the\x20gate\x20never\x20mounts','detail':'The\x20template\x20prose\x20declares\x20a\x20buy/purchase\x20gate\x20(age\x20verification,\x20KYC,\x20identity\x20gate\x20or\x20similar),\x20but\x20the\x20compiler\x20mounts\x20the\x20Service\x20buy\x20guard\x20ONLY\x20from\x20a\x20guard\x20spec\x20with\x20host=\x27service\x27\x20AND\x20key=\x27buy\x27.\x20No\x20such\x20spec\x20exists,\x20so\x20the\x20service\x20would\x20publish\x20with\x20NO\x20purchase\x20gate\x20while\x20trust_mechanisms\x20still\x20claim\x20one.','suggestion':'Add\x20key:\x20\x22buy\x22\x20to\x20the\x20service-host\x20guard\x20spec\x20that\x20implements\x20the\x20gate\x20(host\x20stays\x20\x27service\x27),\x20or\x20drop\x20the\x20gate\x20claim\x20from\x20the\x20prose\x20if\x20no\x20gate\x20is\x20intended.'}),b;}const STAY_DATE_REGEX=/check[\s-]?in|check[\s-]?out|departure\s+date|arrival\s+date|booking\s+date|checkin|checkout|stay\s+date|stay_nights|\bstay\s+nights?\b|\bper\s+night\b|入住|退房|离店|到店日/i,CHAIN_CLOCK_REGEX=/order\.time|progress\.current_time|\border\s+time\b|witness/i,REPOSITORY_DATE_SOURCE_REGEX=/(?:write|writes|written|storing|store|stores|persist|persisted|record|records|read|reads)\b[^.\n]{0,90}repositor|repositor\w*\b[^.\n]{0,90}(?:stay|check[\s-]?in|check[\s-]?out|departure|arrival|date)/i;function timeWindowAnchorChecks(a){const b=templateText(a);if(!STAY_DATE_REGEX['test'](b))return[];if(CHAIN_CLOCK_REGEX['test'](b)||REPOSITORY_DATE_SOURCE_REGEX['test'](b))return[];const c=b['match'](new RegExp(STAY_DATE_REGEX['source'],'gi'))??[],d=/\d+\s*[-–]\s*\d+\s*h(?:ours?|rs?)?\s*(?:adjustable|tunable|configurable)|\badjustable\b|\btunable\b/i['test'](b);return[{'rule_id':'R-WIN-ANCHOR-01','severity':'high','title':'Per-order\x20time\x20window(s)\x20anchored\x20to\x20a\x20stay\x20date\x20that\x20does\x20not\x20exist\x20on\x20chain\x20('+Array['from'](new Set(c))['slice'](0x0,0x5)['join'](',\x20')+')','detail':'The\x20template\x27s\x20windows\x20are\x20relative\x20to\x20a\x20check-in\x20/\x20check-out\x20/\x20departure\x20/\x20night\x20date.\x20No\x20such\x20field\x20exists\x20on\x20chain:\x20'+'`Order.items`\x20is\x20`vector<SaleItem>`\x20with\x20`SaleItem\x20{\x20item,\x20price,\x20quantity,\x20wip_hash\x20}`\x20(order.move:28-33)\x20and\x20the\x20purchasable\x20'+'`Sale\x20{\x20name,\x20price,\x20stock,\x20suspension,\x20wip,\x20wip_hash\x20}`\x20(service.move:100-107)\x20carries\x20no\x20schedule;\x20the\x20only\x20per-order\x20clock\x20is\x20'+'`Order.time`\x20(order.move:74),\x20the\x20CREATION\x20timestamp.\x20`Progress.current_time`\x20(progress.move:85)\x20is\x20overwritten\x20on\x20every\x20forward\x20'+'(progress.move:458)\x20and\x20`Progress.history`\x20records\x20node\x20visits,\x20so\x20neither\x20is\x20a\x20business\x20date.\x20A\x20window\x20declared\x20relative\x20to\x20the\x20'+'stay\x20calendar\x20is\x20therefore\x20UNREACHABLE\x20—\x20every\x20published\x20Guard\x20silently\x20measures\x20from\x20booking\x20time\x20instead,\x20and\x20for\x20a\x20lead\x20time\x20of\x20'+'days-to-weeks\x20that\x20is\x20a\x20material\x20semantic\x20loss,\x20not\x20a\x20rounding\x20error.'+(d?'\x20The\x20window\x20is\x20also\x20advertised\x20as\x20adjustable,\x20which\x20is\x20doubly\x20unreachable:\x20a\x20Guard\x20is\x20frozen\x20at\x20creation\x20'+'(transfer::freeze_object,\x20guard.move:262)\x20and\x20Machine\x20forwards\x20are\x20immutable\x20after\x20publish\x20(the\x20not-published\x20guard,\x20'+'machine.move:316),\x20so\x20an\x20\x27N-Mh\x20adjustable\x27\x20window\x20means\x20one\x20separately\x20published\x20Guard\x20per\x20window\x20value,\x20never\x20a\x20tunable\x20one.':''),'suggestion':'Express\x20every\x20window\x20relative\x20to\x20`order.time`\x20(or\x20`order.time\x20+\x20<window>`),\x20and\x20if\x20the\x20business\x20promise\x20is\x20genuinely\x20a\x20stay-date\x20'+'deadline,\x20write\x20the\x20stay\x20dates\x20into\x20a\x20Repository\x20at\x20buy\x20time,\x20pin\x20that\x20Repository\x20address\x20as\x20a\x20table\x20constant,\x20and\x20read\x20them\x20in\x20the\x20'+'Guard\x20(`query\x20repository.data`).\x20State\x20the\x20residual\x20semantic\x20loss\x20in\x20build_notes\x20rather\x20than\x20declaring\x20a\x20calendar-relative\x20window.'}];}function signerRefundChecks(a){const b=[],c=a['allocator']['rows']??[],d=c['find'](j=>j['recipient']==='signer'),e=a['allocator']['recipient']==='signer';if(!d&&!e)return b;const f=templateText(a),g=/refund|chargeback|repay|退款|(?:pay(?:ment|out)?|release|send|transfer|settle)\w*[^.\n]{0,40}to the (?:buyer|order|customer)/i['test'](f);if(!g)return b;const h=d?'allocator\x20row\x20'+d['track']+'/'+(d['recipient_key']??'?'):'allocator.recipient=\x27signer\x27';return b['push']({'rule_id':'R-SIGNER-02','severity':'high','title':'Refund\x20leg\x20pays\x20Recipient::Signer\x20—\x20the\x20keeper,\x20not\x20the\x20buyer\x20('+h+')','detail':'`Recipient::Signer`\x20resolves\x20to\x20`tx_context::sender(ctx)`\x20(allocation.move:615-617),\x20i.e.\x20whoever\x20signed\x20the\x20transaction\x20that\x20triggered\x20'+'`alloc`.\x20Time-driven\x20refunds\x20are\x20keeper-triggered\x20by\x20construction,\x20so\x20this\x20leg\x20pays\x20the\x20KEEPER,\x20and\x20because\x20`alloc()`\x20records\x20no\x20'+'consumed\x20flag\x20for\x20the\x20recipient,\x20first-come-first-served.\x20Only\x20`Recipient::GuardIdentifier`\x20(resolved\x20through\x20the\x20Guard\x20submission,\x20'+'allocation.move:585-611)\x20or\x20an\x20explicit\x20`Entity`\x20is\x20safe\x20for\x20a\x20refund.','suggestion':'Replace\x20the\x20Signer\x20refund\x20row\x20with\x20a\x20`{GuardIdentifier:\x200}`\x20row\x20(the\x20submission\x20for\x20a\x20Service-created\x20Allocation\x20is\x20pinned\x20to\x20the\x20paying\x20'+'Order,\x20so\x20only\x20`order.owner`\x20can\x20receive\x20it)\x20and\x20bind\x20the\x20Guard\x20to\x20`order.owner`\x20+\x20`progress.current\x20==\x20<refund\x20node>`.'}),b;}function orderAnchorDeclarationChecks(a){const b=templateText(a),c=a['allocator']['refund_track']==='order_anchored'||/order[\s-]anchored|order anchor|refund recipient is the order|anchor row|guardidentifier\s*\(\s*0\s*\)|for_object|退款接收方为订单/i['test'](b);if(!c)return[];const d=(a['allocator']['rows']??[])['some'](g=>g['recipient']==='guard_identifier'||g['recipient']==='guard_identifier_to_order'),e=a['guards']['some'](h=>h['template_id']==='pattern.allocator_order_anchor');if(d||e)return[];const f=a['allocator']['recipient']??'?';return[{'rule_id':'R-RECIPIENT-02','severity':'high','title':'Order-anchored\x20refund\x20recipient\x20is\x20asserted\x20in\x20prose\x20but\x20declared\x20nowhere\x20machine-checkable','detail':'The\x20template\x20claims\x20an\x20order-anchored\x20escrow\x20/\x20refund\x20recipient\x20while\x20its\x20machine-readable\x20allocator\x20says\x20recipient=\x27'+f+'\x27\x20'+'with\x20no\x20`guard_identifier`\x20row\x20and\x20no\x20`pattern.allocator_order_anchor`\x20Guard\x20reference.\x20Two\x20on-chain\x20facts\x20make\x20the\x20claim\x20as\x20written\x20'+'unbuildable:\x20(1)\x20`Recipient`\x20has\x20only\x20`GuardIdentifier(u8)`\x20/\x20`Entity(address)`\x20/\x20`Signer`\x20(allocation.move:148-152)\x20—\x20there\x20is\x20NO\x20'+'`Order`\x20variant,\x20so\x20\x27the\x20refund\x20recipient\x20is\x20the\x20order\x20object\x27\x20can\x20only\x20be\x20written\x20as\x20a\x20`GuardIdentifier`\x20row;\x20(2)\x20recipients\x20that\x20are\x20'+'all\x20fixed\x20`Entity`\x20rows\x20resolve\x20without\x20the\x20passport\x20submission\x20(allocation.move:612-614)\x20and\x20the\x20Allocation\x20never\x20enters\x20the\x20Guard\x20'+'context,\x20so\x20the\x20Guard\x20has\x20no\x20order\x20to\x20bind\x20at\x20all\x20—\x20the\x20CR-01\x20drain\x20shape.\x20A\x20build\x20agent\x20reading\x20the\x20prose\x20instead\x20of\x20the\x20schema\x20will\x20'+'emit\x20an\x20Entity\x20refund\x20leg\x20to\x20the\x20merchant,\x20or\x20a\x20Signer\x20leg\x20to\x20the\x20keeper.','suggestion':'Declare\x20the\x20anchor\x20machine-checkably:\x20one\x20`{\x20recipient:\x20\x27guard_identifier\x27,\x20recipient_key:\x20\x270\x27,\x20mode:\x20\x27rate\x27,\x20value:\x200\x20}`\x20row\x20(the\x20'+'pattern.allocator_order_anchor\x20convention)\x20plus\x20`refund_track:\x20\x27order_anchored\x27`,\x20and\x20reference\x20`pattern.allocator_order_anchor`\x20in\x20the\x20'+'guard\x20set\x20with\x20the\x20`logic_equal[order.service,\x20<this\x20service>]`\x20binding\x20stated\x20in\x20its\x20purpose.'}];}const EDGE_DEPENDENCY_REGEX=/\b(?:incoming|outgoing|arb_refund)\s+edge\b|\bstop[\s-]node\b|\bedges?\b|\bpairs?\b|\bforwards?\b|one pair|two pairs/i;function topologyChecks(a){const b=[],c=templateText(a);if(a['machine_shape']['some'](j=>(j['from']??[])['length']>0x0))return b;EDGE_DEPENDENCY_REGEX['test'](c)&&b['push']({'rule_id':'R-TOPO-01','severity':'high','title':'machine_shape\x20ships\x20nodes\x20only\x20—\x20no\x20Pair/forward\x20list,\x20so\x20stop-node\x20fund-exit\x20coverage\x20is\x20unauditable','detail':'This\x20template\x27s\x20correctness\x20depends\x20on\x20Machine\x20edges\x20(its\x20own\x20notes\x20reason\x20about\x20incoming/outgoing\x20edges,\x20pairs\x20and\x20stop-node\x20'+'fund-exit\x20coverage),\x20but\x20`machine_shape`\x20carries\x20NO\x20edges:\x20an\x20edge\x20on\x20chain\x20is\x20`Node[target].pairs\x20=\x20{\x20prev_node,\x20threshold,\x20'+'forwards[]\x20}`,\x20which\x20this\x20schema\x20cannot\x20express.\x20The\x20scanner\x20therefore\x20has\x20to\x20invent\x20a\x20linear\x20chain,\x20and\x20the\x20mandatory\x20'+'stop-node\x20walk\x20(R-M5-03\x20/\x20R-M5-09:\x20every\x20rest\x20state\x20needs\x20a\x20defined\x20withdrawal\x20AND\x20refund\x20rule,\x20satisfiable\x20in\x20both\x20directions)\x20'+'cannot\x20be\x20performed\x20—\x20an\x20uncovered\x20stop\x20node\x20strands\x20escrow\x20permanently\x20once\x20Machine\x20+\x20Allocator\x20are\x20frozen\x20at\x20publish.','suggestion':'Either\x20state\x20the\x20edges\x20explicitly\x20in\x20build_notes\x20as\x20`prev\x20─forward(op,w)→\x20next`\x20with\x20the\x20Pair\x20grouping,\x20or\x20declare\x20a\x20machine-readable\x20'+'edge\x20list\x20so\x20the\x20scanner\x20can\x20audit\x20stop-node\x20coverage\x20and\x20prev_node\x20uniqueness\x20instead\x20of\x20guessing.'});const d=a['machine_shape']['map'](j=>j['name']);if(d['length']===0x0)return b;const e=d['filter'](j=>BRANCH_STATE_REGEX['test'](j));if(e['length']===0x0)return b;const f=d[0x0],g=!BRANCH_STATE_REGEX['test'](d[0x1]),h=(g?0x1:0x0)+e['length'];if(h<=0x1)return b;return b['push']({'rule_id':'R-TOPO-02','severity':'medium','title':'Node\x20\x27'+f+'\x27\x20has\x20'+h+'\x20outgoing\x20rails\x20—\x20declare\x20the\x20Pair\x20grouping\x20(E_DUPLICATE_NODE_PREV\x20is\x20per\x20TARGET\x20node,\x20not\x20per\x20source)','detail':'From\x20\x27'+f+'\x27\x20the\x20declared\x20node\x20set\x20requires\x20'+h+'\x20distinct\x20rails\x20'+('('+(g?'the\x20linear\x20rail\x20to\x20\x27'+d[0x1]+'\x27,\x20':''))+(e['map'](j=>'the\x20branch\x20to\x20\x27'+j+'\x27')['join'](',\x20')+').\x20These\x20are\x20LEGAL\x20and\x20must\x20NOT\x20be\x20merged:\x20an\x20edge\x20A→B\x20is\x20')+'stored\x20in\x20`Node[B].pairs\x20=\x20{\x20prev_node:\x20A,\x20threshold,\x20forwards[]\x20}`,\x20and\x20the\x20chain\x20rejects\x20only\x20the\x20SAME\x20`prev_node`\x20appearing\x20'+'twice\x20inside\x20ONE\x20node\x27s\x20pairs\x20(`assert!(!vector::contains(&res,\x20&pair.prev_node),\x20E_DUPLICATE_NODE_PREV)`,\x20machine.move:171\x20and\x20'+'machine.move:440).\x20Rails\x20into\x20different\x20targets\x20occupy\x20different\x20nodes,\x20so\x20each\x20`prev_node`\x20still\x20appears\x20exactly\x20once\x20per\x20node.\x20'+'THE\x20HAZARD\x20IS\x20THE\x20MIRROR\x20IMAGE:\x20two\x20forwards\x20from\x20the\x20SAME\x20source\x20into\x20the\x20SAME\x20target\x20must\x20be\x20ONE\x20Pair\x20carrying\x20both\x20forwards\x20—\x20'+'a\x20builder\x20that\x20emits\x20one\x20Pair\x20per\x20forward\x20duplicates\x20`prev_node`\x20and\x20ABORTS\x20at\x20publish,\x20after\x20Machine\x20+\x20Guard\x20are\x20frozen.\x20Note\x20'+'also\x20that\x20one\x20forward\x20cannot\x20satisfy\x20two\x20operators:\x20each\x20forward\x20contributes\x20its\x20weight\x20at\x20most\x20once\x20(locked\x20by\x20its\x20first\x20operator,\x20'+'progress.move:425-431),\x20so\x20a\x20dual-confirmation\x20step\x20needs\x20`threshold\x20=\x202`\x20with\x20two\x20DISTINCT\x20forwards.\x20A\x20node\x20list\x20cannot\x20distinguish\x20'+'these\x20cases,\x20which\x20is\x20why\x20this\x20is\x20advisory\x20and\x20not\x20a\x20proven\x20defect.','suggestion':'Do\x20NOT\x20merge\x20the\x20rails.\x20Instead\x20declare\x20the\x20grouping\x20explicitly\x20in\x20build_notes\x20as\x20'+'`prev\x20─forward(op,w)→\x20next`,\x20marking\x20which\x20forwards\x20SHARE\x20one\x20target\x20and\x20therefore\x20belong\x20in\x20ONE\x20Pair,\x20and\x20state\x20each\x20Pair\x27s\x20'+'`threshold`\x20(2\x20with\x20two\x20distinct\x20forwards\x20when\x20two\x20different\x20operators\x20must\x20act).\x20This\x20also\x20lets\x20the\x20scanner\x20audit\x20prev_node\x20'+'uniqueness\x20instead\x20of\x20guessing.\x20Related:\x20R-TOPO-01\x20(high)\x20is\x20the\x20finding\x20that\x20records\x20that\x20edges\x20are\x20unauditable\x20at\x20all.'}),b;}function reachabilityChecks(a){const b=a['machine_shape']??[];if(b['length']===0x0)return[];if(!b['some'](s=>(s['from']??[])['length']>0x0))return[];const c=new Map(b['map'](s=>[s['name'],s])),d=new Map(),f=[];for(const s of b){for(const u of s['from']??[]){const v=typeof u==='string'?u:u?.['prev'];if(v==='')f['push'](s['name']);else{if(!d['has'](v))d['set'](v,[]);d['get'](v)['push'](s['name']);}}}const g=[];if(f['length']===0x0)g['push']('no\x20entry\x20edge\x20(prev:\x20\x22\x22)\x20—\x20the\x20Machine\x20has\x20no\x20starting\x20Pair\x20and\x20orders\x20can\x20never\x20begin');else f['length']>0x1&&g['push'](f['length']+'\x20entry\x20edges\x20(prev:\x20\x22\x22)\x20into\x20'+f['map'](w=>'\x27'+w+'\x27')['join'](',\x20')+'\x20—\x20'+'exactly\x20one\x20starting\x20Pair\x20is\x20expressible\x20on\x20chain\x20(the\x20first\x20pair\x20with\x20prev_node\x20\x22\x22)');const h=new Set(f),j=[...f];while(j['length']>0x0){const w=j['pop']();for(const x of d['get'](w)??[]){!h['has'](x)&&(h['add'](x),j['push'](x));}}const k=b['filter'](y=>!h['has'](y['name']))['map'](y=>'\x27'+y['name']+'\x27');k['length']>0x0&&g['push']('unreachable\x20from\x20the\x20entry\x20(declared\x20but\x20dead):\x20'+k['join'](',\x20'));const l=y=>y['semantic_role']==='final'||y['semantic_role']==='cancelled',n=new Map();for(const [y,z]of d){for(const A of z){if(!n['has'](A))n['set'](A,[]);n['get'](A)['push'](y);}}const o=new Set(),p=b['filter'](l)['map'](B=>B['name']);p['forEach'](B=>o['add'](B));while(p['length']>0x0){const B=p['pop']();for(const C of n['get'](B)??[]){!o['has'](C)&&(o['add'](C),p['push'](C));}}const q=b['filter'](D=>!l(D)&&!o['has'](D['name'])&&(d['get'](D['name'])??[])['length']>0x0)['map'](D=>{const E='exits\x20lead\x20only\x20to\x20'+[...new Set(d['get'](D['name'])??[])]['map'](F=>'\x27'+F+'\x27')['join'](',\x20')+',\x20none\x20of\x20which\x20reaches\x20a\x20settlement\x20or\x20refund\x20endpoint';return'\x27'+D['name']+'\x27\x20('+(D['semantic_role']??'no\x20semantic_role')+')\x20—\x20'+E;});q['length']>0x0&&g['push']('no\x20path\x20to\x20a\x20terminal\x20(final/cancelled):\x20'+q['join'](';\x20'));if(g['length']===0x0)return[];return[{'rule_id':'R-TOPO-03','severity':'high','title':'Machine\x20edge\x20graph\x20breaks\x20reachability\x20—\x20declared\x20semantics\x20can\x20never\x20execute\x20or\x20never\x20end','detail':'Auditing\x20the\x20structured\x20from-edges:\x20'+g['join'](';\x20')+'.\x20Every\x20declared\x20node\x20must\x20be\x20'+'reachable\x20from\x20the\x20single\x20entry\x20Pair,\x20and\x20every\x20non-terminal\x20node\x20must\x20reach\x20a\x20final/cancelled\x20'+'endpoint\x20—\x20buy\x20escrows\x20ATOMICALLY,\x20so\x20a\x20node\x20from\x20which\x20the\x20world\x20cannot\x20end\x20strands\x20the\x20pool.\x20'+'Machine\x20topology\x20is\x20frozen\x20at\x20publish\x20(IMMUT-001),\x20so\x20these\x20defects\x20are\x20unfixable\x20after\x20the\x20fact;\x20'+'the\x20only\x20remedy\x20is\x20correcting\x20the\x20template\x20BEFORE\x20the\x20Machine\x20is\x20built.\x20Zero-exit\x20leaves\x20are\x20'+'reported\x20by\x20R-DEAD-END\x20(an\x20`optional:\x20true`\x20mark\x20does\x20not\x20rescue\x20them);\x20this\x20finding\x20covers\x20nodes\x20'+'WITH\x20exits\x20whose\x20exits\x20never\x20reach\x20an\x20endpoint.','suggestion':'Fix\x20the\x20edge\x20data:\x20give\x20every\x20non-entry\x20node\x20a\x20from-edge\x20chain\x20back\x20to\x20the\x20entry,\x20give\x20every\x20mandatory\x20'+'state\x20at\x20least\x20one\x20forward\x20path\x20into\x20a\x20final/cancelled\x20endpoint,\x20and\x20mark\x20genuinely\x20skippable\x20side\x20'+'actions\x20`optional:\x20true`\x20(which\x20exempts\x20them\x20from\x20THIS\x20audit\x27s\x20mandatory-flow\x20reading\x20only\x20—\x20a\x20'+'zero-exit\x20optional\x20leaf\x20is\x20still\x20an\x20R-DEAD-END\x20lockup).\x20One\x20entry\x20edge\x20(prev:\x20\x22\x22)\x20only\x20—\x20the\x20'+'on-chain\x20Machine\x20has\x20exactly\x20one\x20starting\x20Pair.'}];}function loopFundChecks(a){const b=a['machine_shape']??[];if(b['length']===0x0||!b['some'](s=>(s['from']??[])['length']>0x0))return[];const c=new Map();for(const s of b){for(const u of s['from']??[]){const v=typeof u==='string'?u:u?.['prev'];if(typeof v!=='string'||v==='')continue;if(!c['has'](v))c['set'](v,[]);c['get'](v)['push'](s['name']);}}const d=findLoopCycles(c);if(d['length']===0x0)return[];const f=[],g=a['reentry_kind']&&a['reentry_kind']!=='none'?a['reentry_kind']:undefined,h=d['filter'](w=>classifyLoopCycle(w['cycle'],g)==='remedy');h['length']>0x0&&f['push']({'rule_id':'R-LOOP-FUND','severity':'low','title':'Remedy\x20loop\x20cycle(s)\x20'+h['map'](w=>'['+w['cycle']['join']('\x20->\x20')+']')['join'](',\x20')+'\x20—\x20same-order\x20revisit,\x20no\x20new\x20charge\x20implied','detail':'A\x20revision/review/rework/refund/cancel/claim-family\x20cycle\x20re-enters\x20work\x20states\x20WITHIN\x20one\x20paid\x20order,\x20so\x20it\x20needs\x20'+'no\x20fund\x20gate\x20while\x20the\x20revisit\x20is\x20free\x20(crs\x20P2-3\x20visibility).\x20If\x20the\x20business\x20EVER\x20intends\x20a\x20revisit\x20'+'to\x20cost\x20money,\x20that\x20fee\x20IS\x20enforceable\x20via\x20the\x20allocation.balance\x20Guard\x20query\x20(1051,\x20witness\x20'+'OrderAllocation\x20109)\x20—\x20but\x20that\x20reshapes\x20the\x20cycle\x20into\x20the\x20charge\x20tier\x20below.','suggestion':'Keep\x20remedy\x20loops\x20single-charge\x20(one\x20paid\x20order,\x20revisions\x20included)\x20—\x20or,\x20if\x20each\x20revisit\x20'+'must\x20be\x20paid,\x20declare\x20the\x20guard-layer\x20fund\x20gate\x20convention\x20(see\x20the\x20charge\x20tier)\x20or\x20replace\x20the\x20loop\x20'+'with\x20per-period\x20NEW\x20Orders\x20(REUSE\x20pattern\x20—\x20a\x20fresh\x20order\x20per\x20period\x20instead\x20of\x20an\x20in-order\x20loop\x20that\x20replays\x20its\x20forwards\x20every\x20lap).'});const j=templateText(a),k=/order_renew/i['test'](j)&&/atomic|re-fund/i['test'](j),l=d['filter'](w=>classifyLoopCycle(w['cycle'],g)==='renewal'),n=k?[]:l,o=d['filter'](w=>classifyLoopCycle(w['cycle'],g)==='charge'),p=[...o,...n];if(p['length']===0x0)return f;const q=o['length']===0x0?'the\x20atomic\x20order_renew\x20funding\x20convention\x20is\x20not\x20declared\x20in\x20the\x20template\x20prose':n['length']===0x0?'a\x20cycle\x20implies\x20a\x20per-revisit\x20charge\x20(retake\x20/\x20session-card\x20shape)\x20whose\x20fund\x20gate\x20is\x20not\x20declared\x20in\x20the\x20template\x20prose':'a\x20cycle\x20implies\x20a\x20per-revisit\x20charge\x20with\x20no\x20declared\x20fund\x20gate,\x20AND\x20the\x20renewal-shaped\x20cycles\x20lack\x20the\x20declared\x20order_renew\x20convention';return f['push']({'rule_id':'R-LOOP-FUND','severity':'critical','title':'Loop\x20cycle(s)\x20'+p['map'](w=>'['+w['cycle']['join']('\x20->\x20')+']')['join'](',\x20')+'\x20—\x20revisit\x20funding\x20is\x20not\x20declared\x20at\x20the\x20template\x20layer','detail':'A\x20cycle\x20lets\x20an\x20order\x20revisit\x20nodes,\x20and\x20the\x20contract\x20never\x20verifies\x20that\x20a\x20revisit\x20re-funds\x20the\x20'+'Allocation\x20—\x20every\x20charge-bearing\x20loop\x20forward\x20MUST\x20carry\x20the\x20new-period\x20payment\x20atomically\x20or\x20the\x20loop\x20allows\x20'+'zero-value\x20re-delivery\x20cycles\x20(test/11\x20R2-F3,\x20crs\x20P2-3).\x20The\x20allocation.balance\x20Guard\x20query\x20(1051,\x20witness\x20'+'OrderAllocation\x20109)\x20makes\x20the\x20fee\x20enforceable\x20at\x20the\x20guard\x20layer,\x20but\x20this\x20template\x20does\x20not\x20DECLARE\x20that\x20'+('convention,\x20and\x20here\x20'+q+'.'),'suggestion':(n['length']>0x0?'For\x20the\x20renewal-shaped\x20cycle(s)\x20'+n['map'](w=>'['+w['cycle']['join']('\x20->\x20')+']')['join'](',\x20')+':\x20declare\x20the\x20'+'atomic\x20order_renew\x20convention\x20in\x20build_notes\x20—\x20\x27use\x20the\x20order\x20call\x27s\x20`order_renew`\x20field:\x20ONE\x20PTB\x20pays\x20'+'the\x20period\x20amount\x20into\x20the\x20Allocation\x20and\x20advances\x20the\x20renew\x20forward\x20atomically\x20(fund\x20+\x20record\x20+\x20'+'advance,\x20no\x20unfunded-advance\x20window)\x27.\x20':'')+'For\x20charge-bearing\x20cycles\x20that\x20are\x20not\x20renewal-shaped,\x20declare\x20the\x20guard-layer\x20fund\x20gate\x20in\x20build_notes\x20—\x20'+'\x27the\x20revisit\x20forward\x20carries\x20a\x20Guard:\x20constant\x20=\x20order\x20address,\x20convert_witness\x20OrderAllocation(109),\x20'+'allocation.balance\x20(query\x201051)\x20>=\x20revisit\x20fee\x27\x20—\x20or\x20replace\x20the\x20loop\x20'+'with\x20per-period\x20NEW\x20Orders\x20(REUSE\x20pattern\x20—\x20a\x20fresh\x20order\x20per\x20period)\x20or\x20remove\x20the\x20back-edge\x20—\x20rework\x20the\x20business\x20'+'flow\x20so\x20re-entry\x20is\x20a\x20fresh\x20order,\x20not\x20a\x20node\x20revisit.'}),f;}function deadEndLockChecks(a){const b=a['machine_shape']??[];if(b['length']===0x0||!b['some'](k=>(k['from']??[])['length']>0x0))return[];const c=new Map(),d=[];for(const k of b){for(const l of k['from']??[]){const n=typeof l==='string'?l:l?.['prev'];if(n==='')d['push'](k['name']);else{if(!c['has'](n))c['set'](n,[]);c['get'](n)['push'](k['name']);}}}const f=new Set(d),g=[...d];while(g['length']>0x0){const o=g['pop']();for(const p of c['get'](o)??[]){!f['has'](p)&&(f['add'](p),g['push'](p));}}const h=q=>/pool is empty|pool drains?ed|drains? in full|already (?:released|paid)|escrow (?:is )?(?:empty|drained)/i['test'](q),j=b['filter'](q=>q['semantic_role']!=='final'&&q['semantic_role']!=='cancelled')['filter'](q=>f['has'](q['name'])&&(c['get'](q['name'])??[])['length']===0x0)['filter'](q=>!h(q['role']))['map'](q=>'\x27'+q['name']+'\x27\x20('+(q['semantic_role']??'no\x20semantic_role')+(q['optional']===!![]?',\x20optional':'')+')');if(j['length']===0x0)return[];return[{'rule_id':'R-DEAD-END','severity':'high','title':'Dead-end\x20node(s)\x20'+j['join'](',\x20')+'\x20—\x20taking\x20the\x20forward\x20locks\x20the\x20order\x20and\x20its\x20escrow\x20forever','detail':'A\x20reachable\x20node\x20with\x20no\x20outgoing\x20forward\x20strands\x20the\x20order\x20the\x20moment\x20someone\x20advances\x20into\x20it:\x20'+'Machine\x20topology\x20freezes\x20at\x20publish,\x20so\x20there\x20is\x20no\x20later\x20repair,\x20and\x20`optional:\x20true`\x20does\x20NOT\x20help\x20—\x20'+'the\x20buyer\x20can\x20still\x20take\x20the\x20optional\x20forward,\x20and\x20the\x20order\x20then\x20stands\x20at\x20a\x20node\x20from\x20which\x20no\x20Pair\x20'+'exists\x20(Etsy\x20mainnet\x20ets1_o2\x20stopped\x20exactly\x20there:\x20delivered\x20→\x20reviewed,\x20history\x20ends,\x20no\x20rail\x20can\x20'+'ever\x20anchor\x20that\x20state\x20again).\x20Buy\x20escrows\x20ATOMICALLY,\x20so\x20the\x20full\x20pool\x20rides\x20into\x20the\x20dead\x20end\x20'+'unless\x20a\x20rail\x20drained\x20it\x20upstream.\x20This\x20is\x20the\x20defect\x20class\x20the\x20old\x20optional-leaf\x20exemption\x20in\x20'+'R-TOPO-03\x20let\x20ship\x20into\x20two\x20builtin\x20templates.','suggestion':'Wire\x20an\x20exit\x20edge\x20back\x20into\x20the\x20live\x20flow\x20(review\x20re-joins\x20the\x20settlement\x20rail,\x20e.g.\x20reviewed\x20'+'─settle→\x20completed)\x20or\x20remove\x20the\x20node\x20from\x20machine_shape\x20and\x20keep\x20the\x20action\x20off-Machine\x20'+'(Repository\x20/\x20Reward).\x20If\x20the\x20node\x20is\x20genuinely\x20a\x20record\x20state\x20whose\x20pool\x20already\x20drained\x20upstream,\x20'+'say\x20so\x20in\x20its\x20role\x20(\x27pool\x20is\x20empty\x27)\x20so\x20this\x20rule\x20and\x20TERMINAL-NO-RAIL\x20exempt\x20it.'}];}function reviewNoRaceChecks(a){const b=a['machine_shape'];if(b['length']===0x0)return[];const c=[],d=k=>/review(ed|ing)?\b/i['test'](k)&&!/un|no |not |without |expire/i['test'](k),f=k=>/unreviewed|no[_ -]?review|not[_ -]?reviewed|without[_ -]?review|review[^.;]{0,40}expire|expire[^.;]{0,40}review|review[_ -]?timeout|auto[_ -]?accept[^.;]{0,30}review/i['test'](k),g=k=>/\b(accept(ed|ance)?|approv(ed|e|al)|place(ment|d)?|rul(ed|ing)|valid(ated)?|award(ed)?|winner)\b/i['test'](k)&&!/timeout|expire|auto[_ -]?accept|un|no |not |without |reject|denied|dismiss/i['test'](k),h=k=>/accept(ance)?[_ -]?timeout|auto[_ -]?accept|judge[_ -]?timeout|ruling[_ -]?timeout|decision[_ -]?timeout|placement[_ -]?timeout|accept[^.;]{0,30}expire|expire[^.;]{0,30}accept|appeal[^.;]{0,20}expire/i['test'](k),j=new Map();for(const k of b){const l=new Set();for(const m of k['from']??[]){const o=typeof m==='string'?{'prev':m}:m;if(!o['prev']||l['has'](o['prev']))continue;l['add'](o['prev']);const p=j['get'](o['prev'])??[];p['push']({'name':k['name'],'role':k['role']??''}),j['set'](o['prev'],p);}}for(const [q,s]of j){const u=s['find'](A=>d(A['name']+'\x20'+A['role'])),v=s['find'](A=>A['name']!==u?.['name']&&f(A['name']+'\x20'+A['role'])),w=s['find'](A=>g(A['name']+'\x20'+A['role'])),x=s['find'](A=>A['name']!==w?.['name']&&h(A['name']+'\x20'+A['role'])),y=u??w,z=u!==undefined&&v!==undefined?v:w!==undefined&&x!==undefined?x:undefined;if(y===undefined||z===undefined)continue;c['push']({'rule_id':'R-REVIEW-NORACE','severity':'high','title':'Node\x20\x27'+q+'\x27\x20fans\x20out\x20\x27'+y['name']+'\x27\x20and\x20its\x20complement\x20\x27'+z['name']+'\x27\x20as\x20SIBLING\x20outgoing\x20edges\x20—\x20complementary\x20conditions\x20race\x20(F-REVIEW-BLOCK)','detail':'Sibling\x20forwards\x20on\x20one\x20NodePair\x20have\x20no\x20on-chain\x20mutual\x20exclusion.\x20Reviewed/unreviewed\x20(or\x20accepted/acceptance-timeout)\x20'+'as\x20parallel\x20edges\x20race\x20on\x20their\x20time\x20conditions:\x20in\x20an\x20overlap\x20BOTH\x20fire\x20(double\x20movement),\x20in\x20a\x20gap\x20NEITHER\x20fires\x20—\x20and\x20with\x20'+'topology\x20frozen\x20at\x20publish\x20the\x20neither-gap\x20is\x20a\x20permanent\x20deadlock\x20that\x20no\x20later\x20repair\x20can\x20close.','suggestion':'Fold\x20the\x20complement\x20into\x20ONE\x20release\x20guard\x20as\x20a\x20logic_or\x20time\x20variant\x20(\x27reviewed\x20OR\x20unreviewed\x20after\x20T\x27\x20/\x20\x27accepted\x20OR\x20'+'auto-accept\x20after\x20T\x27)\x20on\x20a\x20single\x20edge\x20—\x20REVIEW-GATED\x20RELEASE\x20in\x20guard-design-patterns\x20—\x20or\x20give\x20each\x20sibling\x20its\x20own\x20NodePair\x20'+'so\x20the\x20choice\x20is\x20a\x20build-time\x20topology\x20decision,\x20not\x20a\x20runtime\x20race.'});}return c;}function afterSalesRailChecks(a){const b=a['after_sales_mode'];if(b===undefined||b==='none')return[];const c=a['machine_shape'],d=b==='return'?/return|refund/i:b==='exchange'?/exchange|replace|reship|swap/i:/warranty|repair|claim/i;if(c['some'](e=>d['test'](e['name'])))return[];return[{'rule_id':'R-AFTER-SALES-RAIL','severity':'high','title':'after_sales_mode\x20\x27'+b+'\x27\x20declares\x20a\x20buyer\x20remedy\x20but\x20machine_shape\x20has\x20no\x20backing\x20rail\x20(no\x20node\x20matching\x20'+d+')','detail':'A\x20declared\x20after-sales\x20capability\x20the\x20topology\x20cannot\x20walk\x20is\x20a\x20false\x20promise\x20at\x20quote\x20time.\x20compile\x20hard-blocks\x20'+'this\x20(AFTER_SALES_RAIL_MISSING);\x20the\x20scanner\x20surfaces\x20it\x20at\x20authoring\x20time.\x20The\x20money-safety\x20invariants\x20'+'(claimed_by\x20polarity\x20pair,\x20delivered-entry\x20window\x20anchor,\x20no\x20double-remedy)\x20are\x20separate\x20generic\x20rules\x20and\x20are\x20'+'NOT\x20re-checked\x20here.','suggestion':'Add\x20the\x20\x27'+b+'\x27\x20node\x20family\x20(e.g.\x20return_requested\x20->\x20returned\x20for\x20\x27return\x27)\x20with\x20its\x20claimed_by\x20polarity\x20pair\x20'+'(refund\x20leg\x20some==false\x20/\x20merchant-recovery\x20leg\x20some==true,\x20INV-C1)\x20anchored\x20on\x20the\x20delivered\x20ENTRY\x20time\x20(INV-C2),\x20'+'de-conflicted\x20against\x20settlement\x20so\x20the\x20two\x20never\x20both\x20pay\x20(INV-C3)\x20—\x20or\x20set\x20after_sales_mode\x20\x27none\x27.'}];}function acceptanceModeChecks(a){const b=a['acceptance_mode'];if(b===undefined||b==='none')return[];const c=[],d=b==='contest'||b==='bounty'||b==='agent';d&&a['arbitration_mode']!=='third_party'&&c['push']({'rule_id':'R-ACCEPTANCE-JUDGE','severity':'high','title':'acceptance_mode\x20\x27'+b+'\x27\x20is\x20judge-decided\x20but\x20arbitration_mode\x20is\x20\x27'+(a['arbitration_mode']??'none')+'\x27,\x20not\x20\x27third_party\x27\x20(INV-A3)','detail':'A\x20judge-decided\x20acceptance\x20(contest\x20ranking\x20/\x20bounty\x20triage\x20/\x20agent\x20evaluator)\x20lets\x20a\x20third\x20party\x20rule\x20on\x20whether\x20the\x20'+'escrow\x20releases.\x20If\x20that\x20decider\x20is\x20not\x20independent\x20of\x20the\x20party\x20owing\x20the\x20payout,\x20the\x20merchant\x20self-adjudicates\x20its\x20own\x20'+'obligation.\x20compile\x20hard-blocks\x20this\x20(ACCEPTANCE_JUDGE_NOT_INDEPENDENT);\x20the\x20scanner\x20surfaces\x20it\x20at\x20authoring\x20time.\x20The\x20'+'publish-gate\x20controller-disjointness\x20half\x20is\x20checkArbitrationNeutrality,\x20which\x20already\x20gates\x20every\x20build.','suggestion':'Set\x20arbitration_mode\x20\x27third_party\x27\x20so\x20an\x20independent\x20venue/judge\x20Permission\x20rules\x20(R2),\x20or\x20use\x20acceptance_mode\x20\x27milestone\x27\x20'+'if\x20the\x20buyer\x20genuinely\x20self-adjudicates\x20the\x20delivery.'});const e=a['fee_params']?.['revision_rounds_max'],f=typeof e==='number'||typeof e==='string'&&e['trim']()!==''&&/^\d+$/['test'](e['trim']());if(f){const g=(a['guards']??[])['some'](h=>h['host']==='repository'||/repository/i['test'](h['template_id']??''));!g&&c['push']({'rule_id':'R-ACCEPTANCE-REVISION','severity':'high','title':'acceptance_mode\x20\x27'+b+'\x27\x20declares\x20a\x20finite\x20revision\x20cap\x20(revision_rounds_max\x20=\x20'+String(e)+')\x20with\x20no\x20counter-backed\x20Repository\x20guard\x20(INV-A1)','detail':'progress.move\x20caps\x20EDGE\x20count\x20(MAX_FORWARD\x20/\x20MAX_NODE_PAIR),\x20never\x20VISIT\x20count,\x20so\x20a\x20revision\x20loop\x20can\x20be\x20re-entered\x20any\x20'+'number\x20of\x20times.\x20A\x20finite\x20revision_rounds_max\x20written\x20in\x20fee_params\x20alone\x20is\x20a\x20promise\x20the\x20chain\x20cannot\x20keep\x20—\x20compile\x20'+'hard-blocks\x20it\x20(ACCEPTANCE_REVISION_UNBOUNDED).\x20This\x20is\x20the\x20authoring-time\x20twin.','suggestion':'Declare\x20revision_rounds_max\x20\x27unlimited\x27\x20(the\x20honest\x20form\x20—\x20the\x20loop\x20is\x20then\x20genuinely\x20unbounded),\x20or\x20mount\x20a\x20counter-backed\x20'+'Repository\x20guard\x20(pattern.repository_data_check\x20reading\x20a\x20per-order\x20revision\x20tally\x20written\x20via\x20'+'pattern.repository_write_authorization)\x20that\x20gates\x20redelivery\x20once\x20the\x20tally\x20reaches\x20the\x20cap.'});}return c;}function installmentModeChecks(a){const b=a['installment_mode'];if(b===undefined||b==='none')return[];const c=a['machine_shape']??[];if(c['length']===0x0||!c['some'](o=>(o['from']??[])['length']>0x0))return[];const d=/(due|owed|owing|unpaid|awaiting|pending)/i,f=/(paid|captured|funded|settled)/i,g=/(deposit|down_?pay|balance_due|balance_owed|awaiting|installment|milestone)/i,h=/(refund|cancel|exit|forfeit|kill|void|abandon|release|expire|lapse)/i,j=[];for(const o of c){for(const p of o['from']??[]){if(typeof p==='string')j['push']({'prev':p,'target':o['name']});else j['push']({'prev':p?.['prev']??'','target':o['name'],'guardKey':p?.['guard_key']});}}const k=[],l=j['filter'](q=>d['test'](q['prev'])&&f['test'](q['target'])&&(q['guardKey']===undefined||q['guardKey']['trim']()===''));l['length']>0x0&&k['push']({'rule_id':'R-INSTALLMENT-FUNDING','severity':'high','title':'installment_mode\x20\x27'+b+'\x27\x20has\x20an\x20ungated\x20funding\x20forward\x20('+l['map'](q=>'\x27'+q['prev']+'\x27\x20→\x20\x27'+q['target']+'\x27')['join'](',\x20')+')\x20—\x20a\x20bare\x20advance\x20is\x20a\x20zero-value\x20capture\x20(INV-B1)','detail':'A\x20capture\x20forward\x20(a\x20DUE\x20state\x20advancing\x20into\x20a\x20PAID\x20state)\x20with\x20no\x20guard_key\x20lets\x20the\x20Machine\x20advance\x20WITHOUT\x20the\x20'+'later\x20payment\x20landing\x20in\x20the\x20Allocation\x20—\x20the\x20balance\x20is\x20recorded\x20paid\x20on\x20a\x20zero-value\x20advance\x20(H4).\x20compile\x20hard-blocks\x20'+'this\x20(INSTALLMENT_FUNDING_UNGATED);\x20the\x20scanner\x20surfaces\x20it\x20at\x20authoring\x20time.\x20Whether\x20the\x20bound\x20Guard\x20actually\x20reads\x20'+'allocation.balance\x20is\x20R-LOOP-FUND\x27s\x20job,\x20not\x20this\x20rule\x27s.','suggestion':'Bind\x20a\x20fund-gate\x20Guard\x20on\x20each\x20capture\x20forward\x20(constant\x20=\x20order\x20address,\x20convert_witness\x20OrderAllocation(109),\x20'+'allocation.balance\x20query\x201051\x20>=\x20the\x20capture\x20amount)\x20and\x20route\x20the\x20buyer\x27s\x20agent\x20through\x20the\x20one-PTB\x20order_renew\x20call\x20'+'(single\x20transaction:\x20create\x20the\x20payment\x20receipt\x20→\x20fund\x20the\x20Allocation\x20→\x20issue\x20the\x20payment\x20→\x20advance)\x20so\x20capture\x20+\x20advance\x20are\x20atomic.\x20Pair\x20the\x20'+'balance\x20gate\x20with\x20the\x20once\x20slot\x20(H5\x20—\x20the\x20fund\x20gate\x20is\x20a\x20STATE\x20READ,\x20not\x20a\x20once).'});const n=[];for(const q of c){if(!g['test'](q['name']))continue;const s=j['filter'](u=>u['prev']===q['name']);if(!s['some'](u=>h['test'](u['target'])))n['push'](q['name']);}return n['length']>0x0&&k['push']({'rule_id':'R-INSTALLMENT-DEPOSIT','severity':'high','title':'installment_mode\x20\x27'+b+'\x27\x20holds\x20buyer\x20funds\x20at\x20'+n['map'](u=>'\x27'+u+'\x27')['join'](',\x20')+'\x20with\x20no\x20deposit-exit\x20rail\x20(INV-B2)','detail':'There\x20is\x20no\x20on-chain\x20obligation\x20to\x20pay\x20the\x20balance\x20(H1).\x20A\x20deposit-held\x20state\x20whose\x20only\x20outgoing\x20edges\x20go\x20forward\x20(pay\x20'+'more)\x20strands\x20the\x20already-paid\x20portion\x20when\x20the\x20buyer\x20walks\x20away\x20—\x20Machine\x20+\x20Allocator\x20are\x20immutable\x20(IMMUT-001),\x20so\x20it\x20is\x20'+'a\x20permanent\x20stranding,\x20not\x20a\x20fixable\x20typo.\x20compile\x20hard-blocks\x20this\x20(INSTALLMENT_DEPOSIT_STRANDED);\x20this\x20is\x20the\x20'+'authoring-time\x20twin.','suggestion':'Add\x20a\x20deposit-exit\x20rail\x20from\x20each\x20held\x20state\x20—\x20a\x20refund/cancel\x20forward\x20into\x20an\x20exit\x20node\x20whose\x20allocator\x20returns\x20the\x20held\x20'+'funds\x20to\x20the\x20order\x20payer\x20(GuardIdentifier(0))\x20or\x20applies\x20the\x20declared\x20deposit_exit_policy\x20(full\x20refund\x20vs\x20a\x20kill\x20fee\x20'+'compensating\x20the\x20merchant\x20for\x20the\x20reserved\x20capacity).'}),k;}function affiliateModeChecks(a){const b=a['affiliate_mode'];if(b===undefined||b==='none')return[];const c=[],d=/(commission|affiliate|referr|attribut|partner_?payout)/i,e=a['machine_shape']??[],f=e['some'](l=>d['test'](l['name'])),g=a['allocator']?.['rows']??[],h=g['some'](l=>d['test'](l['value_from']??'')||d['test'](l['recipient_key']??''));!f&&!h&&c['push']({'rule_id':'R-AFFILIATE-RAIL','severity':'high','title':'affiliate_mode\x20\x27'+b+'\x27\x20declares\x20a\x20commission\x20overlay\x20with\x20no\x20commission\x20node\x20and\x20no\x20commission\x20allocator\x20row\x20(INV-D3)','detail':'A\x20declared\x20referral/affiliate\x20commission\x20with\x20no\x20rail\x20to\x20walk\x20it\x20is\x20a\x20false\x20promise\x20at\x20quote\x20time.\x20compile\x20hard-blocks\x20this\x20'+'(AFFILIATE_RAIL_MISSING);\x20the\x20scanner\x20surfaces\x20it\x20at\x20authoring\x20time.\x20The\x20commission\x20leg\x20MUST\x20be\x20INDEPENDENT\x20of\x20the\x20goods\x20escrow\x20'+'(防抢池)\x20—\x20that\x20money-safety\x20half\x20rides\x20the\x20generic\x20DUAL-RAIL-01\x20+\x20once/order-anchor\x20audits,\x20not\x20this\x20rule.','suggestion':'Add\x20an\x20INDEPENDENT\x20commission\x20leg:\x20a\x20Rate\x20row\x20off\x20a\x20dedicated\x20commission\x20pool\x20(never\x20a\x20Surplus/Rate\x20drain\x20of\x20the\x20buyer\x27s\x20goods\x20'+'escrow)\x20to\x20an\x20explicit\x20non-empty\x20partner\x20Entity,\x20gated\x20by\x20a\x20window-anchored\x20claim\x20guard\x20(INV-D1\x20rides\x20TIME-ANCHOR-01)\x20so\x20the\x20'+'commission\x20is\x20claimable\x20only\x20after\x20the\x20attribution/refund\x20window\x20closes.\x20Name\x20the\x20node\x20or\x20the\x20row\x20recipient_key/value_from\x20'+'with\x20a\x20commission-family\x20token\x20so\x20the\x20rail\x20is\x20machine-detectable\x20(a\x20free-text\x20note\x20is\x20NOT\x20a\x20detection\x20signal\x20—\x20direct-sales\x20'+'templates\x20carry\x20\x270%\x20commission\x27\x20negation\x20notes).'});const j=/(post-?lock|锁后|clawback|不可追偿|不可撤销|unrecoverable|irrevocab|no\s*(?:revers|recov|clawback)|cannot be reversed|once released|released commission)/i,k=(a['build_notes']??[])['some'](l=>j['test'](l));return!k&&c['push']({'rule_id':'R-AFFILIATE-DISCLOSURE','severity':'high','title':'affiliate_mode\x20\x27'+b+'\x27\x20has\x20no\x20build_note\x20disclosing\x20the\x20post-lock\x20no-clawback\x20truth\x20(INV-D2)','detail':'SOLE\x20TRUTH:\x20Allocation\x20distribute\x20is\x20a\x20ONE-WAY\x20outflow\x20(no\x20debit/clawback\x20primitive,\x20§11.0\x20G2),\x20so\x20once\x20a\x20commission\x20is\x20RELEASED\x20it\x20'+'CANNOT\x20be\x20reversed\x20on\x20chain\x20—\x20a\x20refund/chargeback\x20after\x20the\x20attribution\x20window\x20leaves\x20the\x20affiliate\x20commission\x20unrecoverable.\x20A\x20'+'template\x20that\x20declares\x20the\x20overlay\x20without\x20disclosing\x20this\x20implies\x20a\x20recovery\x20capability\x20the\x20chain\x20does\x20not\x20have\x20(L-04/D-5).\x20'+'compile\x20hard-blocks\x20it\x20(AFFILIATE_CLAWBACK_UNDISCLOSED);\x20this\x20is\x20the\x20authoring-time\x20twin.','suggestion':'Add\x20a\x20build_note\x20stating\x20the\x20post-lock\x20truth\x20honestly,\x20e.g.\x20\x22post-lock:\x20a\x20released\x20affiliate\x20commission\x20is\x20unrecoverable\x20/\x20'+'不可追偿\x20—\x20refunds\x20after\x20the\x20attribution\x20window\x20do\x20NOT\x20claw\x20back\x20the\x20partner\x20payout.\x22\x20Pair\x20with\x20the\x20INV-D1\x20window\x20anchor\x20so\x20the\x20'+'commission\x20is\x20only\x20claimable\x20once\x20the\x20refund\x20window\x20has\x20closed,\x20minimizing\x20the\x20unrecoverable\x20surface.'}),c;}function crowdfundingModeChecks(a){const b=a['crowdfunding_mode'];if(b===undefined||b==='none')return[];const c=[],d=/(releas|settle|funded|disburs|project)/i,e=/(refund|missed|unmet|return|reimburse)/i,f=a['machine_shape']??[],g=a['allocator']?.['rows']??[],h=f['some'](u=>d['test'](u['name'])),j=g['some'](u=>u['track']==='settlement'&&(d['test'](u['guard_key']??'')||d['test'](u['recipient_key']??''))),k=f['some'](u=>e['test'](u['name'])),l=g['some'](u=>u['track']==='refund'||e['test'](u['guard_key']??''));!h&&!j&&c['push']({'rule_id':'R-CROWDFUNDING-RAIL','severity':'high','title':'crowdfunding_mode\x20\x27'+b+'\x27\x20declares\x20a\x20campaign\x20with\x20no\x20release/settlement\x20node\x20and\x20no\x20settlement\x20allocator\x20row\x20(INV-E1)','detail':'A\x20declared\x20campaign\x20with\x20no\x20exit\x20rail\x20strands\x20the\x20escrowed\x20contributions\x20at\x20the\x20deadline.\x20compile\x20hard-blocks\x20this\x20'+'(CROWDFUNDING_THRESHOLD_GATE_MISSING);\x20the\x20scanner\x20surfaces\x20it\x20at\x20authoring\x20time.\x20The\x20money-safety\x20half\x20(claimed_by\x20'+'polarity\x20pair\x20/\x20no\x20double-remedy)\x20rides\x20the\x20generic\x20DUAL-RAIL-01\x20+\x20RAIL_POLARITY_COLLISION\x20audits,\x20not\x20this\x20rule.','suggestion':'Add\x20a\x20release\x20leg:\x20a\x20Rate\x2010000\x20row\x20to\x20a\x20NON-EMPTY\x20project\x20Entity,\x20gated\x20at\x20the\x20campaign-deadline\x20settlement\x20terminal.\x20Name\x20'+'the\x20node\x20or\x20the\x20row\x20guard_key/recipient_key\x20with\x20a\x20release-family\x20token\x20so\x20the\x20rail\x20is\x20machine-detectable\x20(a\x20free-text\x20note\x20'+'is\x20NOT\x20a\x20detection\x20signal).'});b==='threshold'&&!k&&!l&&c['push']({'rule_id':'R-CROWDFUNDING-RAIL','severity':'high','title':'crowdfunding_mode\x20\x27threshold\x27\x20declares\x20an\x20all-or-nothing\x20campaign\x20with\x20no\x20refund-family\x20node/row\x20(INV-E1\x20/\x20D-BUG-2)','detail':'A\x20missed\x20goal\x20would\x20strand\x20every\x20contribution\x20instead\x20of\x20returning\x20it.\x20compile\x20hard-blocks\x20this\x20'+'(CROWDFUNDING_THRESHOLD_GATE_MISSING).\x20The\x20release\x20and\x20refund\x20legs\x20are\x20mutually\x20exclusive\x20on\x20the\x20same\x20aggregate\x20'+'(D-BUG-2\x20escrow-exit\x20polarity):\x20aggregate\x20>=\x20goal\x20→\x20release;\x20aggregate\x20<\x20goal\x20→\x20refund.','suggestion':'Add\x20the\x20refund\x20leg\x20as\x20the\x20D-BUG-2\x20twin\x20of\x20the\x20release\x20leg:\x20a\x20per-contributor\x20refund\x20row\x20(for_object\x20slot\x20254,\x20claimed_by\x20'+'some==false)\x20on\x20a\x20\x27refund\x27\x20track\x20or\x20a\x20refund-family\x20guard_key,\x20plus\x20a\x20recover_gate\x20rail\x20(claimed_by\x20some==true)\x20so\x20an\x20'+'arbitration-awarded\x20order\x27s\x20residual\x20still\x20exits.'});if(b==='threshold'){const u=a['guards']??[],v=u['some'](w=>(w['host']==='repository'||/repository_write/i['test'](w['template_id']))&&(w['policy']?.['id_from']??'')['toLowerCase']()==='signer');!v&&c['push']({'rule_id':'R-CROWDFUNDING-AGGREGATE','severity':'high','title':'crowdfunding_mode\x20\x27threshold\x27\x20gates\x20release\x20on\x20an\x20aggregate\x20with\x20no\x20writer-bound\x20(id_from\x20signer)\x20Repository\x20policy\x20(INV-E2)','detail':'The\x20threshold\x20total\x20is\x20a\x20repository.data\x20sum-where\x20(query\x201174\x20→\x20U256)\x20over\x20contribution\x20rows.\x20If\x20those\x20rows\x20are\x20NOT\x20'+'writer-bound,\x20the\x20aggregate\x20is\x20forgeable\x20—\x20anyone\x20could\x20inflate\x20the\x20total\x20and\x20fake\x20a\x20\x27goal\x20met\x27\x20(R-X1-17\x20'+'existence-is-not-trust).\x20compile\x20hard-blocks\x20it\x20(CROWDFUNDING_AGGREGATE_UNBOUND);\x20this\x20is\x20the\x20authoring-time\x20twin.','suggestion':'Mount\x20a\x20host:\x22repository\x22\x20guard\x20resolving\x20pattern.repository_write_authorization\x20with\x20policy\x20id_from\x20signer\x20and\x20an\x20'+'identity\x20write_guard\x20(order.owner==Signer\x20/\x20order.agent\x20has\x20Signer),\x20so\x20each\x20backer\x20can\x20record\x20only\x20their\x20OWN\x20contribution\x20'+'row.\x20repository.move\x20only\x20asserts\x20the\x20write_guard\x20LIST\x20is\x20non-empty\x20(E_POLICY_WRITE_GUARD_REQUIRED=22),\x20never\x20what\x20a\x20listed\x20'+'guard\x20proves\x20—\x20a\x20placeholder\x20that\x20returns\x20true\x20is\x20an\x20OPEN\x20write.'});}const m=a['build_notes']??[],n=/(attest|keeper|aggregate trust|read-?only sum|not a chain-?verified|只读求和|聚合值|独立重算)/i,o=/(not investment|non-?investment|不构成投资|收益承诺|no (?:investment )?return|never promise)/i,p=/(kyc|aml|securities|money-?transmission|regulatory|跨境|合规)/i,q=/(no-?refund|non-?refundable|keep-?it-?all|不退|不提供退款|不设达标)/i,s=[];if(b==='threshold'&&!m['some'](w=>n['test'](w)))s['push']('the\x20aggregate-trust\x20boundary\x20(the\x20funding\x20total\x20is\x20a\x20keeper-attested\x20Repository\x20sum,\x20NOT\x20a\x20chain-verified\x20money\x20oracle)');if(!m['some'](w=>o['test'](w)))s['push']('the\x20L-01\x20non-investment\x20statement\x20(never\x20promise\x20returns\x20/\x20promote\x20coin\x20price;\x20不构成投资建议或收益承诺)');if(!m['some'](w=>p['test'](w)))s['push']('the\x20L-05\x20KYC/AML\x20+\x20cross-border\x20regulatory\x20caution\x20(HIGH\x20intensity)');if(b==='flexible'&&!m['some'](w=>q['test'](w)))s['push']('the\x20flexible\x20keep-it-all\x20NO-REFUND\x20posture\x20(contributions\x20non-refundable\x20once\x20the\x20deadline\x20passes;\x20不提供退款)');return s['length']>0x0&&c['push']({'rule_id':'R-CROWDFUNDING-DISCLOSURE','severity':'high','title':'crowdfunding_mode\x20\x27'+b+'\x27\x20has\x20build_notes\x20missing\x20honest\x20disclosure(s):\x20'+s['length']+'\x20(INV-E3)','detail':'Missing:\x20'+s['join'](';\x20')+'.\x20A\x20campaign\x20that\x20declares\x20the\x20overlay\x20without\x20these\x20disclosures\x20implies\x20a\x20chain-verified\x20'+'custody\x20proof,\x20an\x20investment\x20return,\x20or\x20a\x20refund\x20the\x20model\x20does\x20not\x20have\x20(L-04/L-01/L-05).\x20compile\x20hard-blocks\x20it\x20'+'(CROWDFUNDING_DISCLOSURE_MISSING);\x20this\x20is\x20the\x20authoring-time\x20twin.','suggestion':'Add\x20build_notes\x20stating\x20each\x20honestly:\x20the\x20aggregate\x20is\x20a\x20read-only\x20sum\x20over\x20keeper-attested\x20writer-bound\x20rows\x20(not\x20an\x20'+'independent\x20re-computation\x20of\x20every\x20escrow\x20balance);\x20a\x20threshold/flexible\x20raise\x20is\x20NOT\x20an\x20investment\x20(never\x20promise\x20returns\x20or\x20'+'promote\x20coin\x20price);\x20pooled\x20cross-border\x20fundraising\x20is\x20HIGH\x20regulatory\x20intensity\x20(KYC/AML);\x20and\x20for\x20a\x20flexible\x20model,\x20'+'contributions\x20are\x20non-refundable\x20once\x20the\x20deadline\x20passes.'}),c;}export function rootHasRewardRecordGate(a){if(a===null||typeof a!=='object')return![];const b=a;if(b['type']==='query_reward_record_exists')return!![];if(b['type']==='query'&&typeof b['query']==='string'&&/^reward\.record[ .](has|count|find|exists_where)/i['test'](b['query']))return!![];if(b['type']==='query'&&typeof b['query']==='number'&&[0x64c,0x64d,0x65a,0x65d]['includes'](b['query']))return!![];for(const c of b['nodes']??[])if(rootHasRewardRecordGate(c))return!![];for(const d of b['and']??[])if(rootHasRewardRecordGate(d))return!![];for(const e of b['or']??[])if(rootHasRewardRecordGate(e))return!![];if(b['node']!==undefined&&rootHasRewardRecordGate(b['node']))return!![];return![];}function subtreeHasOrderAmount(a){if(Array['isArray'](a))return a['some'](subtreeHasOrderAmount);if(a===null||typeof a!=='object')return![];const b=a;if(b['type']==='query'&&b['query']==='order.amount')return!![];if(b['type']==='query'&&b['query']===0x619)return!![];return(b['nodes']??[])['some'](subtreeHasOrderAmount);}export function rootHasPositiveAmountLeg(a){if(a===null||typeof a!=='object')return![];const b=a;if(typeof b['type']==='string'&&/^logic_as_u256_greater/['test'](b['type'])&&subtreeHasOrderAmount(b))return!![];for(const c of b['nodes']??[])if(rootHasPositiveAmountLeg(c))return!![];for(const d of b['and']??[])if(rootHasPositiveAmountLeg(d))return!![];for(const e of b['or']??[])if(rootHasPositiveAmountLeg(e))return!![];if(b['node']!==undefined&&rootHasPositiveAmountLeg(b['node']))return!![];return![];}function rewardZeroOrderChecks(a){const b=(a['guards']??[])['filter'](h=>h['host']==='reward');if(b['length']===0x0)return[];const c=b['some'](h=>{if(!h['template_id']['startsWith']('tpl_'))return![];const j=GUARD_TEMPLATES['find'](k=>k['id']===h['template_id']);return rootHasPositiveAmountLeg(j?.['example_root']);}),d=templateText(a),e=/order\.amount/i['test'](d)&&/positive[- ]amount|zero[- ]?(total|value)|0[- ]?value/i['test'](d);if(c||e)return[];const f=b['map'](h=>h['key']??h['template_id']);return[{'rule_id':'R-REWARD-ZERO-ORDER','severity':'medium','title':'Reward-claim\x20guard(s)\x20['+f['join'](',\x20')+']\x20not\x20positive-amount\x20gated\x20—\x20a\x20zero-total\x20order\x20can\x20mint\x20a\x20reward\x20claim','detail':'A\x20coupon\x20that\x20zeroes\x20the\x20basket\x20(MINUS\x20value\x20>=\x20the\x20SKU\x20price,\x20RATES\x2010000)\x20creates\x20a\x20ZERO-VALUE\x20order:\x20'+'the\x20escrow\x20holds\x200\x20while\x20the\x20order\x20still\x20walks\x20the\x20machine\x20nodes.\x20A\x20claim\x20guard\x20without\x20a\x20positive-amount\x20'+'leg\x20lets\x20that\x20free\x20buy\x20clear\x20the\x20review\x20node\x20and\x20collect\x20the\x20bounty\x20—\x20zero-cost\x20incentive\x20arbitrage\x20'+'(bkmn\x20F-M39/T6).\x20Reward\x20guards\x20are\x20immutable\x20once\x20the\x20Reward\x20object\x20is\x20published,\x20so\x20the\x20leg\x20must\x20be\x20in\x20'+'the\x20design\x20BEFORE\x20publish.\x20The\x20coupon\x20side\x20is\x20floored\x20at\x20issuance\x20(zeroing\x20coupons\x20are\x20blocked\x20unless\x20the\x20'+'free\x20tier\x20is\x20declared\x20via\x20allow_zero_total);\x20this\x20leg\x20is\x20the\x20claim-side\x20half\x20of\x20the\x20pair.','suggestion':'Add\x20to\x20every\x20reward\x20claim\x20root,\x20wrapped\x20in\x20logic_and\x20with\x20the\x20identity\x20+\x20replay\x20legs:\x20'+'logic_as_u256_greater_or_equal[query(order.amount),\x20identifier[N](1)]\x20(declare\x20slot\x20N\x20as\x20a\x20static\x20U64\x20'+'value\x201\x20—\x20see\x20tpl_reward_one_time_claim\x20v55\x20notes);\x20or\x20reference\x20a\x20tpl_*\x20guard\x20whose\x20example_root\x20already\x20'+'carries\x20the\x20positive-amount\x20leg;\x20or\x20declare\x20the\x20requirement\x20verbatim\x20in\x20the\x20build\x20notes\x20'+'(order.amount\x20+\x20positive-amount\x20phrasing)\x20so\x20the\x20generated\x20root\x20includes\x20it.'}];}function rewardReplayChecks(a){const b=(a['guards']??[])['filter'](f=>f['host']==='reward');if(b['length']===0x0)return[];const c=b['some'](f=>{if(!f['template_id']['startsWith']('tpl_'))return![];const h=GUARD_TEMPLATES['find'](j=>j['id']===f['template_id']);return rootHasRewardRecordGate(h?.['example_root']);}),d=/query_reward_record_exists/i['test'](templateText(a))||/reward\.record[ .](has|count|find|exists_where)/i['test'](templateText(a))||/reward[ -]record[ -]gate/i['test'](templateText(a));if(c||d)return[];const e=b['map'](f=>f['key']??f['template_id']);return[{'rule_id':'R-REWARD-REPLAY','severity':'high','title':'Reward-claim\x20guard(s)\x20['+e['join'](',\x20')+']\x20not\x20record-gated\x20—\x20the\x20replay\x20defense\x20this\x20template\x20implies\x20does\x20not\x20exist\x20on-chain','detail':'Reward.claim\x20pays\x20Recipient::Signer\x20with\x20no\x20order\x20binding\x20of\x20its\x20own:\x20the\x20armed\x20rail\x20is\x20the\x20record\x20gate\x20—\x20'+'logic_not(query_reward_record_exists(...))\x20inside\x20the\x20claim\x20guard\x20root,\x20forced\x20together\x20with\x20an\x20identity\x20leg\x20'+'(Signer\x20==\x20order.owner).\x20The\x20PRIMARY\x20form\x20is\x20ORDER-SCOPED\x20(where.storeFromId\x20=\x20the\x20submitted\x20Order\x20address\x20slot,\x20'+'the\x20same\x20slot\x20the\x20guard_add\x20entry\x20stamps;\x20azx7-mn-261014\x20live\x20T8)\x20=\x20once\x20per\x20buyer\x20per\x20order;\x20the\x20EMPTY-where\x20'+'variant\x20is\x20the\x20deliberate\x20once-per-buyer-FOR-LIFE\x20choice\x20(upw\x20F-48:\x20it\x20silently\x20kills\x20the\x20buyer\x27s\x20second\x20order).\x20'+'The\x20ofn-mn-261012\x20F-01\x20\x27storeFromId\x20filter\x20is\x20a\x20silent\x20no-op\x27\x20verdict\x20described\x20UNSTAMPED/legacy\x20rewards\x20only\x20—\x20'+'records\x20written\x20without\x20the\x20guard_add\x20entry\x20stamp\x20carry\x20store_from\x20=\x20none\x20and\x20match\x20no\x20storeFromId\x20predicate;\x20the\x20'+'MCP\x20stamp\x20gate\x20(UPW-K7)\x20now\x20rejects\x20unstamped\x20record-consuming\x20entries.\x20This\x20template\x20'+'mounts\x20host:\x22reward\x22\x20claim\x20machinery\x20yet\x20arms\x20it\x20nowhere:\x20no\x20tpl_*\x20guard\x20whose\x20example_root\x20carries\x20the\x20record\x20gate,\x20'+'no\x20prose\x20declaring\x20the\x20idiom.\x20reward_claim_policy\x20is\x20a\x20documentation\x20field\x20with\x20no\x20compile\x20wiring\x20and\x20does\x20NOT\x20arm\x20'+'anything\x20(same\x20ruling\x20as\x20once_per_order\x20/\x20R-ONCE-ARM)\x20—\x20a\x20funded\x20pool\x20behind\x20an\x20un-armed\x20claim\x20guard\x20is\x20a\x20drainable\x20target.','suggestion':'Arm\x20the\x20claim\x20guard\x20root:\x20add,\x20wrapped\x20in\x20logic_and\x20with\x20the\x20identity\x20leg\x20(Signer\x20==\x20order.owner)\x20and\x20the\x20existing\x20'+'state\x20checks,\x20logic_not(query_reward_record_exists(object=<reward\x20object>,\x20where:{storeFromId:{identifier:<order\x20slot>}}))\x20'+'—\x20the\x20SV-2\x20ORDER-SCOPED\x20form\x20(once\x20per\x20buyer\x20per\x20order;\x20swap\x20to\x20an\x20EMPTY\x20where\x20ONLY\x20for\x20a\x20deliberate\x20'+'one-bounty-per-buyer\x20design).\x20The\x20reward.guard_add\x20store_from_id\x20STAMP\x20is\x20the\x20separate,\x20mandatory\x20field:\x20a\x20'+'record-consuming\x20guard\x20must\x20be\x20added\x20with\x20store_from_id\x20=\x20the\x20per-order\x20stamp\x20slot\x20(the\x20submitted\x20Order\x20address,\x20'+'conventionally\x20slot\x200)\x20or\x20the\x20MCP\x20stamp\x20gate\x20rejects\x20the\x20entry.\x20Reference\x20a\x20tpl_*\x20guard\x20whose\x20example_root\x20already\x20'+'carries\x20the\x20order-scoped\x20gate;\x20or\x20declare\x20the\x20idiom\x20verbatim\x20in\x20the\x20'+'build\x20notes\x20so\x20the\x20generated\x20guard\x20root\x20includes\x20it\x20(guard-risk\x20R-X1-14\x20then\x20audits\x20the\x20built\x20guard\x20and\x20flags\x20the\x20'+'un-wrapped\x20pseudo-protection\x20form).\x20Until\x20armed,\x20keep\x20the\x20Reward\x20pool\x20unfunded\x20—\x20an\x20unfunded\x20incentive\x20promise\x20is\x20'+'already\x20blocked\x20at\x20compile\x20(INV-4\x20reward_funding).'}];}function rewardFundedChecks(a){if(a['review_mode']!=='review_reward')return[];const b=Object['keys'](a['fee_params']??{}),c=b['some'](d=>/review_reward_pool|reward_pool/i['test'](d))||/review_reward_pool|reward_pool/i['test'](templateText(a))||a['reward_claim_policy']?.['max_total_per_recipient']!==undefined;if(c)return[];return[{'rule_id':'R-REWARD-FUNDED','severity':'high','title':'review_reward\x20template\x20declares\x20no\x20reward\x20pool\x20surface\x20—\x20an\x20unfunded\x20incentive\x20promise\x20must\x20not\x20publish\x20(INV-4)','detail':'review_mode\x20\x27review_reward\x27\x20promises\x20buyers\x20a\x20claim\x20reward,\x20but\x20the\x20template\x20declares\x20neither\x20a\x20pool\x20'+'fee_param\x20(review_reward_pool)\x20nor\x20a\x20pool-sizing\x20reward_claim_policy\x20cap.\x20At\x20compile\x20the\x20reward_funding\x20'+'input\x20hard-gates\x20the\x20build,\x20so\x20the\x20promise\x20dies\x20at\x20build\x20time\x20—\x20surface\x20the\x20pool\x20plan\x20in\x20the\x20template\x20'+'so\x20the\x20wizard\x20can\x20ask\x20the\x20funding\x20question\x20with\x20real\x20numbers.','suggestion':'Declare\x20a\x20review_reward_pool\x20fee_param\x20(>=\x20expected\x20orders\x20x\x20per-order\x20reward)\x20and\x20fund\x20it\x20at\x20build\x20time\x20'+'via\x20the\x20reward_funding\x20input\x20(sale-time\x20planning:\x20the\x20buyer\x20perceives\x20the\x20funded\x20reward\x20at\x20quote/buy),\x20'+'or\x20set\x20a\x20reward_claim_policy\x20max_total_per_recipient\x20that\x20sizes\x20the\x20pool.'}];}function ratingKeyRowIsSubmittedOrder(a){return!!a&&a['value_type']==='Address'&&a['b_submission']===!![];}function ratingKeyIdViolation(a,b){if(a===null||typeof a!=='object')return'row-id\x20parameter\x20missing\x20or\x20malformed';const c=a;if(c['type']==='context'&&c['context']==='Signer')return'row-id\x20keyed\x20on\x20context\x20Signer\x20(the\x20Signer-keyed\x20display\x20row\x20never\x20carries\x20the\x20per-order\x20rating)';if((c['type']==='identifier'||c['type']===undefined)&&typeof c['identifier']==='number'){const d=b['find'](e=>e['identifier']===c['identifier']);if(!ratingKeyRowIsSubmittedOrder(d)){if(!d)return'row-id\x20references\x20table\x20slot\x20'+c['identifier']+'\x20which\x20the\x20table\x20does\x20not\x20declare\x20(dangling\x20read\x20—\x20fails\x20closed)';if(d['value_type']!=='Address')return'row-id\x20resolves\x20to\x20table\x20slot\x20'+c['identifier']+'\x20typed\x20'+d['value_type']+'\x20(a\x20display/text\x20row)\x20instead\x20of\x20the\x20Address-typed\x20submitted\x20order';return'row-id\x20resolves\x20to\x20static\x20table\x20slot\x20'+c['identifier']+'\x20(b_submission=false)\x20—\x20the\x20same\x20row\x20is\x20read\x20for\x20EVERY\x20claim\x20instead\x20of\x20the\x20submitted\x20order';}return null;}return'row-id\x20parameter\x20type\x20\x22'+(c['type']??'unknown')+'\x22\x20is\x20neither\x20the\x20Signer\x20context\x20nor\x20a\x20table\x20identifier';}function ratingKeyReads(a,b,c,d){if(Array['isArray'](a)){for(const f of a)ratingKeyReads(f,b,c,d);return;}if(a===null||typeof a!=='object')return;const e=a;if(e['type']==='vec_contains_address')d['value']=!![];if(e['type']==='query'&&typeof e['query']==='string'&&/^repository\.data( has)?$/i['test'](e['query'])){const g=Array['isArray'](e['parameters'])?e['parameters'][0x1]:undefined,h=ratingKeyIdViolation(g,c);if(h)b['push'](e['query']+':\x20'+h);}if(e['type']==='query_repository_data_keys_where'){const j=e['where']!==null&&typeof e['where']==='object'&&Object['keys'](e['where'])['length']===0x0;if(j)b['push']('query_repository_data_keys_where:\x20EMPTY\x20where\x20—\x20a\x20presence\x20probe\x20with\x20no\x20floor\x20predicate\x20gates\x20presence,\x20not\x20rating');else{const k=ratingKeyIdViolation(e['id'],c);if(k)b['push']('query_repository_data_keys_where:\x20'+k);}}if(e['type']==='query_repository_data_count_where'||e['type']==='query_repository_data_find_where'||e['type']==='query_repository_data_sum_where'){if(!d['value']){const l=e['ids'],m=l&&typeof l['identifier']==='number'?c['find'](o=>o['identifier']===l['identifier']):undefined;m&&m['b_submission']===!![]&&b['push'](e['type']+':\x20buyer-submitted\x20candidate\x20ids\x20with\x20NO\x20vec_contains_address\x20pin\x20—\x20a\x20padded\x20candidate\x20list\x20borrows\x20another\x20order\x27s\x20row\x20(pin\x20the\x20matched\x20set\x20to\x20the\x20submitted\x20order)');}}for(const o of e['nodes']??[])ratingKeyReads(o,b,c,d);if(e['node']!==undefined)ratingKeyReads(e['node'],b,c,d);}function treeHasVecAddressPin(a){if(Array['isArray'](a))return a['some'](c=>treeHasVecAddressPin(c));if(a===null||typeof a!=='object')return![];const b=a;if(b['type']==='vec_contains_address')return!![];if((b['nodes']??[])['some'](c=>treeHasVecAddressPin(c)))return!![];return b['node']!==undefined&&treeHasVecAddressPin(b['node']);}export function auditRewardRootRatingKey(a,b){const c=[],d={'value':treeHasVecAddressPin(a)};return ratingKeyReads(a,c,b,d),c['map'](e=>String(e));}function rewardRatingKeyChecks(a){const b=(a['guards']??[])['filter'](e=>e['host']==='reward');if(b['length']===0x0)return[];const c=[];for(const e of b){const f=e['template_id'];if(!f?.['startsWith']('tpl_'))continue;const h=GUARD_TEMPLATES['find'](j=>j['id']===f);if(!h?.['example_root'])continue;for(const j of auditRewardRootRatingKey(h['example_root'],h['example_table']??[])){c['push']('['+f+']\x20'+j);}}if(c['length']===0x0)return[];const d=b['map'](k=>k['key']??k['template_id']);return[{'rule_id':'R-REWARD-RATING-KEY','severity':'critical','title':'Reward-claim\x20guard(s)\x20['+d['join'](',\x20')+']\x20gate\x20on\x20wrongly-keyed\x20repository\x20reads\x20—\x20a\x20rating\x20gate\x20that\x20never\x20reads\x20THIS\x20order\x27s\x20rating\x20row\x20(upwk-mn-261017\x20F-62)','detail':'A\x20minimum-rating\x20bounty\x20is\x20ENFORCEABLE\x20only\x20by\x20the\x20CLAIM\x20guard\x20reading\x20the\x20ORDER-KEYED\x20U64\x20rating\x20row\x20'+'(id\x20=\x20the\x20submitted\x20order\x20address,\x20under\x20the\x20compile-emitted\x20\x27rating\x27\x20policy\x20the\x20buyer\x20writes\x20at\x20review\x20'+'time).\x20The\x20Signer-keyed\x20review\x20TEXT\x20row\x20is\x20display-only:\x20keying\x20the\x20gate\x20on\x20it\x20either\x20gates\x20nothing\x20'+'(presence\x20of\x20any\x20review)\x20or\x20dead-locks\x20the\x20claim\x20fail-closed\x20(F-62\x20four-layer\x20break:\x20adjudication\x20right,\x20'+'data\x20row\x20missing,\x20template\x20leg\x20missing,\x20scanner\x20blind\x20—\x20this\x20rule\x20closes\x20layer\x204).\x20Violations:\x0a'+c['map'](k=>'\x20\x20-\x20'+k)['join']('\x0a'),'suggestion':'Replace\x20the\x20wrongly-keyed\x20read\x20with\x20the\x20canonical\x20rating\x20leg\x20(tpl_reward_one_time_claim\x20v1.14.0):\x20'+'logic_as_u256_greater_or_equal[query(repository.data,\x20object=<plan-bound\x20\x27_review\x27\x20repository>,\x20'+'parameters=[<rating\x20policy\x20name\x20row>,\x20<SUBMITTED\x20order\x20Address\x20row>]),\x20<floor\x20U64\x20row>]\x20—\x20the\x20row\x20id\x20IS\x20'+'the\x20submitted\x20order\x20(b_submission\x20Address\x20slot);\x20membership\x20probes\x20must\x20carry\x20the\x20floor\x20predicate\x20in\x20'+'their\x20where;\x20candidate-list\x20forms\x20must\x20carry\x20a\x20vec_contains_address\x20pin\x20on\x20the\x20submitted\x20order.\x20Emit\x20'+'the\x20order-keyed\x20rating\x20ROW\x20(compile\x20review\x20component)\x20and\x20this\x20LEG\x20as\x20a\x20pair,\x20or\x20ship\x20neither\x20—\x20a\x20leg\x20'+'without\x20its\x20data\x20row\x20dead-locks\x20the\x20bounty.'}];}function compoundPayoutChecks(a){const b=templateText(a),c=a['allocator']['rows']??[],d=a['allocator']['refund_track']!==undefined||c['some'](f=>f['track']==='refund')||/refund|退款/i['test'](a['allocator']['description']);if(!d)return[];const e=a['guards']['some'](f=>f['host']==='arbitration')||a['trust_mechanisms']['some'](f=>/^R2\b/['test'](f))||/compensation[_ ]fund/i['test'](b);if(!e)return[];return[{'rule_id':'R-COMPOUND-01','severity':'low','title':'Dual\x20buyer-remedy\x20rails\x20(escrow\x20refund\x20+\x20compensation\x20fund)\x20—\x20the\x20arbitrator\x20nets\x20the\x20award','detail':'This\x20template\x20carries\x20BOTH\x20buyer-remedy\x20channels\x20by\x20design:\x20a\x20refund\x20Allocator\x20paying\x20out\x20of\x20the\x20order\x20escrow\x20AND\x20a\x20bound\x20'+'Arbitration\x20paying\x20out\x20of\x20the\x20Service\x27s\x20compensation\x20fund.\x20The\x20two\x20channels\x20are\x20independent\x20on-chain\x20and\x20the\x20platform\x20does\x20not\x20'+'hard-block\x20a\x20double\x20payout\x20at\x20the\x20protocol\x20level\x20—\x20that\x20is\x20an\x20intentional\x20commercial\x20game,\x20not\x20a\x20defect:\x20the\x20merchant\x20chose\x20the\x20'+'arbitrator,\x20and\x20the\x20arbitrator\x20rules\x20on\x20the\x20full\x20fund\x20picture.\x20Every\x20query\x20of\x20an\x20Arb\x20case\x20auto-attaches\x20the\x20order-side\x20fund\x20facts\x20'+'(_order_fund_facts:\x20amount,\x20escrow\x20balance,\x20withdraw\x20history,\x20claimed_by,\x20workflow\x20node),\x20and\x20every\x20case\x20operation\x20result\x20carries\x20'+'order_fund_facts,\x20so\x20a\x20refund-then-claim\x20ordering\x20is\x20visible\x20at\x20ruling\x20time\x20and\x20the\x20award\x20is\x20expected\x20to\x20net\x20out\x20the\x20already-refunded\x20principal.','suggestion':'No\x20structural\x20change\x20required.\x20Keep\x20the\x20operational\x20rule:\x20arbitrators\x20read\x20order_fund_facts\x20before\x20finalizing\x20the\x20indemnity\x20and\x20net\x20'+'any\x20positive\x20escrow_deficit\x20/\x20withdraw_history\x20payouts\x20against\x20the\x20award.\x20If\x20a\x20template\x20intends\x20a\x20non-monetary\x20remedy\x20instead,\x20say\x20so\x20'+'explicitly\x20in\x20the\x20arbitration\x20proposition\x20wording.'}];}function surplusTrackChecks(a){const b=a['allocator']['rows']??[],c=[],d=b['filter'](h=>h['track']==='refund'&&h['mode']==='surplus'),e=b['filter'](h=>h['track']==='settlement'&&h['mode']==='amount');d['length']>0x0&&e['length']>0x0&&c['push']({'rule_id':'R-SURPLUS-01','severity':'critical','title':'Refund-track\x20Surplus\x20sweeps\x20UNPAID\x20settlement\x20Amounts\x20out\x20of\x20the\x20shared\x20pool','detail':'An\x20order\x20funds\x20ONE\x20pool\x20—\x20`track`\x20is\x20a\x20build-time\x20grouping\x20the\x20chain\x20never\x20sees.\x20The\x20refund\x20row\x20'+'runs\x20Surplus\x20mode,\x20which\x20pays\x20the\x20ENTIRE\x20remaining\x20balance\x20(allocation.move:494-505;\x20template\x20rows\x20cannot\x20set\x20'+'`Allocator.max`,\x20so\x20the\x20sweep\x20is\x20uncapped),\x20while\x20the\x20settlement\x20track\x20still\x20carries\x20fixed\x20Amount\x20obligations\x20'+('('+e['map'](h=>h['recipient_key']??h['recipient'])['join'](',\x20')+').\x20Track\x20guards\x20are\x20independent\x20—\x20a\x20')+'time-locked\x20deposit\x20release\x20does\x20not\x20wait\x20for\x20month-gated\x20rent\x20—\x20so\x20when\x20the\x20refund\x20fires\x20first,\x20the\x20sweep\x20hands\x20'+'the\x20unpaid\x20Amounts\x20to\x20the\x20refund\x20recipient.\x20VERIFIED\x20LIVE\x20on\x20ziroom\x20mainnet\x20T-05:\x20the\x20deposit_back\x20Surplus\x20paid\x20'+'the\x20tenant\x20the\x20deposit\x20PLUS\x20the\x20unreleased\x20rent\x20(585/525\x20in\x20full);\x20the\x20landlord\x20received\x200.','suggestion':'Size\x20the\x20refund\x20leg\x20explicitly:\x20an\x20Amount\x20row\x20pinned\x20to\x20the\x20deposit\x20value\x20(value/value_from),\x20so\x20the\x20payout\x20can\x20'+'never\x20exceed\x20its\x20own\x20scope\x20—\x20or\x20split\x20the\x20two\x20fund\x20scopes\x20into\x20separate\x20Allocation\x20objects\x20so\x20a\x20sweep\x20can\x20only\x20'+'reach\x20its\x20own\x20pool.\x20If\x20an\x20uncapped\x20sweep\x20is\x20truly\x20intended,\x20gate\x20it\x20on\x20a\x20node\x20that\x20provably\x20follows\x20the\x20FINAL\x20'+'settlement\x20release,\x20and\x20state\x20in\x20the\x20template\x20that\x20any\x20obligation\x20unpaid\x20by\x20then\x20is\x20forfeit.'});const f=b['filter'](h=>h['track']==='settlement'&&h['mode']==='surplus'),g=b['filter'](h=>h['track']==='refund'&&h['mode']==='amount');return f['length']>0x0&&g['length']>0x0&&c['push']({'rule_id':'R-SURPLUS-02','severity':'high','title':'Settlement-track\x20Surplus\x20can\x20drain\x20the\x20pool\x20ahead\x20of\x20a\x20fixed-Amount\x20refund','detail':'The\x20settlement\x20sweep\x20(Surplus,\x20uncapped\x20—\x20allocation.move:494-505)\x20pays\x20the\x20merchant\x20the\x20entire\x20remainder\x20while\x20'+('the\x20refund\x20track\x20still\x20owes\x20fixed\x20Amounts\x20('+g['map'](h=>h['recipient_key']??h['recipient'])['join'](',\x20')+').\x20')+'If\x20the\x20settlement\x20guard\x20fires\x20while\x20a\x20refund\x20obligation\x20is\x20still\x20open\x20(the\x20tracks\x20are\x20gated\x20independently),\x20the\x20'+'pool\x20is\x20empty\x20when\x20the\x20refund\x20fires\x20and\x20alloc()\x20aborts\x20on\x20insufficient\x20balance\x20(allocation.move:390)\x20—\x20the\x20buyer\x20'+'remedy\x20is\x20bricked\x20and\x20the\x20merchant\x20keeps\x20money\x20the\x20template\x20declared\x20refundable.','suggestion':'Make\x20the\x20two\x20tracks\x20mutually\x20exclusive\x20by\x20construction\x20(refund\x20fires\x20only\x20from\x20cancel\x20nodes\x20the\x20settlement\x20'+'guard\x20can\x20never\x20reach,\x20and\x20vice\x20versa),\x20or\x20size\x20the\x20refund\x20as\x20a\x20Rate\x20so\x20it\x20degrades\x20to\x20a\x20share\x20instead\x20of\x20'+'aborting.\x20NOTE:\x20there\x20is\x20no\x20on-chain\x20holdback\x20(FACT-ALLOC-03)\x20—\x20do\x20NOT\x20try\x20to\x20\x27reserve\x27\x20the\x20refund\x20Amount\x20'+'via\x20a\x20fix\x20value;\x20split\x20the\x20two\x20fund\x20scopes\x20into\x20separate\x20Allocation\x20objects\x20if\x20isolation\x20is\x20required.'}),c;}const BRANCH_STATE_REGEX=/(cancel|return|withdraw|exit|expired)/i;function amountDeadlockChecks(a){const b=a['allocator']['rows']??[],c=b['filter'](f=>f['track']==='settlement');if(c['length']===0x0||!c['every'](f=>f['mode']==='amount'))return[];const d=[a['allocator']['description'],...a['build_notes'],...a['trust_mechanisms'],...a['guards']['map'](f=>f['template_id']+'\x20'+f['purpose'])]['join']('\x20\x0a\x20'),e=Object['keys'](a['fee_params'])['some'](f=>MIN_PRICE_KEY_REGEX['test'](f))||FLOOR_TEXT_REGEX['test'](d);if(e)return[];return[{'rule_id':'R-DEADLOCK-01','severity':'medium','title':'Settlement\x20track\x20is\x20ALL\x20fixed\x20Amount\x20—\x20an\x20under-funded\x20pool\x20deadlocks\x20permanently','detail':'Every\x20settlement\x20row\x20is\x20mode\x20\x27amount\x27\x20('+c['length']+'\x20row(s));\x20each\x20asserts\x20balance\x20>=\x20fix\x20at\x20release\x20'+'(allocation.move:390).\x20When\x20the\x20pool\x20is\x20smaller\x20than\x20the\x20pinned\x20leg\x20—\x20a\x20discount\x20code,\x20a\x20low-price\x20SKU,\x20a\x20'+'partially-funded\x20order\x20—\x20the\x20call\x20aborts\x20and\x20NO\x20later\x20call\x20can\x20settle\x20a\x20smaller\x20amount:\x20the\x20merchant\x27s\x20payout\x20'+'path\x20is\x20bricked\x20for\x20that\x20order\x20(ziroom\x20CR-02:\x20fixed\x20Amount\x20legs\x20+\x20a\x20cheap\x20SKU\x20=\x20permanent\x20settlement\x20abort).\x20'+'Rate\x20and\x20Surplus\x20legs\x20degrade\x20to\x20whatever\x20the\x20pool\x20actually\x20holds;\x20Amount\x20legs\x20cannot.','suggestion':'Carry\x20at\x20least\x20one\x20Rate/Surplus\x20leg\x20as\x20the\x20degradation\x20path\x20(e.g.\x20the\x20merchant\x20remainder\x20as\x20Rate).\x20'+'If\x20the\x20fixed\x20legs\x20are\x20the\x20design\x20(staged\x20tuition,\x20per-session\x20releases),\x20the\x20BUY\x20path\x20already\x20enforces\x20'+'order\x20>=\x20the\x20fixed-leg\x20SUM\x20per\x20order\x20(the\x20b6-11-family\x20fixed-leg\x20gate,\x20error\x20'+'order_below_fixed_leg_sum\x20—\x20a\x20discounted\x20order\x20is\x20rejected\x20before\x20any\x20money\x20moves),\x20so\x20the\x20template-side\x20'+'duty\x20narrows\x20to\x20pricing\x20every\x20SKU\x20at\x20or\x20above\x20the\x20fixed-leg\x20sum\x20(state\x20that\x20floor\x20in\x20fee_params)\x20—\x20a\x20SKU\x20'+'below\x20the\x20floor\x20could\x20never\x20complete\x20a\x20sale.'}];}const DISCOUNT_FIXED_KEY_REGEX=/(?:discount|coupon)[a-z0-9_]*(?:value|amount)/i,DISCOUNT_RATE_KEY_REGEX=/(?:discount|coupon)[a-z0-9_]*(?:rate_bps|bps|percent)/i,DISCOUNT_ISSUANCE_PROSE_REGEX=/create a discount|discount object|coupon handoff|run promotions|(?:mint|issue)\s+(?:a\s+|the\s+)?coupon|first-order discount/i,TIER_VARIANT_REGEX=/\btiers?\b|\bvariants?\b|\bpackages?\b|\bplans?\b/i;function numericFeeParam(a,b){const c=Object['keys'](a)['find'](d=>b['test'](d)&&typeof a[d]==='number');return c!==undefined?a[c]:undefined;}function railValue(a,b){if(typeof a['value']==='number')return a['value'];if(typeof a['value']==='string'&&/^\d+(\.\d+)?$/['test'](a['value']['trim']()))return Number(a['value']);if(a['value_from']!==undefined){const c=b[a['value_from']];if(typeof c==='number')return c;if(typeof c==='string'&&/^\d+(\.\d+)?$/['test'](c['trim']()))return Number(c);}return null;}function discountRailScaleChecks(a){const b=a['fee_params'],c=(a['allocator']['rows']??[])['filter'](n=>n['track']==='settlement'&&n['mode']==='amount');if(c['length']===0x0)return[];const d=numericFeeParam(b,DISCOUNT_FIXED_KEY_REGEX),e=numericFeeParam(b,DISCOUNT_RATE_KEY_REGEX),f=DISCOUNT_ISSUANCE_PROSE_REGEX['test'](templateText(a));if(d===undefined&&e===undefined&&!f)return[];const h=Object['keys'](b)['find'](n=>MIN_PRICE_KEY_REGEX['test'](n)&&typeof b[n]==='number'),j=h!==undefined?b[h]:undefined;let k;if(j!==undefined&&d!==undefined)k=Math['max'](0x0,j-d);else{if(j!==undefined&&e!==undefined)k=j*(0x2710-Math['min'](e,0x2710))/0x2710;}const l=n=>TIER_VARIANT_REGEX['test']((n['note']??'')+'\x20'+(n['guard_key']??'')),m=new Map();if(c['length']>=0x2&&c['every'](l))for(const n of c){const o=n['guard_key']??n['recipient_key']??'row/'+n['recipient'],p=m['get'](o)??{'label':o,'sum':0x0,'resolvable':!![]},q=railValue(n,b);if(q===null)p['resolvable']=![];else p['sum']+=q;m['set'](o,p);}else{let s=0x0,u=!![];for(const w of c){const x=railValue(w,b);if(x===null)u=![];else s+=x;}m['set']('settlement',{'label':'settlement','sum':s,'resolvable':u});}if(k!==undefined){const y=[...m['values']()]['filter'](z=>z['resolvable']&&z['sum']>k);if(y['length']>0x0)return[{'rule_id':'R-FAMT-SCALE','severity':'critical','title':'Absolute\x20Amount\x20rails\x20exceed\x20the\x20minimum\x20post-discount\x20payable\x20('+y['map'](z=>z['label']+':\x20'+z['sum']+'\x20>\x20'+k)['join'](';\x20')+')','detail':'This\x20template\x20combines\x20ABSOLUTE\x20Amount\x20rails\x20with\x20a\x20discount\x20configuration,\x20and\x20the\x20arithmetic\x20is\x20'+('resolvable\x20at\x20build\x20time:\x20minimum\x20order\x20value\x20'+j+'\x20('+h+')\x20minus\x20the\x20discount\x20leaves\x20'+k+',\x20')+'while\x20the\x20settlement\x20Amount\x20rail(s)\x20named\x20above\x20sum\x20to\x20more.\x20On\x20chain\x20the\x20order\x20escrows\x20the\x20POST-discount\x20'+'total\x20(the\x20discounted-quote\x20computation,\x20service.move:370-383)\x20and\x20every\x20Amount\x20leg\x20asserts\x20balance\x20>=\x20fix\x20at\x20release\x20'+'(allocation.move:390)\x20—\x20the\x20LAST\x20rail\x20to\x20fire\x20aborts\x20mid-workflow\x20and\x20the\x20order\x20strands\x20with\x20its\x20remaining\x20'+'pool.\x20Machines\x20and\x20allocators\x20are\x20immutable\x20after\x20publish:\x20no\x20late\x20repair\x20exists.\x20Offending\x20rail\x20'+('scope(s)\x20(each\x20tier\x20judged\x20on\x20its\x20own\x20selected\x20variant,\x20not\x20the\x20first\x20row):\x20'+y['map'](z=>z['label'])['join'](',\x20')+'.'),'suggestion':'Shrink\x20the\x20rails\x20to\x20fit\x20the\x20discounted\x20floor\x20('+y['map'](z=>z['label']+'\x20<=\x20'+k)['join'](',\x20')+'),\x20or\x20'+'express\x20the\x20rails\x20as\x20Rate/RateGross\x20legs\x20which\x20degrade\x20to\x20whatever\x20the\x20discounted\x20pool\x20actually\x20holds.\x20A\x20'+'percentage\x20discount\x20keeps\x20rails\x20payable\x20only\x20when\x20the\x20rails\x20are\x20percentage-based\x20too.'}];if([...m['values']()]['every'](z=>z['resolvable']))return[];}return[{'rule_id':'R-FAMT-SCALE','severity':'medium','title':'Absolute\x20Amount\x20rails\x20combined\x20with\x20a\x20discount\x20—\x20the\x20tail\x20rail\x20can\x20strand\x20when\x20the\x20discounted\x20total\x20undercuts\x20the\x20rails','detail':'This\x20template\x20directs\x20the\x20build\x20to\x20attach\x20a\x20Service-side\x20discount\x20(coupon)\x20while\x20its\x20settlement\x20track\x20carries\x20fixed\x20'+'Amount\x20rails.\x20The\x20order\x20escrows\x20the\x20POST-discount\x20total\x20(the\x20discounted-quote\x20computation,\x20service.move:370-383)\x20and\x20every\x20'+'Amount\x20leg\x20asserts\x20balance\x20>=\x20fix\x20at\x20release\x20(allocation.move:390),\x20so\x20whenever\x20the\x20discounted\x20payable\x20falls\x20below\x20'+'the\x20rail\x20sum\x20the\x20LAST\x20rail\x20aborts\x20and\x20the\x20order\x20strands\x20—\x20unrepairable\x20after\x20publish.\x20The\x20minimum\x20post-discount\x20'+'payable\x20cannot\x20be\x20resolved\x20at\x20build\x20time\x20here\x20(the\x20order\x20value\x20is\x20a\x20merchant\x20runtime\x20input\x20such\x20as\x20the\x20SKU\x20price,\x20'+'or\x20the\x20discount\x20magnitude\x20is\x20declared\x20only\x20in\x20prose),\x20so\x20the\x20scale\x20cannot\x20be\x20proven\x20safe\x20statically.','suggestion':'Prefer\x20percentage-based\x20rails:\x20express\x20the\x20settlement\x20legs\x20as\x20Rate/RateGross\x20(which\x20degrade\x20to\x20whatever\x20the\x20'+'discounted\x20pool\x20holds)\x20instead\x20of\x20fixed\x20Amounts\x20—\x20or\x20pin\x20BOTH\x20sides\x20machine-checkably\x20(a\x20numeric\x20min_*\x20'+'order-value\x20floor\x20in\x20fee_params\x20plus\x20a\x20numeric\x20discount\x20magnitude\x20key)\x20so\x20the\x20build-time\x20scale\x20check\x20can\x20run.\x20'+'Otherwise\x20keep\x20the\x20discount\x20budget\x20documented\x20so\x20the\x20merchant\x20prices\x20coupons\x20above\x20the\x20rail\x20sum.'}];}function cancelCoverageChecks(a){const b=a['allocator']['rows']??[];if(b['some'](d=>d['track']==='refund'))return[];if(a['allocator']['refund_track']!==undefined)return[];const c=a['machine_shape']['find'](d=>BRANCH_STATE_REGEX['test'](d['name']));if(!c)return[];return[{'rule_id':'R-CANCEL-01','severity':'high','title':'Machine\x20models\x20\x27'+c['name']+'\x27\x20but\x20the\x20allocator\x20has\x20NO\x20refund-track\x20rows\x20—\x20money\x20locks\x20on\x20that\x20path','detail':'The\x20machine\x20shape\x20carries\x20a\x20cancel/return/exit\x20state,\x20yet\x20no\x20allocator\x20row\x20pays\x20on\x20the\x20refund\x20track.\x20Text-level\x20'+'claims\x20(guard\x20purposes,\x20allocator\x20description)\x20may\x20still\x20say\x20\x27refund\x27,\x20but\x20on\x20chain\x20only\x20rows\x20move\x20money:\x20an\x20'+'order\x20that\x20reaches\x20this\x20state\x20keeps\x20its\x20escrow\x20with\x20no\x20rail\x20out\x20(ofn\x20#P-02:\x20the\x20subscription\x20template\x27s\x20refund\x20'+'rails\x20missed\x20closed_cancel\x20and\x200.5\x20WOW\x20locked\x20permanently;\x20verified\x20live).','suggestion':'Add\x20refund-track\x20rows\x20covering\x20EVERY\x20cancel-ish\x20terminal\x20(order-anchored\x20GuardIdentifier(0)\x20recipient,\x20'+'Rate-sized\x20with\x20the\x20group\x20summing\x2010000),\x20or\x20remove\x20the\x20state\x20from\x20the\x20machine\x20so\x20orders\x20can\x20never\x20enter\x20it.'}];}function redundGuardObjectMismatchChecks(a){const b=a['allocator']['rows']??[],c=b['filter'](h=>h['track']==='refund'&&h['recipient']==='guard_identifier');if(c['length']===0x0)return[];const d=new Set(c['map'](h=>h['guard_key'])['filter'](h=>typeof h==='string')),e=a['guards']['some'](h=>h['key']!==undefined&&d['has'](h['key'])&&(/arb|ruling|arbitration/i['test'](h['template_id'])||/arb|ruling|arbitration/i['test'](h['purpose'])));if(!e)return[];const f=templateText(a),g=/two[- ]slot|slot\s*0.*order|slot\s*1.*arb|arb\.order.*==|for_object.*binding/i['test'](f);if(g)return[{'rule_id':'REDUND-GUARD-OBJECT-MISMATCH','severity':'low','title':'Arb-refund\x20guard\x20uses\x20two-slot\x20design\x20(Order\x20+\x20Arb)\x20—\x20self-certifying\x20pair','detail':'The\x20template\x20carries\x20a\x20refund\x20allocator\x20row\x20with\x20a\x20GuardIdentifier\x20recipient\x20AND\x20an\x20arbitration-ruling\x20guard.\x20'+'The\x20two-slot\x20design\x20(slot\x200\x20=\x20Order\x20for\x20the\x20allocator\x20recipient,\x20slot\x201\x20=\x20Arb\x20for\x20the\x20ruling\x20state)\x20is\x20the\x20'+'correct\x20resolution\x20of\x20the\x20F-02\x20slot\x20conflict:\x20the\x20allocator\x20reads\x20slot\x200\x20(payment_info.for_object\x20binding),\x20'+'the\x20forward\x20reads\x20slot\x201\x20(arb.indemnity\x20state),\x20and\x20the\x20binding\x20assertion\x20query(\x22arb.order\x22,\x20slot1)\x20==\x20slot0\x20'+'makes\x20the\x20pair\x20self-certifying\x20against\x20redirect\x20attacks.','suggestion':'Verify\x20the\x20guard\x20is\x20tpl_forward_arb_ruling_won\x20(two-slot\x20form)\x20or\x20an\x20equivalent\x20custom\x20guard\x20with\x20the\x20same\x20'+'slot\x20layout\x20and\x20binding\x20assertion.\x20Single-slot\x20arb-refund\x20guards\x20are\x20unreachable\x20(F-02).'}];return[{'rule_id':'REDUND-GUARD-OBJECT-MISMATCH','severity':'high','title':'Arb-refund\x20guard\x20may\x20use\x20a\x20SINGLE\x20slot\x20—\x20unreachable\x20rail\x20(F-02)','detail':'The\x20template\x20carries\x20a\x20refund\x20allocator\x20row\x20with\x20a\x20GuardIdentifier\x20recipient\x20AND\x20an\x20arbitration-ruling\x20guard,\x20'+'but\x20the\x20template\x20text\x20does\x20not\x20mention\x20the\x20two-slot\x20design.\x20A\x20single-slot\x20guard\x20cannot\x20satisfy\x20both\x20consumers:\x20'+'the\x20forward\x20needs\x20the\x20Arb\x20object\x20(to\x20read\x20arb.indemnity),\x20while\x20the\x20allocator\x20recipient\x20GuardIdentifier(0)\x20needs\x20'+'the\x20Order\x20object\x20(payment_info.for_object\x20binding).\x20F-02\x20verified\x20live:\x20Order\x20address\x20→\x20forward\x20aborts;\x20Arb\x20address\x20'+'→\x20allocation\x20aborts\x2015\x20(ERECIPIENT_NOT_FOR_OBJECT).\x20The\x20escrow\x20strands\x20permanently\x20with\x20no\x20on-chain\x20exit.','suggestion':'Use\x20tpl_forward_arb_ruling_won\x20(two-slot\x20form:\x20slot\x200\x20=\x20Order,\x20slot\x201\x20=\x20Arb,\x20with\x20arb.order\x20==\x20order\x20binding),\x20'+'or\x20document\x20the\x20two-slot\x20design\x20explicitly\x20in\x20the\x20template\x20build_notes.\x20A\x20single-slot\x20arb-refund\x20guard\x20is\x20'+'unreachable\x20by\x20construction\x20(F-02).'}];}function zeroAmountGuardChecks(a){const b=templateText(a),c=/zero[- ]amount|0[ -]?amount|free[^a-z]|price\s*=\s*0|amount\s*>\s*0|min_booking_amount/i['test'](b)||/no[- ]charge|gratis|complimentary/i['test'](b);if(c)return[];const d=new Set((a['allocator']['rows']??[])['map'](f=>f['guard_key'])['filter'](f=>typeof f==='string')),e=a['guards']['some'](f=>f['host']==='machine'&&!(f['key']!==undefined&&d['has'](f['key']))&&(/claimed_by|allocation|payment\s|alloc\b/i['test'](f['template_id'])||/claimed_by|allocation|payment\s|alloc\b/i['test'](f['purpose']))&&!/refund|pro-?rata|staged[_ -]?release|recovery|polarity/i['test'](f['template_id']+'\x20'+f['purpose']));if(!e)return[];return[{'rule_id':'D7-ZERO-AMOUNT-GUARD','severity':'medium','title':'Machine\x20progress\x20guards\x20may\x20depend\x20on\x20allocator\x20events\x20—\x20zero-amount\x20orders\x20deadlock','detail':'The\x20protocol\x20does\x20NOT\x20create\x20an\x20Allocation\x20for\x20a\x20zero-amount\x20order\x20(amount\x20>\x200\x20is\x20required).\x20'+'A\x20zero-amount\x20order\x20therefore\x20has\x20NO\x20claimed_by,\x20NO\x20payment\x20history,\x20and\x20NO\x20allocation\x20balance.\x20'+'This\x20template\x20carries\x20machine\x20guards\x20that\x20reference\x20allocator-dependent\x20state\x20(claimed_by\x20/\x20allocation\x20/\x20payment),\x20'+'but\x20the\x20template\x20does\x20NOT\x20explicitly\x20exclude\x20zero-amount\x20items.\x20A\x20zero-amount\x20order\x20can\x20never\x20satisfy\x20such\x20a\x20guard\x20'+'and\x20deadlocks\x20at\x20the\x20node\x20with\x20no\x20exit.','suggestion':'Either\x20(a)\x20exclude\x20zero-amount\x20items\x20explicitly\x20(e.g.\x20min_booking_amount,\x20amount\x20>\x200\x20in\x20build_notes),\x20or\x20'+'(b)\x20redesign\x20progress\x20guards\x20to\x20use\x20order-native\x20signals\x20(order.time,\x20signer,\x20progress.current,\x20Repository\x20data)\x20'+'instead\x20of\x20allocator-derived\x20state,\x20so\x20zero-amount\x20orders\x20can\x20still\x20advance.'}];}function terminalRailCoverageChecks(a){const b=a['machine_shape'];if(b['length']===0x0||!b['some'](w=>(w['from']??[])['length']>0x0))return[];const c=a['allocator']['rows']??[];if(c['length']===0x0)return[];const d=[...a['guards']['map'](w=>w['purpose']),...c['map'](w=>w['note']??'')];if(!d['some'](w=>/current\s*==/i['test'](w)))return[];const f=a['allocator']['description']??'',g=new Set();for(const w of b){for(const x of w['from']??[]){const y=typeof x==='string'?x:x?.['prev'];if(y)g['add'](y);}}const h=b['filter'](z=>!g['has'](z['name']));if(h['length']===0x0)return[];const j=z=>z['replace'](/[.*+?^${}()|[\]\\]/g,'\x5c$&'),k=z=>{const A=new RegExp('current\x5cs*==\x5cs*[\x22\x27]?'+j(z)+'\x5cb','i');if(a['guards']['some'](C=>A['test'](C['purpose'])))return!![];if(c['some'](C=>C['note']!==undefined&&A['test'](C['note'])))return!![];const B=new RegExp('\x5cb'+j(z)+'\x5cb','i');if(a['guards']['some'](C=>B['test'](C['purpose'])))return!![];if(c['some'](C=>C['note']!==undefined&&B['test'](C['note'])))return!![];return B['test'](f);},l=z=>/pool is empty|pool drains?ed|drains? in full|already (?:released|paid)|escrow (?:is )?(?:empty|drained)/i['test'](z),n=h['filter'](z=>!k(z['name'])&&!l(z['role']))['map'](z=>'\x27'+z['name']+'\x27'),o=/cancel|refund|return|withdraw|compensat/i,p=/refund|repay|chargeback|compensat/i,q=z=>z['semantic_role']==='cancelled'||o['test'](z['name']),s=z=>{const A=new RegExp('current\x5cs*==\x5cs*[\x22\x27]?'+j(z)+'\x5cb','i'),B=new RegExp('\x5cb'+j(z)+'\x5cb','i');if(c['some'](C=>C['track']==='refund'&&(A['test'](C['note']??'')||B['test'](C['note']??''))))return!![];return a['guards']['some'](C=>(A['test'](C['purpose'])||B['test'](C['purpose']))&&p['test'](C['template_id']+'\x20'+C['purpose']));},u=h['filter'](z=>q(z)&&k(z['name'])&&!s(z['name'])&&!l(z['role']))['map'](z=>'\x27'+z['name']+'\x27'),v=[];return n['length']>0x0&&v['push']({'rule_id':'TERMINAL-NO-RAIL','severity':'critical','title':'Terminal\x20node(s)\x20'+n['join'](',\x20')+'\x20have\x20no\x20allocator\x20rail\x20—\x20escrow\x20strands\x20permanently\x20(publish\x20blocked)','detail':'An\x20order\x20that\x20reaches\x20a\x20terminal\x20node\x20moves\x20no\x20money\x20by\x20itself:\x20settlement\x20is\x20a\x20separate\x20keeper\x20'+'submit\x20against\x20an\x20allocator\x20whose\x20guard\x20anchors\x20that\x20node\x20(progress.current\x20==\x20<terminal>).\x20'+'A\x20terminal\x20without\x20a\x20rail\x20publishes\x20into\x20a\x20permanent\x20strand\x20—\x20the\x20escrow\x20of\x20every\x20order\x20that\x20stops\x20'+'there\x20is\x20unrecoverable\x20(mainnet\x20az-mn-261007:\x200.299\x20stranded;\x20ofshop:\x200.25\x20stranded\x20at\x20\x27expired\x27),\x20'+'and\x20topology\x20+\x20allocators\x20are\x20both\x20immutable\x20after\x20publish.\x20Either\x20this\x20terminal\x20needs\x20its\x20own\x20'+'settlement/refund\x20rail\x20(canonical\x20guard\x20designs:\x20tpl_allocator_node_gate_settle\x20/\x20'+'tpl_allocator_node_gate_refund,\x20M-T12),\x20or\x20the\x20pool\x20legitimately\x20drains\x20at\x20an\x20EARLIER\x20node\x20—\x20in\x20'+'which\x20case\x20document\x20that\x20in\x20the\x20terminal\x27s\x20role\x20(e.g.\x20\x27pool\x20is\x20empty\x27)\x20so\x20this\x20rule\x20can\x20exempt\x20it.','suggestion':'For\x20each\x20listed\x20terminal:\x20add\x20an\x20allocator\x20row\x20whose\x20guard\x20purpose\x20anchors\x20progress.current\x20==\x20<terminal>,\x20'+'or\x20state\x20in\x20the\x20node\x20role\x20that\x20the\x20pool\x20is\x20already\x20empty\x20when\x20the\x20terminal\x20is\x20reached.'}),u['length']>0x0&&v['push']({'rule_id':'TERMINAL-WRONG-RAIL','severity':'critical','title':'Refund\x20terminal(s)\x20'+u['join'](',\x20')+'\x20anchored\x20ONLY\x20by\x20the\x20settlement\x20track\x20—\x20the\x20refund\x20pays\x20the\x20merchant\x20(publish\x20blocked)','detail':'A\x20cancel-flavored\x20terminal\x20must\x20drain\x20through\x20the\x20REFUND\x20track\x20(order-anchored\x20GuardIdentifier\x20rows):\x20'+'the\x20only\x20anchor\x20that\x20currently\x20covers\x20it\x20lives\x20on\x20a\x20settlement\x20row\x20or\x20a\x20guard\x20with\x20no\x20refund\x20intent,\x20'+'and\x20a\x20settlement\x20rail\x20resolves\x20its\x20recipients\x20to\x20the\x20merchant\x20side.\x20Triggered\x20that\x20way,\x20the\x20buyer\x27s\x20'+'refund\x20is\x20paid\x20to\x20the\x20counterparty\x20—\x20same\x20irreversibility\x20class\x20as\x20a\x20missing\x20rail\x20(topology\x20and\x20'+'allocators\x20are\x20immutable\x20after\x20publish).','suggestion':'For\x20each\x20listed\x20terminal:\x20add\x20refund-track\x20rows\x20anchored\x20to\x20it\x20(progress.current\x20==\x20<terminal>\x20on\x20a\x20'+'track:\x22refund\x22\x20row\x20note,\x20or\x20a\x20guard\x20purpose\x20that\x20names\x20both\x20the\x20node\x20and\x20the\x20refund\x20intent),\x20or\x20state\x20'+'in\x20the\x20node\x20role\x20that\x20the\x20pool\x20is\x20already\x20empty\x20when\x20the\x20terminal\x20is\x20reached.'}),v;}function railNodeDriftChecks(a){const b=a['machine_shape'];if(b['length']===0x0)return[];const c=a['allocator']['rows']??[],d=[...a['guards']['map'](h=>h['purpose']),...c['map'](h=>h['note']??'')];if(!d['some'](h=>/current\s*==|current_time\s+of/i['test'](h)))return[];d['push'](a['allocator']['description']??'');const e=new Set(b['map'](h=>h['name']['toLowerCase']())),f=new Set(),g=h=>{const j=(h[0x1]??h[0x2]??'')['trim']();if(j===''||/^<.*>$/['test'](j))return;if(!/^[A-Za-z0-9_]+$/['test'](j))return;if(!e['has'](j['toLowerCase']()))f['add']('\x27'+j+'\x27');};for(const h of d){for(const j of h['matchAll'](/current\s*==\s*(?:"([^"]+)"|'([^']+)')/gi))g(j);for(const k of h['matchAll'](/current_time\s+of\s+(?:"([^"]+)"|'([^']+)')/gi))g(k);}if(f['size']===0x0)return[];return[{'rule_id':'RAIL-NODE-DRIFT','severity':'high','title':'Progress\x20anchor(s)\x20'+[...f]['join'](',\x20')+'\x20name\x20no\x20machine_shape\x20node\x20—\x20the\x20rail\x20can\x20never\x20fire','detail':'These\x20progress\x20anchors\x20(current\x20==\x20\x27X\x27\x20/\x20current_time\x20of\x20\x27X\x27)\x20reference\x20node\x20names\x20absent\x20from\x20'+'machine_shape,\x20so\x20the\x20guard\x20can\x20never\x20match\x20a\x20real\x20progress\x20state\x20and\x20whatever\x20the\x20rail\x20drains\x20'+'(settlement,\x20refund,\x20compensation)\x20strands\x20permanently.\x20The\x20usual\x20cause\x20is\x20a\x20node\x20rename\x20that\x20did\x20'+'not\x20propagate:\x20rails\x20pinned\x20\x27cancelled\x27\x20while\x20the\x20node\x20shipped\x20as\x20\x27guest_cancelled\x27\x20killed\x20every\x20'+'refund\x20path\x20on\x20a\x20live\x20store.\x20Chain\x20publishability\x20does\x20NOT\x20compare\x20anchor\x20literals\x20against\x20the\x20'+'node\x20set\x20—\x20this\x20prose-drift\x20is\x20only\x20visible\x20to\x20a\x20scan.','suggestion':'Align\x20each\x20listed\x20anchor\x20with\x20the\x20actual\x20machine_shape\x20node\x20name\x20(preferred:\x20update\x20the\x20guard\x20'+'purpose\x20/\x20allocator\x20note\x20to\x20the\x20current\x20node\x20name),\x20or\x20restore\x20the\x20node\x20name\x20in\x20machine_shape\x20'+'if\x20the\x20anchor\x20was\x20correct\x20and\x20the\x20shape\x20drifted.'}];}function siblingForwardExclusivityChecks(a){const b=a['machine_shape'];if(b['length']===0x0)return[];const d=new Map();for(const n of a['guards'])if(n['key'])d['set'](n['key'],n);const f=new Map();for(const o of a['conditional_guards']??[]){f['set'](o['param'],(f['get'](o['param'])??0x0)+0x1);}const h=new Set((a['conditional_guards']??[])['filter'](p=>(f['get'](p['param'])??0x0)>0x1)['map'](p=>p['guard_key'])),j=a['allocator']['rows']??[],k=p=>{const q=j['find'](s=>s['guard_key']===p||s['guard_key']===p+'_refund');return q?String(q['value']??q['value_from']??q['mode']):undefined;},l=p=>{if(!p)return![];const q=d['get'](p);if(!q)return![];return/time_lock/['test'](q['template_id'])||/until\b|within\b|\bdays?\b|\bhours?\b|\bwindow\b|deadline|before (?:check[- ]?in|delivery|deadline)/i['test'](q['purpose']);},m=[];for(const p of b){const q=new Map();for(const s of p['from']??[]){const u=typeof s==='string'?{'prev':s}:s;if(!u['prev'])continue;const v=u['operator']??(u['permission_index']!==undefined?'perm:'+u['permission_index']:p['operator']??'merchant'),w=q['get'](u['prev'])??[];w['push']({'guard_key':u['guard_key'],'actor':v}),q['set'](u['prev'],w);}for(const [x,y]of q){const z=y['filter'](F=>F['guard_key']!==undefined);if(z['length']<0x2)continue;const A=new Set(z['map'](F=>F['actor']));if(A['size']>0x1)continue;const B=z['filter'](F=>l(F['guard_key']));if(B['length']<0x2)continue;if(B['every'](F=>h['has'](F['guard_key'])))continue;const C=B['map'](F=>F['guard_key']),D=[...new Set(C['map'](F=>k(F))['filter'](F=>F!==undefined&&F!==''))],E=D['length']>0x1;m['push']({'rule_id':'SIBLING-FORWARD-EXCLUSIVITY','severity':E?'high':'medium','title':'Node\x20\x27'+p['name']+'\x27\x20(pair\x20from\x20\x27'+x+'\x27)\x20carries\x20'+B['length']+'\x20sibling\x20forwards\x20gated\x20by\x20'+('time-window\x20guards\x20under\x20one\x20actor\x20('+[...A]['join']('/')+')\x20—\x20no\x20on-chain\x20mutual\x20exclusion'),'detail':E?'Sibling\x20guards\x20resolve\x20to\x20DIFFERENT\x20settlement\x20amounts\x20('+D['join']('\x20vs\x20')+').\x20Sibling\x20forwards\x20on\x20one\x20'+'NodePair\x20have\x20no\x20on-chain\x20mutual\x20exclusion\x20and\x20Order.allocation\x20is\x20write-once\x20—\x20all\x20their\x20rails\x20share\x20'+'ONE\x20immutable\x20pool,\x20so\x20overlapping\x20windows\x20let\x20the\x20actor\x20fire\x20the\x20most\x20favourable\x20branch\x20(79678\x20audit\x20'+'F-01.1:\x20a\x20guest\x2040\x20days\x20out\x20can\x20satisfy\x20both\x20a\x20full-refund\x20and\x20a\x20partial-refund\x20tier).':'Sibling\x20forwards\x20on\x20one\x20NodePair\x20have\x20no\x20on-chain\x20mutual\x20exclusion;\x20if\x20their\x20time\x20windows\x20overlap,\x20the\x20'+'actor\x20picks\x20the\x20branch.\x20Verify\x20the\x20intervals\x20are\x20mutually\x20exclusive\x20by\x20construction.','suggestion':E?'Emit\x20ONE\x20forward\x20+\x20ONE\x20rail\x20per\x20selected\x20option\x20(M-T7\x20conditional\x20emission,\x20e.g.\x20user_inputs\x20cancellation_policy\x201..6),\x20'+'or\x20make\x20the\x20guards\x27\x20intervals\x20provably\x20disjoint\x20so\x20at\x20most\x20one\x20can\x20pass\x20at\x20any\x20moment.':'Make\x20the\x20sibling\x20guards\x27\x20time\x20intervals\x20provably\x20disjoint\x20(at\x20most\x20one\x20satisfiable\x20at\x20any\x20moment),\x20'+'or\x20split\x20each\x20option\x20onto\x20its\x20own\x20NodePair\x20so\x20mounting\x20is\x20a\x20build-time\x20choice.'});}}return m;}function serialClaimWindowChecks(a){const b=a['machine_shape']['some'](h=>/claim(?!ed_by)/i['test'](h['name']))||a['guards']['some'](h=>/claim/i['test'](h['key']??'')&&h['host']!=='reward');if(!b)return[];const c=a['allocator']['rows']??[],d=c['some'](h=>h['track']==='settlement'&&(h['mode']==='surplus'||h['mode']==='rate'&&h['value']===0x2710));if(!d)return[];const e=templateText(a),f=a['machine_shape']['some'](h=>/claim_window/i['test'](h['name'])),g=/serial claim[- ]window|claim_window.*serial|serial[- ]claim|claims? (is|are|always) adjudicated while the pool is intact|between checkout and payout|before (any )?release/i['test'](e);if(f&&g)return[{'rule_id':'D2-SERIAL-CLAIM-WINDOW','severity':'low','title':'Serial\x20claim\x20window\x20gates\x20the\x20full-drain\x20release\x20(ABNB2-validated\x20design)','detail':'The\x20template\x20carries\x20claim\x20machinery\x20AND\x20a\x20full-drain\x20settlement\x20group\x20(Rate\x2010000\x20/\x20Surplus),\x20'+'and\x20resolves\x20the\x20race\x20with\x20a\x20serial\x20claim_window\x20node\x20between\x20delivery\x20confirmation\x20and\x20payout:\x20'+'the\x20release\x20can\x20only\x20fire\x20after\x20the\x20window\x20closed\x20with\x20no\x20upheld\x20claim,\x20so\x20the\x20pool\x20is\x20intact\x20'+'whenever\x20money\x20moves.','suggestion':'Verify\x20the\x20release\x20guard\x20anchors\x20on\x20progress.current_time\x20of\x20the\x20claim_window\x20entry\x20'+'(witness-derived),\x20not\x20on\x20order.time\x20—\x20a\x20booking-time\x20delay\x20has\x20always\x20expired\x20before\x20'+'checkout\x20and\x20gives\x20no\x20post-delivery\x20protection.'}];return[{'rule_id':'D2-SERIAL-CLAIM-WINDOW','severity':'high','title':'Full-drain\x20release\x20can\x20fire\x20while\x20a\x20claim\x20is\x20still\x20openable\x20—\x20FCFS\x20race\x20on\x20one\x20pool\x20(FACT-ALLOC-03)','detail':'The\x20template\x20carries\x20claim\x20machinery\x20AND\x20a\x20full-drain\x20settlement\x20group\x20(Rate\x2010000\x20or\x20Surplus),\x20'+'but\x20no\x20serial\x20claim_window\x20node\x20orders\x20them:\x20the\x20payout\x20and\x20a\x20later\x20claim\x20race\x20first-come-first-served\x20'+'on\x20the\x20SAME\x20pool,\x20and\x20the\x20chain\x20has\x20no\x20holdback\x20primitive\x20(fix\x20is\x20the\x20PAID\x20sum\x20of\x20Amount\x20legs,\x20'+'allocation.move:399,540).\x20Once\x20the\x20release\x20fires,\x20a\x20claim\x20can\x20pay\x20nothing\x20from\x20the\x20pool.\x20'+'Airbnb\x20mainnet\x20audit\x202026-10-07:\x20the\x20parallel\x20payout/claim\x20design\x20paid\x20the\x20host\x20in\x20full\x20and\x20left\x20'+'the\x20claim\x20window\x20with\x20an\x20empty\x20pool.','suggestion':'Insert\x20a\x20SERIAL\x20claim_window\x20node\x20between\x20delivery\x20confirmation\x20and\x20payout\x20(ABNB2-validated):\x20'+'checkout\x20→\x20claim_window\x20→\x20payout,\x20with\x20exactly\x20two\x20exits\x20—\x20FileClaim\x20(inside\x20the\x20window,\x20'+'Clock\x20<=\x20current_time(claim_window)\x20+\x20claim_window_days)\x20and\x20ReleaseNoClaim\x20(window\x20elapsed).\x20'+'Gate\x20the\x20release\x20allocator\x20on\x20the\x20post-window\x20node,\x20and\x20give\x20a\x20denied\x20claim\x20its\x20own\x20release\x20'+'forward\x20so\x20no\x20stop\x20node\x20holds\x20funds.'}];}function dismissEdgeGuardChecks(a){const b=a['machine_shape']['some'](d=>/claim/i['test'](d['name']))||a['guards']['some'](d=>/claim/i['test'](d['purpose']));if(!b)return[];const c=[];for(const d of a['machine_shape']){for(const e of d['from']??[]){if(typeof e==='string')continue;if(!e['forward']||!/dismiss|denied|rejected/i['test'](e['forward']))continue;if(e['guard_key']&&e['guard_key']['trim']()!=='')continue;c['push']((e['prev']??'?')+'\x20─'+e['forward']+'→\x20'+d['name']);}}if(c['length']===0x0)return[];return[{'rule_id':'D2-DISMISS-EDGE-GUARD','severity':'high','title':'Claim-dismissal\x20edge\x20is\x20a\x20bare\x20permission\x20wire\x20—\x20the\x20platform\x20can\x20dismiss\x20and\x20release\x20with\x20no\x20ruling\x20evidence\x20(N-T2)','detail':'These\x20dismissal\x20edges\x20carry\x20permission_index\x20but\x20NO\x20guard:\x20'+c['join'](';\x20')+'.\x20The\x20holder\x20of\x20that\x20permission\x20can\x20dismiss\x20the\x20buyer\x27s\x20claim\x20and\x20fire\x20the\x20release/payout\x20in\x20one\x20'+'step,\x20with\x20nothing\x20on-chain\x20proving\x20a\x20ruling\x20ever\x20happened\x20—\x20the\x20serial\x20claim\x20window\x27s\x20time\x20'+'ordering\x20is\x20defeated\x20by\x20its\x20own\x20escape\x20hatch.','suggestion':'Gate\x20each\x20dismissal\x20edge\x20on\x20tpl_forward_arb_ruling_dismissed\x20(arb.order\x20==\x20order\x20AND\x20'+'arb.indemnity.amount\x20==\x200):\x20the\x20native\x20indemnity.amount\x20query\x20errors\x20on\x20a\x20None\x20field,\x20so\x20the\x20'+'leg\x20passes\x20ONLY\x20for\x20a\x20standing\x20Some(0)\x20ruling\x20—\x20never-ruled\x20and\x20reset/objection\x20states\x20(both\x20'+'None)\x20fail\x20closed,\x20and\x20a\x20buyer-favor\x20ruling\x20(Some(>0))\x20fails\x20the\x20equality.\x20ONE\x20INSTANCE\x20PER\x20'+'dismissal\x20edge\x20—\x20never\x20share\x20the\x20guard\x20between\x20two\x20forwards.\x20Never\x20express\x20the\x20gate\x20as\x20'+'\x27arb.indemnity\x20some\x20==\x20false\x27\x20or\x20arb.status\x20(R-X1-16).'}];}function noteNodeDriftChecks(a){const b=new Set(a['machine_shape']['map'](d=>d['name']['toLowerCase']())),c=[];for(const d of a['build_notes']??[]){for(const e of d['matchAll'](/must (?:create|add|declare|include)[^.;]*?'([a-z0-9_]+)'/gi)){const f=e[0x1]['toLowerCase']();if(!b['has'](f))c['push']('\x27'+f+'\x27');}}if(c['length']===0x0)return[];return[{'rule_id':'NOTE-NODE-DRIFT','severity':'medium','title':'A\x20build_note\x20mandates\x20a\x20node\x20the\x20machine_shape\x20does\x20not\x20contain\x20—\x20prose\x20running\x20ahead\x20of\x20structure\x20(N-T6)','detail':'These\x20node\x20names\x20appear\x20under\x20MUST-create\x20language\x20in\x20build_notes\x20but\x20are\x20absent\x20from\x20machine_shape:\x20'+c['join'](',\x20')+'.\x20The\x20generator\x20will\x20read\x20the\x20note\x20and\x20invent\x20a\x20topology\x20the\x20structural\x20audit\x20(edges,\x20reachability,\x20'+'fund-exit\x20coverage)\x20never\x20examined\x20—\x20exactly\x20how\x20unguarded\x20edges\x20and\x20orphan\x20nodes\x20escaped\x20earlier\x20audits.','suggestion':'Either\x20land\x20the\x20mandated\x20node\x20in\x20machine_shape\x20WITH\x20its\x20from-edges\x20in\x20the\x20same\x20edit\x20(a\x20spliced\x20node\x20'+'without\x20edges\x20is\x20a\x20compile\x20blocker\x20and\x20a\x20reachability\x20finding),\x20or\x20reword\x20the\x20note\x20to\x20guidance\x20'+'language\x20(\x27model\x20it\x20as\x27,\x20\x27e.g.\x27)\x20so\x20the\x20optional\x20extension\x20is\x20not\x20read\x20as\x20a\x20structural\x20mandate.'}];}function syntheticMachine(a){const b=a['machine_shape']['map'](e=>({'name':e['name'],'description':e['role'],'operator':e['operator']})),c=[],d=(e,f)=>[{'name':e,'weight':0x1,'named_operator':f==='order_payer'?'':'order_holder'}];b['length']>0x0&&c['push']({'prev_node':'','next_node':b[0x0]['name'],'threshold':0x1,'forwards':d('enter_'+b[0x0]['name'],b[0x0]['operator'])});for(let e=0x0;e<b['length']-0x1;e++){const f=b[e]['name'],g=b[e+0x1];if(BRANCH_STATE_REGEX['test'](g['name']))continue;c['push']({'prev_node':f,'next_node':g['name'],'threshold':0x1,'forwards':d(f+'_to_'+g['name'],g['operator'])});}if(b['length']>0x0)for(const h of b){BRANCH_STATE_REGEX['test'](h['name'])&&c['push']({'prev_node':b[0x0]['name'],'next_node':h['name'],'threshold':0x1,'forwards':d('to_'+h['name'],h['operator'])});}return{'nodes':b,'pairs':c};}function singleNodeGraph(a){return{'network':ENTRYPOINT['Testnet'],'seed':a['id'],'builtAt':Date['now'](),'nodes':new Map([[a['id'],a]]),'edges':[],'out':new Map(),'inc':new Map(),'gaps':[],'truncations':[],'rpcReport':{'batches':0x0,'byChannel':{'objects':0x0,'keyedFields':0x0,'tables':0x0,'events':0x0},'dedupHits':0x0},'budgetExhausted':{}};}function analyzerFindings(a){const b=makeProposalNode('machine',syntheticMachine(a)),c=singleNodeGraph(b),d=buildViewport(c,c['seed'],'neutral');return runNodeAnalyzers(d,[machineRuleNodeAnalyzer,allocationRuleNodeAnalyzer]);}const SEVERITY_ORDER={'low':0x0,'medium':0x1,'high':0x2,'critical':0x3},ONEWAY_GATE_REGEX=/dispute[a-z]*\s*(?:count|len(?:gth)?)?[^.;:\n]{0,24}===?\s*0\b/gi,ONEWAY_NEGATION_REGEX=/\b(?:never|do\s+not|don'?t|not|avoid|instead|substitute|one-way\s+door|welds?|append-only|rather\s+than)\b/i;function onewayDisputeChecks(a){const b=[...a['guards']['map'](d=>['guard\x20'+d['template_id'],d['purpose']]),...(a['allocator']['rows']??[])['map']((d,e)=>['allocator\x20row\x20'+e,d['note']??'']),['allocator\x20description',a['allocator']['description']],...a['build_notes']['map']((d,e)=>['build\x20note\x20'+e,d]),...a['trust_mechanisms']['map']((d,e)=>['trust\x20mechanism\x20'+e,d])],c=[];for(const [d,e]of b){if(!e)continue;ONEWAY_GATE_REGEX['lastIndex']=0x0;for(let f=ONEWAY_GATE_REGEX['exec'](e);f!==null;f=ONEWAY_GATE_REGEX['exec'](e)){const g=e['slice'](Math['max'](0x0,f['index']-0x5a),f['index']+f[0x0]['length']+0x5a);if(ONEWAY_NEGATION_REGEX['test'](g))continue;c['push'](d+':\x20\x22'+f[0x0]['trim']()+'\x22');}}if(c['length']===0x0)return[];return[{'rule_id':'R-ONEWAY-DISPUTE','severity':'critical','title':'Dispute-count\x20gate\x20on\x20an\x20append-only\x20vector\x20—\x20the\x20first\x20filing\x20welds\x20the\x20rail\x20shut','detail':'Order.dispute\x20only\x20grows\x20(the\x20filing\x20entry\x20appends;\x20nothing\x20ever\x20removes).\x20A\x20guard\x20gated\x20on\x20'+'\x22dispute\x20count\x20==\x200\x22\x20is\x20monotone-false\x20after\x20the\x20first\x20case,\x20so\x20one\x20filing\x20permanently\x20closes\x20the\x20'+'gated\x20rail\x20and\x20strands\x20the\x20escrow\x20—\x20verified\x20on\x20mainnet\x20(az-mn-261007\x20T5:\x20the\x20reviewed\x20order\x20walked\x20'+'case\x20->\x20ruling\x20->\x20payout\x20and\x20its\x202.38\x20principal\x20froze\x20with\x20no\x20exit).\x20Offending\x20surfaces:\x20'+c['join'](';\x20')+'.','suggestion':'Gate\x20on\x20the\x20PAYOUT\x20state\x20instead:\x20order.claimed_by\x20via\x20query\x201570\x20—\x20some\x20==\x20false\x20blocks\x20the\x20refund\x20'+'rail\x20only\x20after\x20an\x20award\x20ACTUALLY\x20paid,\x20and\x20the\x20paired\x20merchant-recovery\x20allocator\x20(some\x20==\x20true)\x20'+'keeps\x20the\x20awarded\x20order\x27s\x20escrow\x20exit.\x20Never\x20substitute\x20dispute\x20count\x20==\x200\x20(append-only\x20one-way\x20door).'}];}const ARB_REFERENCE_REGEX=/\barbitration\b|\barbitrator\b|compensation[ -]fund|\barb\.|\bruling\b/i;function noEscrowExitChecks(a){const b=a['allocator']['rows']??[];if(!b['some'](d=>d['track']==='refund'&&d['recipient']==='guard_identifier'))return[];const c=templateText(a,b['map'](d=>d['note']??''));if(!ARB_REFERENCE_REGEX['test'](c))return[];if(/claimed_by/i['test'](c))return[];return[{'rule_id':'R-NO-ESCROW-EXIT','severity':'high','title':'Refund\x20rail\x20never\x20reads\x20the\x20arbitration\x20payout\x20state\x20—\x20double-pay\x20and\x20stranded-escrow\x20hazards','detail':'The\x20template\x20declares\x20an\x20order-anchored\x20refund\x20rail\x20and\x20references\x20arbitration,\x20but\x20no\x20guard\x20design,\x20'+'row\x20note,\x20or\x20build\x20note\x20reads\x20order.claimed_by\x20(query\x201570)\x20—\x20the\x20payout\x20state.\x20After\x20a\x20compensation\x20'+'award\x20pays:\x20the\x20refund\x20rail\x20cannot\x20block\x20(the\x20compensated\x20order\x20still\x20drains\x20the\x20escrow\x20—\x20D-BUG-2\x20'+'double-pay),\x20and\x20no\x20merchant-recovery\x20allocator\x20is\x20declared,\x20so\x20the\x20awarded\x20order\x27s\x20escrow\x20principal\x20'+'has\x20no\x20exit\x20(mainnet\x20az-mn-261007\x20T5:\x202.38\x20stranded).','suggestion':'Gate\x20the\x20refund\x20guard\x20on\x20order.claimed_by\x20some\x20==\x20false\x20(query\x201570)\x20and\x20PAIR\x20a\x20merchant-recovery\x20'+'allocator\x20whose\x20guard\x20asserts\x20order.claimed_by\x20some\x20==\x20true\x20plus\x20order.service\x20binding\x20—\x20'+'deliberately\x20NO\x20node\x20equality\x20leg\x20(UPWC-K1/upwc-cat-261017\x20CAT-B1+CAT-C2:\x20the\x20claimed_by\x20axis\x20'+'alone\x20carries\x20the\x20exclusion;\x20a\x20pinned\x20node\x20literal\x20re-seals\x20the\x20rail)\x20—\x20exactly\x20one\x20of\x20the\x20two\x20legs\x20'+'can\x20ever\x20pass\x20(ESCROW\x20EXIT\x20INVARIANT).'}];}const CLAIMED_FALSE_RE=/claimed_by\s*(?:is\s+)?(?:none|some\s*==\s*false)/i,CLAIMED_TRUE_RE=/claimed_by\s*(?:is\s+)?some\s*==\s*true/i;function pairingProseOnlyChecks(a){const b=a['allocator']['rows']??[];if(!b['some'](j=>j['track']==='refund'&&j['recipient']==='guard_identifier'))return[];const c=templateText(a);if(!ARB_REFERENCE_REGEX['test'](c))return[];if(!/claimed_by/i['test'](c))return[];const d=b['some'](j=>j['track']==='refund'&&CLAIMED_FALSE_RE['test'](j['note']??'')),e=b['some'](j=>j['track']!=='refund'&&CLAIMED_TRUE_RE['test'](j['note']??''));if(d&&e)return[];const f=a['guards']['some'](j=>CLAIMED_FALSE_RE['test'](j['purpose']??'')),g=a['guards']['some'](j=>CLAIMED_TRUE_RE['test'](j['purpose']??'')),h=[!d?'refund\x20leg\x20(claimed_by\x20some\x20==\x20false\x20in\x20the\x20refund\x20row\x20note)':null,!e?'recovery\x20leg\x20(claimed_by\x20some\x20==\x20true\x20in\x20the\x20recovery\x20row\x20note)':null]['filter'](j=>j!==null)['join']('\x20and\x20');if(f&&g)return[{'rule_id':'R-PAIRING-PROSE-ONLY','severity':'low','title':'claimed_by\x20pairing\x20declared\x20in\x20the\x20guard\x20specs\x20but\x20not\x20bound\x20in\x20the\x20row\x20notes','detail':'The\x20claimed_by\x20none/some\x20pairing\x20is\x20declared\x20in\x20the\x20guard\x20specs\x27\x20purposes\x20—\x20accepted\x20as\x20an\x20'+'alternative\x20resolution\x20(ptrn2-ln-261011\x20A2:\x20guard-pair\x20polarity\x20is\x20a\x20chain-validated\x20closure).\x20'+('Missing\x20from\x20the\x20row\x20notes:\x20'+h+'.\x20Row\x20notes\x20are\x20the\x20payload\x20a\x20builder\x20assembles\x20the\x20')+'allocator\x20guards\x20from;\x20rails\x20built\x20from\x20row\x20notes\x20alone\x20would\x20carry\x20no\x20payout\x20polarity:\x20a\x20'+'compensated\x20order\x20double-pays\x20(D-BUG-2)\x20and\x20the\x20awarded\x20order\x20strands\x20its\x20escrow\x20(mainnet\x20'+'az-mn-261007\x20T5).','suggestion':'Mirror\x20the\x20pairing\x20into\x20the\x20row\x20notes\x20so\x20the\x20assembled\x20payload\x20carries\x20it\x20structurally:\x20the\x20'+'refund\x20row\x20note\x20asserts\x20order.claimed_by\x20some\x20==\x20false\x20(query\x201570),\x20the\x20recovery\x20row\x20note\x20'+'asserts\x20some\x20==\x20true\x20+\x20order.service\x20binding\x20with\x20NO\x20node\x20equality\x20leg\x20(UPWC-K1/CAT-C2:\x20the\x20'+'claimed_by\x20axis\x20alone\x20carries\x20the\x20exclusion)\x20—\x20exactly\x20one\x20leg\x20can\x20ever\x20'+'pass\x20(ESCROW\x20EXIT\x20INVARIANT).\x20Canonical\x20shape:\x20subscription/direct-fan-subscription\x27s\x20'+'refund_*\x20+\x20awarded_recover\x20rails.'}];return[{'rule_id':'R-PAIRING-PROSE-ONLY','severity':'medium','title':'claimed_by\x20refund/recovery\x20pairing\x20promised\x20in\x20prose\x20but\x20missing\x20from\x20the\x20row\x20notes','detail':'The\x20template\x27s\x20prose\x20describes\x20the\x20claimed_by\x20none/some\x20pairing\x20(refund\x20blocked\x20once\x20an\x20award\x20'+'ACTUALLY\x20paid\x20+\x20paired\x20merchant-recovery\x20allocator),\x20but\x20the\x20allocator\x20row\x20notes\x20do\x20not\x20declare\x20it.\x20Missing:\x20'+(h+'.\x20Row\x20notes\x20are\x20the\x20payload\x20a\x20builder\x20assembles\x20the\x20guards\x20from\x20—\x20rails\x20built\x20without\x20the\x20')+'declared\x20polarity\x20have\x20none:\x20a\x20compensated\x20order\x20double-pays\x20(D-BUG-2)\x20and\x20the\x20awarded\x20order\x20strands\x20its\x20'+'escrow\x20(mainnet\x20az-mn-261007\x20T5).','suggestion':'Declare\x20the\x20pairing\x20in\x20the\x20row\x20notes:\x20the\x20refund\x20row\x20note\x20asserts\x20order.claimed_by\x20some\x20==\x20false\x20'+'(query\x201570\x20—\x20refund\x20precluded\x20once\x20an\x20award\x20paid),\x20and\x20the\x20recovery\x20row\x20note\x20asserts\x20some\x20==\x20true\x20+\x20'+'order.service\x20binding\x20with\x20NO\x20node\x20equality\x20leg\x20(UPWC-K1/CAT-C2:\x20the\x20claimed_by\x20axis\x20alone\x20carries\x20'+'the\x20exclusion)\x20—\x20exactly\x20one\x20of\x20the\x20two\x20legs\x20can\x20ever\x20pass\x20(ESCROW\x20EXIT\x20'+'INVARIANT).\x20Canonical\x20shape:\x20subscription/direct-fan-subscription\x27s\x20refund_*\x20+\x20awarded_recover\x20rails.'}];}const TIER_PROMISE_RE=/\btiers?\b[^.!?\n]{0,120}?\b(earns?|earned|unlocks?|unlocked|receives?|received|gets?|claims?|claimed|grants?|granted)\b|\b(earns?|earned|unlocks?|unlocked|receives?|received|gets?|claims?|claimed|grants?|granted)\b[^.!?\n]{0,80}?\btiers?\b/i,REWARD_CONTEXT_RE=/\brewards?\b|\bbount(?:y|ies)\b|\bbonus(?:es)?\b|\bhonors?\b|\bperks?\b/i,PROHIBITION_RE=/\b(?:never promise|do not|don'?t|cannot|not constructible|unenforceable|unforced decoration|must be disclosed|MUST be disclosed|either add|drop the wording|word promises? to match|without a guard leg|no guard leg|impossible)\b/i,TIER_PREDICATE_RE=/\bhistor(?:y|ical)\b|\bperiod count\b|\bcount\s*>=|per-order repository|\brepository row\b|\btier predicate\b|\bstore_from_id\b/i;function disclosureEnforceabilityChecks(a){const b=[...a['build_notes'],...a['differences']??[],...a['guards']['map'](e=>e['purpose']??''),...(a['allocator']['rows']??[])['map'](e=>e['note']??'')],c=b['flatMap'](e=>e['split'](/(?<=[.!?])\s+/))['filter'](e=>TIER_PROMISE_RE['test'](e)&&REWARD_CONTEXT_RE['test'](e)&&!PROHIBITION_RE['test'](e)&&!TIER_PREDICATE_RE['test'](e));if(c['length']===0x0)return[];const d=a['guards']['some'](e=>TIER_PREDICATE_RE['test'](e['purpose']??''));if(d)return[];return[{'rule_id':'DISCLOSURE-ENFORCEABILITY','severity':'medium','title':'Tier-scoped\x20reward\x20promise\x20with\x20no\x20enforcement\x20leg\x20—\x20unenforceable\x20decoration','detail':'The\x20template\x27s\x20prose\x20promises\x20tier-scoped\x20rewards\x20('+c['slice'](0x0,0x2)['map'](e=>'\x22'+e['trim']()['slice'](0x0,0x8c)+'\x22')['join'](';\x20')+(c['length']>0x2?'\x20+'+(c['length']-0x2)+'\x20more':'')+'),\x20but\x20no\x20guard\x20design\x20reads\x20tier\x20evidence\x20(history\x20count,\x20per-order\x20repository\x20row).\x20Reward\x20objects\x20'+'are\x20Service-level\x20and\x20sales\x20rows\x20carry\x20no\x20reward\x20field,\x20so\x20the\x20claim\x20guard\x20gates\x20tier-agnostically:\x20'+'buyers\x20are\x20promised\x20a\x20tier\x20benefit\x20the\x20chain\x20cannot\x20verify\x20or\x20pay\x20selectively\x20(ptrn2-ln-261011\x20B3:\x20'+'\x27Co-Producer\x20earns\x20Veteran\x20rewards\x27\x20while\x20the\x20claim\x20guard\x20read\x20history\x20>=\x207\x20for\x20every\x20tier).','suggestion':'Either\x20add\x20the\x20predicate\x20—\x20a\x20claim-guard\x20leg\x20reading\x20per-order\x20repository\x20evidence\x20(or\x20history\x20'+'count)\x20so\x20each\x20tier\x27s\x20promise\x20is\x20actually\x20gated\x20—\x20or\x20reword\x20the\x20promise\x20to\x20match\x20what\x20the\x20guard\x20'+'leg\x20really\x20reads.\x20Never\x20ship\x20tier\x20wording\x20the\x20guard\x20cannot\x20enforce.'}];}function railUnboundChecks(a){const b=a['allocator']['rows']??[],c=b['map']((d,e)=>({'r':d,'i':e}))['filter'](({r:d})=>d['guard_key']===undefined);if(c['length']===0x0)return[];return[{'rule_id':'R-RAIL-UNBOUND','severity':'critical','title':c['length']+'\x20money\x20row(s)\x20bind\x20no\x20guard_key\x20—\x20the\x20rails\x20ship\x20uncovered\x20and\x20FUND-EXIT-01\x20goes\x20critical\x20at\x20generation','detail':'Allocator\x20rows\x20are\x20the\x20payload\x20compile\x20turns\x20into\x20order_allocators.\x20A\x20row\x20without\x20guard_key\x20emits\x20an\x20'+'allocator\x20carrying\x20no\x20guard\x20reference,\x20so\x20(a)\x20the\x20terminal\x20it\x20serves\x20has\x20no\x20resolved\x20allocator\x20guard\x20'+'(FUND-EXIT-01\x20critical),\x20and\x20(b)\x20no\x20pending-judgment\x20surface\x20exists\x20for\x20guard_resolutions\x20to\x20close\x20'+'(the\x20surface\x20is\x20keyed\x20by\x20row\x20guard_key\x20bindings)\x20—\x20the\x20build\x20is\x20deadlocked,\x20not\x20merely\x20warned\x20'+'(upw-ln-261011\x20TPL-01).\x20Unbound\x20rows:\x20'+c['map'](({r:d,i:e})=>'#'+e+'\x20('+d['track']+'/'+d['recipient']+')')['join'](',\x20')+'.','suggestion':'Declare\x20a\x20keyed\x20guard\x20spec\x20per\x20rail\x20and\x20bind\x20every\x20money\x20row\x20via\x20guard_key:\x20settlement\x20rides\x20'+'tpl_allocator_node_gate_settle\x20(the\x20kernel\x20auto-fills\x20it\x20—\x20service_name\x20is\x20seeded\x20from\x20the\x20plan,\x20'+'settle_node\x20defaults\x20to\x20\x27completed\x27)\x20plus\x20a\x20Rate-0\x20ORDER\x20anchor\x20row\x20sharing\x20the\x20key\x20(CR-01);\x20'+'refund/recovery\x20ride\x20pattern.progress_state_check\x20designs\x20with\x20the\x20claimed_by\x20polarity\x20declared\x20in\x20'+'the\x20spec\x20purpose.\x20Canonical\x20shapes:\x20freelance/catalog-tiers\x20(v48)\x20and\x20subscription/direct-fan-subscription.'}];}function counterpartyFundEvidenceChecks(a){const b=a['allocator']['rows']??[],c=a['guards']??[];if(b['length']===0x0||c['length']===0x0)return[];const d=k=>k==='pattern.repository_data_check'||k['startsWith']('tpl_repository_'),e=new Map();for(const k of c){if(k['key']&&d(k['template_id']))e['set'](k['key'],k);}if(e['size']===0x0)return[];const f=/order[- ]holder|order\.owner|co-?writ|co-?sign|both part(?:y|ies)|written by the (?:buyer|payer|order)|writer authorization|write[- ](?:authorization|policy|guard)|build[- ]time|pinned (?:at|to) (?:build|generation|publish)|value_from|fee_param|event evidence only|append[- ]only|a new row|re-?disclos/i,h=b['map']((l,m)=>({'r':l,'i':m}))['filter'](({r:l})=>{const m=l['guard_key']?e['get'](l['guard_key']):undefined;if(!m)return![];return!f['test'](m['purpose'])&&!(l['note']&&f['test'](l['note']));});if(h['length']===0x0)return[];const j=h['map'](({r:l,i:m})=>'#'+m+'\x20('+l['track']+'/'+(l['recipient_key']??l['recipient'])+'\x20->\x20\x27'+l['guard_key']+'\x27)')['join'](',\x20');return[{'rule_id':'R-COUNTERPARTY-FUND-EVIDENCE','severity':'high','title':h['length']+'\x20money\x20row(s)\x20gate\x20on\x20counterparty-mutable\x20repository\x20evidence\x20—\x20fund\x20terms\x20one\x20party\x20can\x20rewrite','detail':'Rows\x20'+j+'\x20bind\x20a\x20repository-data\x20gate,\x20and\x20repository.data\x20is\x20an\x20UPSERT\x20key-value\x20store:\x20'+'its\x20rows\x20stay\x20overwritable\x20by\x20their\x20author\x20(mainnet\x20A/B,\x20ofn-mn-261012\x20F-02)\x20and\x20an\x20overwrite\x20raises\x20'+'no\x20buyer-parseable\x20event\x20(the\x20overwrite\x20event\x20renders\x20\x27Unknown\x20event\x27).\x20Whoever\x20writes\x20the\x20evidence\x20'+'can\x20therefore\x20silently\x20re-decide\x20WHICH\x20rail\x20applies\x20or\x20WHETHER\x20the\x20gate\x20matches\x20at\x20all\x20—\x20the\x20audited\x20'+'airbnb\x20service\x20ran\x20its\x20refunds\x20through\x20gates\x20the\x20host\x20rewrote\x20AFTER\x20the\x20buyer\x20had\x20already\x20cancelled,\x20'+'down\x20to\x20zero\x20matching\x20rails\x20(abnb7-mn-261013\x20F25).\x20Neither\x20the\x20guard\x20purpose\x20nor\x20the\x20row\x20note\x20declares\x20'+'the\x20counterparty\x20discipline.','suggestion':'Pin\x20every\x20fund\x20TERM\x20at\x20build\x20time\x20—\x20amounts\x20and\x20tier\x20selection\x20ride\x20value_from\x20/\x20fee_params\x20and\x20freeze\x20'+'into\x20the\x20allocator\x20at\x20publish;\x20repository\x20rows\x20carry\x20EVENT\x20evidence\x20only\x20and\x20never\x20select\x20between\x20rails.\x20'+'If\x20a\x20repository\x20row\x20must\x20inform\x20money\x20at\x20all,\x20its\x20write\x20authorization\x20MUST\x20include\x20the\x20order\x20holder\x20'+'(co-write\x20/\x20proof\x20signed\x20by\x20the\x20order\x20holder)\x20and\x20changes\x20land\x20as\x20a\x20NEW\x20row\x20with\x20disclosure\x20visible\x20to\x20'+'the\x20counterparty\x20through\x20the\x20Messenger\x20channel\x20—\x20never\x20an\x20in-place\x20overwrite\x20(see\x20p2p-shortstay\x27s\x20'+'guest_claim_evidence\x20for\x20the\x20participation\x20form\x20and\x20its\x20FUND-TERMS\x20build\x20note\x20for\x20the\x20full\x20discipline).'}];}function allocReplayChecks(a){const b=a['allocator']['rows']??[];if(b['length']===0x0)return[];if(a['allocator']['once_per_order']===!![])return[];if(poolPeriodCount(a)!==undefined)return[];const c=new Map();for(const e of b){const f=e['guard_key']??'';c['set'](f,[...c['get'](f)??[],e]);}const d=[];for(const [h,j]of c){if(j['some'](n=>n['mode']==='surplus'))continue;const k=j['filter'](n=>n['mode']==='amount');let l=0x0;for(const n of j)if(n['mode']==='rate')l+=Number(n['value'])||0x0;if(k['length']===0x0&&l>=0x2710)continue;const m=h?'guard\x20\x27'+h+'\x27':'ungrouped\x20rows';k['length']>0x0&&d['push']('fixed-Amount\x20row(s)\x20under\x20'+m+':\x20'+k['map'](o=>o['track']+'/'+(o['recipient_key']??o['recipient']))['join'](',\x20')),l>0x0&&l<0x2710&&d['push']('Rate\x20leg\x20under\x20'+m+'\x20summing\x20'+l+'\x20<\x2010000');}if(d['length']===0x0)return[];return[{'rule_id':'R-ALLOC-REPLAY','severity':'high','title':'Residual-capable\x20rails\x20without\x20a\x20once-slot\x20—\x20replay\x20protection\x20is\x20only\x20the\x20drained-balance\x20side\x20effect','detail':'The\x20allocator\x20declares\x20'+d['join']('\x20and\x20')+'\x20but\x20sets\x20no\x20once_per_order\x20replay\x20slot.\x20The\x20trigger\x20'+'guard\x20can\x20be\x20satisfied\x20repeatedly,\x20and\x20each\x20run\x20pays\x20from\x20any\x20remaining\x20balance:\x20a\x20replayed\x20alloc\x20on\x20a\x20'+'drained\x20pool\x20aborts\x20\x27Insufficient\x20balance\x27\x20—\x20the\x20guard\x20clauses\x20themselves\x20PASS\x20(the\x20once-protection\x20is\x20'+'the\x20zero\x20balance,\x20not\x20a\x20consumed-once\x20flag).\x20Any\x20surplus\x20leg\x20that\x20leaves\x20balance,\x20or\x20a\x20later\x20re-deposit\x20'+'into\x20the\x20Allocation,\x20re-enables\x20payout\x20(mainnet\x20az-mn-261007\x20N5).','suggestion':'Declare\x20allocator.once_per_order=true\x20so\x20generation\x20registers\x20the\x20ONCE-FOR-OBJECT\x20submission\x20slot\x20'+'(identifier\x20254\x20—\x20the\x20chain\x20derives\x20the\x20slot\x20key\x20from\x20payment_info.for_object\x20and\x20a\x20replay\x20aborts\x20with\x20'+'code\x2016\x20regardless\x20of\x20submitted\x20bytes;\x20use\x20identifier\x20255\x20with\x20a\x20\x27period-<N>\x27\x20key\x20only\x20for\x20rails\x20that\x20'+'legitimately\x20run\x20once\x20per\x20period).\x20Alternatively\x20make\x20every\x20leg\x20exhaust\x20its\x20pool\x20(pure\x20Rate\x2010000\x20or\x20a\x20'+'Surplus\x20sweep)\x20so\x20no\x20residual\x20can\x20be\x20replayed.'}];}function draftVoidChecks(a){const b=a['machine_shape']??[];if(b['length']===0x0)return[];if(!b['some'](e=>(e['from']??[])['length']>0x0))return[];const c=f=>{const g=[];for(const h of b){for(const j of h['from']??[]){const k=typeof j==='string'?j:j?.['prev'];if(k!==f)continue;const l=typeof j==='object'&&j?.['operator']?j['operator']:h['operator']??'merchant';g['push']({'target':h,'op':l});}}return g;},d=[];for(const e of b){if(!/escrow/i['test'](e['role']??''))continue;if(/award|pays the (host|seller|creator|merchant|provider)/i['test'](e['role']??''))continue;if(/^(delivered|final|cancelled)$/['test'](e['semantic_role']??''))continue;const f=c(e['name']),g=f['some'](({target:h,op:j})=>j==='order_payer'&&h['semantic_role']==='cancelled');if(g)continue;d['push'](f['length']===0x0?'\x27'+e['name']+'\x27\x20has\x20NO\x20outgoing\x20forward\x20at\x20all\x20(entry\x20dead-end)':'\x27'+e['name']+'\x27\x20exits\x20only\x20via\x20'+f['map'](({target:h,op:j})=>h['name']+'['+j+']')['join'](',\x20'));}if(d['length']===0x0)return[];return[{'rule_id':'R-DRAFT-VOID','severity':'high','title':'Escrowed\x20node\x20without\x20a\x20buyer-side\x20void\x20hop\x20—\x20abandoned\x20orders\x20strand\x20the\x20escrow','detail':'Buy\x20escrows\x20atomically,\x20so\x20the\x20money\x20is\x20pooled\x20from\x20the\x20moment\x20the\x20order\x20exists.\x20'+d['join'](';\x20')+'\x20—\x20none\x20of\x20these\x20routes\x20is\x20an\x20order-payer\x20hop\x20into\x20a\x20cancelled\x20'+'endpoint,\x20so\x20a\x20buyer\x20who\x20abandons\x20or\x20fails\x20mid-order\x20(transport\x20error,\x20second\x20thoughts,\x20'+'a\x20ghost\x20order)\x20has\x20funds\x20locked\x20with\x20no\x20single-hop\x20exit\x20(mainnet\x20az-mn-261007\x20G2:\x20the\x20'+'deployed\x20machine\x27s\x20draft\x20node\x20had\x20only\x20the\x20entry\x20forward;\x20voiding\x20required\x20Enter\x20->\x20'+'CancelBeforePayment).','suggestion':'Add\x20an\x20order-payer\x20forward\x20from\x20every\x20escrowed\x20node\x20to\x20the\x20template\x27s\x20cancelled\x20endpoint\x20'+'(e.g.\x20\x27paid\x20->\x20closed_cancel\x27,\x20operator\x20\x27order_payer\x27)\x20gated\x20by\x20the\x20cancel\x20guard;\x20the\x20refund\x20'+'rail\x20must\x20stay\x20mounted\x20—\x20escrow\x20is\x20funded\x20at\x20order_new,\x20not\x20at\x20first\x20forward.'}];}const DELIVERY_SURFACE_REGEX=/\b(ship(?:s|ping|ped|ment)?|tracking|courier|parcel|pickup|check[- ]?in|hand[- ]?over|redeem(?:s|ed|ption)?)\b/i,REQINFO_SURFACE_REGEX=/required[_ ]?info|customer_required|\b1572\b|required_info_evidence_gate/i;function requiredInfoGateChecks(a){const b=a['machine_shape']['filter'](c=>DELIVERY_SURFACE_REGEX['test'](c['name']+'\x20'+c['role']))['map'](c=>'\x27'+c['name']+'\x27\x20('+c['role']+')');if(b['length']===0x0)return[];if(REQINFO_SURFACE_REGEX['test'](templateText(a)))return[];return[{'rule_id':'R-REQINFO-GATE','severity':'high','title':'Fulfilment\x20flow\x20never\x20enforces\x20buyer\x20required\x20info\x20—\x20Service.customer_required\x20is\x20declarative-only','detail':'The\x20on-chain\x20purchase\x20entry\x20never\x20reads\x20Service.customer_required,\x20so\x20an\x20order\x20that\x20skips\x20every\x20'+'required\x20field\x20still\x20creates.\x20Fulfilment\x20surfaces\x20that\x20physically\x20hand\x20over\x20goods\x20or\x20need\x20to\x20reach\x20'+'the\x20buyer\x20—\x20'+b['join'](';\x20')+'\x20—\x20are\x20the\x20only\x20points\x20where\x20that\x20obligation\x20can\x20be\x20'+'enforced\x20on\x20chain,\x20yet\x20the\x20template\x20declares\x20no\x20required_info\x20surface\x20anywhere\x20(no\x20'+'pattern.required_info_evidence_gate,\x20no\x20order.required_info\x201572\x20reference\x20in\x20any\x20guard\x20purpose\x20'+'or\x20build\x20note).','suggestion':'Mount\x20pattern.required_info_evidence_gate\x20on\x20the\x20fulfilment\x20forward:\x20gate\x20order.required_info\x20some\x20'+'(1572)\x20presence\x20FIRST\x20—\x20a\x20bare\x201573\x20value\x20read\x20aborts\x20while\x20the\x20Option\x20is\x20empty.\x20Presence-only\x20is\x20'+'the\x20right\x20default:\x20the\x20recorded\x20value\x20is\x20unvalidated\x20buyer\x20input\x20and\x20carries\x20no\x20on-chain\x20meaning,\x20'+'so\x20treat\x20the\x20merchant\x27s\x20confirming\x20forward\x20(not\x20the\x20recorded\x20address)\x20as\x20the\x20acceptance\x20basis.'}];}function planReadinessChecks(a){const b=[],c=a['allocator']['rows']??[],d=c['some'](h=>h['track']==='refund'),e=a['allocator']['refund_track']!==undefined||/refund/i['test'](a['allocator']['description']),f=validateAllocatorRows(a);f['length']>0x0&&b['push']({'rule_id':'R-PLAN-01','severity':'critical','title':'Allocator\x20rows\x20are\x20internally\x20inconsistent\x20—\x20the\x20money\x20plan\x20cannot\x20be\x20built','detail':'Template\x20allocator\x20rows\x20are\x20internally\x20inconsistent:\x20'+f['join'](';\x20')+'.','suggestion':'Fix\x20the\x20template\x27s\x20allocator.rows\x20(they\x20are\x20the\x20authoritative\x20money\x20plan;\x20order_allocators\x20is\x20L1-frozen\x20at\x20publish).'});a['allocator']['refund_track']&&!d&&b['push']({'rule_id':'R-PLAN-02','severity':'critical','title':'Declared\x20refund\x20track\x20has\x20no\x20refund\x20row\x20—\x20the\x20plan\x20cannot\x20carry\x20the\x20promised\x20refund\x20rail','detail':'Template\x20declares\x20a\x20\x27'+a['allocator']['refund_track']+'\x27\x20refund\x20track\x20but\x20declares\x20no\x20allocator\x20row\x20with\x20'+'track=\x27refund\x27;\x20the\x20generated\x20plan\x20cannot\x20carry\x20the\x20promised\x20refund\x20rail.','suggestion':'Declare\x20a\x20refund\x20row\x20in\x20allocator.rows\x20(recipient\x20guard_identifier,\x20recipient_key\x20\x270\x27,\x20mode\x20rate,\x20value\x2010000)\x20so\x20the\x20order-anchored\x20full-refund\x20rail\x20rides\x20with\x20the\x20plan.'});if(!e)b['push']({'rule_id':'R-PLAN-03','severity':'high','title':'No\x20refund\x20track\x20declared\x20—\x20returns/refunds\x20have\x20no\x20funded\x20path\x20in\x20the\x20money\x20plan','detail':'The\x20template\x27s\x20allocator\x20declares\x20no\x20refund\x20track\x20—\x20returns/refunds\x20have\x20no\x20funded\x20path\x20in\x20the\x20money\x20plan.','suggestion':'Add\x20the\x20second\x20Allocator\x20(Rate\x2010000\x20to\x20the\x20buyer)\x20bound\x20to\x20the\x20refund\x20Guard,\x20or\x20confirm\x20with\x20the\x20merchant\x20that\x20refunds\x20are\x20out\x20of\x20scope.'});else!a['allocator']['refund_track']&&b['push']({'rule_id':'R-PLAN-04','severity':'medium','title':'Refund\x20intent\x20declared\x20in\x20prose\x20only\x20—\x20the\x20refund\x20recipient\x20is\x20not\x20order-anchored','detail':'A\x20refund\x20track\x20is\x20declared\x20but\x20not\x20order-anchored,\x20so\x20the\x20refund\x20recipient\x20is\x20resolved\x20from\x20the\x20signer/Entity\x20rather\x20than\x20the\x20paying\x20Order.','suggestion':'Gate\x20the\x20refund\x20track\x20with\x20AND[signer\x20==\x20order.owner,\x20progress.node\x20==\x20X]\x20or\x20move\x20it\x20to\x20an\x20order-anchored\x20GuardIdentifier(0)\x20recipient.'});if(c['length']===0x0){a['allocator']['mode']!=='rate'&&b['push']({'rule_id':'R-PLAN-05','severity':'critical','title':'Allocator\x20mode\x20is\x20not\x20expressible\x20as\x20a\x20percentage\x20split','detail':'Template\x20allocator\x20mode\x20is\x20\x27'+a['allocator']['mode']+'\x27,\x20which\x20a\x20percentage\x20pair\x20cannot\x20represent\x20—\x20'+'no\x20percentage\x20hint\x20can\x20be\x20emitted\x20for\x20it.','suggestion':'Declare\x20allocator.rows\x20in\x20the\x20template\x20(per-row\x20amount\x20/\x20rate\x20/\x20surplus);\x20the\x20pipeline\x20will\x20then\x20carry\x20the\x20real\x20split\x20instead\x20of\x20a\x20hint.'});if(a['allocator']['mode']==='rate'){const h=platformShareBps(a['fee_params']),j=h!==undefined&&h>0x0?0x2:0x0;a['allocator']['count']!==0x0&&a['allocator']['count']!==0x2&&b['push']({'rule_id':'R-PLAN-06','severity':'critical','title':'Declared\x20sharing\x20row\x20count\x20can\x20never\x20match\x20the\x20generated\x20percentage\x20hint','detail':'Template\x20declares\x20'+a['allocator']['count']+'\x20sharing\x20row(s)\x20but\x20the\x20generated\x20percentage\x20hint\x20can\x20'+('only\x20ever\x20carry\x20'+j+'\x20row(s)\x20(platform\x20take\x20'+(h??'none')+'\x20bps).'),'suggestion':'Build\x20the\x20Allocation\x20with\x20the\x20template\x27s\x20own\x20row\x20set\x20(order_allocators\x20is\x20L1\x20—\x20frozen\x20at\x20Service\x20publish),\x20or\x20declare\x20allocator.rows\x20in\x20the\x20template.'});}}const g=Object['keys'](a['fee_params'])['filter'](l=>/_(?:days|hours)$/['test'](l));return g['length']>0x0&&!a['time_anchors']&&b['push']({'rule_id':'R-PLAN-07','severity':'medium','title':'Business\x20windows\x20declared\x20without\x20time\x20anchors\x20—\x20release/timeout\x20steps\x20stay\x20unbuildable','detail':'fee_params\x20declares\x20business\x20windows\x20('+g['join'](',\x20')+')\x20but\x20the\x20template\x20declares\x20no\x20time_anchors.','suggestion':'Add\x20time_anchors\x20(or\x20name\x20the\x20window\x20in\x20the\x20Guard\x20set)\x20so\x20the\x20plan\x20emits\x20the\x20release/timeout\x20build\x20steps.'}),b;}const TASK_BINDING_SLOT=0xfe;function declaresAddressSubmissionSlot(a,b){const c=a;return c['identifier']===b&&c['b_submission']===!![]&&c['value_type']==='Address';}function tplSpecByKey(a,b){const c=a['guards']['find'](e=>e['key']===b);if(!c||!c['template_id']['startsWith']('tpl_'))return undefined;const d=GUARD_TEMPLATES['find'](e=>e['id']===c['template_id']);return d?{'templateId':d['id'],'exampleTable':d['example_table']}:undefined;}function taskBindingChecks(a){const b=[],c=new Set();for(const d of a['machine_shape']){for(const f of d['from']??[]){typeof f==='object'&&f!==null&&typeof f['guard_key']==='string'&&c['add'](f['guard_key']);}}for(const g of c){const h=tplSpecByKey(a,g);if(!h)continue;!h['exampleTable']['some'](j=>declaresAddressSubmissionSlot(j,TASK_BINDING_SLOT))&&b['push']({'rule_id':'TASKBIND-01','severity':'critical','title':'Guard\x20template\x20'+h['templateId']+'\x20(edge\x20key\x20\x27'+g+'\x27)\x20lacks\x20the\x20protocol\x20task-binding\x20slot\x20(254)','detail':'Every\x20guarded\x20forward\x20of\x20a\x20machine\x20running\x20on\x20an\x20order\x20Progress\x20requires\x20a\x20slot-254\x20passport\x20submission;\x20the\x20guard\x20table\x20declares\x20none,\x20so\x20the\x20forward\x20aborts\x20(code\x2011)\x20on\x20first\x20order\x20traversal.\x20Tables\x20and\x20machines\x20freeze\x20at\x20publish\x20—\x20shipping\x20now\x20strands\x20the\x20path\x20permanently.','suggestion':'Declare\x20{\x20identifier:\x20254,\x20b_submission:\x20true,\x20value_type:\x20\x27Address\x27\x20}\x20in\x20'+h['templateId']+'.example_table\x20(protocol\x20slot\x20254;\x20the\x20order\x20address\x20is\x20written\x20by\x20order\x20creation).'});}return b;}function allocLegSlotChecks(a){const b=[];for(const c of a['allocator']?.['rows']??[]){if(c['recipient']!=='guard_identifier'||!c['guard_key'])continue;const d=Number(c['recipient_key']??0x0);if(!Number['isInteger'](d)||d<0x0)continue;const e=tplSpecByKey(a,c['guard_key']);if(!e)continue;const f=e['exampleTable']['some'](h=>declaresAddressSubmissionSlot(h,d));if(f)continue;const g=e['exampleTable']['some'](h=>{const j=h;return j['identifier']===d&&j['value_type']==='Address';});b['push']({'rule_id':'TASKBIND-02','severity':'critical','title':g?'Guard\x20template\x20'+e['templateId']+'\x20slot\x20'+d+'\x20is\x20a\x20STATIC\x20Address\x20—\x20allocator\x20leg\x20\x27'+c['guard_key']+'\x27\x20needs\x20a\x20b_submission\x20declaration':'Guard\x20template\x20'+e['templateId']+'\x20never\x20declares\x20slot\x20'+d+'\x20—\x20allocator\x20leg\x20\x27'+c['guard_key']+'\x27\x20will\x20strand\x20escrow','detail':g?'A\x20static\x20Address\x20slot\x20passes\x20creation\x20but\x20fails\x20the\x20allocation\x20assertion\x20(passport\x20submission\x20==\x20payment_info.for_object):\x20the\x20distribution\x20aborts\x20and\x20escrowed\x20funds\x20stay\x20stranded,\x20because\x20the\x20table\x20froze\x20at\x20creation\x20and\x20cannot\x20gain\x20the\x20declaration\x20later\x20(N-11).':'The\x20allocation\x20assert\x20reads\x20a\x20passport\x20submission\x20at\x20this\x20slot;\x20with\x20no\x20declaration\x20the\x20assert\x20fails\x20and\x20the\x20distribution\x20aborts\x20with\x20funds\x20already\x20escrowed.','suggestion':'Declare\x20{\x20identifier:\x20'+d+',\x20b_submission:\x20true,\x20value_type:\x20\x27Address\x27,\x20object_type:\x20\x27Order\x27\x20}\x20in\x20'+e['templateId']+'.example_table\x20so\x20the\x20passing\x20order\x20address\x20is\x20captured.'});}return b;}export function isSplitFamilyFeeParam(a){return/(?:platform|commission|service_fee)[a-z_]*_bps$/['test'](a)||/^attributed_.*_bps$/['test'](a);}function isLandingRequired(a,b){return typeof a['fee_params'][b]==='number';}function feeParamLandingRegex(a){return new RegExp('\x5cb'+a['replace'](/[.*+?^${}()|[\]\\]/g,'\x5c$&')+'\x5cb');}function directiveLanding(a,b){const c=[['build_notes',a['build_notes']],['user_inputs',a['user_inputs']],['allocator.description',[a['allocator']['description']]],['trust_mechanisms',a['trust_mechanisms']],['machine_shape',a['machine_shape']['map'](d=>d['name']+'\x20'+d['role'])]];for(const [d,e]of c){const f=e['find'](g=>b['test'](g));if(f!==undefined)return{'surface':'directive','site':d,'excerpt':f};}return undefined;}export function collectFeeParamLandings(a){const b=new Map();for(const c of Object['keys'](a['fee_params']??{})){const d=[],e=feeParamLandingRegex(c);for(const f of a['guards']){if(e['test'](f['purpose']))d['push']({'surface':'guard','site':f['key']??f['template_id'],'excerpt':f['purpose']});}for(const h of a['allocator']['rows']??[]){const j=h['note']??'';if(e['test'](j)||h['value_from']===c){const k=h['recipient_key'];d['push']({'surface':'allocator_row','site':h['track']+'/'+(k??h['recipient']),'excerpt':j||'value_from:\x20'+String(h['value_from']),'recipient_blank':k===undefined||String(k)['trim']()===''});}}for(const [l,m]of Object['entries'](a['time_anchors']??{})){if(e['test'](m))d['push']({'surface':'time_anchor','site':l,'excerpt':m});}if(d['length']===0x0){const n=directiveLanding(a,e);if(n)d['push'](n);}b['set'](c,d);}return b;}export function buildFeeParamLandingTable(a,b){const c=collectFeeParamLandings(a);return Object['entries'](b)['map'](([d,e])=>({'param':d,'value':e,'split_family':isSplitFamilyFeeParam(d),'landings':c['get'](d)??[]}));}function feeParamLandingChecks(a){const b=[];for(const [c,d]of collectFeeParamLandings(a)){if(d['length']>0x0||isSplitFamilyFeeParam(c)||!isLandingRequired(a,c))continue;b['push']({'rule_id':'R-FEEPARAM-LANDING','severity':'medium','title':'fee_param\x20\x27'+c+'\x27\x20is\x20declared\x20but\x20lands\x20nowhere','detail':'template_generate\x20will\x20print\x20'+c+'='+String(a['fee_params'][c])+',\x20but\x20no\x20guard\x20purpose,\x20allocator\x20row\x20note\x20or\x20time\x20anchor\x20names\x20it\x20—\x20the\x20value\x20has\x20no\x20chain\x20landing,\x20so\x20whoever\x20materializes\x20the\x20template\x20hand-fills\x20the\x20constant\x20and\x20the\x20two\x20drift\x20(the\x20measured\x205-minute\x20/\x2030-day\x20window\x20mismatch\x20class).\x20Dead\x20parameters\x20also\x20mislead\x20the\x20migration\x20questionnaire,\x20which\x20presents\x20them\x20as\x20tunable.','suggestion':'Name\x20\x27'+c+'\x27\x20verbatim\x20at\x20its\x20landing\x20rung\x20—\x20the\x20purpose\x20of\x20the\x20guard\x20that\x20compiles\x20it\x20into\x20a\x20constant\x20(strongest),\x20an\x20allocator\x20row\x20note,\x20a\x20time\x20anchor,\x20or\x20at\x20minimum\x20its\x20directive\x20entry\x20(build_notes\x20/\x20user_inputs).\x20E.g.\x20\x27window\x20=\x20'+c+'\x27.\x20If\x20the\x20parameter\x20has\x20no\x20consumer\x20at\x20all,\x20delete\x20it\x20from\x20fee_params.'});}return b;}export function scanTemplate(a){const b=[...staticChecks(a),...guardRefChecks(a),...buyKeyDeclarationChecks(a),...taskBindingChecks(a),...allocLegSlotChecks(a),...fundAnchorChecks(a),...periodicReleaseChecks(a),...timeWindowAnchorChecks(a),...signerRefundChecks(a),...orderAnchorDeclarationChecks(a),...topologyChecks(a),...reachabilityChecks(a),...deadEndLockChecks(a),...reviewNoRaceChecks(a),...afterSalesRailChecks(a),...acceptanceModeChecks(a),...installmentModeChecks(a),...affiliateModeChecks(a),...crowdfundingModeChecks(a),...rewardReplayChecks(a),...rewardZeroOrderChecks(a),...rewardFundedChecks(a),...rewardRatingKeyChecks(a),...loopFundChecks(a),...terminalRailCoverageChecks(a),...railNodeDriftChecks(a),...siblingForwardExclusivityChecks(a),...compoundPayoutChecks(a),...surplusTrackChecks(a),...amountDeadlockChecks(a),...discountRailScaleChecks(a),...cancelCoverageChecks(a),...redundGuardObjectMismatchChecks(a),...zeroAmountGuardChecks(a),...serialClaimWindowChecks(a),...dismissEdgeGuardChecks(a),...noteNodeDriftChecks(a),...onewayDisputeChecks(a),...noEscrowExitChecks(a),...pairingProseOnlyChecks(a),...railUnboundChecks(a),...counterpartyFundEvidenceChecks(a),...disclosureEnforceabilityChecks(a),...allocReplayChecks(a),...draftVoidChecks(a),...requiredInfoGateChecks(a),...planReadinessChecks(a),...feeParamLandingChecks(a)];for(const e of analyzerFindings(a)){const g=e['severity']==='info'?'low':e['severity'];b['push']({'rule_id':e['ruleId'],'severity':g,'title':e['title'],'detail':e['detail'],'suggestion':e['suggestion']});}b['sort']((h,j)=>SEVERITY_ORDER[j['severity']]-SEVERITY_ORDER[h['severity']]);const c=b['length']>0x0?b[0x0]['severity']:'low',d=b['filter'](h=>h['severity']==='critical')['map'](h=>''+(h['rule_id']?h['rule_id']+':\x20':'')+h['title']);return{'template_id':a['id'],'risk_level':c,'passed':d['length']===0x0,'findings':b,'red_flags':d};}
|