@wowok/agent-mcp 3.3.7 → 3.3.9
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/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/communication/message-cursors.d.ts +35 -0
- package/dist/communication/message-cursors.js +1 -0
- package/dist/communication/wts-attestation.d.ts +5 -0
- package/dist/communication/wts-attestation.js +1 -1
- package/dist/composition/audit.js +1 -1
- package/dist/composition/compile.d.ts +2 -2
- package/dist/composition/compile.js +1 -1
- package/dist/composition/inflight.d.ts +7 -0
- package/dist/composition/inflight.js +1 -1
- package/dist/composition/materialize.d.ts +4 -1
- package/dist/composition/materialize.js +1 -1
- package/dist/config/index.d.ts +1 -0
- package/dist/config/index.js +1 -1
- package/dist/config/store-policy.d.ts +14 -0
- package/dist/config/store-policy.js +1 -0
- package/dist/config/store-policy.spec.d.ts +1 -0
- package/dist/config/store-policy.spec.js +1 -0
- package/dist/customer/industry-risks.js +1 -1
- package/dist/customer/user-preferences.js +1 -1
- package/dist/evaluation/builtins/graph-service.spec.js +1 -1
- package/dist/evaluation/engine.js +1 -1
- package/dist/experience/realtime-feedback.js +1 -1
- package/dist/extensions/business-modules.d.ts +1 -1
- package/dist/extensions/business-modules.js +1 -1
- package/dist/extensions/industry-pack.js +1 -1
- package/dist/extensions/modes.js +1 -1
- package/dist/graph/onchain/analyze.js +1 -1
- package/dist/graph/onchain/expand.js +1 -1
- package/dist/graph/onchain/exposure.js +1 -1
- package/dist/graph/onchain/facts.d.ts +1 -0
- package/dist/graph/onchain/facts.js +1 -1
- package/dist/graph/onchain/facts.spec.js +1 -1
- package/dist/harness/recover.js +1 -1
- package/dist/knowledge/acquisition-flywheel.js +1 -1
- package/dist/knowledge/allocation-ledger.d.ts +1 -0
- package/dist/knowledge/allocation-ledger.js +1 -1
- package/dist/knowledge/allocator-rail-verifier.d.ts +6 -2
- package/dist/knowledge/allocator-rail-verifier.js +1 -1
- package/dist/knowledge/arbitration-ledger.js +1 -1
- package/dist/knowledge/audit-rules.d.ts +37 -0
- package/dist/knowledge/audit-rules.js +1 -1
- package/dist/knowledge/baselines/rules/plan.json +32 -2
- package/dist/knowledge/builtin-templates.d.ts +13 -1
- package/dist/knowledge/builtin-templates.js +1 -1
- package/dist/knowledge/commission-landing.d.ts +26 -0
- package/dist/knowledge/commission-landing.js +1 -0
- package/dist/knowledge/discount-threshold.js +1 -1
- package/dist/knowledge/fund-layer.d.ts +7 -0
- package/dist/knowledge/fund-layer.js +1 -1
- package/dist/knowledge/getting-started.js +1 -1
- package/dist/knowledge/guard-design-patterns.d.ts +1 -1
- package/dist/knowledge/guard-design-patterns.js +1 -1
- package/dist/knowledge/guard-puzzle.js +1 -1
- package/dist/knowledge/guard-render.d.ts +7 -0
- package/dist/knowledge/guard-render.js +1 -1
- package/dist/knowledge/guard-risk.js +1 -1
- package/dist/knowledge/guard-templates.d.ts +1 -1
- package/dist/knowledge/guard-templates.js +1 -1
- package/dist/knowledge/guard-translation.js +1 -1
- package/dist/knowledge/index.js +1 -1
- package/dist/knowledge/industry-generalizer.js +1 -1
- package/dist/knowledge/industry-registry.d.ts +1 -1
- package/dist/knowledge/industry-registry.js +1 -1
- package/dist/knowledge/industry-strategy.js +1 -1
- package/dist/knowledge/jsonrpc-enum.js +1 -1
- package/dist/knowledge/machine-fork-watch.d.ts +9 -0
- package/dist/knowledge/machine-fork-watch.js +1 -0
- package/dist/knowledge/migration-preflight.js +1 -1
- package/dist/knowledge/projection.spec.js +1 -1
- package/dist/knowledge/scenario-modes.d.ts +8 -2
- package/dist/knowledge/scenario-modes.js +1 -1
- package/dist/knowledge/semantic-ir.d.ts +24 -5
- package/dist/knowledge/semantic-ir.js +1 -1
- package/dist/knowledge/service-ledger.js +1 -1
- package/dist/knowledge/strategy-manuals.js +1 -1
- package/dist/knowledge/template-index.js +1 -1
- package/dist/knowledge/template-loader.d.ts +11 -0
- package/dist/knowledge/template-loader.js +1 -1
- package/dist/knowledge/template-registry.js +1 -1
- package/dist/knowledge/template-scanner.d.ts +4 -2
- package/dist/knowledge/template-scanner.js +1 -1
- package/dist/knowledge/template-validation.js +1 -1
- package/dist/knowledge/tools-reference.js +1 -1
- package/dist/monitor/MonitorLoop.js +1 -1
- package/dist/playbooks/service-build/business-puzzle.js +1 -1
- package/dist/playbooks/service-build/machine-panorama.js +1 -1
- package/dist/playbooks/service-build/merchant-guide.d.ts +12 -6
- package/dist/playbooks/service-build/merchant-guide.js +1 -1
- package/dist/playbooks/service-build/migration-planner.d.ts +10 -2
- package/dist/playbooks/service-build/migration-planner.js +1 -1
- package/dist/playbooks/service-build/mode-actions.d.ts +1 -0
- package/dist/playbooks/service-build/mode-actions.js +1 -1
- package/dist/playbooks/service-build/object-panorama.js +1 -1
- package/dist/playbooks/service-build/participation-radar.js +1 -1
- package/dist/playbooks/service-build/relationship-profile.js +1 -1
- package/dist/playbooks/service-build/service-panorama.js +1 -1
- package/dist/playbooks/service-build/service-quote.js +1 -1
- package/dist/playbooks/service-build/service-quote.spec.js +1 -1
- package/dist/review/index.js +1 -1
- package/dist/safety/confirm-gate.js +1 -1
- package/dist/schema/benchmark-migration/index.d.ts +72 -1
- package/dist/schema/benchmark-migration/index.js +1 -1
- package/dist/schema/call/allocation.d.ts +3 -0
- package/dist/schema/call/allocation.js +1 -1
- package/dist/schema/call/base.d.ts +24 -0
- package/dist/schema/call/bridge.d.ts +6 -0
- package/dist/schema/call/error-codes.d.ts +1 -1
- package/dist/schema/call/error-codes.js +1 -1
- package/dist/schema/call/order.js +1 -1
- package/dist/schema/call/semantic.js +1 -1
- package/dist/schema/call/service.js +1 -1
- package/dist/schema/common/index.js +1 -1
- package/dist/schema/config/index.d.ts +24 -0
- package/dist/schema/config/index.js +1 -1
- package/dist/schema/goal/index.d.ts +14 -0
- package/dist/schema/goal/planning.d.ts +26 -0
- package/dist/schema/goal/planning.js +1 -1
- package/dist/schema/industry-pack/index.d.ts +9 -1
- package/dist/schema/industry-pack/modes.d.ts +9 -1
- package/dist/schema/industry-pack/modes.js +1 -1
- package/dist/schema/local/index.d.ts +60 -0
- package/dist/schema/local/index.js +1 -1
- package/dist/schema/messenger/index.d.ts +278 -1
- package/dist/schema/messenger/index.js +1 -1
- package/dist/schema/operations.d.ts +1 -0
- package/dist/schema/query/bi.d.ts +38 -0
- package/dist/schema/query/bi.js +1 -1
- package/dist/schema/query/index.d.ts +3 -0
- package/dist/schema/query/index.js +1 -1
- package/dist/schema/schema-version.js +1 -1
- package/dist/schema/service-clone/index.d.ts +17 -0
- package/dist/schema/service-clone/index.js +1 -1
- package/dist/schema-query-impl/index.js +1 -1
- package/dist/schemas/account_operation.output.json +6 -0
- package/dist/schemas/benchmark_migration_operation.output.json +254 -2
- package/dist/schemas/benchmark_migration_operation.schema.json +87 -5
- package/dist/schemas/bridge_operation.output.json +6 -0
- package/dist/schemas/config_operation.output.json +95 -0
- package/dist/schemas/config_operation.schema.json +16 -1
- package/dist/schemas/goal_operation.schema.json +22 -0
- package/dist/schemas/index.json +1 -1
- package/dist/schemas/industry_pack_operation.output.json +4 -0
- package/dist/schemas/industry_pack_operation.schema.json +40 -3
- package/dist/schemas/local_cache_operation.output.json +6 -0
- package/dist/schemas/local_history_operation.output.json +6 -0
- package/dist/schemas/local_info_operation.output.json +6 -0
- package/dist/schemas/local_mark_operation.output.json +6 -0
- package/dist/schemas/messenger_operation.output.json +609 -1
- package/dist/schemas/messenger_operation.schema.json +96 -1
- package/dist/schemas/onchain_operations.output.json +6 -0
- package/dist/schemas/onchain_operations.schema.json +334 -7
- package/dist/schemas/onchain_operations_allocation.schema.json +10 -1
- package/dist/schemas/onchain_operations_guard.schema.json +318 -0
- package/dist/schemas/onchain_operations_order.schema.json +1 -1
- package/dist/schemas/onchain_operations_service.schema.json +5 -5
- package/dist/schemas/query_toolkit.output.json +271 -8
- package/dist/schemas/service_clone_operation.output.json +79 -0
- package/dist/tools/handlers/benchmark-migration.d.ts +14 -0
- package/dist/tools/handlers/benchmark-migration.js +1 -1
- package/dist/tools/handlers/config.js +1 -1
- package/dist/tools/handlers/messenger.js +1 -1
- package/dist/tools/handlers/onchain.d.ts +19 -1
- package/dist/tools/handlers/onchain.js +1 -1
- package/dist/tools/handlers/query.d.ts +1 -0
- package/dist/tools/handlers/query.js +1 -1
- package/dist/tools/handlers/service-clone.d.ts +18 -0
- package/dist/tools/handlers/service-clone.js +1 -1
- package/dist/tools/registry/business.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{TASK_BINDING_SLOT,ONCE_SLOT_BYTES}from'./onchain-constants.js';import{GUARD_DESIGN_PATTERNS}from'./guard-design-patterns.js';import{unannotatedBuyerActionNodes}from'./scenario-modes.js';import{findLoopCycles}from'./machine-topology.js';import{TWO_TX_RENEW_RECIPE}from'./protocol-facts.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';import{canonicalizeMachineProse,machineProseFields,machineProseFindings,proseClaim}from'./template-prose.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'](B=>PLATFORM_TAKE_KEY['test'](B)&&typeof c[B]==='number'&&c[B]!==0x0);d['length']>0x0&&b['push']({'rule_id':'R-ECON-01','severity':'critical','title':'Template\x20mandates\x20a\x20platform\x20commission\x20('+d['map'](B=>B+'='+c[B])['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=e['split'](/[.;]/)['filter'](B=>!/\b(?:never|no|not|don'?t|cannot|must not|avoid|prohibit\w*|forbid\w*|instead of|rather than|previously)\b/i['test'](B))['join']('\x20.\x20'),g=/(?:commission|take|platform|remainder|share)\s*(?:=|:)\s*order\s*total\s*-\s*(?:segment|sum)/i['test'](f),h=(a['allocator']['rows']??[])['some'](B=>B['mode']==='surplus')||a['allocator']['mode']==='surplus',j=h&&/(?:platform|commission|fee|take)[^.;]{0,120}\bsurplus\b|\bsurplus\b[^.;]{0,120}(?:platform|commission|fee|take)/i['test'](f);g&&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.'});j&&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 k=/\{\s*(?:who|Entity|Signer|GuardIdentifier)\s*:/['test'](e)||/recipient\s*[:=]/i['test'](e),l=/^(?:merchant_service_fee_bps|digital_product_fee_bps|logistics_rate_bps|service_fee_rate_bps)$/,m=Object['keys'](c)['some'](B=>l['test'](B)&&typeof c[B]==='number'&&c[B]!==0x0);if(m&&!k&&d['length']===0x0){const B=collectFeeParamLandings(a),C=Object['keys'](c)['filter'](F=>l['test'](F)&&typeof c[F]==='number'&&c[F]!==0x0),D=C['some'](F=>(B['get'](F)??[])['some'](G=>G['surface']==='guard'||G['surface']==='allocator_row'&&G['recipient_blank']!==!![])),E=!D&&C['some'](F=>(B['get'](F)??[])['some'](G=>G['surface']==='directive'));!D?b['push']({'rule_id':'R-ECON-03','severity':'high','title':E?'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':E?'fee_params\x20carry\x20fee-shaped\x20keys\x20('+C['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('+C['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 n=/(?:layer-?1|service-?level|pool)[^.]*settles? the full amount|full amount to the (?:platform|organizer) pool/i['test'](e);n&&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 o=Object['keys'](c)['find'](F=>/^attributed_.*_bps$/['test'](F)&&typeof c[F]==='number'),p=Object['keys'](c)['find'](F=>/^(?:base_)?commission_rate_bps$/['test'](F)&&typeof c[F]==='number');o&&p&&c[o]>c[p]&&b['push']({'rule_id':'R-ECON-05','severity':'medium','title':'Attribution-priced\x20take:\x20a\x20cheaper\x20acquisition\x20channel\x20is\x20charged\x20MORE','detail':o+'='+c[o]+'\x20exceeds\x20'+p+'='+c[p]+'.\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 F=Object['keys'](c)['filter'](I=>MERCHANT_SHARE_KEY['test'](I)&&typeof c[I]==='number'),G=Object['keys'](c)['filter'](I=>PLATFORM_TAKE_KEY['test'](I)&&typeof c[I]==='number'),H=[...F,...G];if(F['length']>0x0&&G['length']>0x0){const I=H['map'](L=>c[L])['filter'](L=>typeof L==='number'),J=I['reduce']((L,M)=>L+M,0x0),K=/surplus/i['test'](e);J!==0x2710&&!K&&b['push']({'rule_id':'R-ECON-06','severity':'critical','title':'Rate\x20shares\x20sum\x20to\x20'+J+',\x20not\x2010000','detail':'Declared\x20rate\x20shares\x20('+H['map']((L,M)=>L+'='+I[M])['join']('\x20+\x20')+')\x20total\x20'+J+'.\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 q=(a['allocator']['rows']??[])['map']((L,M)=>({'r':L,'i':M})),s=q['filter'](({r:L})=>L['recipient']==='entity'&&!(L['recipient_key']??'')['trim']());s['length']>0x0&&b['push']({'rule_id':ENTITY_RECIPIENT_RULE_ID,'severity':'critical','title':'Allocator\x20row(s)\x20'+s['map'](({i:L})=>'#'+L)['join'](',\x20')+'\x20name\x20no\x20Entity\x20recipient\x20—\x20the\x20share\x20silently\x20pays\x20the\x20deploying\x20merchant','detail':s['map'](({i:L})=>'rows['+L+']')['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\x20full-share\x20row\x20to\x20the\x20merchant\x27s\x20own\x20account\x20({\x20who:\x20{\x20Signer:\x20\x22signer\x22\x20}\x20}\x20when\x20'+'the\x20merchant\x20is\x20always\x20the\x20triggering\x20party,\x20or\x20an\x20explicit\x20Entity\x20row).\x20A\x20{\x20who:\x20{\x20GuardIdentifier:\x200\x20}\x20}\x20leg\x20pays\x20the\x20order\x20anchor,\x20not\x20the\x20'+'merchant\x20—\x20reserve\x20it\x20for\x20refunds\x20(see\x20the\x20order-anchored\x20refund\x20convention).\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\x20row\x20naming\x20the\x20merchant\x27s\x20own\x20account\x20'+'({\x20recipient:\x20\x27entity\x27,\x20recipient_key:\x20\x27<merchant>\x27\x20}\x20or\x20{\x20recipient:\x20\x27signer\x27\x20}\x20when\x20the\x20merchant\x20is\x20always\x20the\x20triggering\x20party);\x20a\x20'+'{\x20recipient:\x20\x27guard_identifier\x27\x20}\x20row\x20pays\x20the\x20order\x20anchor\x20(refund\x20semantics),\x20not\x20the\x20merchant.'});const w=q['filter'](({r:L})=>L['recipient']==='entity'&&/^0x0*$/i['test']((L['recipient_key']??'')['trim']()));w['length']>0x0&&b['push']({'rule_id':ENTITY_RECIPIENT_RULE_ID,'severity':'high','title':'Allocator\x20row(s)\x20'+w['map'](({i:L})=>'#'+L)['join'](',\x20')+'\x20name\x20the\x20zero\x20address\x20as\x20Entity\x20recipient','detail':w['map'](({i:L})=>'rows['+L+']')['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 x=L=>L['recipient']+':'+(L['recipient_key']??'')['trim']()['toLowerCase'](),y=/^(recover_gate|awarded_recover|terminal_settlement_recover)$/,z=new Set((a['allocator']['rows']??[])['filter'](L=>L['mode']==='rate'&&!y['test'](L['guard_key']??''))['map'](x)),A=q['filter'](({r:L})=>L['mode']==='surplus'&&z['has'](x(L)));return A['length']>0x0&&b['push']({'rule_id':'R-RECIPIENT-04','severity':'critical','title':'Surplus\x20row(s)\x20'+A['map'](({i:L})=>'#'+L)['join'](',\x20')+'\x20pay\x20a\x20recipient\x20a\x20Rate\x20leg\x20already\x20pays\x20—\x20the\x20remainder\x20swallows\x20an\x20undeclared\x20share','detail':A['map'](({i:L})=>'rows['+L+']')['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{if(l){const m=/record[ -]waypoint|accepted-node set|money never moves/i['test'](j['role']??'');!m&&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 n of a['guards']){if(/time_lock|order_holder|progress_state/['test'](n['template_id'])&&!/order\.service|project bind|service binding/i['test'](n['purpose'])){const o=d['get'](n['template_id'])??[];o['push'](n['key']??'(no\x20key)'),d['set'](n['template_id'],o);}}for(const [p,q]of d){b['push']({'rule_id':'R-C3-05','severity':'low','title':'Guard\x20\x27'+p+'\x27\x20consumes\x20a\x20submitted\x20Order\x20without\x20project\x20binding\x20('+q['length']+'x:\x20'+q['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'](s=>/refund|cancel/i['test'](s['template_id'])||/refund|cancel/i['test'](s['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'](s=>s['host']==='arbitration')||a['trust_mechanisms']['some'](s=>s['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'](s=>'\x27'+s+'\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']===TASK_BINDING_SLOT||p?.['identifier']===ONCE_SLOT_BYTES);}),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-OBJECT\x20for\x20settlement/claim\x20rails,\x20255\x20byte-keyed\x20for\x20per-period\x20repeats)\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\x20SETTLEMENT\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\x20SETTLEMENT\x20allocator\x20Guard\x20(never\x20a\x20refund\x20rail\x20—\x20a\x20refund\x20pays\x20the\x20Order\x20through\x20user\x20slot\x200\x20and\x20a\x20later\x20re-entry\x20would\x20abort\x2016,\x20OFN\x20#P-04)\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'+'The\x20order\x20items\x20vector\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:117)\x20is\x20overwritten\x20on\x20every\x20forward\x20'+'(progress.move:497)\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'](k=>k['recipient']==='signer'&&k['track']==='refund'),e=templateText(a),f=/Recipient::Signer[^;]{0,200}(?:tx_context::sender|tx[_ ]sender|signer-binding|pins? that claim|identity-bound)/i['test'](e),g=a['allocator']['recipient']==='signer'&&!f;if(!d&&!g)return b;const h=/refund|chargeback|repay|(?:pay(?:ment|out)?|release|send|transfer|settle)\w*[^.\n]{0,40}to the (?:buyer|order|customer)/i['test'](e);if(!h)return b;const j=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('+j+')','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:614-616)\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 w of s['from']??[]){const x=typeof w==='string'?w:w?.['prev'];if(x==='')f['push'](s['name']);else{if(!d['has'](x))d['set'](x,[]);d['get'](x)['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'](y=>'\x27'+y+'\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 y=j['pop']();for(const z of d['get'](y)??[]){!h['has'](z)&&(h['add'](z),j['push'](z));}}const k=b['filter'](A=>!h['has'](A['name']))['map'](A=>'\x27'+A['name']+'\x27');k['length']>0x0&&g['push']('unreachable\x20from\x20the\x20entry\x20(declared\x20but\x20dead):\x20'+k['join'](',\x20'));const l=A=>A['semantic_role']==='final'||A['semantic_role']==='cancelled',n=new Map();for(const [A,B]of d){for(const C of B){if(!n['has'](C))n['set'](C,[]);n['get'](C)['push'](A);}}const o=new Set(),p=b['filter'](l)['map'](D=>D['name']);p['forEach'](D=>o['add'](D));while(p['length']>0x0){const D=p['pop']();for(const E of n['get'](D)??[]){!o['has'](E)&&(o['add'](E),p['push'](E));}}const q=b['filter'](F=>!l(F)&&!o['has'](F['name'])&&(d['get'](F['name'])??[])['length']>0x0)['map'](F=>{const G='exits\x20lead\x20only\x20to\x20'+[...new Set(d['get'](F['name'])??[])]['map'](H=>'\x27'+H+'\x27')['join'](',\x20')+',\x20none\x20of\x20which\x20reaches\x20a\x20settlement\x20or\x20refund\x20endpoint';return'\x27'+F['name']+'\x27\x20('+(F['semantic_role']??'no\x20semantic_role')+')\x20—\x20'+G;});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 w of s['from']??[]){const x=typeof w==='string'?w:w?.['prev'];if(typeof x!=='string'||x==='')continue;if(!c['has'](x))c['set'](x,[]);c['get'](x)['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'](y=>classifyLoopCycle(y['cycle'],g)==='remedy');h['length']>0x0&&f['push']({'rule_id':'R-LOOP-FUND','severity':'low','title':'Remedy\x20loop\x20cycle(s)\x20'+h['map'](y=>'['+y['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'](y=>classifyLoopCycle(y['cycle'],g)==='renewal'),n=k?[]:l,o=d['filter'](y=>classifyLoopCycle(y['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'](y=>'['+y['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'](y=>'['+y['cycle']['join']('\x20->\x20')+']')['join'](',\x20')+':\x20declare\x20the\x20'+'order_renew\x20re-fund\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\x20(fund\x20+\x20record\x20+\x20'+'advance,\x20no\x20unfunded-advance\x20window);\x20NEVER\x20bind\x20an\x20allocation.balance\x20gate\x20on\x20this\x20forward\x20—\x20guards\x20read\x20the\x20COMMITTED\x20pre-transaction\x20balance,\x20so\x20the\x20same-PTB\x20payment\x20is\x20invisible\x20to\x20them\x20(esound-mn-261021\x20B-1)\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 w=s['find'](C=>d(C['name']+'\x20'+C['role'])),x=s['find'](C=>C['name']!==w?.['name']&&f(C['name']+'\x20'+C['role'])),y=s['find'](C=>g(C['name']+'\x20'+C['role'])),z=s['find'](C=>C['name']!==y?.['name']&&h(C['name']+'\x20'+C['role'])),A=w??y,B=w!==undefined&&x!==undefined?x:y!==undefined&&z!==undefined?z:undefined;if(A===undefined||B===undefined)continue;c['push']({'rule_id':'R-REVIEW-NORACE','severity':'high','title':'Node\x20\x27'+q+'\x27\x20fans\x20out\x20\x27'+A['name']+'\x27\x20and\x20its\x20complement\x20\x27'+B['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;}export function afterSalesRailRegex(a){return a==='return'?/return|refund/i:a==='exchange'?/exchange|replace|reship|swap/i:/warranty|repair|claim/i;}export function afterSalesRailNodeMatches(a,b){if(!afterSalesRailRegex(a)['test'](b))return![];return!/missed|withdraw|pre_deadline|goal/i['test'](b);}function afterSalesRailChecks(a){const b=a['after_sales_mode'];if(b===undefined||b==='none')return[];const c=a['machine_shape'],d=afterSalesRailRegex(b);if(c['some'](e=>afterSalesRailNodeMatches(b,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).\x20PRE-STATE\x20CONSTRAINT\x20(esound-mn-261021\x20B-1,\x20mainnet-verified):\x20'+'the\x20gate\x20reads\x20the\x20COMMITTED\x20pre-transaction\x20balance\x20—\x20the\x20one-PTB\x20order_renew\x20payment\x20is\x20INVISIBLE\x20to\x20it,\x20so\x20a\x20'+'balance-gated\x20capture\x20advanced\x20by\x20order_renew\x20ALWAYS\x20aborts.\x20'+TWO_TX_RENEW_RECIPE+'\x20Pair\x20the\x20balance\x20gate\x20with\x20'+'the\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'](w=>w['prev']===q['name']);if(!s['some'](w=>h['test'](w['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'](w=>'\x27'+w+'\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'+'(anti-grab\x20pool)\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'+'Non-recoverable\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'](w=>d['test'](w['name'])),j=g['some'](w=>w['track']==='settlement'&&(d['test'](w['guard_key']??'')||d['test'](w['recipient_key']??''))),k=f['some'](w=>e['test'](w['name'])),l=g['some'](w=>w['track']==='refund'||e['test'](w['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(order-anchored\x20user\x20slot\x200\x20—\x20'+'the\x20submitted\x20Order,\x20extracted\x20by\x20the\x20Order\x27s\x20owner-claim\x20entry;\x20NEVER\x20slot\x20254\x20on\x20a\x20refund\x20rail:\x20254\x20is\x20the\x20ONCE-FOR-OBJECT\x20slot,\x20'+'so\x20a\x20refund\x20node\x20re-entered\x20in\x20a\x20later\x20period\x20aborts\x20E_ONCE_TRIGGERED(16),\x20OFN\x20#P-04;\x20claimed_by\x20some==false)\x20on\x20a\x20\x27refund\x27\x20'+'track\x20or\x20a\x20refund-family\x20guard_key,\x20plus\x20a\x20recover_gate\x20rail\x20(claimed_by\x20some==true)\x20so\x20an\x20arbitration-awarded\x20order\x27s\x20'+'residual\x20still\x20exits.'});if(b==='threshold'){const w=a['guards']??[],x=w['filter'](A=>A['host']==='repository'||/repository_write/i['test'](A['template_id'])),y=x['length']>0x0,z=x['some'](A=>{const B=(A['policy']?.['id_from']??'')['toLowerCase']();return B==='signer'||B==='clock';});if(!y)c['push']({'rule_id':'R-CROWDFUNDING-AGGREGATE','severity':'high','title':'crowdfunding_mode\x20\x27threshold\x27\x20gates\x20release\x20on\x20an\x20aggregate\x20with\x20no\x20write-bound\x20Repository\x20policy\x20(INV-E2)','detail':'The\x20threshold\x20total\x20is\x20an\x20escrow-bound\x20repository\x20sum\x20(query\x201179\x20→\x20U256,\x20per-row\x20min(row,\x20order.amount))\x20over\x20'+'ORDER-keyed\x20contribution\x20rows.\x20With\x20NO\x20write-bound\x20policy\x20the\x20rows\x20are\x20unauthenticated\x20—\x20anyone\x20could\x20inflate\x20'+'the\x20total\x20and\x20fake\x20a\x20\x27goal\x20met\x27\x20(R-X1-17\x20existence-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\x20an\x20identity\x20write_guard\x20'+'(order.owner==Signer\x20/\x20order.agent\x20has\x20Signer)\x20and\x20key\x20the\x20contribution\x20rows\x20by\x20the\x20funder\x27s\x20ORDER\x20(policy\x20'+'id_from\x20unset;\x20row\x20id\x20=\x20the\x20Order\x20address).\x20repository.move\x20only\x20asserts\x20the\x20write_guard\x20LIST\x20is\x20non-empty\x20'+'(E_POLICY_WRITE_GUARD_REQUIRED=22),\x20never\x20what\x20a\x20listed\x20guard\x20proves\x20—\x20a\x20placeholder\x20that\x20returns\x20true\x20is\x20an\x20'+'OPEN\x20write.'});else{if(z){const A=x['filter'](B=>{const C=(B['policy']?.['id_from']??'')['toLowerCase']();return C==='signer'||C==='clock';})['map'](B=>'\x27'+B['key']+'\x27')['join'](',\x20');c['push']({'rule_id':'R-CROWDFUNDING-AGGREGATE','severity':'high','title':'crowdfunding_mode\x20\x27threshold\x27\x20keys\x20contribution\x20rows\x20by\x20the\x20WALLET\x20(id_from\x20signer/clock)\x20on\x20'+A+'\x20—\x20the\x20pre-migration\x20shape\x20(INV-E2,\x20ksc-tn-261024\x20F-01/F-05)','detail':'Wallet-keyed\x20rows\x20feed\x20the\x20escrow-bound\x20sum\x20(query\x201179,\x20per-row\x20min(row,\x20order.amount))\x20ZERO\x20—\x20the\x20goal\x20gate\x20'+'silently\x20bricks\x20—\x20and\x20the\x20free-form\x20sum-where\x20(1174)\x20stays\x20self-reported,\x20so\x20a\x20backer\x20can\x20record\x201.0\x20for\x20a\x200.1\x20'+'pledge.\x20compile\x20hard-blocks\x20it\x20(CROWDFUNDING_SIGNER_KEYED_ROWS);\x20this\x20is\x20the\x20authoring-time\x20twin.','suggestion':'Key\x20the\x20contribution\x20rows\x20by\x20the\x20funder\x27s\x20ORDER:\x20policy\x20id_from\x20unset,\x20the\x20backer\x27s\x20tooling\x20submits\x20the\x20row\x20id\x20=\x20'+'their\x20Order\x20address\x20through\x20the\x20passport-bearing\x20data\x20write,\x20and\x20the\x20gate\x20passes\x20those\x20ORDER\x20addresses\x20as\x20the\x20aggregate\x27s\x20'+'candidate\x20ids.\x20Pair\x20the\x20gate\x20with\x20the\x20live-escrow\x20leg\x20(allocation.balance\x20query\x201051\x20via\x20convert_witness\x20'+'OrderAllocation\x20109,\x20>=\x20order.amount)\x20so\x20a\x20refunded/never-funded\x20order\x20can\x20neither\x20count\x20toward\x20the\x20goal\x20nor\x20be\x20'+'settled,\x20and\x20make\x20the\x20withdrawal\x20flow\x20ZERO\x20the\x20row\x20value\x20(an\x20upsert\x20of\x200\x20through\x20the\x20same\x20write\x20guard)\x20so\x20the\x20'+'valueMin:1\x20aggregate\x20predicate\x20stops\x20counting\x20it\x20even\x20when\x20the\x20row\x20itself\x20remains.'});}}}const m=a['build_notes']??[],n=/(attest|keeper|aggregate trust|read-?only sum|not a chain-?verified|independent recomputation)/i,o=/(not investment|non-?investment|no (?:investment )?return|never promise)/i,p=/(kyc|aml|securities|money-?transmission|regulatory|cross-border|compliance)/i,q=/(no-?refund|non-?refundable|keep-?it-?all)/i,s=[];if(b==='threshold'&&!m['some'](B=>n['test'](B)))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'](B=>o['test'](B)))s['push']('the\x20L-01\x20non-investment\x20statement\x20(never\x20promise\x20returns\x20/\x20promote\x20coin\x20price;\x20not\x20investment\x20advice\x20or\x20a\x20return\x20promise)');if(!m['some'](B=>p['test'](B)))s['push']('the\x20L-05\x20KYC/AML\x20+\x20cross-border\x20regulatory\x20caution\x20(HIGH\x20intensity)');if(b==='flexible'&&!m['some'](B=>q['test'](B)))s['push']('the\x20flexible\x20keep-it-all\x20NO-REFUND\x20posture\x20(contributions\x20non-refundable\x20once\x20the\x20deadline\x20passes;\x20no\x20refunds)');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.'}];}const PROSE_REVIEW_MODE_CLAIM=/(?<!inputs\.)\breview_mode\s*[=:]\s*["']?(none|review|review_reward)\b/gi,PROSE_OFFERING_CONTEXT=/inputs?\b|addable|per[ -]?build|opt[ -]?in|via the input|override/i;function phantomReviewModeFinding(a,b){return{'rule_id':'PROSE-CAPABILITY-01','severity':'high','title':'Build\x20prose\x20claims\x20review_mode=\x27'+a+'\x27\x20but\x20the\x20template\x20declares\x20\x27'+b+'\x27\x20'+'(phantom\x20capability)','detail':'The\x20compiled\x20service\x20is\x20built\x20from\x20the\x20DECLARED\x20review_mode\x20(\x27'+b+'\x27),\x20so\x20a\x20prose\x20'+('claim\x20of\x20\x27'+a+'\x27\x20ships\x20a\x20service\x20without\x20the\x20promised\x20review\x20rail\x20while\x20the\x20build\x20')+'notes\x20tell\x20the\x20merchant\x20(and\x20through\x20them\x20the\x20buyer)\x20it\x20exists\x20—\x20a\x20template-level\x20false\x20'+'promise\x20(bstn-tn-261024\x20F-01:\x20the\x20licensing\x20build\x20note\x20promised\x20a\x20review\x20route\x20the\x20shape\x20'+'could\x20never\x20carry).\x20Compile\x20gates\x20the\x20reviewed\x20node\x20against\x20the\x20declared\x20mode\x20only\x20'+'(REVIEW_NODE_MISSING);\x20it\x20cannot\x20see\x20prose.','suggestion':'Make\x20the\x20prose\x20tell\x20the\x20truth:\x20either\x20set\x20the\x20template\x27s\x20review_mode\x20to\x20\x27'+a+'\x27\x20AND\x20'+'ship\x20the\x20matching\x20shape\x20(reviewed\x20node\x20+\x20rail,\x20reward\x20guards\x20when\x20review_reward),\x20or\x20'+'rewrite\x20the\x20claim\x20as\x20per-build\x20availability\x20—\x20e.g.\x20\x22addable\x20per-build\x20via\x20'+('inputs.review_mode=\x27'+a+'\x27\x22\x20—\x20only\x20where\x20the\x20shape\x20actually\x20supports\x20the\x20addition.')};}function proseCapabilityChecks(a,b=a){const c=a['review_mode']??'none';for(const f of machineProseFields(b)){const g=proseClaim(b,f['address'],'review_mode');if(typeof g==='string'&&g!==c)return[phantomReviewModeFinding(g,c)];}const d=[],e=[...a['build_notes']??[],a['allocator']['description'],...a['trust_mechanisms']??[]];for(const h of e){for(const j of h['split'](/[;\n]/)){const k=[...j['matchAll'](PROSE_REVIEW_MODE_CLAIM)];if(k['length']===0x0||PROSE_OFFERING_CONTEXT['test'](j))continue;for(const l of k){const n=l[0x1]['toLowerCase']();if(n===c)continue;d['push'](phantomReviewModeFinding(n,c));break;}if(d['length']>0x0)return d;}}return d;}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'||e['type']==='query_repository_data_sum_where_bound'){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).\x20A\x20Signer-keyed\x20review\x20TEXT\x20row\x20(custom\x20policies;\x20the\x20compile-emitted\x20\x27review\x27\x20default\x20is\x20'+'order-keyed\x20since\x20F09,\x20yfd-ln-261024)\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 repoDataHasRef(a){if(a['type']==='query'){const c=a['query'];if(typeof c==='string'&&c['trim']()['toLowerCase']()==='repository.data\x20has')return!![];if(c===0x48e||c==='1166')return!![];}const b=a['type'];return typeof b==='string'&&b['toLowerCase']()==='query_repository_data_has';}function subtreeRefsRepoDataHas(a){if(Array['isArray'](a))return a['some'](subtreeRefsRepoDataHas);if(typeof a!=='object'||a===null)return![];const b=a;if(repoDataHasRef(b))return!![];return Object['values'](b)['some'](subtreeRefsRepoDataHas);}export function rootNegatesRepoDataHasTemplateRoot(a){if(Array['isArray'](a))return a['some'](rootNegatesRepoDataHasTemplateRoot);if(typeof a!=='object'||a===null)return![];const b=a;if(b['type']==='logic_not'&&subtreeRefsRepoDataHas(b['node']))return!![];return Object['values'](b)['some'](rootNegatesRepoDataHasTemplateRoot);}function repoWriteOnceIdiomChecks(a){const b=a['guards']??[],c=[];for(const d of b){if(d['host']!=='repository')continue;if(!d['template_id']?.['startsWith']('tpl_'))continue;const e=GUARD_TEMPLATES['find'](f=>f['id']===d['template_id']);if(!e?.['example_root'])continue;rootNegatesRepoDataHasTemplateRoot(e['example_root'])&&c['push']('\x27'+(d['key']??d['template_id'])+'\x27\x20->\x20'+d['template_id']);}if(c['length']===0x0)return[];return[{'rule_id':'R-REPO-WRITE-ONCE-INEFFECTIVE','severity':'critical','title':'Repository\x20write\x20guard(s)\x20['+c['join'](',\x20')+']\x20negate\x20the\x20row-existence\x20probe\x20—\x20the\x20write-once\x20leg\x20is\x20INEFFECTIVE\x20and\x20must\x20not\x20publish','detail':'The\x20write\x20guard\x20is\x20verified\x20INSIDE\x20the\x20same\x20PTB\x20as\x20the\x20write,\x20before\x20the\x20row\x20exists:\x20a\x20logic_not\x20over\x20'+'\x22repository.data\x20has\x22\x20(1166)\x20always\x20evaluates\x20the\x20PRE-write\x20state,\x20so\x20the\x20leg\x20cannot\x20enforce\x20write-once.\x20'+'Mainnet\x20A/B\x20(ofn-mn-261012\x20F-02):\x20the\x20identical\x20guard\x20minus\x20the\x20leg\x20succeeded,\x20and\x20the\x20author\x20then\x20'+'overwrote\x20their\x20own\x205-star\x20review\x20with\x201\x20star.\x20A\x20defence\x20that\x20cannot\x20be\x20enforced\x20is\x20worse\x20than\x20none\x20—\x20'+'the\x20publish\x20gate\x20flags\x20it\x20INEFFECTIVE\x20instead\x20of\x20accepting\x20it.','suggestion':'Drop\x20the\x20negated-existence\x20leg\x20and\x20enforce\x20write-once\x20with\x20a\x20primitive\x20that\x20actually\x20binds:\x20'+'PolicyRule.write_once=true\x20on\x20the\x20target\x20policy\x20(a\x20second\x20write\x20to\x20the\x20same\x20id\x20aborts\x20with\x20repository\x20'+'error\x2024,\x20E_POLICY_WRITE_ONCE_CONFLICT,\x20live-verified\x20amz9-ln-261023),\x20or\x20scope\x20the\x20ONCE(255)\x20submission\x20'+'slot\x20(per\x20guard-pool\x20—\x20pair\x20with\x20the\x20order\x20anchor\x20R-ANCHOR-01)\x20/\x20the\x20254\x20task-binding\x20slot\x20for\x20'+'order-bound\x20rails.'}];}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,w=!![];for(const x of c){const y=railValue(x,b);if(y===null)w=![];else s+=y;}m['set']('settlement',{'label':'settlement','sum':s,'resolvable':w});}if(k!==undefined){const z=[...m['values']()]['filter'](A=>A['resolvable']&&A['sum']>k);if(z['length']>0x0)return[{'rule_id':'R-FAMT-SCALE','severity':'critical','title':'Absolute\x20Amount\x20rails\x20exceed\x20the\x20minimum\x20post-discount\x20payable\x20('+z['map'](A=>A['label']+':\x20'+A['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'+z['map'](A=>A['label'])['join'](',\x20')+'.'),'suggestion':'Shrink\x20the\x20rails\x20to\x20fit\x20the\x20discounted\x20floor\x20('+z['map'](A=>A['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'](A=>A['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.\x20RUNTIME\x20'+'ENFORCEMENT\x20FACE:\x20this\x20advisory\x20does\x20NOT\x20mean\x20the\x20shape\x20ships\x20unguarded\x20—\x20the\x20buy\x20path\x20carries\x20the\x20fixed-leg\x20'+'completion\x20gate\x20(order_below_fixed_leg_sum,\x20b6-11\x20family):\x20it\x20computes\x20the\x20minimum\x20completion-route\x20fixed-leg\x20'+'sum\x20for\x20THIS\x20machine\x20(completion\x20routes\x20only\x20—\x20refund/cancel\x20early-exit\x20routes\x20are\x20excluded,\x20yfd-ln-261024\x20F04)\x20'+'and\x20rejects\x20the\x20buy\x20before\x20any\x20money\x20moves\x20when\x20the\x20discounted\x20payable\x20cannot\x20cover\x20it.\x20With\x20that\x20gate\x20live\x20the\x20'+'residual\x20exposure\x20is\x20buy-time\x20rejections\x20(a\x20coupon\x20priced\x20below\x20the\x20rail\x20sum\x20makes\x20orders\x20unbuyable\x20—\x20a\x20merchant\x20'+'UX\x20problem),\x20not\x20escrow\x20stranding;\x20the\x20MCP-side\x20gate\x20is\x20an\x20enforcement\x20courtesy,\x20not\x20a\x20chain\x20invariant,\x20so\x20a\x20'+'build\x20that\x20bypasses\x20the\x20buy\x20tool\x20face\x20still\x20strands.','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\x20(the\x20buy-path\x20'+'order_below_fixed_leg_sum\x20gate\x20will\x20otherwise\x20reject\x20discounted\x20orders\x20one\x20by\x20one\x20—\x20correct,\x20but\x20the\x20merchant\x20'+'should\x20learn\x20it\x20from\x20this\x20report,\x20not\x20from\x20failed\x20buys).'}];}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/i['test'](h['template_id'])||/arb\.(?:indemnity|order|winner|status|ruling|case)/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'](y=>(y['from']??[])['length']>0x0))return[];const c=a['allocator']['rows']??[];if(c['length']===0x0)return[];const d=[...a['guards']['map'](y=>y['purpose']),...c['map'](y=>y['note']??'')];if(!d['some'](y=>/current\s*==/i['test'](y)))return[];const f=a['allocator']['description']??'',g=new Set();for(const y of b){for(const z of y['from']??[]){const A=typeof z==='string'?z:z?.['prev'];if(A)g['add'](A);}}const h=b['filter'](B=>!g['has'](B['name']));if(h['length']===0x0)return[];const j=B=>B['replace'](/[.*+?^${}()|[\]\\]/g,'\x5c$&'),k=B=>{const C=new RegExp('current\x5cs*==\x5cs*[\x22\x27]?'+j(B)+'\x5cb','i');if(a['guards']['some'](E=>C['test'](E['purpose'])))return!![];if(c['some'](E=>E['note']!==undefined&&C['test'](E['note'])))return!![];const D=new RegExp('\x5cb'+j(B)+'\x5cb','i');if(a['guards']['some'](E=>D['test'](E['purpose'])))return!![];if(c['some'](E=>E['note']!==undefined&&D['test'](E['note'])))return!![];return D['test'](f);},l=B=>/pool is empty|pool drains?ed|drains? in full|already (?:released|paid)|escrow (?:is )?(?:empty|drained)/i['test'](B),n=h['filter'](B=>!k(B['name'])&&!l(B['role']))['map'](B=>'\x27'+B['name']+'\x27'),o=/cancel|refund|return|withdraw|compensat/i,p=/refund|repay|chargeback|compensat/i,q=B=>B['semantic_role']==='cancelled'||o['test'](B['name']),s=B=>{const C=new RegExp('current\x5cs*==\x5cs*[\x22\x27]?'+j(B)+'\x5cb','i'),D=new RegExp('\x5cb'+j(B)+'\x5cb','i');if(c['some'](E=>E['track']==='refund'&&(C['test'](E['note']??'')||D['test'](E['note']??''))))return!![];return a['guards']['some'](E=>(C['test'](E['purpose'])||D['test'](E['purpose']))&&p['test'](E['template_id']+'\x20'+E['purpose']));},w=h['filter'](B=>q(B)&&k(B['name'])&&!s(B['name'])&&!l(B['role']))['map'](B=>'\x27'+B['name']+'\x27'),x=[];return n['length']>0x0&&x['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.'}),w['length']>0x0&&x['push']({'rule_id':'TERMINAL-WRONG-RAIL','severity':'critical','title':'Refund\x20terminal(s)\x20'+w['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.'}),x;}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.'}];}const PATH_CLASS_PATH_CAP=0x1388;function extractHistoryAnchorLiteral(a){for(const b of a['matchAll'](/next_node\s*=\s*["']([A-Za-z0-9_]+)["']/g)){const c=a['slice'](Math['max'](0x0,b['index']-0x40),b['index']);if(/progress\.history\.time[\s\S]{0,48}$/i['test'](c))return b[0x1];}return undefined;}function enumeratePathClasses(a,b,c,d,e){const f=d['toLowerCase'](),g=c['toLowerCase'](),h=new Set(),j=[];let k=0x0,l=![];const m=n=>{const o=n['toLowerCase']();if(o===f)return;j['push'](n),h['add'](o);if(o===g){k+=0x1;if(k>PATH_CLASS_PATH_CAP)l=!![];else e['length']<0x3&&e['push'](j['join']('→')+'\x20avoiding\x20\x27'+d+'\x27');}else for(const p of a['get'](n)??[]){if(l)break;if(h['has'](p['toLowerCase']()))continue;m(p);}j['pop'](),h['delete'](o);};for(const n of b){if(l)break;m(n);}return{'violated':k>0x0,'capped':l};}function pathClassAnchorChecks(a){const b=a['machine_shape']??[];if(b['length']===0x0)return[];if(!b['some'](k=>(k['from']??[])['some'](l=>typeof l!=='string'&&!!l['guard_key'])))return[];const c=new Map(),d=new Map();for(const k of b){for(const l of k['from']??[]){const n=typeof l==='string'?l:l['prev'];if(!c['has'](n))c['set'](n,[]);c['get'](n)['push'](k['name']);if(n!=='')d['set'](k['name'],(d['get'](k['name'])??0x0)+0x1);}}const f=b['filter'](o=>(d['get'](o['name'])??0x0)===0x0)['map'](o=>o['name']);if(f['length']===0x0)return[];const h=[],j=new Set();for(const o of a['guards']){if(!o['key']||j['has'](o['key']))continue;if(!/history[\s\S]{0,200}next_node|next_node[\s\S]{0,200}history/i['test'](o['purpose']))continue;const p=extractHistoryAnchorLiteral(o['purpose']);if(!p)continue;if(!b['some'](z=>z['name']['toLowerCase']()===p['toLowerCase']()))continue;j['add'](o['key']);const q=[];for(const z of b){for(const A of z['from']??[]){if(typeof A==='string'||A['guard_key']!==o['key'])continue;q['push']({'u':A['prev'],'v':z['name']});}}const s=[],w=[];let x=![];const y=new Map();for(const {u:B,v:C}of q){const D=B['toLowerCase']();let E=y['get'](D);!E&&(E=enumeratePathClasses(c,f,B,p,s),y['set'](D,E));if(E['capped'])w['push'](B+'→'+C);if(E['violated'])x=!![];}if(!x)continue;h['push']({'rule_id':'PATH-CLASS-ANCHOR-01','severity':'high','title':'History-time\x20anchor\x20\x27'+p+'\x27\x20is\x20missing\x20from\x20some\x20path\x20class\x20reaching\x20guard\x20\x27'+o['key']+'\x27\x20—\x20'+'the\x20guard\x20aborts\x20(MovePrimitiveRuntimeError),\x20not\x20a\x20clean\x20false','detail':'A\x20guard\x20purpose\x20that\x20declares\x20a\x20HISTORY-time\x20anchor\x20(progress.history.time\x20...,\x20next_node=\x27'+p+'\x27,\x20'+('find=last)\x20hard-depends\x20on\x20node\x20\x27'+p+'\x27\x20being\x20present\x20in\x20the\x20order\x27s\x20history.\x20An\x20order\x20that\x20reaches\x20')+('one\x20of\x20this\x20guard\x27s\x20edges\x20via\x20a\x20path\x20class\x20that\x20never\x20visits\x20\x27'+p+'\x27\x20makes\x20that\x20repository\x20query\x20')+'return\x20W_FIELD_NOT_FOUND,\x20and\x20the\x20passport\x20validator\x20re-raises\x20it\x20as\x20a\x20MovePrimitiveRuntimeError:\x20the\x20'+'ENTIRE\x20guard\x20aborts\x20instead\x20of\x20returning\x20a\x20clean\x20predicate\x20false,\x20so\x20whatever\x20it\x20gates\x20(an\x20expiry,\x20a\x20'+'release,\x20a\x20refund\x20window)\x20never\x20evaluates\x20on\x20that\x20path\x20class.\x20Topological\x20reachability\x20(F-TPL-01)\x20is\x20'+'necessary\x20but\x20NOT\x20sufficient\x20—\x20the\x20anchor\x20must\x20DOMINATE\x20every\x20path\x20class\x20reaching\x20the\x20guarded\x20edge\x27s\x20'+('pre-node.\x20Violating\x20path\x20classes\x20(start→...→pre-node\x20avoiding\x20\x27'+p+'\x27):\x20'+s['join'](';\x20')+'.')+(w['length']>0x0?'\x20Path\x20enumeration\x20hit\x20the\x20'+PATH_CLASS_PATH_CAP+'-path\x20determinism\x20cap\x20on\x20'+w['join'](',\x20')+'\x20—\x20'+'those\x20edges\x20were\x20skipped\x20as\x20under-audited,\x20not\x20cleared.':''),'suggestion':'Anchor\x20the\x20history-time\x20leg\x20only\x20on\x20a\x20node\x20present\x20on\x20EVERY\x20path\x20class\x20that\x20can\x20reach\x20the\x20guarded\x20'+'edges\x20(the\x20dominance\x20rule)\x20—\x20e.g.\x20anchor\x20an\x20expiry\x20on\x20the\x20delivered\x20entry\x20rather\x20than\x20a\x20renewal-only\x20'+'node;\x20or\x20split\x20the\x20edge/guard\x20so\x20each\x20path\x20class\x20gets\x20its\x20own\x20anchor\x20(a\x20logic_or\x20of\x20per-class\x20anchors).'});}return h;}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 w=typeof s==='string'?{'prev':s}:s;if(!w['prev'])continue;const x=w['operator']??(w['permission_index']!==undefined?'perm:'+w['permission_index']:p['operator']??'merchant'),y=q['get'](w['prev'])??[];y['push']({'guard_key':w['guard_key'],'actor':x}),q['set'](w['prev'],y);}for(const [z,A]of q){const B=A['filter'](H=>H['guard_key']!==undefined);if(B['length']<0x2)continue;const C=new Set(B['map'](H=>H['actor']));if(C['size']>0x1)continue;const D=B['filter'](H=>l(H['guard_key']));if(D['length']<0x2)continue;if(D['every'](H=>h['has'](H['guard_key'])))continue;const E=D['map'](H=>H['guard_key']),F=[...new Set(E['map'](H=>k(H))['filter'](H=>H!==undefined&&H!==''))],G=F['length']>0x1;m['push']({'rule_id':'SIBLING-FORWARD-EXCLUSIVITY','severity':G?'high':'medium','title':'Node\x20\x27'+p['name']+'\x27\x20(pair\x20from\x20\x27'+z+'\x27)\x20carries\x20'+D['length']+'\x20sibling\x20forwards\x20gated\x20by\x20'+('time-window\x20guards\x20under\x20one\x20actor\x20('+[...C]['join']('/')+')\x20—\x20no\x20on-chain\x20mutual\x20exclusion'),'detail':G?'Sibling\x20guards\x20resolve\x20to\x20DIFFERENT\x20settlement\x20amounts\x20('+F['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':G?'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'))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).\x20DIRECTION\x20CAVEAT\x20(bs-mn-261022\x20F-BS-54/56):\x20this\x20axis\x20'+'records\x20\x27the\x20case\x20closed\x20onto\x20the\x20order\x27,\x20never\x20\x27who\x20won\x27\x20—\x20a\x20zero-indemnity\x20DISMISSAL\x20can\x20never\x20'+'claim,\x20so\x20claimed_by\x20moves\x20only\x20when\x20a\x20keeper\x20drives\x20the\x20dismissal\x20conclusion\x20at\x20ruling\x20time;\x20the\x20'+'recovery\x20leg\x20then\x20fires\x20on\x20a\x20PAID\x20buyer-favoured\x20award\x20or\x20a\x20concluded\x20dismissal.\x20Present\x20the\x20rail\x20as\x20'+'\x27escrow\x20exits\x20to\x20the\x20seller\x20after\x20the\x20case\x20closed\x20against\x20the\x20buyer\x27,\x20NEVER\x20as\x20\x27the\x20merchant\x20won\x27.'}];}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'))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 CLAIMED_WIN_FRAME_RE=/\b(?:merchant|seller|producer|store|vendor|we)\b[^.;\n]{0,48}\b(?:win|wins|won|prevail(?:ed)?)\b/i,CLAIMED_WIN_FRAME_ALT_RE=/\bdismiss(?:al|ed|s)?\b|\bbuyer\s+(?:lose|loses|lost)\b|\bclaw(?:ed|s)?\s+back\b/i,CLAIMED_WIN_NEGATION_RE=/\b(?:never|do\s+not|don'?t|not|avoid|instead|rather\s+than|cannot)\b/i;function claimedDirectionVoidChecks(a){const b=[...(a['allocator']['rows']??[])['filter'](d=>d['track']!=='refund')['map']((d,e)=>['allocator\x20row\x20'+e+'\x20(track\x20'+d['track']+')',d['note']??'']),...a['guards']['map'](d=>['guard\x20\x27'+d['key']+'\x27',d['purpose']??''])],c=[];for(const [d,e]of b){if(!CLAIMED_TRUE_RE['test'](e))continue;for(const f of[CLAIMED_WIN_FRAME_RE,CLAIMED_WIN_FRAME_ALT_RE]){f['lastIndex']=0x0;for(let g=f['exec'](e);g!==null;g=f['exec'](e)){const h=e['slice'](Math['max'](0x0,g['index']-0x5a),g['index']+g[0x0]['length']+0x5a);if(CLAIMED_WIN_NEGATION_RE['test'](h))continue;c['push'](d+':\x20\x22'+g[0x0]['trim']()+'\x22');break;}if(c['some'](j=>j['startsWith'](d)))break;}}if(c['length']===0x0)return[];return[{'rule_id':'R-CLAIMED-DIRECTION-VOID','severity':'critical','title':'Recovery\x20rail\x20framed\x20as\x20winning-side\x20recovery\x20on\x20the\x20claimed_by\x20axis\x20—\x20polarity\x20voided\x20by\x20the\x20always-on\x20zero-indemnity\x20gate','detail':'order.claimed_by\x20is\x20written\x20when\x20the\x20case\x20is\x20CLOSED\x20onto\x20the\x20order\x20—\x20by\x20a\x20PAYING\x20claim\x20'+'(buyer-favoured)\x20or\x20by\x20the\x20dismissal\x20conclusion\x20(defendant-favoured,\x20always\x20on).\x20A\x20zero-indemnity\x20'+'award\x20itself\x20can\x20never\x20claim\x20(zero-indemnity\x20gate,\x20abort\x2011),\x20so\x20before\x20the\x20conclusion\x20existed\x20'+'claimed_by\x20stayed\x20none\x20after\x20a\x20dismissal.\x20The\x20axis\x20records\x20\x27the\x20case\x20closed\x20onto\x20this\x20order\x27,\x20'+'never\x20\x27who\x20won\x27:\x20some\x20==\x20true\x20covers\x20a\x20PAID\x20buyer\x20award\x20AND\x20a\x20concluded\x20dismissal.\x20A\x20rail\x20framed\x20'+'as\x20merchant-wins-recovery\x20therefore\x20pays\x20the\x20merchant\x20exactly\x20when\x20the\x20merchant\x20LOST\x20(live\x20'+'bs-mn-261022\x20O8)\x20unless\x20a\x20keeper\x20drives\x20the\x20dismissal\x20conclusion\x20at\x20ruling\x20time;\x20until\x20then\x20the\x20'+'paired\x20refund\x20leg\x20(some\x20==\x20false)\x20stays\x20open\x20and\x20the\x20buyer\x20loses\x20the\x20dispute\x20at\x20zero\x20cost\x20(O6).\x20Offending\x20surfaces:\x20'+c['join'](';\x20')+'.','suggestion':'Re-frame\x20the\x20rail\x27s\x20semantics\x20honestly:\x20claimed_by\x20some\x20==\x20true\x20means\x20\x27the\x20case\x20closed\x20onto\x20'+'the\x20order\x27\x20(a\x20buyer-favoured\x20award\x20was\x20PAID,\x20or\x20a\x20dismissal\x20was\x20concluded)\x20—\x20present\x20the\x20rail\x20as\x20'+'UPWC-K1\x20escrow-exit\x20(\x27the\x20awarded\x20order\x27s\x20escrow\x20principal\x20exits\x20to\x20the\x20seller\x20once\x20the\x20case\x20'+'closes\x27),\x20never\x20as\x20\x27the\x20merchant\x20won\x20the\x20dispute\x27.\x20Drive\x20the\x20dismissal\x20conclusion\x20at\x20ruling\x20time\x20'+'so\x20the\x20case\x20lands\x20on\x20the\x20order\x20and\x20the\x20refund\x20leg\x20closes.\x20Gating\x20on\x20ruling\x20DIRECTION\x20is\x20not\x20'+'expressible\x20on\x20this\x20axis\x20—\x20that\x20needs\x20the\x20chain-side\x20ruling-direction\x20accessor\x20(arb.winner,\x20bs-mn-261022).'}];}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 rewardBypassChecks(a){const b=a['machine_shape']??[];if(b['length']===0x0)return[];const c=new Set();for(const l of a['guards']){if(l['host']!=='reward')continue;for(const [n,o]of Object['entries'](l['params']??{})){if(/^expected_.*_node$/['test'](n)&&typeof o==='string'&&o!=='')c['add'](o);}}if(c['size']===0x0)return[];const d=new Set(b['map'](p=>p['name'])),f=new Map(),h=new Map();for(const p of b){for(const q of p['from']??[]){const s=typeof q==='string'?q:q?.['prev'];if(s==='')continue;if(!f['has'](s))f['set'](s,[]);f['get'](s)['push'](p['name']);if(!h['has'](p['name']))h['set'](p['name'],[]);h['get'](p['name'])['push'](s);}}const j=[];for(const w of[...c]['sort']()){if(!d['has'](w)){j['push']('\x27'+w+'\x27\x20is\x20promised\x20by\x20reward-claim\x20machinery\x20but\x20absent\x20from\x20machine_shape\x20(dead\x20literal)');continue;}const x=h['get'](w)??[];if(x['length']!==0x1)continue;const y=f['get'](x[0x0])??[];if(y['length']<0x2)continue;const z=y['filter'](A=>A!==w)['map'](A=>'\x27'+A+'\x27')['join'](',\x20');j['push']('\x27'+w+'\x27\x20hangs\x20on\x20a\x20single\x20in-edge\x20from\x20\x27'+x[0x0]+'\x27\x20whose\x20sibling\x20forward(s)\x20('+z+')\x20let\x20the\x20order\x20leave\x20forever\x20—\x20the\x20promised\x20state\x20is\x20skippable');}if(j['length']===0x0)return[];return[{'rule_id':'R-REWARD-BYPASS','severity':'medium','title':'Reward-promise\x20node(s)\x20can\x20be\x20bypassed:\x20'+j['length']+'\x20skippable/unresolvable\x20promise(s)','detail':'ADVISORY\x20(never\x20blocks):\x20a\x20reward-host\x20guard\x20spec\x20promises\x20these\x20states\x20via\x20its\x20expected_*_node\x20'+'params,\x20but\x20the\x20topology\x20lets\x20an\x20order\x20miss\x20them\x20permanently\x20—\x20'+j['join'](';\x20')+'.\x20The\x20chain\x20has\x20no\x20scheduler:\x20once\x20the\x20order\x20advances\x20past\x20the\x20fork\x20through\x20the\x20sibling\x20forward\x20'+'(its\x20own\x20guard\x20passed,\x20or\x20a\x20keeper\x20edge\x20fired),\x20no\x20edge\x20leads\x20back\x20and\x20the\x20promised\x20state\x20—\x20and\x20'+'every\x20reward\x20gated\x20on\x20it\x20—\x20becomes\x20dead\x20for\x20that\x20order.\x20abnb14-mn\x20F01\x20(live):\x20the\x20review\x20window\x20'+'was\x20swallowed\x20by\x20the\x20claim\x20window\x20for\x20every\x20late\x20reviewer\x20because\x20`reviewed`\x20hung\x20on\x20a\x20single\x20'+'completed-only\x20entry\x20while\x20completed\x20also\x20opened\x20the\x20claim\x20window.\x20If\x20the\x20bypass\x20IS\x20the\x20design\x20'+'(a\x20genuinely\x20optional\x20reward),\x20leave\x20it\x20—\x20this\x20finding\x20exists\x20so\x20the\x20choice\x20is\x20deliberate\x20and\x20'+'documented\x20in\x20the\x20spec\x20purpose,\x20not\x20an\x20accident\x20of\x20array\x20order.','suggestion':'Give\x20the\x20promised\x20node\x20a\x20SECOND\x20entry\x20edge\x20from\x20the\x20post-fork\x20waypoint\x20(the\x20v102\x20fix:\x20reviewed\x20'+'re-entered\x20from\x20claim_window\x20via\x20the\x20same\x20forward),\x20or\x20demote\x20the\x20promise:\x20drop\x20the\x20'+'expected_*_node\x20param\x20and\x20say\x20in\x20the\x20spec\x20purpose\x20that\x20the\x20reward\x20rides\x20an\x20optional\x20state.\x20'+'A\x20promise\x20node\x20absent\x20from\x20machine_shape\x20is\x20a\x20dead\x20literal\x20—\x20fix\x20the\x20name\x20or\x20delete\x20the\x20param.'}];}function guardUnmountedChecks(a){const b=a['guards']['filter'](k=>typeof k['key']==='string'&&k['key']!=='');if(b['length']===0x0)return[];const d=new Set(['reward','repository','service']),f=new Set();for(const k of a['machine_shape']??[]){for(const l of k['from']??[]){if(typeof l!=='string'&&l?.['guard_key'])f['add'](l['guard_key']);}}for(const m of a['allocator']['rows']??[]){if(m['guard_key'])f['add'](m['guard_key']);}for(const o of a['conditional_guards']??[]){if(o['guard_key'])f['add'](o['guard_key']);}const g=new Set((a['machine_shape']??[])['map'](p=>p['name'])),h=p=>/DESIGN-ONLY|nothing binds|AND into/i['test'](p['purpose'])||[...g]['some'](q=>p['purpose']['includes'](q)),j=b['filter'](p=>!d['has'](p['host'])&&!f['has'](p['key'])&&!h(p));if(j['length']===0x0)return[];return[{'rule_id':'R-GUARD-UNMOUNTED','severity':'medium','title':j['length']+'\x20guard\x20spec(s)\x20declare\x20a\x20key\x20nothing\x20mounts:\x20'+j['map'](p=>'\x27'+p['key']+'\x27')['join'](',\x20'),'detail':'ADVISORY\x20(never\x20blocks):\x20the\x20declared\x20key\x20surface\x20is\x20the\x20mounting\x20surface\x20—\x20an\x20edge\x27s\x20guard_key,\x20'+'an\x20allocator\x20row\x27s\x20guard_key,\x20or\x20a\x20conditional_guards\x20emission.\x20These\x20'+j['map'](p=>'\x27'+p['key']+'\x27\x20(host\x20'+p['host']+',\x20'+p['template_id']+')')['join'](',\x20')+'\x20are\x20referenced\x20by\x20none\x20of\x20them,\x20so\x20compile\x20never\x20collects\x20them\x20into\x20the\x20build\x20'+'(audit-261012\x20B3:\x20an\x20unbound\x20GuardSpec\x20is\x20never\x20emitted).\x20The\x20template\x20ships\x20the\x20spec\x27s\x20purpose\x20'+'as\x20a\x20promise\x20while\x20the\x20published\x20Machine\x20carries\x20no\x20such\x20guard\x20—\x20the\x20reader\x20believes\x20a\x20'+'protection\x20exists\x20that\x20does\x20not.','suggestion':'Mount\x20each\x20spec\x20by\x20binding\x20its\x20key\x20to\x20the\x20edge(s)\x20it\x20should\x20gate\x20(machine_shape\x20from[].guard_key)\x20'+'or\x20the\x20allocator\x20row(s)\x20it\x20should\x20cover\x20(allocator.rows[].guard_key);\x20if\x20the\x20protection\x20is\x20not\x20'+'wanted,\x20delete\x20the\x20spec\x20—\x20a\x20declared-but-unmounted\x20guard\x20is\x20dead\x20weight\x20that\x20inflates\x20the\x20trust\x20'+'surface.\x20reward/repository/service\x20hosts\x20need\x20no\x20key\x20reference\x20(host-mounted)\x20and\x20are\x20exempt.'}];}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;}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=machineProseFindings(a),c=canonicalizeMachineProse(a),d=[...b,...staticChecks(c),...guardRefChecks(c),...buyKeyDeclarationChecks(c),...taskBindingChecks(c),...allocLegSlotChecks(c),...fundAnchorChecks(c),...periodicReleaseChecks(c),...timeWindowAnchorChecks(c),...signerRefundChecks(c),...orderAnchorDeclarationChecks(c),...topologyChecks(c),...reachabilityChecks(c),...deadEndLockChecks(c),...reviewNoRaceChecks(c),...afterSalesRailChecks(c),...acceptanceModeChecks(c),...installmentModeChecks(c),...affiliateModeChecks(c),...crowdfundingModeChecks(c),...rewardReplayChecks(c),...rewardZeroOrderChecks(c),...rewardFundedChecks(c),...proseCapabilityChecks(c,a),...rewardRatingKeyChecks(c),...loopFundChecks(c),...terminalRailCoverageChecks(c),...railNodeDriftChecks(c),...pathClassAnchorChecks(c),...siblingForwardExclusivityChecks(c),...compoundPayoutChecks(c),...surplusTrackChecks(c),...amountDeadlockChecks(c),...discountRailScaleChecks(c),...cancelCoverageChecks(c),...redundGuardObjectMismatchChecks(c),...zeroAmountGuardChecks(c),...serialClaimWindowChecks(c),...dismissEdgeGuardChecks(c),...noteNodeDriftChecks(c),...onewayDisputeChecks(c),...noEscrowExitChecks(c),...pairingProseOnlyChecks(c),...claimedDirectionVoidChecks(c),...railUnboundChecks(c),...rewardBypassChecks(c),...guardUnmountedChecks(c),...counterpartyFundEvidenceChecks(c),...repoWriteOnceIdiomChecks(c),...disclosureEnforceabilityChecks(c),...allocReplayChecks(c),...draftVoidChecks(c),...requiredInfoGateChecks(c),...planReadinessChecks(c),...feeParamLandingChecks(c)];for(const h of analyzerFindings(c)){const j=h['severity']==='info'?'low':h['severity'];d['push']({'rule_id':h['ruleId'],'severity':j,'title':h['title'],'detail':h['detail'],'suggestion':h['suggestion']});}d['sort']((k,l)=>SEVERITY_ORDER[l['severity']]-SEVERITY_ORDER[k['severity']]);const e=d['length']>0x0?d[0x0]['severity']:'low',g=d['filter'](k=>k['severity']==='critical')['map'](k=>''+(k['rule_id']?k['rule_id']+':\x20':'')+k['title']);return{'template_id':c['id'],'risk_level':e,'passed':g['length']===0x0,'findings':d,'red_flags':g};}
|
|
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{TASK_BINDING_SLOT,ONCE_SLOT_BYTES}from'./onchain-constants.js';import{GUARD_DESIGN_PATTERNS}from'./guard-design-patterns.js';import{unannotatedBuyerActionNodes}from'./scenario-modes.js';import{findLoopCycles}from'./machine-topology.js';import{TWO_TX_RENEW_RECIPE}from'./protocol-facts.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{PLATFORM_TAKE_KEY,platformShareBps,validateAllocatorRows}from'./template-loader.js';import{canonicalizeMachineProse,machineProseFields,machineProseFindings,proseClaim}from'./template-prose.js';export{PLATFORM_TAKE_KEY};const 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'](B=>PLATFORM_TAKE_KEY['test'](B)&&typeof c[B]==='number'&&c[B]!==0x0);d['length']>0x0&&b['push']({'rule_id':'R-ECON-01','severity':'critical','title':'Template\x20mandates\x20a\x20platform\x20commission\x20('+d['map'](B=>B+'='+c[B])['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=e['split'](/[.;]/)['filter'](B=>!/\b(?:never|no|not|don'?t|cannot|must not|avoid|prohibit\w*|forbid\w*|instead of|rather than|previously)\b/i['test'](B))['join']('\x20.\x20'),g=/(?:commission|take|platform|remainder|share)\s*(?:=|:)\s*order\s*total\s*-\s*(?:segment|sum)/i['test'](f),h=(a['allocator']['rows']??[])['some'](B=>B['mode']==='surplus')||a['allocator']['mode']==='surplus',j=h&&/(?:platform|commission|fee|take)[^.;]{0,120}\bsurplus\b|\bsurplus\b[^.;]{0,120}(?:platform|commission|fee|take)/i['test'](f);g&&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.'});j&&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 k=/\{\s*(?:who|Entity|Signer|GuardIdentifier)\s*:/['test'](e)||/recipient\s*[:=]/i['test'](e),l=/^(?:merchant_service_fee_bps|digital_product_fee_bps|logistics_rate_bps|service_fee_rate_bps)$/,m=Object['keys'](c)['some'](B=>l['test'](B)&&typeof c[B]==='number'&&c[B]!==0x0);if(m&&!k&&d['length']===0x0){const B=collectFeeParamLandings(a),C=Object['keys'](c)['filter'](F=>l['test'](F)&&typeof c[F]==='number'&&c[F]!==0x0),D=C['some'](F=>(B['get'](F)??[])['some'](G=>G['surface']==='guard'||G['surface']==='allocator_row'&&G['recipient_blank']!==!![])),E=!D&&C['some'](F=>(B['get'](F)??[])['some'](G=>G['surface']==='directive'));!D?b['push']({'rule_id':'R-ECON-03','severity':'high','title':E?'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':E?'fee_params\x20carry\x20fee-shaped\x20keys\x20('+C['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('+C['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 n=/(?:layer-?1|service-?level|pool)[^.]*settles? the full amount|full amount to the (?:platform|organizer) pool/i['test'](e);n&&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 o=Object['keys'](c)['find'](F=>/^attributed_.*_bps$/['test'](F)&&typeof c[F]==='number'),p=Object['keys'](c)['find'](F=>/^(?:base_)?commission_rate_bps$/['test'](F)&&typeof c[F]==='number');o&&p&&c[o]>c[p]&&b['push']({'rule_id':'R-ECON-05','severity':'medium','title':'Attribution-priced\x20take:\x20a\x20cheaper\x20acquisition\x20channel\x20is\x20charged\x20MORE','detail':o+'='+c[o]+'\x20exceeds\x20'+p+'='+c[p]+'.\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 F=Object['keys'](c)['filter'](I=>MERCHANT_SHARE_KEY['test'](I)&&typeof c[I]==='number'),G=Object['keys'](c)['filter'](I=>PLATFORM_TAKE_KEY['test'](I)&&typeof c[I]==='number'),H=[...F,...G];if(F['length']>0x0&&G['length']>0x0){const I=H['map'](L=>c[L])['filter'](L=>typeof L==='number'),J=I['reduce']((L,M)=>L+M,0x0),K=/surplus/i['test'](e);J!==0x2710&&!K&&b['push']({'rule_id':'R-ECON-06','severity':'critical','title':'Rate\x20shares\x20sum\x20to\x20'+J+',\x20not\x2010000','detail':'Declared\x20rate\x20shares\x20('+H['map']((L,M)=>L+'='+I[M])['join']('\x20+\x20')+')\x20total\x20'+J+'.\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 q=(a['allocator']['rows']??[])['map']((L,M)=>({'r':L,'i':M})),s=q['filter'](({r:L})=>L['recipient']==='entity'&&!(L['recipient_key']??'')['trim']());s['length']>0x0&&b['push']({'rule_id':ENTITY_RECIPIENT_RULE_ID,'severity':'critical','title':'Allocator\x20row(s)\x20'+s['map'](({i:L})=>'#'+L)['join'](',\x20')+'\x20name\x20no\x20Entity\x20recipient\x20—\x20the\x20share\x20silently\x20pays\x20the\x20deploying\x20merchant','detail':s['map'](({i:L})=>'rows['+L+']')['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\x20full-share\x20row\x20to\x20the\x20merchant\x27s\x20own\x20account\x20({\x20who:\x20{\x20Signer:\x20\x22signer\x22\x20}\x20}\x20when\x20'+'the\x20merchant\x20is\x20always\x20the\x20triggering\x20party,\x20or\x20an\x20explicit\x20Entity\x20row).\x20A\x20{\x20who:\x20{\x20GuardIdentifier:\x200\x20}\x20}\x20leg\x20pays\x20the\x20order\x20anchor,\x20not\x20the\x20'+'merchant\x20—\x20reserve\x20it\x20for\x20refunds\x20(see\x20the\x20order-anchored\x20refund\x20convention).\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\x20row\x20naming\x20the\x20merchant\x27s\x20own\x20account\x20'+'({\x20recipient:\x20\x27entity\x27,\x20recipient_key:\x20\x27<merchant>\x27\x20}\x20or\x20{\x20recipient:\x20\x27signer\x27\x20}\x20when\x20the\x20merchant\x20is\x20always\x20the\x20triggering\x20party);\x20a\x20'+'{\x20recipient:\x20\x27guard_identifier\x27\x20}\x20row\x20pays\x20the\x20order\x20anchor\x20(refund\x20semantics),\x20not\x20the\x20merchant.'});const w=q['filter'](({r:L})=>L['recipient']==='entity'&&/^0x0*$/i['test']((L['recipient_key']??'')['trim']()));w['length']>0x0&&b['push']({'rule_id':ENTITY_RECIPIENT_RULE_ID,'severity':'high','title':'Allocator\x20row(s)\x20'+w['map'](({i:L})=>'#'+L)['join'](',\x20')+'\x20name\x20the\x20zero\x20address\x20as\x20Entity\x20recipient','detail':w['map'](({i:L})=>'rows['+L+']')['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 x=L=>L['recipient']+':'+(L['recipient_key']??'')['trim']()['toLowerCase'](),y=/^(recover_gate|awarded_recover|terminal_settlement_recover)$/,z=new Set((a['allocator']['rows']??[])['filter'](L=>L['mode']==='rate'&&!y['test'](L['guard_key']??''))['map'](x)),A=q['filter'](({r:L})=>L['mode']==='surplus'&&z['has'](x(L)));return A['length']>0x0&&b['push']({'rule_id':'R-RECIPIENT-04','severity':'critical','title':'Surplus\x20row(s)\x20'+A['map'](({i:L})=>'#'+L)['join'](',\x20')+'\x20pay\x20a\x20recipient\x20a\x20Rate\x20leg\x20already\x20pays\x20—\x20the\x20remainder\x20swallows\x20an\x20undeclared\x20share','detail':A['map'](({i:L})=>'rows['+L+']')['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{if(l){const m=/record[ -]waypoint|accepted-node set|money never moves/i['test'](j['role']??'');!m&&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 n of a['guards']){if(/time_lock|order_holder|progress_state/['test'](n['template_id'])&&!/order\.service|project bind|service binding/i['test'](n['purpose'])){const o=d['get'](n['template_id'])??[];o['push'](n['key']??'(no\x20key)'),d['set'](n['template_id'],o);}}for(const [p,q]of d){b['push']({'rule_id':'R-C3-05','severity':'low','title':'Guard\x20\x27'+p+'\x27\x20consumes\x20a\x20submitted\x20Order\x20without\x20project\x20binding\x20('+q['length']+'x:\x20'+q['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'](s=>/refund|cancel/i['test'](s['template_id'])||/refund|cancel/i['test'](s['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'](s=>s['host']==='arbitration')||a['trust_mechanisms']['some'](s=>s['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'](s=>'\x27'+s+'\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']===TASK_BINDING_SLOT||p?.['identifier']===ONCE_SLOT_BYTES);}),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-OBJECT\x20for\x20settlement/claim\x20rails,\x20255\x20byte-keyed\x20for\x20per-period\x20repeats)\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\x20SETTLEMENT\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\x20SETTLEMENT\x20allocator\x20Guard\x20(never\x20a\x20refund\x20rail\x20—\x20a\x20refund\x20pays\x20the\x20Order\x20through\x20user\x20slot\x200\x20and\x20a\x20later\x20re-entry\x20would\x20abort\x2016,\x20OFN\x20#P-04)\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'+'The\x20order\x20items\x20vector\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:117)\x20is\x20overwritten\x20on\x20every\x20forward\x20'+'(progress.move:497)\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'](k=>k['recipient']==='signer'&&k['track']==='refund'),e=templateText(a),f=/Recipient::Signer[^;]{0,200}(?:tx_context::sender|tx[_ ]sender|signer-binding|pins? that claim|identity-bound)/i['test'](e),g=a['allocator']['recipient']==='signer'&&!f;if(!d&&!g)return b;const h=/refund|chargeback|repay|(?:pay(?:ment|out)?|release|send|transfer|settle)\w*[^.\n]{0,40}to the (?:buyer|order|customer)/i['test'](e);if(!h)return b;const j=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('+j+')','detail':'`Recipient::Signer`\x20resolves\x20to\x20`tx_context::sender(ctx)`\x20(allocation.move:628-630),\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:625-627)\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 w of s['from']??[]){const x=typeof w==='string'?w:w?.['prev'];if(x==='')f['push'](s['name']);else{if(!d['has'](x))d['set'](x,[]);d['get'](x)['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'](y=>'\x27'+y+'\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 y=j['pop']();for(const z of d['get'](y)??[]){!h['has'](z)&&(h['add'](z),j['push'](z));}}const k=b['filter'](A=>!h['has'](A['name']))['map'](A=>'\x27'+A['name']+'\x27');k['length']>0x0&&g['push']('unreachable\x20from\x20the\x20entry\x20(declared\x20but\x20dead):\x20'+k['join'](',\x20'));const l=A=>A['semantic_role']==='final'||A['semantic_role']==='cancelled',n=new Map();for(const [A,B]of d){for(const C of B){if(!n['has'](C))n['set'](C,[]);n['get'](C)['push'](A);}}const o=new Set(),p=b['filter'](l)['map'](D=>D['name']);p['forEach'](D=>o['add'](D));while(p['length']>0x0){const D=p['pop']();for(const E of n['get'](D)??[]){!o['has'](E)&&(o['add'](E),p['push'](E));}}const q=b['filter'](F=>!l(F)&&!o['has'](F['name'])&&(d['get'](F['name'])??[])['length']>0x0)['map'](F=>{const G='exits\x20lead\x20only\x20to\x20'+[...new Set(d['get'](F['name'])??[])]['map'](H=>'\x27'+H+'\x27')['join'](',\x20')+',\x20none\x20of\x20which\x20reaches\x20a\x20settlement\x20or\x20refund\x20endpoint';return'\x27'+F['name']+'\x27\x20('+(F['semantic_role']??'no\x20semantic_role')+')\x20—\x20'+G;});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 w of s['from']??[]){const x=typeof w==='string'?w:w?.['prev'];if(typeof x!=='string'||x==='')continue;if(!c['has'](x))c['set'](x,[]);c['get'](x)['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'](y=>classifyLoopCycle(y['cycle'],g)==='remedy');h['length']>0x0&&f['push']({'rule_id':'R-LOOP-FUND','severity':'low','title':'Remedy\x20loop\x20cycle(s)\x20'+h['map'](y=>'['+y['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'](y=>classifyLoopCycle(y['cycle'],g)==='renewal'),n=k?[]:l,o=d['filter'](y=>classifyLoopCycle(y['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'](y=>'['+y['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'](y=>'['+y['cycle']['join']('\x20->\x20')+']')['join'](',\x20')+':\x20declare\x20the\x20'+'order_renew\x20re-fund\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\x20(fund\x20+\x20record\x20+\x20'+'advance,\x20no\x20unfunded-advance\x20window);\x20NEVER\x20bind\x20an\x20allocation.balance\x20gate\x20on\x20this\x20forward\x20—\x20guards\x20read\x20the\x20COMMITTED\x20pre-transaction\x20balance,\x20so\x20the\x20same-PTB\x20payment\x20is\x20invisible\x20to\x20them\x20(esound-mn-261021\x20B-1)\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 w=s['find'](C=>d(C['name']+'\x20'+C['role'])),x=s['find'](C=>C['name']!==w?.['name']&&f(C['name']+'\x20'+C['role'])),y=s['find'](C=>g(C['name']+'\x20'+C['role'])),z=s['find'](C=>C['name']!==y?.['name']&&h(C['name']+'\x20'+C['role'])),A=w??y,B=w!==undefined&&x!==undefined?x:y!==undefined&&z!==undefined?z:undefined;if(A===undefined||B===undefined)continue;c['push']({'rule_id':'R-REVIEW-NORACE','severity':'high','title':'Node\x20\x27'+q+'\x27\x20fans\x20out\x20\x27'+A['name']+'\x27\x20and\x20its\x20complement\x20\x27'+B['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;}export function afterSalesRailRegex(a){return a==='return'?/return|refund/i:a==='exchange'?/exchange|replace|reship|swap/i:/warranty|repair|claim/i;}export function afterSalesRailNodeMatches(a,b){if(!afterSalesRailRegex(a)['test'](b))return![];return!/missed|withdraw|pre_deadline|goal/i['test'](b);}function afterSalesRailChecks(a){const b=a['after_sales_mode'];if(b===undefined||b==='none')return[];const c=a['machine_shape'],d=afterSalesRailRegex(b);if(c['some'](e=>afterSalesRailNodeMatches(b,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).\x20PRE-STATE\x20CONSTRAINT\x20(esound-mn-261021\x20B-1,\x20mainnet-verified):\x20'+'the\x20gate\x20reads\x20the\x20COMMITTED\x20pre-transaction\x20balance\x20—\x20the\x20one-PTB\x20order_renew\x20payment\x20is\x20INVISIBLE\x20to\x20it,\x20so\x20a\x20'+'balance-gated\x20capture\x20advanced\x20by\x20order_renew\x20ALWAYS\x20aborts.\x20'+TWO_TX_RENEW_RECIPE+'\x20Pair\x20the\x20balance\x20gate\x20with\x20'+'the\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'](w=>w['prev']===q['name']);if(!s['some'](w=>h['test'](w['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'](w=>'\x27'+w+'\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'+'(anti-grab\x20pool)\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'+'Non-recoverable\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,f=/(refund|missed|unmet|return|reimburse)/i,g=a['machine_shape']??[],h=a['allocator']?.['rows']??[],j=g['some'](A=>d['test'](A['name'])),k=h['some'](A=>A['track']==='settlement'&&(d['test'](A['guard_key']??'')||d['test'](A['recipient_key']??''))),l=g['some'](A=>f['test'](A['name'])),n=h['some'](A=>A['track']==='refund'||f['test'](A['guard_key']??''));!j&&!k&&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'&&!l&&!n&&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(order-anchored\x20user\x20slot\x200\x20—\x20'+'the\x20submitted\x20Order,\x20extracted\x20by\x20the\x20Order\x27s\x20owner-claim\x20entry;\x20NEVER\x20slot\x20254\x20on\x20a\x20refund\x20rail:\x20254\x20is\x20the\x20ONCE-FOR-OBJECT\x20slot,\x20'+'so\x20a\x20refund\x20node\x20re-entered\x20in\x20a\x20later\x20period\x20aborts\x20E_ONCE_TRIGGERED(16),\x20OFN\x20#P-04;\x20claimed_by\x20some==false)\x20on\x20a\x20\x27refund\x27\x20'+'track\x20or\x20a\x20refund-family\x20guard_key,\x20plus\x20a\x20recover_gate\x20rail\x20(claimed_by\x20some==true)\x20so\x20an\x20arbitration-awarded\x20order\x27s\x20'+'residual\x20still\x20exits.'});const o=g['find'](A=>(A['from']??[])['some'](B=>typeof B!=='string'&&B['prev']===''))?.['name'],p=[];for(const A of g){if(!/cancel/i['test'](A['name'])||A['semantic_role']!=='cancelled')continue;for(const B of A['from']??[]){if(typeof B==='string')continue;if(B['operator']!=='order_payer')continue;if(o!==undefined&&B['prev']===o)continue;p['push']((B['prev']||'(entry)')+'\x20--'+(B['forward']??'advance')+'-->\x20'+A['name']);}}p['length']>0x0&&c['push']({'rule_id':'R-CROWDFUNDING-CANCEL-RAIL','severity':'high','title':'crowdfunding_mode\x20\x27'+b+'\x27\x20anchors\x20a\x20buyer-cancel\x20rail\x20AFTER\x20the\x20pledge\x20entry\x20('+p['length']+'\x20edge(s):\x20'+p['join'](',\x20')+')\x20—\x20post-goal\x20escrow\x20drain\x20(ksr-tn-261026\x20Q8-F02)','detail':'The\x20campaign\x20goal\x20is\x20a\x20commitment\x20snapshot\x20taken\x20at\x20the\x20deadline:\x20once\x20the\x20goal\x20decision\x20passes,\x20a\x20backer\x20can\x20no\x20longer\x20'+'cancel\x20their\x20pledge.\x20In\x20a\x20threshold\x20campaign\x20every\x20node\x20below\x20the\x20entry\x20is\x20reachable\x20only\x20AFTER\x20the\x20deadline\x20(the\x20goal\x20'+'decision\x20requires\x20Clock\x20>=\x20deadline),\x20so\x20an\x20order_payer\x20cancel\x20edge\x20from\x20a\x20non-entry\x20prev\x20opens\x20a\x2030-day-style\x20'+'hist(<goal-node>)+N\x20drain\x20window\x20on\x20an\x20already-met\x20campaign\x20—\x20the\x20project\x20schedules\x20production\x20against\x20a\x20total\x20the\x20'+'backer\x20can\x20then\x20claw\x20back.\x20This\x20is\x20the\x20exact\x20face\x20the\x20ksr-tn-261026\x20run\x20proved\x20live\x20(CancelPledge\x20after\x20funded_released\x20'+'moved\x200.05\x20WOW\x20of\x20escrow\x20back\x20to\x20the\x20backer).','suggestion':'Remove\x20the\x20post-goal\x20cancel\x20rail\x20(node\x20+\x20forwards\x20+\x20its\x20refund\x20allocator\x20row).\x20Keep\x20ONE\x20buyer-cancellation\x20path:\x20the\x20'+'PRE-DEADLINE\x20withdrawal\x20from\x20the\x20entry\x20node,\x20gated\x20by\x20lte(context(Clock),\x20identifier[N](campaign_deadline_ms))\x20—\x20the\x20'+'ABSOLUTE\x20shared\x20deadline,\x20the\x20ksrq8-g-withdraw\x20form.\x20After\x20the\x20goal\x20decision\x20the\x20buyer\x27s\x20only\x20remedies\x20are\x20the\x20'+'post-delivery\x20return\x20rail\x20and\x20arbitration.\x20If\x20a\x20variant\x20genuinely\x20needs\x20a\x20cooling-off\x20window,\x20anchor\x20it\x20at\x20'+'min(deadline,\x20release+24h)\x20and\x20disclose\x20it\x20—\x20never\x20a\x20default\x20post-goal\x20window.'});if(b==='threshold'){const C=a['guards']??[],D=C['filter'](G=>G['host']==='repository'||/repository_write/i['test'](G['template_id'])),E=D['length']>0x0,F=D['some'](G=>{const H=(G['policy']?.['id_from']??'')['toLowerCase']();return H==='signer'||H==='clock';});if(!E)c['push']({'rule_id':'R-CROWDFUNDING-AGGREGATE','severity':'high','title':'crowdfunding_mode\x20\x27threshold\x27\x20gates\x20release\x20on\x20an\x20aggregate\x20with\x20no\x20write-bound\x20Repository\x20policy\x20(INV-E2)','detail':'The\x20threshold\x20total\x20is\x20an\x20escrow-bound\x20repository\x20sum\x20(query\x201179\x20→\x20U256,\x20per-row\x20min(row,\x20order.amount))\x20over\x20'+'ORDER-keyed\x20contribution\x20rows.\x20With\x20NO\x20write-bound\x20policy\x20the\x20rows\x20are\x20unauthenticated\x20—\x20anyone\x20could\x20inflate\x20'+'the\x20total\x20and\x20fake\x20a\x20\x27goal\x20met\x27\x20(R-X1-17\x20existence-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\x20an\x20identity\x20write_guard\x20'+'(order.owner==Signer\x20/\x20order.agent\x20has\x20Signer)\x20and\x20key\x20the\x20contribution\x20rows\x20by\x20the\x20funder\x27s\x20ORDER\x20(policy\x20'+'id_from\x20unset;\x20row\x20id\x20=\x20the\x20Order\x20address).\x20repository.move\x20only\x20asserts\x20the\x20write_guard\x20LIST\x20is\x20non-empty\x20'+'(E_POLICY_WRITE_GUARD_REQUIRED=22),\x20never\x20what\x20a\x20listed\x20guard\x20proves\x20—\x20a\x20placeholder\x20that\x20returns\x20true\x20is\x20an\x20'+'OPEN\x20write.'});else{if(F){const G=D['filter'](H=>{const I=(H['policy']?.['id_from']??'')['toLowerCase']();return I==='signer'||I==='clock';})['map'](H=>'\x27'+H['key']+'\x27')['join'](',\x20');c['push']({'rule_id':'R-CROWDFUNDING-AGGREGATE','severity':'high','title':'crowdfunding_mode\x20\x27threshold\x27\x20keys\x20contribution\x20rows\x20by\x20the\x20WALLET\x20(id_from\x20signer/clock)\x20on\x20'+G+'\x20—\x20the\x20pre-migration\x20shape\x20(INV-E2,\x20ksc-tn-261024\x20F-01/F-05)','detail':'Wallet-keyed\x20rows\x20feed\x20the\x20escrow-bound\x20sum\x20(query\x201179,\x20per-row\x20min(row,\x20order.amount))\x20ZERO\x20—\x20the\x20goal\x20gate\x20'+'silently\x20bricks\x20—\x20and\x20the\x20free-form\x20sum-where\x20(1174)\x20stays\x20self-reported,\x20so\x20a\x20backer\x20can\x20record\x201.0\x20for\x20a\x200.1\x20'+'pledge.\x20compile\x20hard-blocks\x20it\x20(CROWDFUNDING_SIGNER_KEYED_ROWS);\x20this\x20is\x20the\x20authoring-time\x20twin.','suggestion':'Key\x20the\x20contribution\x20rows\x20by\x20the\x20funder\x27s\x20ORDER:\x20policy\x20id_from\x20unset,\x20the\x20backer\x27s\x20tooling\x20submits\x20the\x20row\x20id\x20=\x20'+'their\x20Order\x20address\x20through\x20the\x20passport-bearing\x20data\x20write,\x20and\x20the\x20gate\x20passes\x20those\x20ORDER\x20addresses\x20as\x20the\x20aggregate\x27s\x20'+'candidate\x20ids.\x20Pair\x20the\x20gate\x20with\x20the\x20live-escrow\x20leg\x20(allocation.balance\x20query\x201051\x20via\x20convert_witness\x20'+'OrderAllocation\x20109,\x20>=\x20order.amount)\x20so\x20a\x20refunded/never-funded\x20order\x20can\x20neither\x20count\x20toward\x20the\x20goal\x20nor\x20be\x20'+'settled,\x20and\x20make\x20the\x20withdrawal\x20flow\x20ZERO\x20the\x20row\x20value\x20(an\x20upsert\x20of\x200\x20through\x20the\x20same\x20write\x20guard)\x20so\x20the\x20'+'valueMin:1\x20aggregate\x20predicate\x20stops\x20counting\x20it\x20even\x20when\x20the\x20row\x20itself\x20remains.'});}}}const q=a['build_notes']??[],s=/(attest|keeper|aggregate trust|read-?only sum|not a chain-?verified|independent recomputation)/i,w=/(not investment|non-?investment|no (?:investment )?return|never promise)/i,x=/(kyc|aml|securities|money-?transmission|regulatory|cross-border|compliance)/i,y=/(no-?refund|non-?refundable|keep-?it-?all)/i,z=[];if(b==='threshold'&&!q['some'](H=>s['test'](H)))z['push']('the\x20aggregate-trust\x20boundary\x20(the\x20funding\x20total\x20is\x20a\x20keeper-attested\x20Repository\x20sum,\x20NOT\x20a\x20chain-verified\x20money\x20oracle)');if(!q['some'](H=>w['test'](H)))z['push']('the\x20L-01\x20non-investment\x20statement\x20(never\x20promise\x20returns\x20/\x20promote\x20coin\x20price;\x20not\x20investment\x20advice\x20or\x20a\x20return\x20promise)');if(!q['some'](H=>x['test'](H)))z['push']('the\x20L-05\x20KYC/AML\x20+\x20cross-border\x20regulatory\x20caution\x20(HIGH\x20intensity)');if(b==='flexible'&&!q['some'](H=>y['test'](H)))z['push']('the\x20flexible\x20keep-it-all\x20NO-REFUND\x20posture\x20(contributions\x20non-refundable\x20once\x20the\x20deadline\x20passes;\x20no\x20refunds)');return z['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'+z['length']+'\x20(INV-E3)','detail':'Missing:\x20'+z['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;}function logisticsModeChecks(a){const b=a['logistics_mode'];if(b===undefined||b==='none')return[];const c=[],d=a['machine_shape']??[],e=d['some'](g=>g['named_operator']!==undefined||(g['from']??[])['some'](h=>typeof h!=='string'&&h['named_operator']!==undefined)),f=a['allocator']?.['rows']??[];if(b==='courier'){if(!e)c['push']({'rule_id':'R-LOGISTICS-COURIER','severity':'high','title':'logistics_mode\x20\x27courier\x27\x20declares\x20dispatched\x20riders\x20with\x20no\x20named_operator\x20handover\x20rail','detail':'A\x20dispatched\x20rider\x20is\x20NEITHER\x20a\x20permission\x20entity\x20NOR\x20the\x20buyer\x20—\x20the\x20only\x20forward\x20they\x20can\x20ever\x20pass\x20is\x20a\x20'+'namedOperator\x20roster\x20rail\x20(roster\x20written\x20per\x20order\x20by\x20the\x20dispatch\x20keeper\x20via\x20permission\x20index\x20221).\x20compile\x20'+'hard-blocks\x20the\x20missing\x20rail\x20(LOGISTICS_COURIER_RAIL_MISSING);\x20this\x20is\x20the\x20authoring-time\x20twin.','suggestion':'Bind\x20the\x20handover\x20forwards\x20(merchant→courier\x20pickup,\x20courier→buyer\x20drop-off)\x20with\x20named_operator\x20\x27<namespace>\x27\x20'+'and\x20disclose\x20the\x20roster\x20duty\x20in\x20a\x20build_note.\x20For\x20EXCLUSIVE\x20admission\x20—\x20non-roster\x20addresses\x20actually\x20BARRED,\x20not\x20'+'merely\x20members\x20authorized\x20—\x20also\x20mount\x20the\x20kernel\x20roster-membership\x20predicate\x20(query\x201575,\x20protocol\x20v138\x20flag)\x20on\x20'+'both\x20handover\x20edges\x20(template\x20tpl_forward_roster_member_gate);\x20the\x20rail\x20alone\x20AUTHORIZES\x20without\x20denying.\x20Also\x20keep\x20'+'the\x20delivery\x20fee\x20OFF\x20the\x20goods\x20pool:\x20a\x20SURPLUS\x20row\x20in\x20a\x20delivery-fee\x20family\x20drains\x20the\x20buyer\x27s\x20escrow\x20(compile\x20'+'LOGISTICS_COURIER_FEE_POOLED)\x20—\x20use\x20an\x20independent\x20Amount/Rate\x20leg\x20(the\x20fee\x20is\x20known\x20at\x20order\x20time).'});else{const g=/(deliver|courier|shipping|freight|ride|dispatch|logistic)/i,h=f['some'](j=>j['mode']==='surplus'&&g['test']((j['value_from']??'')+'\x20'+(j['recipient_key']??'')));h&&c['push']({'rule_id':'R-LOGISTICS-COURIER','severity':'high','title':'logistics_mode\x20\x27courier\x27\x20has\x20a\x20delivery-fee\x20SURPLUS\x20row\x20draining\x20the\x20goods\x20pool','detail':'A\x20surplus\x20leg\x20takes\x20the\x20remainder\x20of\x20the\x20pool\x20it\x20hangs\x20on\x20—\x20for\x20a\x20courier\x20build\x20that\x20pool\x20IS\x20the\x20buyer\x27s\x20goods\x20'+'escrow\x20(the\x20grab-pool\x20shape\x20the\x20affiliate\x20INV-D3\x20family\x20bans).\x20compile\x20hard-blocks\x20it\x20'+'(LOGISTICS_COURIER_FEE_POOLED);\x20this\x20is\x20the\x20authoring-time\x20twin.','suggestion':'Make\x20the\x20delivery\x20fee\x20an\x20INDEPENDENT\x20leg:\x20a\x20fixed\x20Amount\x20row\x20(the\x20buyer\x20sees\x20and\x20pays\x20the\x20fee\x20before\x20dispatch)\x20'+'or\x20a\x20Rate\x20row\x20off\x20a\x20dedicated\x20delivery-fee\x20pool\x20funded\x20separately\x20—\x20never\x20a\x20Surplus\x20drain\x20of\x20the\x20goods\x20pool.'});}}if(b==='pickup_point'){const j=(a['guards']??[])['some'](l=>l['template_id']==='pattern.time_lock_absolute'||l['template_id']==='tpl_time_lock_absolute_ms'),k=(a['guards']??[])['some'](l=>l['template_id']==='pattern.time_window_upper_bound'||l['template_id']==='tpl_time_window_upper'||l['template_id']==='tpl_time_window_upper_absolute_ms');(!j||!k)&&c['push']({'rule_id':'R-LOGISTICS-CUTOFF','severity':'high','title':'logistics_mode\x20\x27pickup_point\x27\x20is\x20missing\x20'+(!j?'the\x20absolute\x20batch-cutoff\x20gate':'')+(!j&&!k?'\x20and\x20':'')+(!k?'the\x20unclaimed-goods\x20exit\x20window':''),'detail':'Consolidation\x20batch\x20semantics\x20need\x20BOTH:\x20releases\x20anchor\x20on\x20the\x20SAME\x20shared\x20cutoff\x20clock\x20(per-order\x20entry+duration\x20'+'is\x20not\x20a\x20batch),\x20and\x20goods\x20never\x20picked\x20up\x20must\x20refund/return\x20at\x20a\x20bounded\x20deadline\x20(never\x20hold\x20open-ended).\x20compile\x20'+'hard-blocks\x20it\x20(LOGISTICS_PICKUP_CUTOFF_MISSING);\x20this\x20is\x20the\x20authoring-time\x20twin.','suggestion':'Add\x20a\x20pattern.time_lock_absolute\x20guard\x20on\x20the\x20batch\x20release\x20forward\x20AND\x20a\x20pattern.time_window_upper_bound\x20guard\x20on\x20'+'the\x20unclaimed-goods\x20refund/return\x20exit.'});}if(b==='carrier'){const l=/(track|shipping evidence|waybill|airbill|carrier record|parcel evidence)/i,m=(a['guards']??[])['some'](n=>n['host']==='machine'&&l['test']((n['key']??'')+'\x20'+n['purpose']));!m&&c['push']({'rule_id':'R-LOGISTICS-EVIDENCE','severity':'high','title':'logistics_mode\x20\x27carrier\x27\x20binds\x20no\x20shipping/tracking\x20evidence\x20guard','detail':'A\x20carrier\x20shipment\x20with\x20no\x20evidence\x20binding\x20has\x20no\x20dispute-ready\x20record\x20of\x20what\x20was\x20shipped\x20and\x20when.\x20The\x20retail\x20'+'idiom\x20(a\x20tracking-hash\x20repository_data_check\x20on\x20the\x20ship\x20forward,\x20written\x20by\x20an\x20authorized\x20writer)\x20is\x20the\x20MANDATORY\x20'+'floor.\x20compile\x20hard-blocks\x20it\x20(LOGISTICS_CARRIER_EVIDENCE_MISSING);\x20this\x20is\x20the\x20authoring-time\x20twin.','suggestion':'Add\x20a\x20pattern.repository_data_check\x20guard\x20on\x20the\x20ship\x20forward\x20keyed\x20to\x20a\x20tracking-hash\x20row;\x20pair\x20it\x20with\x20'+'pattern.repository_write_authorization\x20so\x20a\x20counterparty\x20cannot\x20pre-write\x20the\x20tracking\x20row.'});}{const n=/(lost|loss|damag|theft)/i,o=w=>w['replace'](/permanently lost/gi,''),p=/(transit loss|lost (?:parcel|package|goods|in transit)|in[- ]transit loss|carrier lost|loss (?:is |)remed|loss route|lost shipment)/i,q=d['some'](w=>n['test'](w['name'])||n['test'](w['role']))||(a['guards']??[])['some'](w=>w['host']==='machine'&&n['test'](o((w['key']??'')+'\x20'+w['purpose']))),s=(a['build_notes']??[])['some'](w=>p['test'](w));!q&&!s&&c['push']({'rule_id':'R-LOGISTICS-TRANSIT','severity':'high','title':'logistics_mode\x20\x27'+b+'\x27\x20has\x20no\x20in-transit\x20loss\x20rail\x20and\x20no\x20loss-remedy\x20disclosure','detail':'Goods\x20can\x20be\x20lost\x20or\x20damaged\x20between\x20handover\x20and\x20acceptance\x20in\x20EVERY\x20physical\x20mode\x20—\x20silence\x20means\x20the\x20buyer\x27s\x20funds\x20'+'strand\x20behind\x20an\x20undeliverable\x20order\x20with\x20no\x20taught\x20route\x20(the\x20STOP-NODE-FUND-EXIT-COVERAGE\x20logistics\x20specialization).\x20'+'compile\x20hard-blocks\x20it\x20(LOGISTICS_TRANSIT_LOSS_UNCOVERED);\x20this\x20is\x20the\x20authoring-time\x20twin.','suggestion':'Either\x20express\x20the\x20loss\x20waypoint\x20(a\x20lost-parcel\x20record\x20node,\x20or\x20a\x20loss-evidence\x20machine\x20guard)\x20or\x20add\x20a\x20build_note\x20'+'disclosing\x20the\x20remedy\x20route\x20(e.g.\x20the\x20buyer\x27s\x20arbitration\x20path\x20into\x20the\x20refund\x20rail;\x20the\x20carrier\x20claim\x20is\x20an\x20'+'off-chain\x20recovery).'});}if(b==='courier'||b==='pickup_point'){const w=/(dispatch|schedul|no.{0,24}oracle|no on-chain.{0,24}(dispatch|scheduler)|off-chain keeper|keeper.{0,40}dispatch|roster|named.?operator|permission.{0,12}221)/i,x=(a['build_notes']??[])['some'](y=>w['test'](y));!x&&c['push']({'rule_id':'R-LOGISTICS-DISCLOSURE','severity':'high','title':'logistics_mode\x20\x27'+b+'\x27\x20discloses\x20neither\x20dispatch\x20boundary','detail':'The\x20chain\x20has\x20NO\x20dispatch/scheduling\x20primitive\x20(dispatch\x20is\x20an\x20OFF-CHAIN\x20keeper\x20duty;\x20the\x20roster\x20rides\x20permission\x20'+'index\x20221)\x20and\x20NO\x20distance/weight/weather\x20oracle\x20(ETA,\x20route,\x20and\x20dynamic\x20pricing\x20are\x20NOT\x20chain-verifiable).\x20'+'Undisclosed,\x20a\x20builder\x20assumes\x20on-chain\x20dispatch\x20exists\x20and\x20designs\x20a\x20silent\x20brick.\x20compile\x20hard-blocks\x20it\x20'+'(LOGISTICS_DISPATCH_UNDISCLOSED);\x20this\x20is\x20the\x20authoring-time\x20twin.','suggestion':'Add\x20a\x20build_note\x20stating\x20WHO\x20dispatches\x20(the\x20keeper),\x20WHAT\x20the\x20keeper\x20writes\x20(the\x20namedOperator\x20roster,\x20per\x20'+'order/shift,\x20via\x20permission\x20index\x20221),\x20and\x20that\x20ETA/pricing\x20live\x20off-chain.'});}return c;}function allocatorRecipientId(a){return(a['recipient']??'?')+'/'+(a['recipient_key']??'');}function groupBuyBlockerChecks(a){const b=[],c=a['build_notes']??[],d=[...c,a['allocator']?.['description']??'',a['key_risk']??'',...(a['machine_shape']??[])['map'](E=>E['role']),...(a['guards']??[])['map'](E=>E['purpose'])],f=a['allocator']?.['rows']??[],g=a['machine_shape']??[],h=numericFeeParam(a['fee_params']??{},/^platform_(commission|take|fee)_bps$/)===0x0||numericFeeParam(a['fee_params']??{},/^(courier_|platform_)?retention_bps$/)===0x2710,j=d['some'](E=>/(?:zero|0%|no)\s+(?:platform\s+)?(?:commission|take|cut|rate)/i['test'](E)),k=f['some'](E=>{if(E['recipient']!=='entity')return![];if(!/^(platform|tool.?fee)/i['test'](E['recipient_key']??''))return![];return typeof E['value']==='number'&&E['value']>0x0;}),l=d['some'](E=>/(?:membership|admission|joining|access)\s+fee|traffic\s+compensat|separately\s+priced|separate\s+fee\s+service/i['test'](E));(h||j)&&k&&!l&&b['push']({'rule_id':'R-GB-ALLOC-CONSISTENCY','severity':'high','title':'ZERO_TAKE_RATE_HIDDEN_FEE:\x20a\x20zero-take\x20claim\x20coexists\x20with\x20a\x20positive\x20platform\x20leg\x20and\x20no\x20admission/traffic-compensation\x20disclosure','detail':'The\x20template\x20claims\x20the\x20platform\x20takes\x20nothing\x20while\x20an\x20allocator\x20row\x20still\x20pays\x20a\x20platform\x20Entity\x20—\x20the\x20\x27zero\x20take\x27\x20'+'is\x20only\x20honest\x20when\x20the\x20platform\x27s\x20real\x20income\x20lives\x20on\x20a\x20SEPARATE,\x20separately-priced\x20surface\x20(a\x20membership/admission-fee\x20'+'Service)\x20or\x20is\x20compensated\x20another\x20way\x20(disclosed\x20traffic\x20compensation).\x20Silence\x20here\x20is\x20the\x20hidden-fee\x20pattern\x20the\x20'+'UU\x20errand\x20dossier\x20defined\x20blocker\x20#1\x20for.\x20The\x20shipped\x20benchmark\x20shapes\x20do\x20not\x20fire:\x20their\x20platform\x20legs\x20carry\x20value\x200.','suggestion':'Either\x20zero\x20the\x20platform\x20leg,\x20or\x20add\x20a\x20build_note\x20disclosing\x20WHERE\x20the\x20platform\x27s\x20income\x20comes\x20from\x20(a\x20separately-priced\x20'+'membership/admission-fee\x20Service,\x20or\x20an\x20explicit\x20traffic-compensation\x20arrangement)\x20so\x20the\x20zero-take\x20claim\x20is\x20auditable.'});const n=numericFeeParam(a['fee_params']??{},/^(min|minimum)_order(_price)?$/),o=numericFeeParam(a['fee_params']??{},/^supply(_unit)?_price$/);n!==undefined&&o!==undefined&&o>=n&&b['push']({'rule_id':'R-GB-ALLOC-CONSISTENCY','severity':'high','title':'SUPPLY_PRICE_ABOVE_MIN_ORDER:\x20supply_price\x20('+o+')\x20>=\x20min_order_price\x20('+n+')\x20—\x20the\x20reseller\x20margin\x20is\x20negative\x20or\x20zero\x20by\x20construction','detail':'A\x20reseller\x20whose\x20supply\x20price\x20is\x20at\x20or\x20above\x20their\x20minimum-order\x20floor\x20earns\x20nothing\x20on\x20every\x20admissible\x20order,\x20and\x20any\x20'+'fixed\x20fulfillment\x20leg\x20then\x20hard-subtracts\x20past\x20the\x20balance\x20(alloc()\x20asserts\x20balance\x20>=\x20fix,\x20EINSUFFICIENT_BALANCE)\x20—\x20the\x20'+'order\x20can\x20neither\x20settle\x20nor\x20refund.\x20This\x20is\x20the\x20kuaituantuan\x20challenger\x27s\x20CR-02\x20deadlock\x20as\x20a\x20template-data\x20check.','suggestion':'Set\x20supply_price\x20strictly\x20BELOW\x20min_order_price,\x20or\x20drop\x20the\x20reseller\x20overlay\x20—\x20the\x20margin\x20must\x20live\x20strictly\x20between\x20'+'the\x20two\x20numbers.'});const q=numericFeeParam(a['fee_params']??{},/^total_(take|fee|commission)_bps$/),s=numericFeeParam(a['fee_params']??{},/^leader_commission_bps$/),w=numericFeeParam(a['fee_params']??{},/^(platform_fee|platform_commission|platform_tool_fee)_bps$/);if(q!==undefined&&s!==undefined&&w!==undefined){const E=s+w;E!==q&&b['push']({'rule_id':'R-GB-ALLOC-CONSISTENCY','severity':'high','title':'TIER_COMMISSION_SUM_MISMATCH:\x20leader_commission_bps\x20('+s+')\x20+\x20platform\x20fee\x20bps\x20('+w+')\x20=\x20'+E+'\x20!=\x20total_take_bps\x20('+q+')','detail':'The\x20tier\x20split\x20(leader\x20share\x20+\x20platform\x20share)\x20is\x20declared\x20as\x20ONE\x20total\x20take;\x20when\x20the\x20two\x20legs\x20do\x20not\x20sum\x20to\x20it,\x20the\x20'+'generation\x20rebalance\x20cannot\x20hold\x20the\x20declared\x20economics\x20and\x20one\x20leg\x20silently\x20drifts.\x20The\x20tier\x20difference\x20is\x20WHO\x20gets\x20'+'how\x20much\x20of\x20the\x20SAME\x20total\x20—\x20never\x20two\x20independent\x20rates.','suggestion':'Make\x20leader_commission_bps\x20+\x20platform_fee_bps\x20equal\x20total_take_bps\x20(or\x20drop\x20total_take_bps\x20and\x20declare\x20the\x20two\x20legs\x20'+'independently\x20with\x20a\x20build_note\x20stating\x20their\x20declared\x20sum).'});}if(n!==undefined){const F=f['filter'](G=>G['track']==='settlement'&&G['mode']==='amount'&&typeof G['value']==='number'&&G['value']>=n);F['length']>0x0&&b['push']({'rule_id':'R-GB-ALLOC-CONSISTENCY','severity':'high','title':'FIXED_LEG_EXCEEDS_MIN_ORDER:\x20'+F['length']+'\x20fixed\x20Amount\x20settlement\x20leg(s)\x20>=\x20min_order_price\x20('+n+')\x20—\x20hard\x20deadlock','detail':'A\x20fixed\x20Amount\x20leg\x20at\x20or\x20above\x20the\x20order\x20floor\x20subtracts\x20the\x20WHOLE\x20(or\x20more\x20than\x20the)\x20escrowed\x20total:\x20alloc()\x20asserts\x20'+'balance\x20>=\x20fix,\x20so\x20an\x20order\x20at\x20the\x20floor\x20can\x20neither\x20settle\x20NOR\x20refund\x20—\x20every\x20admissible\x20order\x20deadlocks.\x20This\x20is\x20the\x20'+'taocaicai\x20absolute\x20gate;\x20it\x20precedes\x20the\x20ratio\x20check\x20(#6),\x20which\x20governs\x20sustainability,\x20not\x20liveness.','suggestion':'Reduce\x20the\x20fixed\x20leg\x20strictly\x20below\x20min_order_price\x20(the\x20FULFILLMENT_FIXED_LEG_RATIO\x20bar\x20adds\x20the\x2025-30%\x20'+'sustainability\x20ceiling\x20on\x20top\x20of\x20this\x20liveness\x20floor),\x20or\x20convert\x20it\x20to\x20a\x20Rate\x20leg.'});}if(f['length']>0x0){const G=new Map();for(const I of f){const J=(I['guard_key']??'?')+'::'+allocatorRecipientId(I),K=G['get'](J)??new Set();if(I['mode']==='rate'||I['mode']==='surplus')K['add'](I['mode']);G['set'](J,K);}const H=[...G['entries']()]['filter'](([,L])=>L['has']('rate')&&L['has']('surplus'))['map'](([L])=>L);H['length']>0x0&&b['push']({'rule_id':'R-GB-ALLOC-CONSISTENCY','severity':'high','title':'COMMISSION_AND_SURPLUS_COEXIST:\x20recipient(s)\x20'+H['join'](',\x20')+'\x20hold\x20BOTH\x20a\x20Rate\x20leg\x20and\x20a\x20Surplus\x20leg\x20in\x20the\x20SAME\x20allocator','detail':'Rate\x20and\x20Surplus\x20are\x20two\x20different\x20claims\x20on\x20the\x20SAME\x20money:\x20a\x20recipient\x20holding\x20both\x20is\x20paid\x20its\x20rate\x20share\x20AND\x20'+'the\x20residual\x20—\x20the\x20jd-pingpin\x20double-pay.\x20A\x20recipient\x27s\x20claim\x20shape\x20is\x20ONE\x20of\x20the\x20two;\x20the\x20residual\x20either\x20goes\x20to\x20'+'them\x20or\x20it\x20does\x20not.','suggestion':'Split\x20the\x20recipient\x20into\x20two\x20identities\x20(a\x20commission\x20Entity\x20and\x20a\x20residual\x20Entity)\x20or\x20drop\x20one\x20of\x20the\x20legs\x20—\x20never\x20'+'let\x20one\x20identity\x20draw\x20both\x20claim\x20shapes\x20in\x20the\x20same\x20allocator.'});}if(s!==undefined&&w!==undefined){const L=s+w,M=[a['variant'],...c,a['allocator']?.['description']??'']['join']('\x20'),N=[[/fresh|grocery|produce|vegetable|fruit|cold.?chain/i,0xdac,'fresh\x20grocery'],[/prepared|ready.?to.?eat|hot\s?food|deli/i,0x1388,'prepared\x20food'],[/packaged|snack|canned|dry\s?goods|standard goods/i,0x1770,'packaged\x20goods'],[/errand|cleaning|repair|installation/i,0x1f40,'services']];for(const [O,P,Q]of N){if(!O['test'](M))continue;L>P&&b['push']({'rule_id':'R-GB-ALLOC-CONSISTENCY','severity':'high','title':'COMMISSION_EXCEEDS_CATEGORY_MARGIN:\x20leader_commission_bps\x20+\x20platform\x20fee\x20bps\x20=\x20'+L+'\x20>\x20'+P+'\x20('+Q+'\x20ceiling)','detail':'The\x20combined\x20take\x20exceeds\x20the\x20category\x27s\x20margin\x20ceiling\x20—\x20the\x20Meituan\x20Youxuan\x20failure\x20mode:\x20a\x20fulfillment\x20cost\x20'+'structure\x20the\x20take\x20rate\x20cannot\x20carry,\x20so\x20every\x20order\x20LOSES\x20money\x20and\x20volume\x20only\x20accelerates\x20the\x20loss.\x20The\x20ceiling\x20'+'table\x20comes\x20from\x20the\x20dossier\x27s\x20cross-sample\x20margin\x20study\x20(fresh\x203500\x20/\x20prepared\x205000\x20/\x20packaged\x206000\x20/\x20service\x208000).','suggestion':'Bring\x20the\x20combined\x20take\x20to\x20<=\x20'+P+'\x20bps\x20for\x20a\x20'+Q+'\x20build,\x20or\x20move\x20the\x20cost\x20structure\x20(fixed\x20legs,\x20logistics\x20mode)\x20until\x20the\x20unit\x20economics\x20close.'});break;}}const x=f['some'](R=>/leader/i['test'](R['recipient_key']??''));if(a['archetype']==='challenger'&&x){const R=d['some'](S=>{const T=/(?:1002|settl\w+)/i['test'](S)&&/(?:1000|leader)/i['test'](S);if(!T)return![];return/different|distinct|separate|differ|not the same|another address|own address|must not be the same/i['test'](S);});!R&&b['push']({'rule_id':'R-GB-EXIT-AVAILABILITY','severity':'high','title':'CHALLENGER_SETTLER_IS_LEADER:\x20a\x20challenger\x20leader\x20build\x20discloses\x20no\x20distinct-address\x20requirement\x20between\x20the\x20settlement\x20slot\x20and\x20the\x20leader\x20slot','detail':'In\x20the\x20challenger\x20shape\x20the\x20LEADER\x20sources\x20and\x20fulfills;\x20the\x20settlement\x20executor\x20(permission\x20index\x201002)\x20is\x20the\x20'+'counterweight\x20that\x20drives\x20the\x20buyer\x27s\x20two\x20fund\x20exits\x20(the\x20unclaimed/missed\x20refund\x20and\x20the\x20arbitration\x20refund).\x20If\x20'+'the\x20builder\x20binds\x201002\x20to\x20the\x20leader\x27s\x20own\x20address\x20(1000),\x20BOTH\x20exits\x20depend\x20on\x20one\x20party\x27s\x20goodwill\x20—\x20the\x20leader\x20'+'walks\x20away\x20and\x20every\x20buyer\x27s\x20money\x20locks.\x20The\x20template\x20must\x20TEACH\x20the\x20distinctness;\x20it\x20cannot\x20be\x20expressed\x20as\x20a\x20'+'guard\x20(the\x20two\x20slots\x20bind\x20different\x20Permission\x20entities\x20at\x20build\x20time).','suggestion':'Add\x20a\x20build_note:\x20\x27the\x20settling\x20permission\x20slot\x20(1002)\x20MUST\x20be\x20bound\x20to\x20a\x20DIFFERENT\x20address\x20from\x20the\x20leader\x20slot\x20'+'(1000)\x20—\x20bind\x20it\x20to\x20the\x20platform\x27s\x20settlement\x20keeper\x20or\x20an\x20independent\x20operator,\x20never\x20the\x20leader\x27.'});}const y=[];for(const S of g){for(const T of S['from']??[]){if(typeof T==='string')continue;if(!T['named_operator'])continue;const U=T['forward']??'';(/hand.?over/i['test'](U)||/hand.?over/i['test'](S['name']))&&y['push']((T['prev']||'(entry)')+'\x20--'+(U||'advance')+'-->\x20'+S['name']);}}const z=g['some'](V=>(V['from']??[])['some'](W=>typeof W!=='string'&&W['operator']==='order_payer'&&/collect|pick.?up|receipt|confirm/i['test'](W['forward']??V['name'])));y['length']>0x0&&!z&&b['push']({'rule_id':'R-GB-EXIT-AVAILABILITY','severity':'high','title':'LEADER_SELF_HANDOVER_EDGE:\x20'+y['length']+'\x20handover\x20edge(s)\x20with\x20NO\x20buyer-signed\x20collect/receipt\x20edge\x20—\x20the\x20handover\x20signature\x20is\x20the\x20only\x20proof','detail':'A\x20third-party\x20handover\x20whose\x20ONLY\x20evidence\x20is\x20the\x20handover\x20signer\x27s\x20own\x20signature\x20proves\x20nothing\x20when\x20that\x20signer\x20is\x20the\x20'+'party\x20that\x20loses\x20money\x20by\x20admitting\x20a\x20failed\x20handover\x20(the\x20leader\x20self-certifying\x20their\x20own\x20delivery).\x20The\x20narrowed\x20rule\x20'+'(the\x20Amazon\x20Hub\x20Locker\x20correction)\x20fires\x20only\x20when\x20no\x20buyer-signed\x20collect\x20edge\x20exists:\x20with\x20the\x20buyer\x27s\x20own\x20'+'confirmation\x20edge\x20present,\x20the\x20buyer\x27s\x20signature\x20is\x20the\x20STRONGER\x20evidence\x20and\x20the\x20handover\x20edge\x20is\x20auxiliary.','suggestion':'Add\x20a\x20buyer-signed\x20collect/receipt\x20edge\x20(operator\x20order_payer\x20+\x20an\x20identity_check_order_holder\x20guard)\x20from\x20the\x20handover\x20'+'node,\x20or\x20switch\x20the\x20arrival\x20design\x20to\x20the\x20automated/locker\x20variant\x20where\x20the\x20buyer\x27s\x20access-code\x20retrieval\x20is\x20the\x20receipt.'});const A=a['logistics_mode']==='pickup_point'||g['some'](V=>/at_point|pickup|self.?pick/i['test'](V['name'])),B=g['some'](V=>/unclaimed|abandon|refund|withdraw|cancel/i['test'](V['name'])||(V['from']??[])['some'](W=>typeof W!=='string'&&/unclaimed|abandon|refund|withdraw|cancel/i['test'](W['forward']??'')));A&&!B&&b['push']({'rule_id':'R-GB-EXIT-AVAILABILITY','severity':'medium','title':'ABANDON_EXIT_MISSING:\x20a\x20pickup-point\x20fulfillment\x20shape\x20with\x20no\x20abandon-family\x20node/edge','detail':'Goods\x20sitting\x20at\x20a\x20pickup\x20point\x20with\x20no\x20unclaimed-refund\x20/\x20abandon-self-heal\x20exit\x20strand\x20silently:\x20the\x20buyer\x20who\x20never\x20'+'comes,\x20never\x20refunds,\x20and\x20the\x20escrow\x20waits\x20on\x20a\x20keeper\x20timeout\x20this\x20shape\x20does\x20not\x20declare.\x20The\x20GF2-30\x20idiom\x20(the\x20'+'buyer\x20refunds\x20THEMSELVES\x20while\x20the\x20pickup\x20window\x20is\x20open)\x20is\x20the\x20benchmark\x20self-heal;\x20a\x20keeper\x20timeout\x20exit\x20is\x20the\x20'+'fallback.','suggestion':'Add\x20an\x20unclaimed/abandon\x20exit:\x20a\x20buyer\x20self-serve\x20refund\x20edge\x20(order_payer,\x20time_window_upper_bound\x20on\x20the\x20pickup-node\x20'+'entry)\x20or\x20a\x20keeper\x20timeout\x20advance,\x20disclosed\x20in\x20a\x20build_note.'});if(n!==undefined&&n>0x0){const V=f['filter'](Z=>Z['track']==='settlement'&&Z['mode']==='amount'&&typeof Z['value']==='number')['reduce']((Z,a0)=>Z+a0['value'],0x0),W=V/n,X=d['some'](Z=>/overseas|cross.?border|international/i['test'](Z)),Y=X?0.25:0.3;W>Y&&W<=0x1&&b['push']({'rule_id':'R-GB-UNIT-ECONOMICS','severity':W>0.3?'high':'medium','title':'FULFILLMENT_FIXED_LEG_RATIO:\x20fixed\x20Amount\x20settlement\x20legs\x20sum\x20to\x20'+V+'\x20=\x20'+(W*0x64)['toFixed'](0x1)+'%\x20of\x20min_order_price\x20('+n+')\x20>\x20'+(Y*0x64)['toFixed'](0x0)+'%\x20bar','detail':'The\x20fixed\x20fulfillment\x20cost\x20per\x20order\x20exceeds\x20the\x20sustainable\x20share\x20of\x20the\x20order\x20floor\x20—\x20the\x20Meituan\x20Youxuan\x20failure\x20'+'mode\x20at\x20template\x20time:\x20volume\x20scales\x20the\x20LOSS.\x2030%\x20is\x20the\x20domestic\x20bar;\x20an\x20overseas\x20build\x20(cross-border\x20fulfillment\x20'+'costs)\x20carries\x20the\x20tighter\x2025%\x20bar,\x20detected\x20from\x20the\x20template\x27s\x20own\x20overseas\x20disclosure.\x20The\x20absolute\x20liveness\x20gate\x20'+'(FIXED_LEG_EXCEEDS_MIN_ORDER)\x20covers\x20ratio\x20>=\x201;\x20this\x20rule\x20governs\x20the\x20band\x20below\x20it.','suggestion':'Cut\x20the\x20fixed\x20legs\x20below\x20'+(Y*0x64)['toFixed'](0x0)+'%\x20of\x20the\x20floor\x20(subsume\x20them\x20into\x20the\x20goods\x20price\x20as\x20a\x20Rate\x20split),\x20or\x20raise\x20min_order_price\x20to\x20carry\x20them.'});}const C=/\b(never|no|not|don'?t|cannot|must not|avoid|prohibit\w*|forbid\w*|absent|impossible|unenforceable|inexpressible|instead of|rather than|without|discard\w*|drop\w*|refut\w*|considered and DISCARDED)\b/i,D=[];for(const Z of d){for(const a0 of Z['split'](/[.;]/)){if(C['test'](a0))continue;const a1=/\b(multi.?(level|layer|tier)|pyramid|mlm|headhunt\w*|downline|recruit\w*)\b/i['test'](a0)&&/\b(reward|bonus|commission|incentive|rebate|payout)\b/i['test'](a0),a2=/\b(cumulat\w*|accumulat\w*|points?|badges?)\b/i['test'](a0)&&/\b(reward|bonus|payout|earn)\b/i['test'](a0)&&/\b(across|per|every|each|total|count)\b/i['test'](a0),a3=/\b(?:per|for each|every)\s+\d+\s+(?:orders?|referrals?|members?|invites?|signups?|heads?)\b/i['test'](a0);if(a1||a2||a3)D['push'](a0['trim']()['slice'](0x0,0xa0));}}return D['length']>0x0&&b['push']({'rule_id':'R-GB-UNIT-ECONOMICS','severity':'high','title':'TIERED_INCENTIVE_ON_CHAIN:\x20'+D['length']+'\x20affirmative\x20tiered/cumulative/per-head\x20incentive\x20claim(s)\x20the\x20chain\x20cannot\x20express','detail':'The\x20chain\x20expresses\x20a\x20commission\x20as\x20ONE\x20layer,\x20per-order,\x20fixed-ratio\x20(Rate\x20legs).\x20A\x20multi-tier\x20ladder,\x20a\x20cross-order\x20'+'cumulative\x20counter,\x20or\x20a\x20per-head-count\x20payment\x20needs\x20either\x20a\x20cross-order\x20aggregate\x20as\x20a\x20PAYMENT\x20condition\x20(the\x20read-only\x20'+'repository\x20aggregates\x20gate\x20nothing\x20as\x20a\x20payment\x20condition\x20—\x20a\x20guard\x20built\x20on\x20one\x20is\x20permanently\x20unsatisfiable\x20and\x20strands\x20'+'the\x20funding)\x20or\x20cross-order\x20identity\x20bookkeeping\x20no\x20primitive\x20provides.\x20Affirmative\x20claims\x20found:\x20'+D['slice'](0x0,0x3)['join']('\x20|\x20'),'suggestion':'Restructure\x20the\x20incentive\x20to\x20a\x20single-layer\x20per-order\x20Rate\x20leg\x20or\x20a\x20per-order\x20claim\x20Reward;\x20keep\x20multi-tier/cumulative\x20'+'incentives\x20OFF\x20the\x20machine\x20as\x20an\x20off-chain\x20loyalty\x20program,\x20disclosed\x20as\x20such.'}),b;}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\x20'+'unconditionally\x20—\x20BSX-F07:\x20allow_zero_total\x20waives\x20nothing);\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 rewardScaleChecks(a){const b=(a['guards']??[])['filter'](d=>d['host']==='reward');if(b['length']===0x0)return[];const c=b['filter'](d=>d['params']!==undefined&&d['params']['reward_claim_amount']!==undefined)['map'](d=>d['key']??d['template_id']);if(c['length']===0x0)return[];return[{'rule_id':'R-REWARD-SCALE','severity':'medium','title':'Reward-claim\x20guard(s)\x20['+c['join'](',\x20')+']\x20hard-pin\x20the\x20per-claim\x20bounty\x20(reward_claim_amount)\x20in\x20template\x20data','detail':'A\x20spec-level\x20reward_claim_amount\x20pin\x20DEFEATS\x20the\x20T-02\x20compile\x20derivation\x20(2%\x20of\x20the\x20cheapest\x20'+'positive\x20SKU,\x20floored\x20at\x201\x20smallest\x20unit)\x20—\x20spec\x20params\x20beat\x20build\x20inputs,\x20so\x20every\x20adopter\x20gets\x20'+'the\x20same\x20fixed\x20bounty\x20regardless\x20of\x20their\x20SKU\x20prices.\x20The\x20shipped\x20templates\x27\x20former\x201000000000\x20'+'pin\x20was\x2050x\x20a\x200.02-WOW\x20SKU:\x20every\x20claimed\x20order\x20paid\x20out\x20more\x20than\x20the\x20sale\x20earned,\x20and\x20no\x20audit\x20'+'flagged\x20it\x20(bsn7-tn-261026).\x20Template-level\x20pins\x20must\x20be\x20conscious\x20economics\x20rulings,\x20not\x20defaults.','suggestion':'Remove\x20the\x20reward_claim_amount\x20param\x20from\x20the\x20guard\x20spec\x20and\x20let\x20compile\x20derive\x20the\x20bounty\x20from\x20'+'the\x20adopter\x27s\x20sales\x20catalog;\x20if\x20a\x20fixed\x20bounty\x20is\x20the\x20template\x27s\x20deliberate\x20economics\x20(e.g.\x20a\x20'+'denominated\x20loyalty\x20point),\x20restate\x20the\x20pin\x20in\x20the\x20build\x20notes\x20WITH\x20the\x20ratio\x20rationale\x20—\x20the\x20'+'plan\x20audit\x20(PLAN-REWARD-SCALE-01)\x20still\x20judges\x20the\x20resulting\x20ratio\x20against\x20the\x20catalog.'}];}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.'}];}const PROSE_REVIEW_MODE_CLAIM=/(?<!inputs\.)\breview_mode\s*[=:]\s*["']?(none|review|review_reward)\b/gi,PROSE_OFFERING_CONTEXT=/inputs?\b|addable|per[ -]?build|opt[ -]?in|via the input|override/i;function phantomReviewModeFinding(a,b){return{'rule_id':'PROSE-CAPABILITY-01','severity':'high','title':'Build\x20prose\x20claims\x20review_mode=\x27'+a+'\x27\x20but\x20the\x20template\x20declares\x20\x27'+b+'\x27\x20'+'(phantom\x20capability)','detail':'The\x20compiled\x20service\x20is\x20built\x20from\x20the\x20DECLARED\x20review_mode\x20(\x27'+b+'\x27),\x20so\x20a\x20prose\x20'+('claim\x20of\x20\x27'+a+'\x27\x20ships\x20a\x20service\x20without\x20the\x20promised\x20review\x20rail\x20while\x20the\x20build\x20')+'notes\x20tell\x20the\x20merchant\x20(and\x20through\x20them\x20the\x20buyer)\x20it\x20exists\x20—\x20a\x20template-level\x20false\x20'+'promise\x20(bstn-tn-261024\x20F-01:\x20the\x20licensing\x20build\x20note\x20promised\x20a\x20review\x20route\x20the\x20shape\x20'+'could\x20never\x20carry).\x20Compile\x20gates\x20the\x20reviewed\x20node\x20against\x20the\x20declared\x20mode\x20only\x20'+'(REVIEW_NODE_MISSING);\x20it\x20cannot\x20see\x20prose.','suggestion':'Make\x20the\x20prose\x20tell\x20the\x20truth:\x20either\x20set\x20the\x20template\x27s\x20review_mode\x20to\x20\x27'+a+'\x27\x20AND\x20'+'ship\x20the\x20matching\x20shape\x20(reviewed\x20node\x20+\x20rail,\x20reward\x20guards\x20when\x20review_reward),\x20or\x20'+'rewrite\x20the\x20claim\x20as\x20per-build\x20availability\x20—\x20e.g.\x20\x22addable\x20per-build\x20via\x20'+('inputs.review_mode=\x27'+a+'\x27\x22\x20—\x20only\x20where\x20the\x20shape\x20actually\x20supports\x20the\x20addition.')};}function proseCapabilityChecks(a,b=a){const c=a['review_mode']??'none';for(const f of machineProseFields(b)){const g=proseClaim(b,f['address'],'review_mode');if(typeof g==='string'&&g!==c)return[phantomReviewModeFinding(g,c)];}const d=[],e=[...a['build_notes']??[],a['allocator']['description'],...a['trust_mechanisms']??[]];for(const h of e){for(const j of h['split'](/[;\n]/)){const k=[...j['matchAll'](PROSE_REVIEW_MODE_CLAIM)];if(k['length']===0x0||PROSE_OFFERING_CONTEXT['test'](j))continue;for(const l of k){const n=l[0x1]['toLowerCase']();if(n===c)continue;d['push'](phantomReviewModeFinding(n,c));break;}if(d['length']>0x0)return d;}}return d;}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'||e['type']==='query_repository_data_sum_where_bound'){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).\x20A\x20Signer-keyed\x20review\x20TEXT\x20row\x20(custom\x20policies;\x20the\x20compile-emitted\x20\x27review\x27\x20default\x20is\x20'+'order-keyed\x20since\x20F09,\x20yfd-ln-261024)\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 repoDataHasRef(a){if(a['type']==='query'){const c=a['query'];if(typeof c==='string'&&c['trim']()['toLowerCase']()==='repository.data\x20has')return!![];if(c===0x48e||c==='1166')return!![];}const b=a['type'];return typeof b==='string'&&b['toLowerCase']()==='query_repository_data_has';}function subtreeRefsRepoDataHas(a){if(Array['isArray'](a))return a['some'](subtreeRefsRepoDataHas);if(typeof a!=='object'||a===null)return![];const b=a;if(repoDataHasRef(b))return!![];return Object['values'](b)['some'](subtreeRefsRepoDataHas);}export function rootNegatesRepoDataHasTemplateRoot(a){if(Array['isArray'](a))return a['some'](rootNegatesRepoDataHasTemplateRoot);if(typeof a!=='object'||a===null)return![];const b=a;if(b['type']==='logic_not'&&subtreeRefsRepoDataHas(b['node']))return!![];return Object['values'](b)['some'](rootNegatesRepoDataHasTemplateRoot);}function repoWriteOnceIdiomChecks(a){const b=a['guards']??[],c=[];for(const d of b){if(d['host']!=='repository')continue;if(!d['template_id']?.['startsWith']('tpl_'))continue;const e=GUARD_TEMPLATES['find'](f=>f['id']===d['template_id']);if(!e?.['example_root'])continue;rootNegatesRepoDataHasTemplateRoot(e['example_root'])&&c['push']('\x27'+(d['key']??d['template_id'])+'\x27\x20->\x20'+d['template_id']);}if(c['length']===0x0)return[];return[{'rule_id':'R-REPO-WRITE-ONCE-INEFFECTIVE','severity':'critical','title':'Repository\x20write\x20guard(s)\x20['+c['join'](',\x20')+']\x20negate\x20the\x20row-existence\x20probe\x20—\x20the\x20write-once\x20leg\x20is\x20INEFFECTIVE\x20and\x20must\x20not\x20publish','detail':'The\x20write\x20guard\x20is\x20verified\x20INSIDE\x20the\x20same\x20PTB\x20as\x20the\x20write,\x20before\x20the\x20row\x20exists:\x20a\x20logic_not\x20over\x20'+'\x22repository.data\x20has\x22\x20(1166)\x20always\x20evaluates\x20the\x20PRE-write\x20state,\x20so\x20the\x20leg\x20cannot\x20enforce\x20write-once.\x20'+'Mainnet\x20A/B\x20(ofn-mn-261012\x20F-02):\x20the\x20identical\x20guard\x20minus\x20the\x20leg\x20succeeded,\x20and\x20the\x20author\x20then\x20'+'overwrote\x20their\x20own\x205-star\x20review\x20with\x201\x20star.\x20A\x20defence\x20that\x20cannot\x20be\x20enforced\x20is\x20worse\x20than\x20none\x20—\x20'+'the\x20publish\x20gate\x20flags\x20it\x20INEFFECTIVE\x20instead\x20of\x20accepting\x20it.','suggestion':'Drop\x20the\x20negated-existence\x20leg\x20and\x20enforce\x20write-once\x20with\x20a\x20primitive\x20that\x20actually\x20binds:\x20'+'PolicyRule.write_once=true\x20on\x20the\x20target\x20policy\x20(a\x20second\x20write\x20to\x20the\x20same\x20id\x20aborts\x20with\x20repository\x20'+'error\x2024,\x20E_POLICY_WRITE_ONCE_CONFLICT,\x20live-verified\x20amz9-ln-261023),\x20or\x20scope\x20the\x20ONCE(255)\x20submission\x20'+'slot\x20(per\x20guard-pool\x20—\x20pair\x20with\x20the\x20order\x20anchor\x20R-ANCHOR-01)\x20/\x20the\x20254\x20task-binding\x20slot\x20for\x20'+'order-bound\x20rails.'}];}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 d=b[a['value_from']];if(typeof d==='number')return d;if(typeof d==='string'&&/^\d+(\.\d+)?$/['test'](d['trim']()))return Number(d);}const c=a['value_from_complement'];if(c!==undefined){const e=b[c],f=typeof e==='number'?e:typeof e==='string'&&/^\d+(\.\d+)?$/['test'](e['trim']())?Number(e):NaN;if(Number['isFinite'](f))return 0x2710-f;}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,w=!![];for(const x of c){const y=railValue(x,b);if(y===null)w=![];else s+=y;}m['set']('settlement',{'label':'settlement','sum':s,'resolvable':w});}if(k!==undefined){const z=[...m['values']()]['filter'](A=>A['resolvable']&&A['sum']>k);if(z['length']>0x0)return[{'rule_id':'R-FAMT-SCALE','severity':'critical','title':'Absolute\x20Amount\x20rails\x20exceed\x20the\x20minimum\x20post-discount\x20payable\x20('+z['map'](A=>A['label']+':\x20'+A['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'+z['map'](A=>A['label'])['join'](',\x20')+'.'),'suggestion':'Shrink\x20the\x20rails\x20to\x20fit\x20the\x20discounted\x20floor\x20('+z['map'](A=>A['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'](A=>A['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.\x20RUNTIME\x20'+'ENFORCEMENT\x20FACE:\x20this\x20advisory\x20does\x20NOT\x20mean\x20the\x20shape\x20ships\x20unguarded\x20—\x20the\x20buy\x20path\x20carries\x20the\x20fixed-leg\x20'+'completion\x20gate\x20(order_below_fixed_leg_sum,\x20b6-11\x20family):\x20it\x20computes\x20the\x20minimum\x20completion-route\x20fixed-leg\x20'+'sum\x20for\x20THIS\x20machine\x20(completion\x20routes\x20only\x20—\x20refund/cancel\x20early-exit\x20routes\x20are\x20excluded,\x20yfd-ln-261024\x20F04)\x20'+'and\x20rejects\x20the\x20buy\x20before\x20any\x20money\x20moves\x20when\x20the\x20discounted\x20payable\x20cannot\x20cover\x20it.\x20With\x20that\x20gate\x20live\x20the\x20'+'residual\x20exposure\x20is\x20buy-time\x20rejections\x20(a\x20coupon\x20priced\x20below\x20the\x20rail\x20sum\x20makes\x20orders\x20unbuyable\x20—\x20a\x20merchant\x20'+'UX\x20problem),\x20not\x20escrow\x20stranding;\x20the\x20MCP-side\x20gate\x20is\x20an\x20enforcement\x20courtesy,\x20not\x20a\x20chain\x20invariant,\x20so\x20a\x20'+'build\x20that\x20bypasses\x20the\x20buy\x20tool\x20face\x20still\x20strands.','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\x20(the\x20buy-path\x20'+'order_below_fixed_leg_sum\x20gate\x20will\x20otherwise\x20reject\x20discounted\x20orders\x20one\x20by\x20one\x20—\x20correct,\x20but\x20the\x20merchant\x20'+'should\x20learn\x20it\x20from\x20this\x20report,\x20not\x20from\x20failed\x20buys).'}];}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/i['test'](h['template_id'])||/arb\.(?:indemnity|order|winner|status|ruling|case)/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'](y=>(y['from']??[])['length']>0x0))return[];const c=a['allocator']['rows']??[];if(c['length']===0x0)return[];const d=[...a['guards']['map'](y=>y['purpose']),...c['map'](y=>y['note']??'')];if(!d['some'](y=>/current\s*==/i['test'](y)))return[];const f=a['allocator']['description']??'',g=new Set();for(const y of b){for(const z of y['from']??[]){const A=typeof z==='string'?z:z?.['prev'];if(A)g['add'](A);}}const h=b['filter'](B=>!g['has'](B['name']));if(h['length']===0x0)return[];const j=B=>B['replace'](/[.*+?^${}()|[\]\\]/g,'\x5c$&'),k=B=>{const C=new RegExp('current\x5cs*==\x5cs*[\x22\x27]?'+j(B)+'\x5cb','i');if(a['guards']['some'](E=>C['test'](E['purpose'])))return!![];if(c['some'](E=>E['note']!==undefined&&C['test'](E['note'])))return!![];const D=new RegExp('\x5cb'+j(B)+'\x5cb','i');if(a['guards']['some'](E=>D['test'](E['purpose'])))return!![];if(c['some'](E=>E['note']!==undefined&&D['test'](E['note'])))return!![];return D['test'](f);},l=B=>/pool is empty|pool drains?ed|drains? in full|already (?:released|paid)|escrow (?:is )?(?:empty|drained)/i['test'](B),n=h['filter'](B=>!k(B['name'])&&!l(B['role']))['map'](B=>'\x27'+B['name']+'\x27'),o=/cancel|refund|return|withdraw|compensat/i,p=/refund|repay|chargeback|compensat/i,q=B=>B['semantic_role']==='cancelled'||o['test'](B['name']),s=B=>{const C=new RegExp('current\x5cs*==\x5cs*[\x22\x27]?'+j(B)+'\x5cb','i'),D=new RegExp('\x5cb'+j(B)+'\x5cb','i');if(c['some'](E=>E['track']==='refund'&&(C['test'](E['note']??'')||D['test'](E['note']??''))))return!![];return a['guards']['some'](E=>(C['test'](E['purpose'])||D['test'](E['purpose']))&&p['test'](E['template_id']+'\x20'+E['purpose']));},w=h['filter'](B=>q(B)&&k(B['name'])&&!s(B['name'])&&!l(B['role']))['map'](B=>'\x27'+B['name']+'\x27'),x=[];return n['length']>0x0&&x['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.'}),w['length']>0x0&&x['push']({'rule_id':'TERMINAL-WRONG-RAIL','severity':'critical','title':'Refund\x20terminal(s)\x20'+w['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.'}),x;}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.'}];}const PATH_CLASS_PATH_CAP=0x1388;function extractHistoryAnchorLiteral(a){for(const b of a['matchAll'](/next_node\s*=\s*["']([A-Za-z0-9_]+)["']/g)){const c=a['slice'](Math['max'](0x0,b['index']-0x40),b['index']);if(/progress\.history\.time[\s\S]{0,48}$/i['test'](c))return b[0x1];}return undefined;}function enumeratePathClasses(a,b,c,d,e){const f=d['toLowerCase'](),g=c['toLowerCase'](),h=new Set(),j=[];let k=0x0,l=![];const m=n=>{const o=n['toLowerCase']();if(o===f)return;j['push'](n),h['add'](o);if(o===g){k+=0x1;if(k>PATH_CLASS_PATH_CAP)l=!![];else e['length']<0x3&&e['push'](j['join']('→')+'\x20avoiding\x20\x27'+d+'\x27');}else for(const p of a['get'](n)??[]){if(l)break;if(h['has'](p['toLowerCase']()))continue;m(p);}j['pop'](),h['delete'](o);};for(const n of b){if(l)break;m(n);}return{'violated':k>0x0,'capped':l};}function pathClassAnchorChecks(a){const b=a['machine_shape']??[];if(b['length']===0x0)return[];if(!b['some'](k=>(k['from']??[])['some'](l=>typeof l!=='string'&&!!l['guard_key'])))return[];const c=new Map(),d=new Map();for(const k of b){for(const l of k['from']??[]){const n=typeof l==='string'?l:l['prev'];if(!c['has'](n))c['set'](n,[]);c['get'](n)['push'](k['name']);if(n!=='')d['set'](k['name'],(d['get'](k['name'])??0x0)+0x1);}}const f=b['filter'](o=>(d['get'](o['name'])??0x0)===0x0)['map'](o=>o['name']);if(f['length']===0x0)return[];const h=[],j=new Set();for(const o of a['guards']){if(!o['key']||j['has'](o['key']))continue;if(!/history[\s\S]{0,200}next_node|next_node[\s\S]{0,200}history/i['test'](o['purpose']))continue;const p=extractHistoryAnchorLiteral(o['purpose']);if(!p)continue;if(!b['some'](z=>z['name']['toLowerCase']()===p['toLowerCase']()))continue;j['add'](o['key']);const q=[];for(const z of b){for(const A of z['from']??[]){if(typeof A==='string'||A['guard_key']!==o['key'])continue;q['push']({'u':A['prev'],'v':z['name']});}}const s=[],w=[];let x=![];const y=new Map();for(const {u:B,v:C}of q){const D=B['toLowerCase']();let E=y['get'](D);!E&&(E=enumeratePathClasses(c,f,B,p,s),y['set'](D,E));if(E['capped'])w['push'](B+'→'+C);if(E['violated'])x=!![];}if(!x)continue;h['push']({'rule_id':'PATH-CLASS-ANCHOR-01','severity':'high','title':'History-time\x20anchor\x20\x27'+p+'\x27\x20is\x20missing\x20from\x20some\x20path\x20class\x20reaching\x20guard\x20\x27'+o['key']+'\x27\x20—\x20'+'the\x20guard\x20aborts\x20(MovePrimitiveRuntimeError),\x20not\x20a\x20clean\x20false','detail':'A\x20guard\x20purpose\x20that\x20declares\x20a\x20HISTORY-time\x20anchor\x20(progress.history.time\x20...,\x20next_node=\x27'+p+'\x27,\x20'+('find=last)\x20hard-depends\x20on\x20node\x20\x27'+p+'\x27\x20being\x20present\x20in\x20the\x20order\x27s\x20history.\x20An\x20order\x20that\x20reaches\x20')+('one\x20of\x20this\x20guard\x27s\x20edges\x20via\x20a\x20path\x20class\x20that\x20never\x20visits\x20\x27'+p+'\x27\x20makes\x20that\x20repository\x20query\x20')+'return\x20W_FIELD_NOT_FOUND,\x20and\x20the\x20passport\x20validator\x20re-raises\x20it\x20as\x20a\x20MovePrimitiveRuntimeError:\x20the\x20'+'ENTIRE\x20guard\x20aborts\x20instead\x20of\x20returning\x20a\x20clean\x20predicate\x20false,\x20so\x20whatever\x20it\x20gates\x20(an\x20expiry,\x20a\x20'+'release,\x20a\x20refund\x20window)\x20never\x20evaluates\x20on\x20that\x20path\x20class.\x20Topological\x20reachability\x20(F-TPL-01)\x20is\x20'+'necessary\x20but\x20NOT\x20sufficient\x20—\x20the\x20anchor\x20must\x20DOMINATE\x20every\x20path\x20class\x20reaching\x20the\x20guarded\x20edge\x27s\x20'+('pre-node.\x20Violating\x20path\x20classes\x20(start→...→pre-node\x20avoiding\x20\x27'+p+'\x27):\x20'+s['join'](';\x20')+'.')+(w['length']>0x0?'\x20Path\x20enumeration\x20hit\x20the\x20'+PATH_CLASS_PATH_CAP+'-path\x20determinism\x20cap\x20on\x20'+w['join'](',\x20')+'\x20—\x20'+'those\x20edges\x20were\x20skipped\x20as\x20under-audited,\x20not\x20cleared.':''),'suggestion':'Anchor\x20the\x20history-time\x20leg\x20only\x20on\x20a\x20node\x20present\x20on\x20EVERY\x20path\x20class\x20that\x20can\x20reach\x20the\x20guarded\x20'+'edges\x20(the\x20dominance\x20rule)\x20—\x20e.g.\x20anchor\x20an\x20expiry\x20on\x20the\x20delivered\x20entry\x20rather\x20than\x20a\x20renewal-only\x20'+'node;\x20or\x20split\x20the\x20edge/guard\x20so\x20each\x20path\x20class\x20gets\x20its\x20own\x20anchor\x20(a\x20logic_or\x20of\x20per-class\x20anchors).'});}return h;}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 w=typeof s==='string'?{'prev':s}:s;if(!w['prev'])continue;const x=w['operator']??(w['permission_index']!==undefined?'perm:'+w['permission_index']:p['operator']??'merchant'),y=q['get'](w['prev'])??[];y['push']({'guard_key':w['guard_key'],'actor':x}),q['set'](w['prev'],y);}for(const [z,A]of q){const B=A['filter'](H=>H['guard_key']!==undefined);if(B['length']<0x2)continue;const C=new Set(B['map'](H=>H['actor']));if(C['size']>0x1)continue;const D=B['filter'](H=>l(H['guard_key']));if(D['length']<0x2)continue;if(D['every'](H=>h['has'](H['guard_key'])))continue;const E=D['map'](H=>H['guard_key']),F=[...new Set(E['map'](H=>k(H))['filter'](H=>H!==undefined&&H!==''))],G=F['length']>0x1;m['push']({'rule_id':'SIBLING-FORWARD-EXCLUSIVITY','severity':G?'high':'medium','title':'Node\x20\x27'+p['name']+'\x27\x20(pair\x20from\x20\x27'+z+'\x27)\x20carries\x20'+D['length']+'\x20sibling\x20forwards\x20gated\x20by\x20'+('time-window\x20guards\x20under\x20one\x20actor\x20('+[...C]['join']('/')+')\x20—\x20no\x20on-chain\x20mutual\x20exclusion'),'detail':G?'Sibling\x20guards\x20resolve\x20to\x20DIFFERENT\x20settlement\x20amounts\x20('+F['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':G?'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'))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).\x20DIRECTION\x20CAVEAT\x20(bs-mn-261022\x20F-BS-54/56):\x20this\x20axis\x20'+'records\x20\x27the\x20case\x20closed\x20onto\x20the\x20order\x27,\x20never\x20\x27who\x20won\x27\x20—\x20a\x20zero-indemnity\x20DISMISSAL\x20can\x20never\x20'+'claim,\x20so\x20claimed_by\x20moves\x20only\x20when\x20a\x20keeper\x20drives\x20the\x20dismissal\x20conclusion\x20at\x20ruling\x20time;\x20the\x20'+'recovery\x20leg\x20then\x20fires\x20on\x20a\x20PAID\x20buyer-favoured\x20award\x20or\x20a\x20concluded\x20dismissal.\x20Present\x20the\x20rail\x20as\x20'+'\x27escrow\x20exits\x20to\x20the\x20seller\x20after\x20the\x20case\x20closed\x20against\x20the\x20buyer\x27,\x20NEVER\x20as\x20\x27the\x20merchant\x20won\x27.'}];}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'))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 CLAIMED_WIN_FRAME_RE=/\b(?:merchant|seller|producer|store|vendor|we)\b[^.;\n]{0,48}\b(?:win|wins|won|prevail(?:ed)?)\b/i,CLAIMED_WIN_FRAME_ALT_RE=/\bdismiss(?:al|ed|s)?\b|\bbuyer\s+(?:lose|loses|lost)\b|\bclaw(?:ed|s)?\s+back\b/i,CLAIMED_WIN_NEGATION_RE=/\b(?:never|do\s+not|don'?t|not|avoid|instead|rather\s+than|cannot)\b/i;function claimedDirectionVoidChecks(a){const b=[...(a['allocator']['rows']??[])['filter'](d=>d['track']!=='refund')['map']((d,e)=>['allocator\x20row\x20'+e+'\x20(track\x20'+d['track']+')',d['note']??'']),...a['guards']['map'](d=>['guard\x20\x27'+d['key']+'\x27',d['purpose']??''])],c=[];for(const [d,e]of b){if(!CLAIMED_TRUE_RE['test'](e))continue;for(const f of[CLAIMED_WIN_FRAME_RE,CLAIMED_WIN_FRAME_ALT_RE]){f['lastIndex']=0x0;for(let g=f['exec'](e);g!==null;g=f['exec'](e)){const h=e['slice'](Math['max'](0x0,g['index']-0x5a),g['index']+g[0x0]['length']+0x5a);if(CLAIMED_WIN_NEGATION_RE['test'](h))continue;c['push'](d+':\x20\x22'+g[0x0]['trim']()+'\x22');break;}if(c['some'](j=>j['startsWith'](d)))break;}}if(c['length']===0x0)return[];return[{'rule_id':'R-CLAIMED-DIRECTION-VOID','severity':'critical','title':'Recovery\x20rail\x20framed\x20as\x20winning-side\x20recovery\x20on\x20the\x20claimed_by\x20axis\x20—\x20polarity\x20voided\x20by\x20the\x20always-on\x20zero-indemnity\x20gate','detail':'order.claimed_by\x20is\x20written\x20when\x20the\x20case\x20is\x20CLOSED\x20onto\x20the\x20order\x20—\x20by\x20a\x20PAYING\x20claim\x20'+'(buyer-favoured)\x20or\x20by\x20the\x20dismissal\x20conclusion\x20(defendant-favoured,\x20always\x20on).\x20A\x20zero-indemnity\x20'+'award\x20itself\x20can\x20never\x20claim\x20(zero-indemnity\x20gate,\x20abort\x2011),\x20so\x20before\x20the\x20conclusion\x20existed\x20'+'claimed_by\x20stayed\x20none\x20after\x20a\x20dismissal.\x20The\x20axis\x20records\x20\x27the\x20case\x20closed\x20onto\x20this\x20order\x27,\x20'+'never\x20\x27who\x20won\x27:\x20some\x20==\x20true\x20covers\x20a\x20PAID\x20buyer\x20award\x20AND\x20a\x20concluded\x20dismissal.\x20A\x20rail\x20framed\x20'+'as\x20merchant-wins-recovery\x20therefore\x20pays\x20the\x20merchant\x20exactly\x20when\x20the\x20merchant\x20LOST\x20(live\x20'+'bs-mn-261022\x20O8)\x20unless\x20a\x20keeper\x20drives\x20the\x20dismissal\x20conclusion\x20at\x20ruling\x20time;\x20until\x20then\x20the\x20'+'paired\x20refund\x20leg\x20(some\x20==\x20false)\x20stays\x20open\x20and\x20the\x20buyer\x20loses\x20the\x20dispute\x20at\x20zero\x20cost\x20(O6).\x20Offending\x20surfaces:\x20'+c['join'](';\x20')+'.','suggestion':'Re-frame\x20the\x20rail\x27s\x20semantics\x20honestly:\x20claimed_by\x20some\x20==\x20true\x20means\x20\x27the\x20case\x20closed\x20onto\x20'+'the\x20order\x27\x20(a\x20buyer-favoured\x20award\x20was\x20PAID,\x20or\x20a\x20dismissal\x20was\x20concluded)\x20—\x20present\x20the\x20rail\x20as\x20'+'UPWC-K1\x20escrow-exit\x20(\x27the\x20awarded\x20order\x27s\x20escrow\x20principal\x20exits\x20to\x20the\x20seller\x20once\x20the\x20case\x20'+'closes\x27),\x20never\x20as\x20\x27the\x20merchant\x20won\x20the\x20dispute\x27.\x20Drive\x20the\x20dismissal\x20conclusion\x20at\x20ruling\x20time\x20'+'so\x20the\x20case\x20lands\x20on\x20the\x20order\x20and\x20the\x20refund\x20leg\x20closes.\x20Gating\x20on\x20ruling\x20DIRECTION\x20is\x20not\x20'+'expressible\x20on\x20this\x20axis\x20—\x20that\x20needs\x20the\x20chain-side\x20ruling-direction\x20accessor\x20(arb.winner,\x20bs-mn-261022).'}];}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 rewardBypassChecks(a){const b=a['machine_shape']??[];if(b['length']===0x0)return[];const c=new Set();for(const l of a['guards']){if(l['host']!=='reward')continue;for(const [n,o]of Object['entries'](l['params']??{})){if(/^expected_.*_node$/['test'](n)&&typeof o==='string'&&o!=='')c['add'](o);}}if(c['size']===0x0)return[];const d=new Set(b['map'](p=>p['name'])),f=new Map(),h=new Map();for(const p of b){for(const q of p['from']??[]){const s=typeof q==='string'?q:q?.['prev'];if(s==='')continue;if(!f['has'](s))f['set'](s,[]);f['get'](s)['push'](p['name']);if(!h['has'](p['name']))h['set'](p['name'],[]);h['get'](p['name'])['push'](s);}}const j=[];for(const w of[...c]['sort']()){if(!d['has'](w)){j['push']('\x27'+w+'\x27\x20is\x20promised\x20by\x20reward-claim\x20machinery\x20but\x20absent\x20from\x20machine_shape\x20(dead\x20literal)');continue;}const x=h['get'](w)??[];if(x['length']!==0x1)continue;const y=f['get'](x[0x0])??[];if(y['length']<0x2)continue;const z=y['filter'](A=>A!==w)['map'](A=>'\x27'+A+'\x27')['join'](',\x20');j['push']('\x27'+w+'\x27\x20hangs\x20on\x20a\x20single\x20in-edge\x20from\x20\x27'+x[0x0]+'\x27\x20whose\x20sibling\x20forward(s)\x20('+z+')\x20let\x20the\x20order\x20leave\x20forever\x20—\x20the\x20promised\x20state\x20is\x20skippable');}if(j['length']===0x0)return[];return[{'rule_id':'R-REWARD-BYPASS','severity':'medium','title':'Reward-promise\x20node(s)\x20can\x20be\x20bypassed:\x20'+j['length']+'\x20skippable/unresolvable\x20promise(s)','detail':'ADVISORY\x20(never\x20blocks):\x20a\x20reward-host\x20guard\x20spec\x20promises\x20these\x20states\x20via\x20its\x20expected_*_node\x20'+'params,\x20but\x20the\x20topology\x20lets\x20an\x20order\x20miss\x20them\x20permanently\x20—\x20'+j['join'](';\x20')+'.\x20The\x20chain\x20has\x20no\x20scheduler:\x20once\x20the\x20order\x20advances\x20past\x20the\x20fork\x20through\x20the\x20sibling\x20forward\x20'+'(its\x20own\x20guard\x20passed,\x20or\x20a\x20keeper\x20edge\x20fired),\x20no\x20edge\x20leads\x20back\x20and\x20the\x20promised\x20state\x20—\x20and\x20'+'every\x20reward\x20gated\x20on\x20it\x20—\x20becomes\x20dead\x20for\x20that\x20order.\x20abnb14-mn\x20F01\x20(live):\x20the\x20review\x20window\x20'+'was\x20swallowed\x20by\x20the\x20claim\x20window\x20for\x20every\x20late\x20reviewer\x20because\x20`reviewed`\x20hung\x20on\x20a\x20single\x20'+'completed-only\x20entry\x20while\x20completed\x20also\x20opened\x20the\x20claim\x20window.\x20If\x20the\x20bypass\x20IS\x20the\x20design\x20'+'(a\x20genuinely\x20optional\x20reward),\x20leave\x20it\x20—\x20this\x20finding\x20exists\x20so\x20the\x20choice\x20is\x20deliberate\x20and\x20'+'documented\x20in\x20the\x20spec\x20purpose,\x20not\x20an\x20accident\x20of\x20array\x20order.','suggestion':'Give\x20the\x20promised\x20node\x20a\x20SECOND\x20entry\x20edge\x20from\x20the\x20post-fork\x20waypoint\x20(the\x20v102\x20fix:\x20reviewed\x20'+'re-entered\x20from\x20claim_window\x20via\x20the\x20same\x20forward),\x20or\x20demote\x20the\x20promise:\x20drop\x20the\x20'+'expected_*_node\x20param\x20and\x20say\x20in\x20the\x20spec\x20purpose\x20that\x20the\x20reward\x20rides\x20an\x20optional\x20state.\x20'+'A\x20promise\x20node\x20absent\x20from\x20machine_shape\x20is\x20a\x20dead\x20literal\x20—\x20fix\x20the\x20name\x20or\x20delete\x20the\x20param.'}];}function guardUnmountedChecks(a){const b=a['guards']['filter'](k=>typeof k['key']==='string'&&k['key']!=='');if(b['length']===0x0)return[];const d=new Set(['reward','repository','service']),f=new Set();for(const k of a['machine_shape']??[]){for(const l of k['from']??[]){if(typeof l!=='string'&&l?.['guard_key'])f['add'](l['guard_key']);}}for(const m of a['allocator']['rows']??[]){if(m['guard_key'])f['add'](m['guard_key']);}for(const o of a['conditional_guards']??[]){if(o['guard_key'])f['add'](o['guard_key']);}const g=new Set((a['machine_shape']??[])['map'](p=>p['name'])),h=p=>/DESIGN-ONLY|nothing binds|AND into/i['test'](p['purpose'])||[...g]['some'](q=>p['purpose']['includes'](q)),j=b['filter'](p=>!d['has'](p['host'])&&!f['has'](p['key'])&&!h(p));if(j['length']===0x0)return[];return[{'rule_id':'R-GUARD-UNMOUNTED','severity':'medium','title':j['length']+'\x20guard\x20spec(s)\x20declare\x20a\x20key\x20nothing\x20mounts:\x20'+j['map'](p=>'\x27'+p['key']+'\x27')['join'](',\x20'),'detail':'ADVISORY\x20(never\x20blocks):\x20the\x20declared\x20key\x20surface\x20is\x20the\x20mounting\x20surface\x20—\x20an\x20edge\x27s\x20guard_key,\x20'+'an\x20allocator\x20row\x27s\x20guard_key,\x20or\x20a\x20conditional_guards\x20emission.\x20These\x20'+j['map'](p=>'\x27'+p['key']+'\x27\x20(host\x20'+p['host']+',\x20'+p['template_id']+')')['join'](',\x20')+'\x20are\x20referenced\x20by\x20none\x20of\x20them,\x20so\x20compile\x20never\x20collects\x20them\x20into\x20the\x20build\x20'+'(audit-261012\x20B3:\x20an\x20unbound\x20GuardSpec\x20is\x20never\x20emitted).\x20The\x20template\x20ships\x20the\x20spec\x27s\x20purpose\x20'+'as\x20a\x20promise\x20while\x20the\x20published\x20Machine\x20carries\x20no\x20such\x20guard\x20—\x20the\x20reader\x20believes\x20a\x20'+'protection\x20exists\x20that\x20does\x20not.','suggestion':'Mount\x20each\x20spec\x20by\x20binding\x20its\x20key\x20to\x20the\x20edge(s)\x20it\x20should\x20gate\x20(machine_shape\x20from[].guard_key)\x20'+'or\x20the\x20allocator\x20row(s)\x20it\x20should\x20cover\x20(allocator.rows[].guard_key);\x20if\x20the\x20protection\x20is\x20not\x20'+'wanted,\x20delete\x20the\x20spec\x20—\x20a\x20declared-but-unmounted\x20guard\x20is\x20dead\x20weight\x20that\x20inflates\x20the\x20trust\x20'+'surface.\x20reward/repository/service\x20hosts\x20need\x20no\x20key\x20reference\x20(host-mounted)\x20and\x20are\x20exempt.'}];}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'](g=>(g['from']??[])['length']>0x0))return[];const c=g=>{const h=[];for(const j of b){for(const k of j['from']??[]){const l=typeof k==='string'?k:k?.['prev'];if(l!==g)continue;const o=typeof k==='object'&&k?.['operator']?k['operator']:j['operator']??'merchant';h['push']({'target':j,'op':o});}}return h;},d=[],e=a['crowdfunding_mode']!==undefined&&a['crowdfunding_mode']!=='none',f=e?b['find'](g=>(g['from']??[])['some'](h=>typeof h!=='string'&&h['prev']===''))?.['name']:undefined;for(const g of b){if(!/escrow/i['test'](g['role']??''))continue;if(f!==undefined&&g['name']!==f)continue;if(/award|pays the (host|seller|creator|merchant|provider)/i['test'](g['role']??''))continue;if(/^(delivered|final|cancelled)$/['test'](g['semantic_role']??''))continue;const h=c(g['name']),j=h['some'](({target:k,op:l})=>l==='order_payer'&&k['semantic_role']==='cancelled');if(j)continue;d['push'](h['length']===0x0?'\x27'+g['name']+'\x27\x20has\x20NO\x20outgoing\x20forward\x20at\x20all\x20(entry\x20dead-end)':'\x27'+g['name']+'\x27\x20exits\x20only\x20via\x20'+h['map'](({target:k,op:l})=>k['name']+'['+l+']')['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;}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);}export function isKernelConsumedFeeParam(a){return a==='review_reward_per_claim';}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']??'',k=h['value_from_complement'];if(e['test'](j)||h['value_from']===c||k===c){const l=h['recipient_key'];d['push']({'surface':'allocator_row','site':h['track']+'/'+(l??h['recipient']),'excerpt':j||(k===c?'value_from_complement:\x20'+c:'value_from:\x20'+String(h['value_from'])),'recipient_blank':l===undefined||String(l)['trim']()===''});}}for(const [m,n]of Object['entries'](a['time_anchors']??{})){if(e['test'](n))d['push']({'surface':'time_anchor','site':m,'excerpt':n});}isKernelConsumedFeeParam(c)&&d['push']({'surface':'kernel','site':'compile.ts\x20reward-claim\x20derivation\x20(4R-02)','excerpt':'the\x20value\x20IS\x20the\x20compiled\x20per-claim\x20bounty:\x20spec.params.reward_claim_amount\x20>\x20inputs.reward_claim_amount\x20>\x20this\x20fee_param\x20(override\x20with\x20the\x20reward_claim_amount\x20input)'});if(d['length']===0x0){const o=directiveLanding(a,e);if(o)d['push'](o);}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;}function repositoryKeyDriftChecks(a){const b=[],c=new Set(a['guards']['map'](d=>d['policy']?.['name'])['filter'](d=>typeof d==='string'&&d['length']>0x0));for(const d of a['guards']){const e=d;if(e['template_id']!=='tpl_repository_row_present'&&e['template_id']!=='tpl_repository_row_equals_order_field')continue;const f=e['params']?.['row_name'];if(typeof f!=='string'||f['length']===0x0||c['has'](f))continue;b['push']({'rule_id':'R-REPO-KEY-DRIFT','severity':'medium','title':'evidence\x20gate\x20\x27'+e['key']+'\x27\x20reads\x20policy\x20key\x20\x27'+f+'\x27\x20that\x20no\x20repository\x20write\x20policy\x20in\x20this\x20template\x20creates\x20(AR-3\x20/\x20BSX-F01)','detail':'Guard\x20\x27'+e['key']+'\x27\x20('+e['template_id']+')\x20reads\x20rows\x20under\x20the\x20policy\x20key\x20\x27'+f+'\x27,\x20but\x20the\x20template\x27s\x20'+('host:\x22repository\x22\x20write\x20guards\x20create\x20policies:\x20'+([...c]['map'](h=>'\x27'+h+'\x27')['join'](',\x20')||'(none)')+'.\x20')+'Policies\x20freeze\x20at\x20Repository\x20creation\x20(REPO-GATE-KEY-01);\x20a\x20find_where\x20over\x20a\x20nonexistent\x20key\x20is\x20identically\x20'+'ZERO\x20—\x20the\x20gated\x20forward\x20never\x20opens\x20and\x20every\x20order\x20freezes\x20mid-rail.\x20Live\x20face:\x20BeatStars\x27\x20delivery\x20gate\x20'+'read\x20\x27license_grant\x27\x20while\x20the\x20repository\x20stored\x20\x27grant\x27\x20(bsx\x20BSX-F01).','suggestion':'Make\x20the\x20gate\x27s\x20row_name\x20EQUAL\x20the\x20write\x20policy\x27s\x20name\x20verbatim\x20(case-sensitive)\x20—\x20ONE\x20name\x20for\x20the\x20write\x20'+'side\x20and\x20the\x20read\x20side.\x20If\x20the\x20repository\x20is\x20intentionally\x20caller-supplied\x20(repository_policies\x20input),\x20'+'document\x20the\x20required\x20policy\x20name\x20in\x20the\x20gate\x27s\x20purpose\x20so\x20the\x20reader\x20can\x20satisfy\x20the\x20pairing.'});}return b;}export function scanTemplate(a){const b=machineProseFindings(a),c=canonicalizeMachineProse(a),d=[...b,...staticChecks(c),...guardRefChecks(c),...buyKeyDeclarationChecks(c),...taskBindingChecks(c),...repositoryKeyDriftChecks(c),...allocLegSlotChecks(c),...fundAnchorChecks(c),...periodicReleaseChecks(c),...timeWindowAnchorChecks(c),...signerRefundChecks(c),...orderAnchorDeclarationChecks(c),...topologyChecks(c),...reachabilityChecks(c),...deadEndLockChecks(c),...reviewNoRaceChecks(c),...afterSalesRailChecks(c),...acceptanceModeChecks(c),...installmentModeChecks(c),...affiliateModeChecks(c),...crowdfundingModeChecks(c),...logisticsModeChecks(c),...groupBuyBlockerChecks(c),...rewardReplayChecks(c),...rewardZeroOrderChecks(c),...rewardScaleChecks(c),...rewardFundedChecks(c),...proseCapabilityChecks(c,a),...rewardRatingKeyChecks(c),...loopFundChecks(c),...terminalRailCoverageChecks(c),...railNodeDriftChecks(c),...pathClassAnchorChecks(c),...siblingForwardExclusivityChecks(c),...compoundPayoutChecks(c),...surplusTrackChecks(c),...amountDeadlockChecks(c),...discountRailScaleChecks(c),...cancelCoverageChecks(c),...redundGuardObjectMismatchChecks(c),...zeroAmountGuardChecks(c),...serialClaimWindowChecks(c),...dismissEdgeGuardChecks(c),...noteNodeDriftChecks(c),...onewayDisputeChecks(c),...noEscrowExitChecks(c),...pairingProseOnlyChecks(c),...claimedDirectionVoidChecks(c),...railUnboundChecks(c),...rewardBypassChecks(c),...guardUnmountedChecks(c),...counterpartyFundEvidenceChecks(c),...repoWriteOnceIdiomChecks(c),...disclosureEnforceabilityChecks(c),...allocReplayChecks(c),...draftVoidChecks(c),...requiredInfoGateChecks(c),...planReadinessChecks(c),...feeParamLandingChecks(c)];for(const h of analyzerFindings(c)){const j=h['severity']==='info'?'low':h['severity'];d['push']({'rule_id':h['ruleId'],'severity':j,'title':h['title'],'detail':h['detail'],'suggestion':h['suggestion']});}d['sort']((k,l)=>SEVERITY_ORDER[l['severity']]-SEVERITY_ORDER[k['severity']]);const e=d['length']>0x0?d[0x0]['severity']:'low',g=d['filter'](k=>k['severity']==='critical')['map'](k=>''+(k['rule_id']?k['rule_id']+':\x20':'')+k['title']);return{'template_id':c['id'],'risk_level':e,'passed':g['length']===0x0,'findings':d,'red_flags':g};}
|