@wowok/agent-mcp 3.4.4 → 3.4.5
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/.build-stamp.json +3 -3
- package/dist/chain-semantics/composition-truth.js +1 -1
- package/dist/composition/audit.js +1 -1
- package/dist/composition/compile.js +1 -1
- package/dist/composition/emit-phases.js +1 -1
- package/dist/composition/guard-fill.js +1 -1
- package/dist/composition/input-normalize.js +1 -1
- package/dist/composition/materialize.js +1 -1
- package/dist/composition/mode-gates.js +1 -1
- package/dist/composition/param-disclosure.js +1 -1
- package/dist/composition/plan-run-store.js +1 -0
- package/dist/composition/reflux.js +1 -1
- package/dist/composition/role-bindings.js +1 -0
- package/dist/composition/shape-expand.js +1 -1
- package/dist/composition/supply-chain-emit.js +1 -1
- package/dist/config/judgment.d.ts +13 -25
- package/dist/config/judgment.js +1 -1
- package/dist/config/match-policy-file.js +1 -1
- package/dist/config/rule-engine.d.ts +4 -10
- package/dist/config/rule-engine.js +1 -1
- package/dist/config/template-params.js +1 -1
- package/dist/evaluation/engine.js +1 -1
- package/dist/experience/realtime-feedback.js +1 -1
- package/dist/extensions/capability.js +1 -1
- package/dist/graph/onchain/expand.js +1 -1
- package/dist/graph/onchain/exposure.js +1 -1
- package/dist/harness/forward-roster-preflight.js +1 -0
- package/dist/keeper/detectors.js +1 -1
- package/dist/knowledge/allocator-rail-verifier.js +1 -1
- package/dist/knowledge/arb-operation-face.js +1 -1
- package/dist/knowledge/arbitration-rail-verifier.js +1 -1
- package/dist/knowledge/audit-rules.d.ts +17 -1
- package/dist/knowledge/audit-rules.js +1 -1
- package/dist/knowledge/baselines/rules/alloc_audit.json.good.sha256 +1 -0
- package/dist/knowledge/baselines/rules/allocation.json.good.sha256 +1 -0
- package/dist/knowledge/baselines/rules/arb.json.good.sha256 +1 -0
- package/dist/knowledge/baselines/rules/arbitration.json.good.sha256 +1 -0
- package/dist/knowledge/baselines/rules/bridge.json.good.sha256 +1 -0
- package/dist/knowledge/baselines/rules/contact.json.good.sha256 +1 -0
- package/dist/knowledge/baselines/rules/demand.json.good.sha256 +1 -0
- package/dist/knowledge/baselines/rules/graph.json.good.sha256 +1 -0
- package/dist/knowledge/baselines/rules/guard.json.good.sha256 +1 -0
- package/dist/knowledge/baselines/rules/machine.json.good.sha256 +1 -0
- package/dist/knowledge/baselines/rules/oracle.json.good.sha256 +1 -0
- package/dist/knowledge/baselines/rules/order.json.good.sha256 +1 -0
- package/dist/knowledge/baselines/rules/payment.json.good.sha256 +1 -0
- package/dist/knowledge/baselines/rules/permission.json.good.sha256 +1 -0
- package/dist/knowledge/baselines/rules/personal.json.good.sha256 +1 -0
- package/dist/knowledge/baselines/rules/plan.json +153 -33
- package/dist/knowledge/baselines/rules/plan.json.good +153 -33
- package/dist/knowledge/baselines/rules/plan.json.good.sha256 +1 -0
- package/dist/knowledge/baselines/rules/progress.json.good.sha256 +1 -0
- package/dist/knowledge/baselines/rules/proof.json.good.sha256 +1 -0
- package/dist/knowledge/baselines/rules/registrar.json.good.sha256 +1 -0
- package/dist/knowledge/baselines/rules/repository.json.good.sha256 +1 -0
- package/dist/knowledge/baselines/rules/resource.json.good.sha256 +1 -0
- package/dist/knowledge/baselines/rules/reward.json.good.sha256 +1 -0
- package/dist/knowledge/baselines/rules/service.json.good.sha256 +1 -0
- package/dist/knowledge/baselines/rules/treasury.json.good.sha256 +1 -0
- package/dist/knowledge/baselines/rules/util.json.good.sha256 +1 -0
- package/dist/knowledge/builtin-templates.d.ts +1 -1
- package/dist/knowledge/builtin-templates.js +1 -1
- package/dist/knowledge/discount-threshold.js +1 -1
- package/dist/knowledge/fee-param-bindings.js +1 -1
- package/dist/knowledge/getting-started.js +1 -1
- package/dist/knowledge/guard-binding-table.js +1 -1
- package/dist/knowledge/guard-design-patterns.js +1 -1
- package/dist/knowledge/guard-templates.d.ts +3 -2
- package/dist/knowledge/guard-templates.js +1 -1
- package/dist/knowledge/index.js +1 -1
- package/dist/knowledge/industry-registry.js +1 -1
- package/dist/knowledge/jsonrpc-enum.js +1 -1
- package/dist/knowledge/knob-docs.js +1 -1
- package/dist/knowledge/machine-topology.js +1 -1
- package/dist/knowledge/param-schema.js +1 -1
- package/dist/knowledge/param-tiers.js +1 -1
- package/dist/knowledge/path-oracle/products/alibaba-1688.js +1 -1
- package/dist/knowledge/path-oracle/products/amazon.js +1 -1
- package/dist/knowledge/path-oracle/products/booking-com.js +1 -1
- package/dist/knowledge/path-oracle/products/contra.js +1 -1
- package/dist/knowledge/path-oracle/products/costco.js +1 -1
- package/dist/knowledge/path-oracle/products/duoduo-maicai.js +1 -1
- package/dist/knowledge/path-oracle/products/etsy.js +1 -1
- package/dist/knowledge/path-oracle/products/gamefound.js +1 -1
- package/dist/knowledge/path-oracle/products/gofundme.js +1 -1
- package/dist/knowledge/path-oracle/products/klook.js +1 -1
- package/dist/knowledge/path-oracle/products/ninety-nine-designs.js +1 -1
- package/dist/knowledge/path-oracle/products/pinduoduo-kuaituantuan.js +1 -1
- package/dist/knowledge/path-oracle/products/shansong.js +1 -1
- package/dist/knowledge/path-oracle/products/taobao-presale.js +1 -1
- package/dist/knowledge/path-oracle/products/upwork-catalog.js +1 -1
- package/dist/knowledge/path-oracle/products/upwork.js +1 -1
- package/dist/knowledge/pattern-resolutions.js +1 -1
- package/dist/knowledge/protocol-facts.js +1 -1
- package/dist/knowledge/publish-gate.js +1 -1
- package/dist/knowledge/publish-surface-contract.js +1 -1
- package/dist/knowledge/template-loader.js +1 -1
- package/dist/knowledge/template-registry.js +1 -1
- package/dist/knowledge/template-scanner.js +1 -1
- package/dist/knowledge/time-units.js +1 -0
- package/dist/knowledge/tools-reference.js +1 -1
- package/dist/knowledge/workflow-guidance.js +1 -1
- package/dist/monitor/MonitorLoop.js +1 -1
- package/dist/participation/radar-core.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.js +1 -1
- package/dist/playbooks/service-build/migration-planner.js +1 -1
- package/dist/playbooks/service-build/object-panorama.js +1 -1
- package/dist/playbooks/service-build/participation-radar.js +1 -1
- package/dist/playbooks/service-build/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/review/index.js +1 -1
- package/dist/safety/confirm-gate.js +1 -1
- package/dist/schema/benchmark-migration/index.d.ts +110 -2
- package/dist/schema/benchmark-migration/index.js +1 -1
- package/dist/schema/boundary-coercion.js +1 -0
- package/dist/schema/call/arbitration.js +1 -1
- package/dist/schema/call/base.js +1 -1
- package/dist/schema/call/handler.js +1 -1
- package/dist/schema/call/machine.d.ts +56 -8
- package/dist/schema/call/order.d.ts +37 -10
- package/dist/schema/call/order.js +1 -1
- package/dist/schema/call/permission.d.ts +210 -30
- package/dist/schema/call/personal.d.ts +56 -8
- package/dist/schema/call/progress.d.ts +28 -4
- package/dist/schema/call/semantic.js +1 -1
- package/dist/schema/call/service.d.ts +84 -12
- package/dist/schema/common/index.d.ts +14 -2
- package/dist/schema/common/index.js +1 -1
- package/dist/schema/evaluation/index.js +1 -1
- package/dist/schema/goal/index.d.ts +1 -1
- package/dist/schema/goal/planning.js +1 -1
- package/dist/schema/local/index.js +1 -1
- package/dist/schema/messenger/index.d.ts +168 -24
- package/dist/schema/messenger/index.js +1 -1
- package/dist/schema/operations.d.ts +655 -22
- package/dist/schema/operations.js +1 -1
- package/dist/schema/persona/index.d.ts +22 -110
- package/dist/schema/query/index.js +1 -1
- package/dist/schema/schema-version.js +1 -1
- package/dist/schema/workflow/index.d.ts +4 -0
- package/dist/schema/workflow/index.js +1 -1
- package/dist/schema-query-impl/index.js +1 -1
- package/dist/schemas/benchmark_migration_operation.schema.json +1 -1
- package/dist/schemas/evaluation_operation.schema.json +1 -1
- package/dist/schemas/goal_operation.schema.json +1 -1
- package/dist/schemas/guard_rebind_replacement.schema.json +1 -0
- package/dist/schemas/index.json +1 -1
- package/dist/schemas/messenger_operation.schema.json +1 -1
- package/dist/schemas/onchain_operations.schema.json +1 -1
- package/dist/schemas/onchain_operations_allocation.schema.json +1 -1
- package/dist/schemas/onchain_operations_arbitration.schema.json +1 -1
- package/dist/schemas/onchain_operations_contact.schema.json +1 -1
- package/dist/schemas/onchain_operations_demand.schema.json +1 -1
- package/dist/schemas/onchain_operations_gen_passport.schema.json +1 -1
- package/dist/schemas/onchain_operations_machine.schema.json +1 -1
- package/dist/schemas/onchain_operations_order.schema.json +1 -1
- package/dist/schemas/onchain_operations_permission.schema.json +1 -1
- package/dist/schemas/onchain_operations_personal.schema.json +1 -1
- package/dist/schemas/onchain_operations_progress.schema.json +1 -1
- package/dist/schemas/onchain_operations_proof.schema.json +1 -1
- package/dist/schemas/onchain_operations_repository.schema.json +1 -1
- package/dist/schemas/onchain_operations_reward.schema.json +1 -1
- package/dist/schemas/onchain_operations_service.schema.json +1 -1
- package/dist/schemas/onchain_operations_treasury.schema.json +1 -1
- package/dist/schemas/persona_operation.schema.json +1 -1
- package/dist/schemas/time_convert.schema.json +1 -0
- package/dist/schemas/wip_file.schema.json +1 -1
- package/dist/schemas/workflow_operation.schema.json +1 -1
- package/dist/tools/handlers/benchmark-migration.js +1 -1
- package/dist/tools/handlers/config.js +1 -1
- package/dist/tools/handlers/fund-rail-recipe.js +1 -1
- package/dist/tools/handlers/guard-rebind-replacement.js +1 -0
- package/dist/tools/handlers/local.js +1 -1
- package/dist/tools/handlers/mark-namespace.js +1 -1
- package/dist/tools/handlers/onchain.js +1 -1
- package/dist/tools/handlers/query.js +1 -1
- package/dist/tools/handlers/settle-sweep.js +1 -1
- package/dist/tools/handlers/time-convert.js +1 -0
- package/dist/tools/handlers/wip.js +1 -1
- package/dist/tools/handlers/workflow.js +1 -1
- package/dist/tools/index.d.ts +1 -0
- package/dist/tools/index.js +1 -1
- package/dist/tools/registry/business.js +1 -1
- package/dist/tools/registry/local.js +1 -1
- package/dist/tools/registry/onchain.js +1 -1
- package/dist/tools/wip-verify-ledger.js +1 -1
- package/dist/tools/wrap.js +1 -1
- package/package.json +6 -5
|
@@ -1 +1 @@
|
|
|
1
|
-
import{getJudgmentDoc}from'../config/judgment.js';import{evaluateRuleBook}from'../config/rule-engine.js';import{COMPOSITION_VARIANTS,disclosuresFor,primitivesForVariant,isPathDependentTimeQuery}from'../chain-semantics/index.js';import{MAX_INDEMNITY_MULTIPLE,ONCE_SLOT_BYTES,TASK_BINDING_SLOT}from'../knowledge/onchain-constants.js';import{classifyLoopCycle,numericAmount}from'../knowledge/audit-rules.js';import{abortSafeVerbCheck,equalityFaceCheck,setCollapseCheck,submissionRowIdTrustCheck,thresholdLiteralCheck}from'../knowledge/guard-quality.js';import{findLoopCycles}from'../knowledge/machine-topology.js';import{SKU_NAME_MAX_BYTES,skuNameByteLen}from'../knowledge/sku-name-gate.js';import{createsOf,isRef,refsOf,validatePlan}from'./plan.js';function collectQueries(a,b=[]){if(Array['isArray'](a)){for(const c of a)collectQueries(c,b);}else{if(typeof a==='object'&&a!==null){const d=a;d['type']==='query'&&typeof d['query']==='string'&&b['push']({'query':d['query']});for(const e of Object['values'](d))collectQueries(e,b);}}return b;}function acceptedProgressNodes(a,b){const c=new Map();if(Array['isArray'](b))for(const g of b){if(typeof g==='object'&&g!==null){const h=g;typeof h['identifier']==='number'&&typeof h['value']==='string'&&c['set'](h['identifier'],h['value']);}}const d=i=>{if(typeof i!=='object'||i===null)return undefined;const j=i;if(j['type']==='constant'&&typeof j['value']==='string')return j['value'];if(j['type']==='identifier'&&typeof j['identifier']==='number')return c['get'](j['identifier']);return undefined;},e=[],f=i=>{if(Array['isArray'](i)){for(const n of i)f(n);return;}if(typeof i!=='object'||i===null)return;const j=i,k=Array['isArray'](j['nodes'])?j['nodes']:undefined,l=k?.[0x0]??j['left'],m=k?.[0x1]??j['right'];if(typeof j['type']==='string'&&j['type']['startsWith']('logic')&&typeof l==='object'&&l!==null&&l['type']==='query'&&l['query']==='progress.current'){const o=d(m);if(o!==undefined)e['push'](o);}for(const p of Object['values'](j))f(p);};return f(a),e;}const WIP_HASH_QUERY_NAMES=new Set(['order.item.wip_hash']);function collectWipHashComparisons(a,b,c=[]){const d=new Map();if(Array['isArray'](b))for(const h of b){if(typeof h==='object'&&h!==null){const i=h;typeof i['identifier']==='number'&&typeof i['value']==='string'&&d['set'](i['identifier'],i['value']);}}const e=j=>{if(typeof j!=='object'||j===null)return undefined;const k=j;if(k['type']!=='query'||typeof k['query']!=='string')return undefined;const l=k['query']['trim']()['toLowerCase']();return WIP_HASH_QUERY_NAMES['has'](l)?k['query']:undefined;},f=j=>{if(typeof j!=='object'||j===null)return undefined;const k=j;if(k['type']==='constant'&&typeof k['value']==='string')return k['value'];if(k['type']==='identifier'&&typeof k['identifier']==='number')return d['get'](k['identifier']);return undefined;},g=j=>{if(Array['isArray'](j)){for(const o of j)g(o);return;}if(typeof j!=='object'||j===null)return;const k=j,l=Array['isArray'](k['nodes'])?k['nodes']:undefined,m=l?.[0x0]??k['left'],n=l?.[0x1]??k['right'];if(typeof k['type']==='string'&&k['type']['startsWith']('logic')){const p=e(m)??e(n);if(p!==undefined){const r=e(m)!==undefined?n:m,s=f(r);if(s!==undefined)c['push']({'query':p,'constant':s});}}for(const t of Object['values'](k))g(t);};return g(a),c;}const REPO_WHERE_QUERY_TYPES=new Set(['query_repository_data_count_where','query_repository_data_sum_where','query_repository_data_sum_where_bound','query_repository_data_sum_where_bound_all','query_repository_data_find_where']);function collectRepoWhereQueries(a,b=[]){if(Array['isArray'](a)){for(const c of a)collectRepoWhereQueries(c,b);}else{if(typeof a==='object'&&a!==null){const d=a;typeof d['type']==='string'&&REPO_WHERE_QUERY_TYPES['has'](d['type'])&&b['push'](d);for(const e of Object['values'](d))collectRepoWhereQueries(e,b);}}return b;}const REPO_ROW_READ_TYPES=new Set(['query_repository_data_has','query_repository_data','query_repository_data_author','query_repository_data_count_where','query_repository_data_sum_where','query_repository_data_sum_where_bound','query_repository_data_sum_where_bound_all','query_repository_data_find_where','query_repository_data_keys_where']);function subtreeReadsRepositoryRow(a){if(Array['isArray'](a))return a['some'](subtreeReadsRepositoryRow);if(typeof a!=='object'||a===null)return![];const b=a,c=b['type'];if(typeof c==='string'&&REPO_ROW_READ_TYPES['has'](c))return!![];if(c==='query'){const d=b['query'];if(typeof d==='string'&&d['startsWith']('repository.data'))return!![];if(d===0x48e||d===0x48f||d===0x495||d===0x496||d===0x498||d===0x499||d===0x49e)return!![];}return Object['values'](b)['some'](subtreeReadsRepositoryRow);}function isRepoDataHasRef(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(isRepoDataHasRef(b))return!![];return Object['values'](b)['some'](subtreeRefsRepoDataHas);}function rootNegatesRepoDataHas(a){if(Array['isArray'](a))return a['some'](rootNegatesRepoDataHas);if(typeof a!=='object'||a===null)return![];const b=a;if(b['type']==='logic_not'&&subtreeRefsRepoDataHas(b['node']))return!![];return Object['values'](b)['some'](rootNegatesRepoDataHas);}const SYSTEM_ENTITY_ADDRESS='0xaab',WRITE_GUARD_PROMISE_RE=/\b(?:only\s+\w+|must\s+(?:be|bind)\w*|restrict\w*|whitelist\w*|allowlist\w*|allow\s+list\b|authoriz\w*|permissioned|vetted|pre-?approv\w*|approved\s+\w+)\b/i,WRITE_GUARD_TAUTOLOGY_DISCLOSURE_RE=/\b(?:tautolog\w*|self[- ]?report\w*|self[- ]?assert\w*)\b/i;function writeGuardLegClass(a,b){const c=new Map();if(Array['isArray'](b))for(const j of b){if(typeof j==='object'&&j!==null){const k=j;if(typeof k['identifier']==='number')c['set'](k['identifier'],k);}}const d=l=>typeof l==='object'&&l!==null&&l['type']==='context'&&l['context']==='Signer',e=l=>{if(Array['isArray'](l))return l['some'](e);if(typeof l!=='object'||l===null)return![];const m=l;if(m['type']==='context'&&m['context']==='Signer')return!![];return Object['values'](m)['some'](e);},f=l=>{if(typeof l!=='object'||l===null)return![];const m=l;if(m['type']==='identifier'){const n=c['get'](m['identifier']);if(n===undefined||n['b_submission']===!![])return![];const o=n['value'];return typeof o==='string'&&o['trim']()!==''&&!o['includes']('${');}if(m['type']==='constant'){const p=m['value'];if(typeof p!=='string'||p['includes']('${'))return![];if(p['trim']()['toLowerCase']()===SYSTEM_ENTITY_ADDRESS)return![];return!![];}if(m['type']==='query')return!![];return![];};let g=![];const h=(l,m)=>{if(Array['isArray'](l)){let u=![];for(const w of l)u=h(w,m)||u;return u;}if(typeof l!=='object'||l===null)return![];const n=l,o=n['type'];if(o==='logic_not'){const x=n['node']??(Array['isArray'](n['nodes'])?n['nodes'][0x0]:undefined);return x!==undefined?h(x,m+0x1):![];}if((o==='logic_and'||o==='logic_or')&&Array['isArray'](n['nodes'])){const y=n['nodes'];let z=![],A=!![];for(const B of y){const C=h(B,m);z=z||C;if(!C)A=![];}return o==='logic_and'?z:z&&A;}if(typeof o==='string'&&o['startsWith']('query')&&e(n)&&m%0x2===0x0)return g=!![],!![];const p=Array['isArray'](n['nodes'])?n['nodes']:undefined,q=p?.[0x0]??n['left'],r=p?.[0x1]??n['right'];if(o==='vec_contains_address'&&q!==undefined&&r!==undefined){const D=d(q)?r:d(r)?q:undefined;if(D===undefined||m%0x2!==0x0)return![];g=!![];const E=D,F=E['type']==='identifier'?c['get'](E['identifier']):undefined;if(F===undefined||F['b_submission']===!![])return![];const G=F['value'];if(Array['isArray'](G))return G['length']>0x0;if(typeof G!=='string'||G['trim']()===''||G['includes']('${'))return![];try{const H=JSON['parse'](G);return Array['isArray'](H)&&H['length']>0x0;}catch{return![];}}if(o==='logic_equal'&&q!==undefined&&r!==undefined){if(m%0x2!==0x0||!(d(q)||d(r)))return![];return g=!![],f(d(q)?r:q);}let s=![];for(const I of Object['values'](n)){if(typeof I==='object'&&I!==null)s=h(I,m)||s;}return s;},i=h(a,0x0);return{'hasSignerLeg':g,'hasBindingLeg':i};}function staticStringOperand(a,b){if(typeof a!=='object'||a===null)return undefined;const c=a;if(typeof c['identifier']==='number'){const d=b['find'](e=>typeof e==='object'&&e!==null&&e['identifier']===c['identifier']);if(d===undefined||d['b_submission']===!![])return undefined;return typeof d['value']==='string'?d['value']:undefined;}return typeof c['value']==='string'?c['value']:undefined;}function isPlanLocalObjectOperand(a,b){if(typeof a!=='object'||a===null)return![];const c=a;if(typeof c['identifier']!=='number')return![];const d=b['find'](f=>typeof f==='object'&&f!==null&&f['identifier']===c['identifier']);if(d===undefined||d['b_submission']===!![])return![];const e=d['value'];if(typeof e==='object'&&e!==null)return!![];return typeof e==='string'&&e['startsWith']('$');}const REACH_GREATER_TYPES={'logic_as_u256_greater':'gt','logic_as_u256_greater_or_equal':'ge'},REACH_LESSER_TYPES={'logic_as_u256_lesser':'lt','logic_as_u256_lesser_or_equal':'le'},REACH_EQUAL_TYPES=new Set(['logic_as_u256_equal','logic_equal']);function reachChannel(a){if(a['type']==='context'&&typeof a['context']==='string')return'context:'+a['context'];const b=a['query'];if(a['type']==='query'&&(typeof b==='string'||typeof b==='number'))return'query:'+String(b)['trim']()['toLowerCase']();return undefined;}function reachConstant(a,b){const c=d=>typeof d==='string'||typeof d==='number'||typeof d==='boolean';if(a['type']==='identifier'&&typeof a['identifier']==='number'){const d=b['find'](e=>typeof e==='object'&&e!==null&&e['identifier']===a['identifier']);if(d===undefined||d['b_submission']===!![])return undefined;return c(d['value'])?d['value']:undefined;}if(a['type']==='constant')return c(a['value'])?a['value']:undefined;return undefined;}function flattenAndChain(a,b=[]){if(typeof a!=='object'||a===null)return b;const c=a;if(c['type']==='logic_and'){const d=Array['isArray'](c['nodes'])?c['nodes']:[];for(const e of d)flattenAndChain(e,b);return b;}return b['push'](c),b;}function reachLegsOf(a){const b=Array['isArray'](a['params']['table'])?a['params']['table']:[],c=a['params']['root']??a['params']['logic'],d={'legs':[],'selfStrict':[]};if(typeof c!=='object'||c===null)return d;for(const e of flattenAndChain(c)){const f=typeof e['type']==='string'?e['type']:'',g=Array['isArray'](e['nodes'])?e['nodes']:undefined;if(g===undefined||g['length']<0x2)continue;const h=REACH_GREATER_TYPES[f],j=REACH_LESSER_TYPES[f],k=REACH_EQUAL_TYPES['has'](f);if(h===undefined&&j===undefined&&!k)continue;const l=g[0x0];if(typeof l!=='object'||l===null)continue;const m=reachChannel(l),n=reachConstant(l,b);for(let o=0x1;o<g['length'];o++){const p=g[o];if(typeof p!=='object'||p===null)continue;const q=reachConstant(p,b),r=reachChannel(p);if(m!==undefined&&q!==undefined)d['legs']['push']({'channel':m,'dir':k?'eq':h??j,'constant':q});else{if(r!==undefined&&n!==undefined){const s=k?'eq':h!==undefined?h==='gt'?'lt':'le':j==='lt'?'gt':'ge';d['legs']['push']({'channel':r,'dir':s,'constant':n});}else m!==undefined&&r!==undefined&&(m===r&&(h==='gt'||j==='lt')&&d['selfStrict']['push']({'channel':m,'dir':h==='gt'?'gt':'lt'}));}}}return d;}function reachNumeric(a){if(typeof a==='number')return Number['isFinite'](a)?a:undefined;if(typeof a==='string'&&a['trim']()!==''&&!Number['isNaN'](Number(a)))return Number(a);return undefined;}function findReachContradictions(c,f,g=[]){const h=[];for(const l of g){h['push']('guard\x20\x27'+c+'\x27\x20('+l['channel']+'):\x20'+(l['dir']==='gt'?'>':'<')+'\x20itself\x20—\x20'+'unsatisfiable\x20(same-binding\x20self-comparison)');}const k=new Map();for(const m of f){const n=k['get'](m['channel'])??[];n['push'](m),k['set'](m['channel'],n);}for(const [o,p]of k){const q=p['filter'](v=>v['dir']==='gt'||v['dir']==='ge'),r=p['filter'](v=>v['dir']==='lt'||v['dir']==='le');for(const v of q){const w=reachNumeric(v['constant']);if(w===undefined)continue;for(const x of r){const y=reachNumeric(x['constant']);if(y===undefined)continue;(w>y||w===y&&(v['dir']==='gt'||x['dir']==='lt'))&&h['push']('guard\x20\x27'+c+'\x27\x20('+o+'):\x20'+(v['dir']==='gt'?'>':'>=')+'\x20'+String(v['constant'])+'\x20'+('contradicts\x20'+(x['dir']==='lt'?'<':'<=')+'\x20'+String(x['constant'])+'\x20—\x20unsatisfiable'));}}const t=p['filter'](z=>z['dir']==='eq');for(let z=0x0;z<t['length'];z++){for(let A=z+0x1;A<t['length'];A++){const B=t[z],C=t[A],D=reachNumeric(B['constant']),E=reachNumeric(C['constant']),F=typeof B['constant']==='boolean'&&typeof C['constant']==='boolean'&&B['constant']!==C['constant'],G=D!==undefined&&E!==undefined&&D!==E;(F||G)&&h['push']('guard\x20\x27'+c+'\x27\x20('+o+'):\x20==\x20'+String(B['constant'])+'\x20'+('contradicts\x20==\x20'+String(C['constant'])+'\x20—\x20unsatisfiable'));}}for(const H of t){const I=reachNumeric(H['constant']);if(I===undefined)continue;for(const J of q){J['dir']==='gt'&&reachNumeric(J['constant'])===I&&h['push']('guard\x20\x27'+c+'\x27\x20('+o+'):\x20==\x20'+String(H['constant'])+'\x20'+('contradicts\x20>\x20'+String(J['constant'])+'\x20—\x20unsatisfiable'));}for(const K of r){K['dir']==='lt'&&reachNumeric(K['constant'])===I&&h['push']('guard\x20\x27'+c+'\x27\x20('+o+'):\x20==\x20'+String(H['constant'])+'\x20'+('contradicts\x20<\x20'+String(K['constant'])+'\x20—\x20unsatisfiable'));}}}return h;}function guardProjection(a){const b=a['params']['root']??a['params']['logic'],c=collectQueries(b)['map'](d=>d['query']);return{'stepId':a['id'],'queries':c,'acceptedNodes':acceptedProgressNodes(b,a['params']['table']),'table':Array['isArray'](a['params']['table'])?a['params']['table']:[]};}function allocatorRows(a){const b=[],c=d=>{if(typeof d==='object'&&d!==null&&!Array['isArray'](d)){const e=d;if(Array['isArray'](e['allocators']))d=e['allocators'];}if(!Array['isArray'](d))return;for(const f of d){if(typeof f!=='object'||f===null)continue;const g=f,h=g['guard'],i=g['guard_key'],j=Array['isArray'](g['sharing'])?g['sharing']:[],k=j['map'](l=>typeof l==='object'&&l!==null?l['who']:undefined)['map'](l=>typeof l==='object'&&l!==null?l['GuardIdentifier']:undefined)['filter'](l=>typeof l==='number');b['push']({'track':typeof g['track']==='string'?g['track']:'settlement','guardStep':isRef(h)?h['$ref']:undefined,'guardKey':typeof i==='string'?i:undefined,'identifierLegs':k});}};for(const d of a['steps']){if(d['op']==='create'&&d['object']==='service')c(d['params']['order_allocators']);if(d['op']==='configure'&&d['method']==='order_allocators')c(d['params']['allocators']);}return b;}function machineProjection(a){const b=createsOf(a,'machine')[0x0];if(b===undefined)return undefined;const c=b['params']['nodes'];if(!Array['isArray'](c))return{'nodes':[],'edges':[],'terminals':[],'optionalNodes':[],'forwardGuardRefs':[],'finalRoleNodes':[],'cancelledNodes':[]};const d=[],e=[],h=o=>({'name':typeof o?.['name']==='string'?o['name']:'','roster':typeof o?.['namedOperator']==='string'?o['namedOperator']:typeof o?.['named_operator']==='string'?o['named_operator']:undefined,'perm':typeof o?.['permissionIndex']==='number'?o['permissionIndex']:typeof o?.['permission_index']==='number'?o['permission_index']:undefined}),i=[],j=[],k=[],l=[];for(const o of c){if(typeof o!=='object'||o===null)continue;const q=o,r=typeof q['name']==='string'?q['name']:undefined;if(r===undefined)continue;d['push'](r);const s=typeof q['role']==='string'?q['role']:undefined;if(s==='final'||s==='cancelled')k['push'](r);if(s==='cancelled')l['push'](r);if(q['optional']===!![])i['push'](r);const t=Array['isArray'](q['pairs'])?q['pairs']:[];for(const u of t){const v=u,w=v?.['prev_node'],x=Array['isArray'](v?.['forwards'])?v['forwards']:[],y=[],z=[],A=[];for(const B of x){const C=B,D=C?.['guard'];isRef(D)&&(y['push'](D['$ref']),j['push'](D['$ref']));if(typeof C?.['name']==='string')z['push'](C['name']);A['push'](h(C));}if(typeof w==='string')e['push']({'prev':w,'next':r,'guards':y,'forwardNames':z,'forwardRails':A});}}const m=b['params']['pairs'];if(Array['isArray'](m))for(const E of m){const F=E;if(typeof F?.['prev_node']==='string'&&typeof F?.['next_node']==='string'){const G=Array['isArray'](F['forwards'])?F['forwards']:[],H=[],I=[],J=[];for(const K of G){const L=K,M=L?.['guard'];isRef(M)&&(H['push'](M['$ref']),j['push'](M['$ref']));if(typeof L?.['name']==='string')I['push'](L['name']);J['push'](h(L));}e['push']({'prev':F['prev_node'],'next':F['next_node'],'guards':H,'forwardNames':I,'forwardRails':J});}}const n=new Set(e['filter'](N=>N['prev']!==''&&N['prev']!==N['next'])['map'](N=>N['prev']));return{'nodes':d,'edges':e,'terminals':d['filter'](N=>!n['has'](N)),'optionalNodes':i,'forwardGuardRefs':j,'finalRoleNodes':k,'cancelledNodes':l};}function pathCountCap2(a,b){const c=new Map();for(const g of a){const h=c['get'](g['prev'])??[];h['push'](g['next']),c['set'](g['prev'],h);}let d=0x0;const f=(i,j)=>{if(d>=0x2)return;if(i===b){d+=0x1;return;}if(j['has'](i))return;const k=new Set(j)['add'](i);for(const l of c['get'](i)??[])f(l,k);};for(const i of c['get']('')??[])f(i,new Set());return d;}const WRITE_ONLY_ENFORCEMENT_SOURCES=[{'object':'service','param':'customer_required','coverQuery':'order.required_info','extract':a=>Array['isArray'](a['params']['customer_required'])&&a['params']['customer_required']['length']>0x0},{'object':'service','param':'sales[].wip','coverQuery':'service.sale.wip','extract':a=>Array['isArray'](a['params']['sales'])&&a['params']['sales']['some'](b=>typeof b==='object'&&b!==null&&typeof b['wip']==='string'&&b['wip']['length']>0x0)}],PROSE_UNIT_MS={'minute':0xea60,'hour':0x36ee80,'hrs':0x36ee80,'hr':0x36ee80,'h':0x36ee80,'day':0x5265c00,'week':0x240c8400},PROSE_DURATION_RE=/(\d+)\s*[-\s]?\s*(minute|hour|hrs|hr|h|day|week)s?\b/gi,WINDOW_CONTEXT_RE=/review|accept|cancel|refund|return|window|claim|bounty|escrow|release|revision|dispute/i;function isPlausibleMsDuration(a){return Number['isFinite'](a)&&a>=0xea60&&a%0x3e8===0x0&&a<=0xa*0x16d*0x5265c00;}function formatMs(a){const b=a/0x5265c00;if(Number['isInteger'](b)&&b>=0x2)return b+'\x20days';const c=a/0x36ee80;if(Number['isInteger'](c)&&c>=0x2)return c+'\x20hours';return a/0xea60+'\x20minutes';}export function extractProseWindowPromises(a){const b=[];for(const c of a['matchAll'](PROSE_DURATION_RE)){const d=Number(c[0x1])*(PROSE_UNIT_MS[c[0x2]['toLowerCase']()]??NaN);if(!Number['isFinite'](d)||d<=0x0||c['index']===undefined)continue;const e=Math['max'](0x0,c['index']-0x50),f=Math['min'](a['length'],c['index']+c[0x0]['length']+0x50);if(!WINDOW_CONTEXT_RE['test'](a['slice'](e,f)))continue;b['push']({'ms':d,'quote':c[0x0]});}return b;}const UNANCHORED_RESTART_RE=/\b(?:restart|reset|renew|start(?:s)? again|begin(?:s)? again)[^.]{0,60}\b(?:window|timer|clock|period)\b|\b(?:window|timer|clock|period)\b[^.]{0,60}\b(?:restart|reset|renew)s?\b/i;function collectEnforcedWindowMs(a){const b=new Set();for(const c of createsOf(a,'guard')){const d=Array['isArray'](c['params']['table'])?c['params']['table']:[];for(const e of d){const f=e;if(f['b_submission']===!![]||f['value_type']!=='U64')continue;const g=f['value'],h=typeof g==='number'?g:typeof g==='string'&&g!==''&&!Number['isNaN'](Number(g))?Number(g):NaN;if(isPlausibleMsDuration(h))b['add'](h);}}return b;}const TIME_CMP_TYPES={'logic_as_u256_greater':'gt','logic_as_u256_greater_or_equal':'ge','logic_as_u256_lesser':'lt','logic_as_u256_lesser_or_equal':'le','logic_as_u256_equal':'eq','logic_equal':'eq'};function isClockContext(a){return a['type']==='context'&&a['context']==='Clock';}function subtreeHasBranch(a){if(Array['isArray'](a))return a['some'](subtreeHasBranch);if(typeof a!=='object'||a===null)return![];const b=a;if(b['type']==='logic_or'||b['type']==='logic_not')return!![];return Object['values'](b)['some'](subtreeHasBranch);}function guardWindowOpen(c){if(typeof c!=='object'||c===null)return!![];if(subtreeHasBranch(c))return!![];let d=![];for(const e of flattenAndChain(c)){const f=TIME_CMP_TYPES[typeof e['type']==='string'?e['type']:''];if(f===undefined)continue;const g=Array['isArray'](e['nodes'])?e['nodes']:undefined;if(g===undefined||g['length']<0x2)continue;const h=g[0x0],i=g[0x1];if(typeof h!=='object'||h===null||typeof i!=='object'||i===null)continue;const j=isClockContext(h),k=isClockContext(i);if(j&&!k){if(f==='lt'||f==='le'||f==='eq')d=!![];}else{if(!j&&k){const l=f==='gt'||f==='ge'?'lt':f==='lt'||f==='le'?'gt':'eq';if(l==='lt')d=!![];}}}return!d;}function collectSlotQueries(a,b=[]){if(Array['isArray'](a)){for(const d of a)collectSlotQueries(d,b);return b;}if(typeof a!=='object'||a===null)return b;const c=a;if(c['type']==='query'&&typeof c['query']==='string'){const e=c['object'],f=typeof e==='object'&&e!==null?e:undefined;b['push']({'query':c['query'],'slot':typeof f?.['identifier']==='number'?f['identifier']:undefined,'witness':typeof f?.['convert_witness']==='string'?f['convert_witness']:undefined});}for(const g of Object['values'](c))collectSlotQueries(g,b);return b;}function tableRows(a){const b=a['params']['table'];if(!Array['isArray'](b))return[];return b['filter'](c=>typeof c==='object'&&c!==null);}function rowIdentifier(a){return typeof a['identifier']==='number'?a['identifier']:undefined;}function servicePinRowIds(a,b){const c=[],d=f=>{const g=f['object'];return f['type']==='query'&&f['query']==='order.service'&&typeof g==='object'&&g!==null&&g['identifier']===b;},e=f=>{if(Array['isArray'](f)){for(const i of f)e(i);return;}if(typeof f!=='object'||f===null)return;const g=f,h=g['nodes'];if(g['type']==='logic_equal'&&Array['isArray'](h)&&h['length']===0x2)for(const [j,k]of[[h[0x0],h[0x1]],[h[0x1],h[0x0]]]){if(typeof j!=='object'||j===null||typeof k!=='object'||k===null)continue;const l=k;d(j)&&l['type']==='identifier'&&typeof l['identifier']==='number'&&c['push'](l['identifier']);}for(const m of Object['values'](g))e(m);};return e(a),c;}function ownServiceIdentities(a){const b=new Set();for(const c of createsOf(a,'service')){b['add'](c['id']);const d=c['params']['name'];if(typeof d==='string')b['add'](d);}return b;}function pinIsExternal(a,b){if(typeof a==='string')return!b['has'](a);if(typeof a==='object'&&a!==null){const c=a;if(typeof c['$ref']==='string')return!b['has'](c['$ref']);const d=c['$late'];if(typeof d==='object'&&d!==null){const e=d['mark'];if(typeof e==='string')return!b['has'](e);}}return!![];}function guardCompositionShapes(a){const b=[],c=ownServiceIdentities(a),d=repositoryWriteGuardIds(a),e=writeOnceKeyedSlots(a);for(const f of createsOf(a,'guard')){const g=f['params']['root']??f['params']['logic'],h=collectSlotQueries(g),i=h['filter'](s=>s['query']['startsWith']('order.')),j=[...new Set(i['map'](s=>s['slot'])['filter'](t=>t!==undefined&&t!==HOST_ORDER_SLOT&&t!==TASK_BINDING_SLOT&&t!==ONCE_SLOT_BYTES))],k=tableRows(f),l=new Set(k['filter'](s=>s['b_submission']===![]&&s['value_type']==='Address')['map'](s=>rowIdentifier(s))['filter'](s=>s!==undefined)),m=j['flatMap'](t=>servicePinRowIds(g,t))['filter'](s=>l['has'](s)),n=[...new Set(i['filter'](s=>s['query']==='order.service')['map'](s=>s['slot'])['filter'](t=>t!==undefined))],o=new Map(k['map'](s=>[rowIdentifier(s),s['value']])),p=s=>s['flatMap'](t=>servicePinRowIds(g,t))['filter'](t=>l['has'](t)&&pinIsExternal(o['get'](t),c)),q=p(j)['length']>0x0||d['has'](f['id'])&&p(n)['length']>0x0,r=i['filter'](s=>s['query']==='order.owner')['map'](s=>s['slot']);b['push']({'stepId':f['id'],'foreignSlots':j,'paired':subtreeReadsRepositoryRow(g)||k['some'](s=>rowIdentifier(s)===ONCE_SLOT_BYTES&&s['b_submission']===!![])||j['some'](t=>e['get'](f['id'])?.['has'](t)),'pinned':m['length']>0x0,'pinnedRowIds':m,'procurementPin':q,'ownerCrossed':r['includes'](HOST_ORDER_SLOT)&&j['some'](t=>r['includes'](t))});}return b;}function repositoryPoliciesMerged(a){const b=new Map();for(const d of a['steps']){if(d['op']!=='configure'||d['method']!=='policies')continue;const e=d['target'],f=typeof e==='object'&&e!==null&&typeof e['$ref']==='string'?e['$ref']:undefined;if(f===undefined)continue;const g=d['params']['policy'];if(!Array['isArray'](g))continue;const h=b['get'](f)??[];h['push'](...g['filter'](i=>typeof i==='object'&&i!==null)),b['set'](f,h);}const c=[];for(const i of createsOf(a,'repository')){const j=Array['isArray'](i['params']['policies'])?i['params']['policies']:[];c['push']({'step':i,'policies':[...j,...b['get'](i['id'])??[]]});}return c;}function repositoryWriteGuardIds(a){const b=new Set();for(const {policies:c}of repositoryPoliciesMerged(a)){for(const d of c){if(typeof d!=='object'||d===null)continue;const e=d['write_guard'];if(!Array['isArray'](e))continue;for(const f of e){if(typeof f!=='object'||f===null)continue;const h=f['guard'];typeof h==='object'&&h!==null&&typeof h['$ref']==='string'&&b['add'](h['$ref']);}}}return b;}function writeOnceKeyedSlots(a){const b=new Map();for(const {policies:c}of repositoryPoliciesMerged(a)){for(const d of c){if(typeof d!=='object'||d===null)continue;const e=d;if(e['write_once']!==!![])continue;const f=e['write_guard'];if(!Array['isArray'](f))continue;for(const h of f){if(typeof h!=='object'||h===null)continue;const i=h,j=i['id_from_submission'];if(typeof j!=='number'||j===HOST_ORDER_SLOT)continue;const k=i['guard'];if(typeof k!=='object'||k===null)continue;const l=k['$ref'];if(typeof l!=='string')continue;const m=b['get'](l)??new Set();m['add'](j),b['set'](l,m);}}}return b;}function emittedPrimitives(a,b){const c=new Set();for(const d of createsOf(a,'guard')){const e=d['params']['root']??d['params']['logic'];if(subtreeReadsRepositoryRow(e))c['add']('P1');}if(b['some'](f=>f['foreignSlots']['length']>0x0))c['add']('P2');if(b['some'](f=>f['procurementPin']))c['add']('P3');for(const f of createsOf(a,'machine')){const g=f['params']['nodes'];if(!Array['isArray'](g))continue;if(JSON['stringify'](g)['includes']('retained_submission'))c['add']('P3');}if(maxDistinctGuardsPerTrack(a)>0x1)c['add']('P4');if(planHasFormulaSharing(a))c['add']('P5');if(createsOf(a,'reward')['length']>0x0)c['add']('P6');return c;}const HOST_ORDER_SLOT=0x0;function maxDistinctGuardsPerTrack(a){const b=new Map(),c=f=>{const h=f['guard'];if(h!==undefined)return JSON['stringify'](h);if(typeof f['guard_key']==='string')return'key:'+f['guard_key'];return'<unbound>';},d=f=>{if(typeof f==='object'&&f!==null&&!Array['isArray'](f)){const g=f;if(Array['isArray'](g['allocators']))f=g['allocators'];}if(!Array['isArray'](f))return;for(const h of f){if(typeof h!=='object'||h===null)continue;const i=h,j=typeof i['track']==='string'?i['track']:'settlement',k=b['get'](j);if(k===undefined)b['set'](j,new Set([c(i)]));else k['add'](c(i));}};for(const f of a['steps']){if(f['op']==='create'&&f['object']==='service')d(f['params']['order_allocators']);if(f['op']==='configure'&&f['method']==='order_allocators')d(f['params']['allocators']);}let e=0x0;for(const g of b['values']())e=Math['max'](e,g['size']);return e;}function planHasFormulaSharing(a){const b=c=>{if(typeof c==='object'&&c!==null&&!Array['isArray'](c)){const d=c;if(Array['isArray'](d['allocators']))c=d['allocators'];}if(!Array['isArray'](c))return![];return c['some'](e=>{if(typeof e!=='object'||e===null)return![];const f=e['sharing'];if(!Array['isArray'](f))return![];return f['some'](g=>{if(typeof g!=='object'||g===null)return![];const h=g;return h['mode']===0x4||h['formula']!==undefined;});});};for(const c of a['steps']){if(c['op']==='create'&&c['object']==='service'&&b(c['params']['order_allocators']))return!![];if(c['op']==='configure'&&c['method']==='order_allocators'&&b(c['params']['allocators']))return!![];}return![];}function thirdPartyLegs(a){const b=[],c=d=>{if(typeof d==='object'&&d!==null&&!Array['isArray'](d)){const e=d;if(Array['isArray'](e['allocators']))d=e['allocators'];}if(!Array['isArray'](d))return;for(const f of d){if(typeof f!=='object'||f===null)continue;const g=f,h=typeof g['track']==='string'?g['track']:'settlement',i=Array['isArray'](g['sharing'])?g['sharing']:[];for(const j of i){if(typeof j!=='object'||j===null)continue;const k=j['who'];if(typeof k!=='object'||k===null)continue;const l=k;if(l['Entity']!==undefined)b['push']({'track':h,'kind':'Entity'});else{if(l['Signer']!==undefined)b['push']({'track':h,'kind':'Signer'});}}}};for(const d of a['steps']){if(d['op']==='create'&&d['object']==='service')c(d['params']['order_allocators']);if(d['op']==='configure'&&d['method']==='order_allocators')c(d['params']['allocators']);}return b;}function publicFaceStrings(a){const b=[],c={'service':['description','location'],'contact':['description','location'],'proof':['description','proof'],'repository':['description'],'demand':['description']};for(const d of a['steps']){if(d['op']!=='create')continue;const e=c[d['object']];if(e===undefined)continue;for(const h of e){const i=d['params'][h];if(typeof i==='string'&&i['length']>0x0)b['push']({'face':d['object']+'.'+h,'stepId':d['id'],'text':i});}const g=d['params']['sales'];if(Array['isArray'](g))for(const j of g){if(typeof j!=='object'||j===null)continue;const k=j;for(const l of['description','name','title']){const m=k[l];typeof m==='string'&&m['length']>0x0&&b['push']({'face':d['object']+'.sales.'+l,'stepId':d['id'],'text':m});}}}for(const n of a['steps']){if(n['op']!=='configure')continue;const o=JSON['stringify'](n['params']);if(o['includes']('\x22data\x22')){const p=n['params']['data'];typeof p==='string'&&p['length']>0x0&&b['push']({'face':'repository.data','stepId':n['id'],'text':p});}}return b;}const PII_PATTERNS=[{'kind':'email','re':/[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}/},{'kind':'street_number','re':/\b\d{1,6}\s+[A-Za-z\u00c0-\u024f\u4e00-\u9fff]+(?:\s+[A-Za-z\u00c0-\u024f\u4e00-\u9fff]+){0,3}\s+(?:st|street|rd|road|ave|avenue|blvd|ln|lane|dr|drive|way|ct|court|fl|floor|apt|unit|rm|room)\b/i},{'kind':'phone','re':/(?:\+\d{1,3}[\s.-]?)?(?:\(\d{2,4}\)[\s.-]?)?\d{3,4}[\s.-]?\d{4}(?:[\s.-]?\d{2,4})?/,'proseOnly':!![]},{'kind':'national_id','re':/\b\d{15}\b|\b\d{17}[\dXx]\b/,'proseOnly':!![]}];function firstPiiHit(a){for(const b of publicFaceStrings(a)){const c=b['face']!=='repository.data';for(const d of PII_PATTERNS){if(d['proseOnly']===!![]&&!c)continue;if(d['re']['test'](b['text']))return{'face':b['face'],'stepId':b['stepId'],'kind':d['kind']};}}return undefined;}const HASH_SHAPE=/^(?:[a-fA-F0-9]{32}|[a-fA-F0-9]{40}|[a-fA-F0-9]{64}|[A-Za-z0-9+/]{43}={0,1}|[A-Za-z0-9+/]{44})$/,TRACKING_SHAPE=/^(?:[A-Za-z]{2,4}[\s-]?\d{8,15}|\d{1,7}[\s-]\d{4,15})$/;function firstRawTrackingValue(a){for(const b of a['steps']){if(b['op']!=='configure')continue;const c=b['params']['data'];if(typeof c!=='string')continue;const d=c['trim']();if(d['length']===0x0||HASH_SHAPE['test'](d))continue;if(TRACKING_SHAPE['test'](d))return{'stepId':b['id'],'value':d};}return undefined;}function perOrderProofBinding(a){for(const b of createsOf(a,'proof')){const c=JSON['stringify'](b['params']['about']??'');if(c['includes']('order'))return b['id'];}for(const d of a['steps']){if(d['op']!=='configure')continue;if(d['method']!=='required_info'&&d['method']!=='required_info_bind')continue;if(JSON['stringify'](d['params'])['includes']('proof'))return d['id'];}return undefined;}function compositionFacts(a){const b=guardCompositionShapes(a),c=emittedPrimitives(a,b),d=b['filter'](t=>t['foreignSlots']['length']>0x0),e=thirdPartyLegs(a),f=c['has']('P6'),g=typeof a['inputs']?.['composition_variant']==='string'?a['inputs']['composition_variant']:undefined,h=g!==undefined&&g in COMPOSITION_VARIANTS,i=typeof a['inputs']?.['fulfillment_axis']==='string'?a['inputs']['fulfillment_axis']:undefined,j=i??(h?COMPOSITION_VARIANTS[g]['fulfillmentAxis']:undefined),k=j==='merchant_procured'||j==='user_procured'||j==='mixed',l=d['length']>0x0||k,m=e['length']>0x0||f,n=h?primitivesForVariant(g)['filter'](s=>!c['has'](s)):[],o=firstPiiHit(a),p={'composition_primitives_emitted':[...c]['sort']()['join'](',\x20'),'composition_cross_order_guard_count':d['length'],'third_party_fulfilment_present':l,'third_party_payout_leg_present':m,'third_party_leg_count':e['length'],'reward_pool_present':f,...j!==undefined?{'fulfillment_axis':j}:{},...g!==undefined?{'composition_variant':g,'composition_variant_known':h}:{}};if(d['length']>0x0){const s=d['find'](w=>!w['paired']),t=d['find'](w=>!w['pinned']),u=j!=='merchant_procured'&&j!=='mixed',v=u?d['find'](w=>!w['ownerCrossed']):undefined;p['first_cross_order_guard']=d[0x0]['stepId'],p['cross_order_slots_display']=d[0x0]['foreignSlots']['join'](',\x20');s!==undefined&&(p['first_cross_order_guard_unpaired']=s['stepId'],p['cross_order_unpaired_count']=d['filter'](w=>!w['paired'])['length']);if(t!==undefined)p['first_cross_order_guard_unpinned']=t['stepId'];if(v!==undefined)p['first_cross_order_guard_no_owner_cross']=v['stepId'];!u&&d['some'](w=>!w['ownerCrossed'])&&(p['cross_order_owner_tie_not_expressible']=!![]);}l&&!m&&(p['third_party_fulfilment_without_payout']=!![]);h&&n['length']>0x0&&(p['composition_variant_missing_primitives']=n['join'](',\x20'),p['composition_variant_missing_count']=n['length']);g==='V3'&&(p['composition_dual_refund_unblockable']=!![],p['composition_disclosure_count']=disclosuresFor('V3')['length']);o!==undefined&&(p['first_pii_public_face']=o['face'],p['first_pii_public_face_step']=o['stepId'],p['first_pii_kind']=o['kind']);const q=firstRawTrackingValue(a);q!==undefined&&(p['first_raw_tracking_value_step']=q['stepId'],p['first_raw_tracking_value']=q['value']);const r=perOrderProofBinding(a);if(r!==undefined)p['per_order_proof_binding_step']=r;return p;}function guardQualityFacts(a){const b=e=>a['filter'](g=>g['rule']===e),c=e=>'guard\x20\x27'+e['key']+'\x27:\x20'+e['subject'],d=(e,f)=>{const g=b(e);if(g['length']===0x0)return{};return{[f+'_count']:g['length'],['first_'+f]:c(g[0x0]),[f+'_display']:g['map'](c)['join'](';\x20')};};return{...d('GUARD-EQUALITY-DRIFT','guard_equality_drift'),...d('GUARD-THRESHOLD-LITERAL','guard_threshold_literal'),...d('GUARD-SET-COLLAPSE','guard_set_collapse'),...d('GUARD-INPUT-TRUST','guard_input_trust'),...d('GUARD-ABORT-SAFE','guard_abort_unsafe')};}export function planFacts(c){const d=new Map(createsOf(c,'guard')['map'](bn=>[bn['id'],guardProjection(bn)])),f=allocatorRows(c),h=machineProjection(c),k=createsOf(c,'service')['length']>0x0,l=createsOf(c,'repository')['length']>0x0,o=c['steps']['some'](bn=>{if(!(bn['op']==='create'&&bn['object']==='service'||bn['op']==='configure'&&bn['method']==='sales'))return![];const bo=bn['params']['sales'];return Array['isArray'](bo)&&bo['length']>0x0;}),q=new Set();for(const bn of f){const bo=bn['guardStep']===undefined?undefined:d['get'](bn['guardStep']);for(const bp of bo?.['acceptedNodes']??[])q['add'](bp);}const u=new Set(h?.['optionalNodes']??[]),w=(h?.['terminals']??[])['filter'](bq=>!u['has'](bq)),x=new Set(),y=new Set(f['map'](bq=>bq['guardStep'])['filter'](bq=>bq!==undefined));for(const bq of h?.['edges']??[]){if(bq['next']===''||bq['guards']['length']===0x0)continue;for(const br of bq['guards']){if(!y['has'](br))continue;if((d['get'](br)?.['acceptedNodes']['length']??0x0)===0x0)x['add'](bq['next']);}}const z=[];for(const bs of h?.['edges']??[]){if(!bs['forwardNames']['includes']('WithdrawClaim')||bs['guards']['length']===0x0)continue;const bt=bs['guards']['map'](bu=>d['get'](bu))['filter'](bu=>bu!==undefined);bt['length']>0x0&&!bt['some'](bu=>bu['queries']['includes']('order.dispute.open'))&&z['push']((bs['prev']||'(entry)')+'->'+bs['next']);}const A=bu=>bu['forwardNames']['some'](bv=>/withdraw/i['test'](bv)),B=[];for(const bu of h?.['edges']??[]){if(A(bu)||bu['guards']['length']===0x0)continue;const bv=bu['guards']['map'](bw=>d['get'](bw))['filter'](bw=>bw!==undefined);bv['some'](bw=>bw['queries']['includes']('order.dispute.open'))&&B['push']((bu['prev']||'(entry)')+'->'+bu['next']);}const C=[];for(const bw of h?.['edges']??[]){if(!A(bw)||bw['guards']['length']===0x0)continue;const bx=bw['guards']['map'](by=>d['get'](by))['filter'](by=>by!==undefined);bx['some'](by=>by['queries']['includes']('order.dispute.open'))&&!bx['some'](by=>by['queries']['includes']('order.claimed_by'))&&C['push']((bw['prev']||'(entry)')+'->'+bw['next']);}const D=(h?.['edges']??[])['some'](by=>by['forwardNames']['some'](bz=>/conclude|compensate/i['test'](bz))),E=B['length']>0x0&&C['length']>0x0&&!D,F=B['length']>0x0&&C['length']>0x0&&D,G=w['find'](by=>!q['has'](by)&&!x['has'](by)),H=(h?.['finalRoleNodes']??[])['find'](by=>!q['has'](by)&&!x['has'](by)),I=(h?.['edges']??[])['find'](by=>(h?.['cancelledNodes']??[])['includes'](by['prev'])&&(by['forwardNames']['some'](bz=>/review|reward/i['test'](bz))||/review|reward/i['test'](by['next']))),J=new Set([...h?.['finalRoleNodes']??[],...q,...x]),K=[[/settle|release|payout|\bband\b/i,'settle'],[/recover|award/i,'recover'],[/refund|return/i,'refund'],[/arb|indemnity|dispute/i,'arb']],L=by=>{const bz=[by['next'],...by['forwardNames'],...by['guards']['flatMap'](bA=>d['get'](bA)?.['queries']??[])];for(const [bA,bB]of K){if(bz['some'](bC=>bA['test'](bC)))return bB;}return undefined;};let M;for(const by of h?.['edges']??[]){if(by['next']===''||!J['has'](by['next']))continue;for(const bz of by['forwardRails']){const bA=bz['perm']!==undefined&&bz['perm']>0x0;typeof bz['roster']==='string'&&bz['roster']!==''&&!bA&&(M??=by['prev']+'->'+by['next']+'\x20(forward\x20'+bz['name']+')');}}const N=new Map();for(const bB of h?.['edges']??[]){if(bB['next']===''||!J['has'](bB['next']))continue;const bC=L(bB);if(bC===undefined)continue;for(const bD of bB['forwardRails']){if(typeof bD['perm']==='number'&&bD['perm']>0x0){const bE=N['get'](bD['perm'])??N['set'](bD['perm'],new Set())['get'](bD['perm']);bE['add'](bC);}}}const O=[...N['entries']()]['find'](([,bF])=>bF['size']>=0x2),P=c['pending_guards']??[],Q=P['filter'](bF=>bF['site']==='allocator')['length'],R=P['filter'](bF=>bF['site']==='allocator'||bF['site']==='machine_edge'),S=P['filter'](bF=>bF['site']==='service_buy'),T=R[0x0]?.['key'],U=S[0x0]?.['key'],V=h?.['nodes']['find'](bF=>/return/i['test'](bF)),W=c['steps']['some'](bF=>{if(bF['op']==='configure'&&bF['method']==='arbitrations'){const bG=bF['params']['objects'];return Array['isArray'](bG)&&bG['length']>0x0;}if(bF['op']==='create'&&bF['object']==='service'){const bH=bF['params']['arbitrations'];return Array['isArray'](bH)&&bH['length']>0x0;}return![];});let X,Y=![];for(const bF of c['steps']){if(bF['op']==='configure'&&bF['method']==='compensation_fund_add'){Y=!![];const bG=numericAmount(bF['params']['balance']);if(bG!==undefined)X=(X??0x0)+bG;}}let Z,a0;const a1=/free[\s_-]*tier|free[\s_-]*trial|trial|\u8bd5\u7528|\u4f53\u9a8c|\u514d\u8d39/i,a2=bH=>{if(!Array['isArray'](bH))return;for(const bI of bH){const bJ=bI,bK=numericAmount(bJ?.['price']);if(bK!==undefined&&bK>0x0){Z=Math['max'](Z??0x0,bK);const bL=typeof bJ?.['name']==='string'?bJ['name']:'';!a1['test'](bL)&&(a0=a0===undefined?bK:Math['min'](a0,bK));}}};for(const bH of c['steps']){if(bH['op']==='create'&&bH['object']==='service')a2(bH['params']['sales']);if(bH['op']==='configure'&&bH['method']==='sales')a2(bH['params']['sales']);}const a3=X!==undefined&&Z!==undefined;let a4,a5=0x0,a6=0x0;const a7=bI=>{if(!Array['isArray'](bI))return;for(const bJ of bI){const bK=bJ?.['name'];if(typeof bK!=='string'||bK==='')continue;const bL=skuNameByteLen(bK);bL>SKU_NAME_MAX_BYTES&&(a6+=0x1,a4===undefined&&(a4=bK,a5=bL));}};for(const bI of c['steps']){if(bI['op']==='create'&&bI['object']==='service')a7(bI['params']['sales']);if(bI['op']==='configure'&&bI['method']==='sales')a7(bI['params']['sales']);}const a8=new Set(),a9=bJ=>{if(!Array['isArray'](bJ))return;for(const bK of bJ){const bL=bK?.['name'];if(typeof bL==='string'&&bL!=='')a8['add'](bL);}};for(const bJ of c['steps']){if(bJ['op']==='create'&&bJ['object']==='service')a9(bJ['params']['sales']);if(bJ['op']==='configure'&&bJ['method']==='sales')a9(bJ['params']['sales']);}const aa=[];if(a8['size']>0x0)for(const bK of createsOf(c,'guard')){const bL=bK['params']['root']??bK['params']['logic'];for(const bM of collectWipHashComparisons(bL,bK['params']['table'])){!a8['has'](bM['constant'])&&aa['push']({'guard':bK['id'],'query':bM['query'],'constant':bM['constant']});}}const ab=createsOf(c,'reward')['length']>0x0;let ac,ad;if(ab)for(const bN of c['steps']){if(bN['op']==='configure'&&bN['method']==='guard_add'){const bO=bN['params']['amount'];if(bO!==undefined&&bO!==null&&bO['type']==='Fixed'){const bP=numericAmount(bO['value']);if(bP!==undefined)ac=Math['max'](ac??0x0,bP);}}if(bN['op']==='configure'&&bN['method']==='coin_add'&&/^reward/['test'](bN['id'])){const bQ=numericAmount(bN['params']['coin']);if(bQ!==undefined)ad=(ad??0x0)+bQ;}}const ae=ac!==undefined&&a0!==undefined,af=/^(arb\.indemnity|arb\.order|arb\.status|order\.dispute)/,ag=/settled|refunded|reviewed|completed|closed|cancel/i;let ah;if(h!==undefined)for(const bR of h['edges']){if(bR['next']===''||bR['guards']['length']===0x0)continue;if(!ag['test'](bR['prev']))continue;if(bR['guards']['some'](bS=>d['get'](bS)?.['queries']['some'](bT=>af['test'](bT)))){ah=bR['prev'];break;}}const ai=ah!==undefined&&(!Y||X===0x0),aj=new Map();for(const bS of createsOf(c,'guard')){aj['set'](bS['id'],bS['params']['root']??bS['params']['logic']);}const ak=h?.['edges']??[],al=bT=>bT['guards']['length']===0x0||bT['guards']['every'](bU=>{const bV=aj['get'](bU);return bV===undefined||guardWindowOpen(bV);});let am;const an=new Set(ak['filter'](bT=>bT['prev']==='')['map'](bT=>bT['next'])),ao=[];for(const bT of new Set(ak['map'](bU=>bU['prev'])['concat'](ak['map'](bU=>bU['next'])))){if(bT===''||an['has'](bT))continue;const bU=ak['filter'](bV=>bV['prev']===bT);if(bU['length']===0x0)continue;if(bU['every'](bV=>!al(bV)))ao['push'](bT);}for(const bV of ao){if(bV==='')ao['splice'](ao['indexOf'](bV),0x1);}for(const bW of ak){if(bW['prev']!==''||bW['next']==='')continue;const bX=ak['filter'](bY=>bY['prev']===bW['next']);if(bX['length']===0x0)continue;if(bX['every'](bY=>!al(bY)))am??=bW['next'];}const ap=f['some'](bY=>bY['guardStep']===undefined&&bY['guardKey']!==undefined),aq=ak['filter'](bY=>bY['guards']['length']>0x0&&bY['guards']['some'](bZ=>d['get'](bZ)?.['queries']['some'](c0=>af['test'](c0))));let ar=![];if(aq['length']>0x0&&!ap){const bY=new Set(aq['map'](c1=>c1['next'])['filter'](c1=>c1!=='')),bZ=new Set(aq['flatMap'](c1=>c1['guards'])),c0=new Set();for(const c1 of f){const c2=c1['guardStep']===undefined?undefined:d['get'](c1['guardStep']);if(c2===undefined)continue;if(c2['acceptedNodes']['length']>0x0){for(const c3 of c2['acceptedNodes'])c0['add'](c3);}else for(const c4 of ak){c4['next']!==''&&c4['guards']['includes'](c1['guardStep'])&&c0['add'](c4['next']);}}for(const c5 of f){const c6=c5['guardStep']===undefined?undefined:d['get'](c5['guardStep']);if(c6===undefined)continue;if(c6['queries']['some'](c7=>af['test'](c7))||bZ['has'](c5['guardStep'])){ar=!![];break;}}if(!ar)for(const c7 of bY){if(c0['has'](c7)){ar=!![];break;}}}const as=aq['length']>0x0&&!ar&&!ap,at=aq[0x0]===undefined?undefined:aq[0x0]['prev']!==''?aq[0x0]['prev']:aq[0x0]['next'],au=[];for(const c8 of c['steps']){const c9=c8['op']==='create'&&c8['object']==='service',ca=c8['op']==='configure'&&c8['method']==='sales';if(!c9&&!ca)continue;const cb=c8['params'];if(typeof cb['description']==='string')au['push'](cb['description']);if(!Array['isArray'](cb['sales']))continue;for(const cc of cb['sales']){if(typeof cc!=='object'||cc===null)continue;for(const cd of Object['values'](cc)){if(typeof cd==='string')au['push'](cd);}}}const av=au['flatMap'](ce=>extractProseWindowPromises(ce)),aw=collectEnforcedWindowMs(c),ax=av['filter'](ce=>!aw['has'](ce['ms'])),ay=[];for(const ce of au){const cf=UNANCHORED_RESTART_RE['exec'](ce);if(cf)ay['push'](cf[0x0]);}const az=f['filter'](cg=>cg['track']==='refund');let aA=![];if(h!==undefined)for(const cg of h['edges']){if(cg['next']!=='closed_refunded'||cg['guards']['length']===0x0)continue;if(cg['guards']['some'](ch=>(d['get'](ch)?.['queries']??[])['includes']('order.principal_refunded'))){aA=!![];break;}}let aB=0x0;const aC=[];if(h!==undefined)for(const ch of h['edges']){const ci=ch['forwardNames']['filter'](cj=>cj['endsWith']('_late'));if(ci['length']===0x0)continue;for(const cj of ci){aB+=0x1;const ck=ch['guards']['some'](cl=>(d['get'](cl)?.['queries']??[])['some'](cm=>/^permission\.entity\.perm/['test'](cm)));if(!ck)aC['push'](ch['prev']+'\x20->\x20'+ch['next']+'\x20('+cj+')');}}const aD=[];let aE=0x0;for(const cl of f){if(cl['track']!=='settlement')continue;const cm=cl['guardStep']===undefined?[]:d['get'](cl['guardStep'])?.['queries']??[],cn=[];if(cm['includes']('order.owner'))cn['push']('order.owner==signer\x20(buyer)');if(cm['includes']('order.agent'))cn['push']('order.agent\x20has\x20signer');if(cm['includes']('order.service'))cn['push']('order.service\x20binding');if(cm['some'](cp=>/^permission\.(owner|admin)$/['test'](cp)))cn['push']('permission\x20role');const co=cl['guardStep']??cl['guardKey']??'<unbound>';cn['length']===0x0?aD['push'](co+':\x20no\x20guard\x20identity\x20face\x20(edge\x20rail:\x20merchant\x20permission\x201000\x20default)'):(cn['every'](cp=>cp['startsWith']('order.owner')||cp['startsWith']('order.agent'))&&!cm['includes']('order.service')&&!cm['some'](cp=>/^permission\./['test'](cp))&&(aE+=0x1),aD['push'](co+':\x20'+cn['join']('\x20|\x20')));}const aF=new Map();for(const cp of h?.['edges']??[]){for(const cq of cp['guards']){const cs=aF['get'](cq)??[];if(cp['prev']!=='')cs['push'](cp['prev']);if(cp['next']!=='')cs['push'](cp['next']);aF['set'](cq,cs);}}let aG,aH=![];for(const ct of d['values']()){if(ct['queries']['some'](isPathDependentTimeQuery)){aG??=ct['stepId'];if(h!==undefined){const cu=[...ct['acceptedNodes'],...aF['get'](ct['stepId'])??[]];for(const cv of cu){if(pathCountCap2(h['edges'],cv)>=0x2){aH=!![],aG=ct['stepId'];break;}}}}if(aH)break;}const aI=[...d['values']()]['flatMap'](cw=>cw['queries']);let aJ;for(const cw of WRITE_ONLY_ENFORCEMENT_SOURCES){for(const cx of createsOf(c,cw['object'])){if(cw['extract'](cx)&&!aI['some'](cy=>cy['startsWith'](cw['coverQuery']))){aJ=cw['param'];break;}}if(aJ!==undefined)break;}const aK=new Set();for(const cy of c['steps']){if(cy['op']==='create'&&cy['object']==='guard')continue;const cz=refsOf(cy['op']==='publish'?cy['target']:cy['params']);for(const cA of cz)aK['add'](cA);if(cy['op']==='configure'){for(const cB of refsOf(cy['target']))aK['add'](cB);}}const aL=[...d['keys']()]['find'](cC=>!aK['has'](cC)),aM=[...d['values']()]['find'](cC=>!l&&cC['queries']['some'](cD=>cD['startsWith']('repository.')))?.['stepId'];let aN;if(k&&h!==undefined)for(const cC of h['forwardGuardRefs']){const cD=d['get'](cC);if(cD===undefined)continue;const cE=cD['table']['some'](cF=>cF['identifier']===TASK_BINDING_SLOT&&cF['b_submission']===!![]);if(!cE){aN=cC;break;}}let aO;for(const cF of f){if(cF['guardStep']===undefined||cF['identifierLegs']['length']===0x0)continue;const cG=d['get'](cF['guardStep']);if(cG===undefined)continue;for(const cH of cF['identifierLegs']){const cI=cG['table']['find'](cJ=>cJ['identifier']===cH);if(cI===undefined||cI['b_submission']!==!![]||cI['value_type']!=='Address'){aO='slot\x20'+cH+'\x20of\x20guard\x20\x27'+cF['guardStep']+'\x27';break;}}if(aO!==undefined)break;}const aP=new Set();for(const {policies:cJ}of repositoryPoliciesMerged(c)){for(const cK of cJ){const cL=cK?.['name'];if(typeof cL==='string')aP['add'](cL);}}const aQ=[];if(aP['size']>0x0)for(const cM of createsOf(c,'guard')){const cN=Array['isArray'](cM['params']['table'])?cM['params']['table']:[];for(const cO of collectRepoWhereQueries(cM['params']['root']??cM['params']['logic'])){const cP=staticStringOperand(cO['key'],cN);if(cP===undefined)continue;if(!isPlanLocalObjectOperand(cO['object'],cN))continue;!aP['has'](cP)&&aQ['push']('\x27'+cP+'\x27\x20in\x20guard\x20\x27'+cM['id']+'\x27');}}const aR=[];for(const cQ of createsOf(c,'guard')){const cR=Array['isArray'](cQ['params']['table'])?cQ['params']['table']:[];for(const cS of collectRepoWhereQueries(cQ['params']['root']??cQ['params']['logic'])){const cT=cS['type'];if(typeof cT!=='string'||!cT['includes']('sum_where'))continue;const cU=cS['object'];if(typeof cU!=='object'||cU===null)continue;const cV=cU['identifier'];if(typeof cV!=='number')continue;const cW=cR['find'](cX=>typeof cX==='object'&&cX!==null&&cX['identifier']===cV);cW!==undefined&&cW['b_submission']===!![]&&aR['push']('slot\x20'+cV+'\x20of\x20guard\x20\x27'+cQ['id']+'\x27');}}const aS=[];{const cX=new Map(createsOf(c,'guard')['map'](d0=>[d0['id'],guardProjection(d0)])),cY=[],cZ=d0=>{if(typeof d0==='object'&&d0!==null&&!Array['isArray'](d0)){const d1=d0;if(Array['isArray'](d1['allocators']))d0=d1['allocators'];}if(!Array['isArray'](d0))return;for(const d2 of d0){if(typeof d2!=='object'||d2===null)continue;const d3=d2,d4=[],d5=Array['isArray'](d3['sharing'])?d3['sharing']:[];for(const d8 of d5){if(typeof d8!=='object'||d8===null)continue;const d9=d8['who'];if(typeof d9!=='object'||d9===null)continue;const da=d9;if(typeof da['GuardIdentifier']==='number')d4['push']('guard-slot:'+da['GuardIdentifier']);else{if(typeof da['Entity']==='string')d4['push']('entity:'+String(da['Entity'])['toLowerCase']());else{if(da['Signer']!==undefined)d4['push']('signer');}}}const d6=isRef(d3['guard'])?d3['guard']['$ref']:undefined,d7=d6!==undefined?cX['get'](d6):undefined;cY['push']({'track':typeof d3['track']==='string'?d3['track']:'settlement','guard':d6??'(keyed)','nodes':d7?[...d7['acceptedNodes']]['sort']():[],'payees':[...d4]['sort']()});}};for(const d0 of c['steps']){if(d0['op']==='create'&&d0['object']==='service')cZ(d0['params']['order_allocators']);if(d0['op']==='configure'&&d0['method']==='order_allocators')cZ(d0['params']['allocators']);}for(let d1=0x0;d1<cY['length'];d1++){for(let d2=d1+0x1;d2<cY['length'];d2++){const d3=cY[d1],d4=cY[d2];if(d3['nodes']['length']===0x0||d4['nodes']['length']===0x0)continue;if(d3['payees']['length']===0x0||d4['payees']['length']===0x0)continue;const d5=d3['nodes']['some'](d7=>d4['nodes']['includes'](d7)),d6=d3['payees']['length']===d4['payees']['length']&&d3['payees']['every']((d7,d8)=>d7===d4['payees'][d8]);d5&&!d6&&aS['push']('row#'+(d1+0x1)+'('+d3['track']+',guard\x20\x27'+d3['guard']+'\x27,pays\x20'+d3['payees']['join']('|')+')\x20vs\x20'+('row#'+(d2+0x1)+'('+d4['track']+',guard\x20\x27'+d4['guard']+'\x27,pays\x20'+d4['payees']['join']('|')+')\x20share\x20node(s)\x20')+('['+d3['nodes']['filter'](d7=>d4['nodes']['includes'](d7))['join'](',')+']\x20with\x20different\x20payees'));}}}const aT=new Set();for(const {policies:d7}of repositoryPoliciesMerged(c)){for(const d8 of d7){const d9=d8?.['write_guard'];if(!Array['isArray'](d9))continue;for(const da of d9){const db=da?.['guard'],dc=isRef(db)?db['$ref']:db;if(typeof dc==='string')aT['add'](dc);}}}let aU,aV=0x0;for(const dd of createsOf(c,'guard')){if(!aT['has'](dd['id']))continue;rootNegatesRepoDataHas(dd['params']['root']??dd['params']['logic'])&&(aV++,aU??=dd['id']);}const aW=[],aX=new Set(),aY=de=>{if(!Array['isArray'](de))return[];return de['filter'](df=>typeof df==='object'&&df!==null)['filter'](df=>df['write_once']===!![]&&typeof df['name']==='string')['map'](df=>df['name']);};for(const de of c['steps']){if(de['op']==='create'&&de['object']==='repository'){for(const di of aY(de['params']['policies']))aX['add'](di);continue;}if(de['op']!=='configure'||de['method']!=='policies')continue;const df=de['params'],dg=typeof df['op']==='string'?df['op']:'add',dh=(dj,dk)=>{aW['push']('step\x20\x27'+de['id']+'\x27\x20'+dj+':\x20'+dk['join'](',\x20'));};if(dg==='set'){const dj=new Set(aY(df['policy'])),dk=[...aX]['filter'](dl=>!dj['has'](dl));if(dk['length']>0x0)dh('REPLACES\x20the\x20policy\x20list\x20and\x20drops\x20write_once\x20attestation(s)',dk);for(const dl of aY(df['policy']))aX['add'](dl);}else{if(dg==='remove'){const dm=Array['isArray'](df['policy'])?df['policy']['filter'](dp=>typeof dp==='string'):[],dn=dm['filter'](dp=>aX['has'](dp));if(dn['length']>0x0)dh('REMOVES\x20write_once\x20attestation\x20policy/policies',dn);for(const dp of dn)aX['delete'](dp);}else{if(dg==='clear'){if(aX['size']>0x0)dh('CLEARS\x20the\x20policy\x20list\x20including\x20write_once\x20attestation(s)',[...aX]);aX['clear']();}else{if(Array['isArray'](df['policy']))for(const dq of df['policy']){const dr=dq;if(typeof dr?.['name']!=='string')continue;const ds=dr['name'];if(dr['write_once']===!![])aX['add'](ds);else aX['has'](ds)&&(dh('UPDATES\x20a\x20write_once\x20policy\x20with\x20write_once\x20unset/false\x20(silent\x20downgrade)',[ds]),aX['delete'](ds));}}}}}const aZ=new Map(createsOf(c,'guard')['map'](dt=>[dt['id'],dt]));let b0,b1=0x0,b2,b3=0x0,b4;for(const {policies:dt}of repositoryPoliciesMerged(c)){for(const du of dt){const dv=du,dw=dv['write_guard'];if(!Array['isArray'](dw))continue;const dx=typeof dv['id_from']==='string'?dv['id_from']['toLowerCase']():'none',dy=dx==='none'?'caller-keyed':dx+'-keyed',dz=typeof dv['description']==='string'?dv['description']:'';for(const dA of dw){const dB=dA?.['guard'],dC=isRef(dB)?dB['$ref']:dB,dD=typeof dC==='string'?aZ['get'](dC):undefined;if(dD===undefined)continue;const dE=writeGuardLegClass(dD['params']['root']??dD['params']['logic'],dD['params']['table']);if(!dE['hasSignerLeg']||dE['hasBindingLeg'])continue;const dF='guard\x20\x27'+dD['id']+'\x27\x20(policy\x20\x27'+String(dv['name']??'?')+'\x27,\x20'+dy+')';dx==='signer'||dx==='clock'?(b3++,b2??=dF):(b1++,b0??=dF),WRITE_GUARD_PROMISE_RE['test'](dz)&&!WRITE_GUARD_TAUTOLOGY_DISCLOSURE_RE['test'](dz)&&(b4??=dF+'\x20—\x20its\x20description\x20promises\x20a\x20bound\x20writer\x20set\x20the\x20guard\x20legs\x20never\x20encode');}}}let b5,b6=0x0;for(const dG of createsOf(c,'service')){const dH=dG['params']['customer_required'];if(!Array['isArray'](dH)||dH['length']===0x0)continue;dG['params']['buy_guard']===undefined&&(b6++,b5??=dG['id']);}let b7,b8=0x0;for(const dI of h?.['edges']??[]){if(dI['prev']===''||dI['guards']['length']===0x0)continue;for(const dJ of dI['guards']){const dK=d['get'](dJ);if(dK===undefined||dK['acceptedNodes']['length']===0x0)continue;!dK['acceptedNodes']['includes'](dI['prev'])&&(b8++,b7??=dJ+'\x20on\x20edge\x20'+dI['prev']+'->'+dI['next']+'\x20(guard\x20pins\x20progress.current\x20in\x20'+('['+dK['acceptedNodes']['join'](',\x20')+']\x20—\x20never\x20\x27'+dI['prev']+'\x27)'));}}let b9;if(h!==undefined){const dL=(h['edges']['find'](dN=>dN['prev']==='')??{'next':''})['next'],dM=new Set([...h['finalRoleNodes'],...h['optionalNodes']]);for(const dN of h['nodes']){if(dM['has'](dN)||dN===dL)continue;const dO=h['edges']['filter'](dQ=>dQ['prev']===dN&&dQ['next']!==dN);if(dO['length']===0x0)continue;const dP=dO['some'](dQ=>dQ['guards']['length']===0x0||dQ['guards']['some'](dR=>{const dS=d['get'](dR);return dS===undefined||dS['acceptedNodes']['length']===0x0||dS['acceptedNodes']['includes'](dN);}));if(!dP)b9??=dN;}}let ba,bb=0x0;{const dQ=new Set(h?.['forwardGuardRefs']??[]);for(const dR of h?.['edges']??[])for(const dS of dR['guards'])dQ['add'](dS);for(const dT of f){const dU=/refund|settle|recover/i['test'](dT['track'])||/refund|settle|recover/i['test'](dT['guardKey']??'');if(!dU||dT['guardStep']===undefined)continue;const dV=d['get'](dT['guardStep']);if(dV===undefined)continue;const dW=dV['acceptedNodes']['length']>0x0||dQ['has'](dT['guardStep'])||dV['queries']['includes']('order.dispute.open'),dX=dV['queries']['includes']('order.owner')||dV['queries']['includes']('order.agent\x20has')||dV['queries']['includes']('order.service');if(dW||dX)continue;bb++,ba??=dT['track']+'\x20row\x20on\x20guard\x20\x27'+(dT['guardKey']??dT['guardStep'])+'\x27\x20('+dT['guardStep']+')\x20—\x20pins\x20no\x20progress\x20node,\x20rides\x20no\x20machine\x20edge,\x20references\x20no\x20order\x20identity\x20or\x20dispute\x20state';}}const bc=[];for(const dY of createsOf(c,'guard')){const dZ=reachLegsOf(dY);bc['push'](...findReachContradictions(dY['id'],dZ['legs'],dZ['selfStrict']));}const bd=[];for(const e0 of createsOf(c,'guard')){const e1=e0['params']['root']??e0['params']['logic'],e2=e0['params']['table'],e3=typeof e0['params']['description']==='string'?e0['params']['description']:'',e4=equalityFaceCheck(e0['id'],e3,e1);if(e4!==null)bd['push'](e4);bd['push'](...thresholdLiteralCheck(e0['id'],e2)),bd['push'](...setCollapseCheck(e0['id'],e2)),bd['push'](...submissionRowIdTrustCheck(e0['id'],e1,e2)),bd['push'](...abortSafeVerbCheck(e0['id'],e1));}const be=new Map();for(const e5 of h?.['edges']??[]){const e6=be['get'](e5['prev'])??[];e6['push'](e5['next']),be['set'](e5['prev'],e6);}const bf=new Map();for(const e7 of findLoopCycles(be)){const e8=classifyLoopCycle(e7['cycle']);for(const e9 of e7['cycle'])bf['set'](e9,e8);}const bg=ea=>{const eb=bf['get'](ea);return eb==='renewal'||eb==='charge';},bh=[];if(bf['size']>0x0)for(const ea of createsOf(c,'guard')){const eb=ea['params']['root']??ea['params']['logic'];if(eb===undefined)continue;const ec=typeof ea['params']['description']==='string'?ea['params']['description']:'',ed=ee=>{if(!ee||typeof ee!=='object')return;if(Array['isArray'](ee)){ee['forEach'](ed);return;}const ef=ee,eg=typeof ef['type']==='string'?ef['type']:'',eh=ef['where']??null;if(eg['startsWith']('query_progress_history_time')&&ef['find']==='first'&&eh!==null&&typeof eh==='object'){const ei=typeof eh['nextNode']==='string'?eh['nextNode']:undefined;if(ei!==undefined&&bg(ei)){const ej=/\bper[- ]period\b|\bthis period\b|\beach period\b|\bevery period\b|\u6bcf\u671f|\u5f53\u671f|\u672c\u671f/i['test'](ec);bh['push']({'guard':ea['id'],'target':ei,'perPeriodClaim':ej});}}for(const ek of Object['values'](ef))ed(ek);};ed(eb);}const bi=ee=>'guard\x20\x27'+ee['guard']+'\x27\x20anchors\x20a\x20history\x20clock\x20at\x20find:\x22first\x22\x20on\x20PERIODIC\x20node\x20\x27'+ee['target']+'\x27\x20'+'(re-enters\x20per\x20billed\x20period)'+(ee['perPeriodClaim']?'\x20while\x20its\x20description\x20claims\x20per-period\x20semantics\x20—\x20period\x202+\x20reads\x20the\x20FIRST\x20visit\x27s\x20timestamp\x20(ofnz8\x20F-61)':'\x20—\x20intentional\x20once-per-life\x20gate,\x20or\x20the\x20stale-anchor\x20defect\x20(ofnz8\x20F-61)?'),bj=bh['find'](ee=>ee['perPeriodClaim'])??bh[0x0],bk=[],bl=[],bm=(ee,ef,eg,eh)=>{if(ef===null||typeof ef!=='object')return;if(Array['isArray'](ef)){ef['forEach']((ei,ej)=>bm(ee,ei,eg+'['+ej+']',eh));return;}for(const [ei,ej]of Object['entries'](ef)){const ek=eg?eg+'.'+ei:ei,el=typeof ej==='number'&&Number['isFinite'](ej)&&!Number['isInteger'](ej);/_days$/['test'](ei)&&ei!=='campaign_duration_days'&&el&&bk['push']('step\x20\x27'+ee+'\x27:\x20'+ek+'\x20=\x20'+ej+'\x20—\x20the\x20U64\x20day\x20slot\x20truncates\x20to\x20'+Math['trunc'](ej)+'\x20at\x20BCS\x20encode'),eh&&(/_hours$/['test'](ei)||/_minutes$/['test'](ei))&&el&&bl['push']('step\x20\x27'+ee+'\x27:\x20'+ek+'\x20=\x20'+ej+'\x20—\x20the\x20U64\x20'+(/_minutes$/['test'](ei)?'minute':'hour')+'\x20slot\x20truncates\x20to\x20'+Math['trunc'](ej)+'\x20at\x20BCS\x20encode'),bm(ee,ej,ek,eh);}};for(const ee of c['steps']){const ef=ee['params'];if(ef!==undefined)bm(ee['id'],ef,'',!![]);}return bm('<plan.inputs>',c['inputs'],'',![]),{...compositionFacts(c),'has_service':k,'has_machine':h!==undefined,'has_repository':l,'sales_step_present':o,'allocator_row_count':f['length'],'refund_row_count':az['length'],'terminal_count':w['length'],'terminal_nodes_display':w['join'](',\x20'),'pending_allocator_guard_count':Q,'pending_guard_total':P['length'],...G===undefined?{}:{'first_uncovered_terminal':G},...H===undefined?{}:{'first_uncovered_final_node':H},...I===undefined?{}:{'first_cancelled_review_bridge':I['prev']+'\x20->\x20'+I['next']+(I['forwardNames']['length']>0x0?'\x20(forward\x20'+I['forwardNames']['join'](',\x20')+')':'')},...M===undefined?{}:{'first_roster_null_perm_edge':M},...O===undefined?{}:{'coarse_perm_bucket_index':O[0x0],'coarse_perm_bucket_classes':[...O[0x1]]['sort']()['join'](',\x20')},...b9===undefined?{}:{'first_pinned_away_exit_node':b9},'direction_blind_pay_edge_count':bb,...ba===undefined?{}:{'first_direction_blind_pay_edge':ba},...aG===undefined?{}:{'first_path_dependent_anchor':aG},'path_sensitive':aH,...aJ===undefined?{}:{'first_write_only_unenforced_field':aJ},...aL===undefined?{}:{'first_orphan_guard':aL},...aM===undefined?{}:{'first_repo_query_without_repository':aM},'repo_write_once_guard_count':aV,...aU===undefined?{}:{'first_repo_write_once_guard':aU},...aW['length']===0x0?{}:{'write_once_removable_count':aW['length'],'first_write_once_removable':aW[0x0],'write_once_removable_display':aW['join'](';\x20')},'tautology_write_guard_count':b1,...b0===undefined?{}:{'first_tautology_write_guard':b0},'keyed_tautology_write_guard_count':b3,...b2===undefined?{}:{'first_keyed_tautology_write_guard':b2},...b4===undefined?{}:{'first_promise_gap_write_guard':b4},'customer_required_unbacked_count':b6,...b5===undefined?{}:{'first_customer_required_unbacked':b5},...aN===undefined?{}:{'first_edge_guard_missing_254':aN},'node_mismatched_guard_count':b8,...b7===undefined?{}:{'first_node_mismatched_guard':b7},'guard_reach_contradiction_count':bc['length'],...bc['length']>0x0?{'first_guard_reach_contradiction':bc[0x0],'guard_reach_contradiction_display':bc['join'](';\x20')}:{},...guardQualityFacts(bd),...bh['length']>0x0?{'first_guard_find_polarity':bi(bj),'guard_find_polarity_count':bh['length'],...bh['some'](eg=>eg['perPeriodClaim'])?{'guard_find_polarity_per_period':!![]}:{},'guard_find_polarity_display':bh['map'](bi)['join'](';\x20')}:{},...bk['length']>0x0?{'fractional_day_knob_count':bk['length'],'first_fractional_day_knob':bk[0x0],'fractional_day_knob_display':bk['join'](';\x20')}:{},...bl['length']>0x0?{'fractional_hour_knob_count':bl['length'],'first_fractional_hour_knob':bl[0x0],'fractional_hour_knob_display':bl['join'](';\x20')}:{},...aO===undefined?{}:{'first_alloc_slot_missing':aO},...T===undefined?{}:{'first_pending_fund_guard':T,'pending_fund_guard_count':R['length'],'pending_fund_guard_keys_display':R['map'](eg=>eg['key'])['join'](',\x20')},...U===undefined?{}:{'first_pending_buy_guard':U,'pending_buy_guard_count':S['length'],'pending_buy_guard_keys_display':S['map'](eg=>eg['key'])['join'](',\x20')},'has_return_rail':V!==undefined,...V===undefined?{}:{'return_rail_node':V},'has_arbitration_binding':W,'fund_topup_present':Y,...X===undefined?{}:{'fund_topup_amount':X},...a3?{'fund_ceiling_breach':X<MAX_INDEMNITY_MULTIPLE*Z,'fund_ceiling_basis':MAX_INDEMNITY_MULTIPLE+'x\x20the\x20highest\x20SKU\x20price','fund_concurrent_orders_coverable':Math['floor'](X/(MAX_INDEMNITY_MULTIPLE*Z))}:{},'fund_ceiling_unverifiable':Y&&!a3,...ac!==undefined?{'reward_bounty_amount':ac,...ad!==undefined?{'reward_funding_amount':ad}:{},...ad!==undefined&&ac>0x0?{'reward_max_claims':Math['floor'](ad/ac)}:{},...ae?{'lowest_sku_price':a0,'reward_scale_breach':ac>0.5*a0,'reward_scale_ratio_display':(ac/a0)['toFixed'](0x2)+'x\x20the\x20cheapest\x20SKU\x20price'}:{'reward_scale_unverifiable':!![]}}:{},...a6>0x0?{'dead_sku_count':a6,'first_dead_sku_name':a4,'first_dead_sku_bytes':a5}:{},...ai?{'first_arb_exit_node':ah,'fund_arb_route_unfunded':!![]}:{},...am===undefined?{}:{'entry_no_open_exit':!![],'entry_strand_node':am},...ao['length']===0x0?{}:{'window_strand_nodes':ao['join'](',\x20'),'window_strand_count':ao['length']},...as&&at!==undefined?{'arb_promise_without_settle_rail':!![],'arb_promise_node':at}:{},...aq['length']>0x0&&ap&&at!==undefined?{'arb_key_plane_opaque':!![],'arb_key_plane_node':at}:{},...av['length']>0x0?{'prose_window_promise_count':av['length'],'enforced_window_ms_display':[...aw]['sort']((eg,eh)=>eg-eh)['map'](formatMs)['join'](',\x20')||'none',...ax['length']>0x0?{'prose_time_mismatch_count':ax['length'],'first_prose_time_mismatch':ax[0x0]['quote'],'prose_time_mismatch_display':ax['map'](eg=>eg['quote'])['join'](';\x20')}:{}}:{},...ay['length']>0x0?{'unanchored_window_promise_count':ay['length'],'first_unanchored_window_promise':ay[0x0]}:{},...aP['size']>0x0?{'repo_policy_keys_display':[...aP]['join'](',\x20'),...aQ['length']>0x0?{'repo_gate_key_unbacked_count':aQ['length'],'first_repo_gate_key_unbacked':aQ[0x0],'repo_gate_key_unbacked_display':aQ['join'](',\x20')}:{}}:{},...aa['length']>0x0?{'wip_query_totality_count':aa['length'],'first_wip_query_totality':aa[0x0]['guard']+':\x20'+aa[0x0]['query']+'\x20vs\x20\x27'+aa[0x0]['constant']+'\x27','wip_query_totality_display':aa['map'](eg=>eg['guard']+':\x20'+eg['query']+'\x20vs\x20\x27'+eg['constant']+'\x27')['join'](';\x20'),'wip_query_totality_sku_display':[...a8]['join'](',\x20')}:{},...aR['length']>0x0?{'repo_agg_submitted_count':aR['length'],'first_repo_agg_submitted':aR[0x0],'repo_agg_submitted_display':aR['join'](',\x20')}:{},...aS['length']>0x0?{'alloc_overlap_payee_count':aS['length'],'first_alloc_overlap_payee':aS[0x0],'alloc_overlap_payee_display':aS['join'](';\x20')}:{},...az['length']>0x0&&!aA?{'refund_convergence_missing':!![]}:{},...aB>0x0?{'late_remedy_edge_count':aB}:{},...aC['length']>0x0?{'late_remedy_gate_missing':!![],'first_late_remedy_gate_missing':aC[0x0],'late_remedy_gate_missing_display':aC['join'](';\x20')}:{},...z['length']>0x0?{'withdraw_no_case_bind_count':z['length'],'first_withdraw_no_case_bind':z[0x0],'withdraw_no_case_bind_display':z['join'](';\x20')}:{},...B['length']>0x0?{'dispute_freeze_rail_count':B['length'],'dispute_freeze_rail_display':B['join'](';\x20')}:{},...B['length']>0x0&&C['length']>0x0?{'dispute_exit_live_withdraw_count':C['length'],'dispute_exit_live_withdraw_display':C['join'](';\x20'),...E?{'dispute_exit_dead_topology':0x1}:{},...F?{'dispute_exit_indirect_stamp':0x1}:{}}:{},...aD['length']>0x0?{'settlement_triggers_display':aD['join'](';\x20'),...aE>0x0?{'settlement_buyer_only_count':aE}:{}}:{}};}function planRuleBook(){const a=getJudgmentDoc()['rules']['domains']['plan'];if(!a)throw new Error('factory\x20rule\x20pack\x20\x27plan\x27\x20missing\x20—\x20broken\x20installation');return a['rules'];}export function auditPlan(a){const b=validatePlan(a),c=planFacts(a),{findings:d}=evaluateRuleBook(planRuleBook(),c),e=b['length']>0x0||d['some'](g=>g['level']==='critical'||g['level']==='high');return{'issues':b,'findings':d,'facts':c,'blocking':e};}
|
|
1
|
+
import{getJudgmentDoc,rulePackDiagnostics}from'../config/judgment.js';import{evaluateRuleBook}from'../config/rule-engine.js';import{COMPOSITION_VARIANTS,disclosuresFor,primitivesForVariant,isPathDependentTimeQuery}from'../chain-semantics/index.js';import{MAX_INDEMNITY_MULTIPLE,ONCE_SLOT_BYTES,TASK_BINDING_SLOT}from'../knowledge/onchain-constants.js';import{classifyLoopCycle,numericAmount}from'../knowledge/audit-rules.js';import{abortSafeVerbCheck,equalityFaceCheck,setCollapseCheck,submissionRowIdTrustCheck,thresholdLiteralCheck}from'../knowledge/guard-quality.js';import{findLoopCycles}from'../knowledge/machine-topology.js';import{SKU_NAME_MAX_BYTES,skuNameByteLen}from'../knowledge/sku-name-gate.js';import{createsOf,isRef,refsOf,validatePlan}from'./plan.js';function collectQueries(a,b=[]){if(Array['isArray'](a)){for(const c of a)collectQueries(c,b);}else{if(typeof a==='object'&&a!==null){const d=a;d['type']==='query'&&typeof d['query']==='string'&&b['push']({'query':d['query']});for(const e of Object['values'](d))collectQueries(e,b);}}return b;}function acceptedProgressNodes(a,b){const c=new Map();if(Array['isArray'](b))for(const g of b){if(typeof g==='object'&&g!==null){const h=g;typeof h['identifier']==='number'&&typeof h['value']==='string'&&c['set'](h['identifier'],h['value']);}}const d=i=>{if(typeof i!=='object'||i===null)return undefined;const j=i;if(j['type']==='constant'&&typeof j['value']==='string')return j['value'];if(j['type']==='identifier'&&typeof j['identifier']==='number')return c['get'](j['identifier']);return undefined;},e=[],f=i=>{if(Array['isArray'](i)){for(const n of i)f(n);return;}if(typeof i!=='object'||i===null)return;const j=i,k=Array['isArray'](j['nodes'])?j['nodes']:undefined,l=k?.[0x0]??j['left'],m=k?.[0x1]??j['right'];if(typeof j['type']==='string'&&j['type']['startsWith']('logic')&&typeof l==='object'&&l!==null&&l['type']==='query'&&l['query']==='progress.current'){const o=d(m);if(o!==undefined)e['push'](o);}for(const p of Object['values'](j))f(p);};return f(a),e;}const WIP_HASH_QUERY_NAMES=new Set(['order.item.wip_hash']);function collectWipHashComparisons(a,b,c=[]){const d=new Map();if(Array['isArray'](b))for(const h of b){if(typeof h==='object'&&h!==null){const i=h;typeof i['identifier']==='number'&&typeof i['value']==='string'&&d['set'](i['identifier'],i['value']);}}const e=j=>{if(typeof j!=='object'||j===null)return undefined;const k=j;if(k['type']!=='query'||typeof k['query']!=='string')return undefined;const l=k['query']['trim']()['toLowerCase']();return WIP_HASH_QUERY_NAMES['has'](l)?k['query']:undefined;},f=j=>{if(typeof j!=='object'||j===null)return undefined;const k=j;if(k['type']==='constant'&&typeof k['value']==='string')return k['value'];if(k['type']==='identifier'&&typeof k['identifier']==='number')return d['get'](k['identifier']);return undefined;},g=j=>{if(Array['isArray'](j)){for(const o of j)g(o);return;}if(typeof j!=='object'||j===null)return;const k=j,l=Array['isArray'](k['nodes'])?k['nodes']:undefined,m=l?.[0x0]??k['left'],n=l?.[0x1]??k['right'];if(typeof k['type']==='string'&&k['type']['startsWith']('logic')){const p=e(m)??e(n);if(p!==undefined){const r=e(m)!==undefined?n:m,s=f(r);if(s!==undefined)c['push']({'query':p,'constant':s});}}for(const t of Object['values'](k))g(t);};return g(a),c;}const REPO_WHERE_QUERY_TYPES=new Set(['query_repository_data_count_where','query_repository_data_sum_where','query_repository_data_sum_where_bound','query_repository_data_sum_where_bound_all','query_repository_data_find_where']);function collectRepoWhereQueries(a,b=[]){if(Array['isArray'](a)){for(const c of a)collectRepoWhereQueries(c,b);}else{if(typeof a==='object'&&a!==null){const d=a;typeof d['type']==='string'&&REPO_WHERE_QUERY_TYPES['has'](d['type'])&&b['push'](d);for(const e of Object['values'](d))collectRepoWhereQueries(e,b);}}return b;}const REPO_ROW_READ_TYPES=new Set(['query_repository_data_has','query_repository_data','query_repository_data_author','query_repository_data_count_where','query_repository_data_sum_where','query_repository_data_sum_where_bound','query_repository_data_sum_where_bound_all','query_repository_data_find_where','query_repository_data_keys_where']);function subtreeReadsRepositoryRow(a){if(Array['isArray'](a))return a['some'](subtreeReadsRepositoryRow);if(typeof a!=='object'||a===null)return![];const b=a,c=b['type'];if(typeof c==='string'&&REPO_ROW_READ_TYPES['has'](c))return!![];if(c==='query'){const d=b['query'];if(typeof d==='string'&&d['startsWith']('repository.data'))return!![];if(d===0x48e||d===0x48f||d===0x495||d===0x496||d===0x498||d===0x499||d===0x49e)return!![];}return Object['values'](b)['some'](subtreeReadsRepositoryRow);}function isRepoDataHasRef(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(isRepoDataHasRef(b))return!![];return Object['values'](b)['some'](subtreeRefsRepoDataHas);}function rootNegatesRepoDataHas(a){if(Array['isArray'](a))return a['some'](rootNegatesRepoDataHas);if(typeof a!=='object'||a===null)return![];const b=a;if(b['type']==='logic_not'&&subtreeRefsRepoDataHas(b['node']))return!![];return Object['values'](b)['some'](rootNegatesRepoDataHas);}const SYSTEM_ENTITY_ADDRESS='0xaab',WRITE_GUARD_PROMISE_RE=/\b(?:only\s+\w+|must\s+(?:be|bind)\w*|restrict\w*|whitelist\w*|allowlist\w*|allow\s+list\b|authoriz\w*|permissioned|vetted|pre-?approv\w*|approved\s+\w+)\b/i,WRITE_GUARD_TAUTOLOGY_DISCLOSURE_RE=/\b(?:tautolog\w*|self[- ]?report\w*|self[- ]?assert\w*)\b/i;function writeGuardLegClass(a,b){const c=new Map();if(Array['isArray'](b))for(const j of b){if(typeof j==='object'&&j!==null){const k=j;if(typeof k['identifier']==='number')c['set'](k['identifier'],k);}}const d=l=>typeof l==='object'&&l!==null&&l['type']==='context'&&l['context']==='Signer',e=l=>{if(Array['isArray'](l))return l['some'](e);if(typeof l!=='object'||l===null)return![];const m=l;if(m['type']==='context'&&m['context']==='Signer')return!![];return Object['values'](m)['some'](e);},f=l=>{if(typeof l!=='object'||l===null)return![];const m=l;if(m['type']==='identifier'){const n=c['get'](m['identifier']);if(n===undefined||n['b_submission']===!![])return![];const o=n['value'];return typeof o==='string'&&o['trim']()!==''&&!o['includes']('${');}if(m['type']==='constant'){const p=m['value'];if(typeof p!=='string'||p['includes']('${'))return![];if(p['trim']()['toLowerCase']()===SYSTEM_ENTITY_ADDRESS)return![];return!![];}if(m['type']==='query')return!![];return![];};let g=![];const h=(l,m)=>{if(Array['isArray'](l)){let u=![];for(const w of l)u=h(w,m)||u;return u;}if(typeof l!=='object'||l===null)return![];const n=l,o=n['type'];if(o==='logic_not'){const x=n['node']??(Array['isArray'](n['nodes'])?n['nodes'][0x0]:undefined);return x!==undefined?h(x,m+0x1):![];}if((o==='logic_and'||o==='logic_or')&&Array['isArray'](n['nodes'])){const y=n['nodes'];let z=![],A=!![];for(const B of y){const C=h(B,m);z=z||C;if(!C)A=![];}return o==='logic_and'?z:z&&A;}if(typeof o==='string'&&o['startsWith']('query')&&e(n)&&m%0x2===0x0)return g=!![],!![];const p=Array['isArray'](n['nodes'])?n['nodes']:undefined,q=p?.[0x0]??n['left'],r=p?.[0x1]??n['right'];if(o==='vec_contains_address'&&q!==undefined&&r!==undefined){const D=d(q)?r:d(r)?q:undefined;if(D===undefined||m%0x2!==0x0)return![];g=!![];const E=D,F=E['type']==='identifier'?c['get'](E['identifier']):undefined;if(F===undefined||F['b_submission']===!![])return![];const G=F['value'];if(Array['isArray'](G))return G['length']>0x0;if(typeof G!=='string'||G['trim']()===''||G['includes']('${'))return![];try{const H=JSON['parse'](G);return Array['isArray'](H)&&H['length']>0x0;}catch{return![];}}if(o==='logic_equal'&&q!==undefined&&r!==undefined){if(m%0x2!==0x0||!(d(q)||d(r)))return![];return g=!![],f(d(q)?r:q);}let s=![];for(const I of Object['values'](n)){if(typeof I==='object'&&I!==null)s=h(I,m)||s;}return s;},i=h(a,0x0);return{'hasSignerLeg':g,'hasBindingLeg':i};}function staticStringOperand(a,b){if(typeof a!=='object'||a===null)return undefined;const c=a;if(typeof c['identifier']==='number'){const d=b['find'](e=>typeof e==='object'&&e!==null&&e['identifier']===c['identifier']);if(d===undefined||d['b_submission']===!![])return undefined;return typeof d['value']==='string'?d['value']:undefined;}return typeof c['value']==='string'?c['value']:undefined;}function isPlanLocalObjectOperand(a,b){if(typeof a!=='object'||a===null)return![];const c=a;if(typeof c['identifier']!=='number')return![];const d=b['find'](f=>typeof f==='object'&&f!==null&&f['identifier']===c['identifier']);if(d===undefined||d['b_submission']===!![])return![];const e=d['value'];if(typeof e==='object'&&e!==null)return!![];return typeof e==='string'&&e['startsWith']('$');}const REACH_GREATER_TYPES={'logic_as_u256_greater':'gt','logic_as_u256_greater_or_equal':'ge'},REACH_LESSER_TYPES={'logic_as_u256_lesser':'lt','logic_as_u256_lesser_or_equal':'le'},REACH_EQUAL_TYPES=new Set(['logic_as_u256_equal','logic_equal']);function reachChannel(a){if(a['type']==='context'&&typeof a['context']==='string')return'context:'+a['context'];const b=a['query'];if(a['type']==='query'&&(typeof b==='string'||typeof b==='number'))return'query:'+String(b)['trim']()['toLowerCase']();return undefined;}function reachConstant(a,b){const c=d=>typeof d==='string'||typeof d==='number'||typeof d==='boolean';if(a['type']==='identifier'&&typeof a['identifier']==='number'){const d=b['find'](e=>typeof e==='object'&&e!==null&&e['identifier']===a['identifier']);if(d===undefined||d['b_submission']===!![])return undefined;return c(d['value'])?d['value']:undefined;}if(a['type']==='constant')return c(a['value'])?a['value']:undefined;return undefined;}function flattenAndChain(a,b=[]){if(typeof a!=='object'||a===null)return b;const c=a;if(c['type']==='logic_and'){const d=Array['isArray'](c['nodes'])?c['nodes']:[];for(const e of d)flattenAndChain(e,b);return b;}return b['push'](c),b;}function reachLegsOf(a){const b=Array['isArray'](a['params']['table'])?a['params']['table']:[],c=a['params']['root']??a['params']['logic'],d={'legs':[],'selfStrict':[]};if(typeof c!=='object'||c===null)return d;for(const e of flattenAndChain(c)){const f=typeof e['type']==='string'?e['type']:'',g=Array['isArray'](e['nodes'])?e['nodes']:undefined;if(g===undefined||g['length']<0x2)continue;const h=REACH_GREATER_TYPES[f],j=REACH_LESSER_TYPES[f],k=REACH_EQUAL_TYPES['has'](f);if(h===undefined&&j===undefined&&!k)continue;const l=g[0x0];if(typeof l!=='object'||l===null)continue;const m=reachChannel(l),n=reachConstant(l,b);for(let o=0x1;o<g['length'];o++){const p=g[o];if(typeof p!=='object'||p===null)continue;const q=reachConstant(p,b),r=reachChannel(p);if(m!==undefined&&q!==undefined)d['legs']['push']({'channel':m,'dir':k?'eq':h??j,'constant':q});else{if(r!==undefined&&n!==undefined){const s=k?'eq':h!==undefined?h==='gt'?'lt':'le':j==='lt'?'gt':'ge';d['legs']['push']({'channel':r,'dir':s,'constant':n});}else m!==undefined&&r!==undefined&&(m===r&&(h==='gt'||j==='lt')&&d['selfStrict']['push']({'channel':m,'dir':h==='gt'?'gt':'lt'}));}}}return d;}function reachNumeric(a){if(typeof a==='number')return Number['isFinite'](a)?a:undefined;if(typeof a==='string'&&a['trim']()!==''&&!Number['isNaN'](Number(a)))return Number(a);return undefined;}function findReachContradictions(c,f,g=[]){const h=[];for(const l of g){h['push']('guard\x20\x27'+c+'\x27\x20('+l['channel']+'):\x20'+(l['dir']==='gt'?'>':'<')+'\x20itself\x20—\x20'+'unsatisfiable\x20(same-binding\x20self-comparison)');}const k=new Map();for(const m of f){const n=k['get'](m['channel'])??[];n['push'](m),k['set'](m['channel'],n);}for(const [o,p]of k){const q=p['filter'](v=>v['dir']==='gt'||v['dir']==='ge'),r=p['filter'](v=>v['dir']==='lt'||v['dir']==='le');for(const v of q){const w=reachNumeric(v['constant']);if(w===undefined)continue;for(const x of r){const y=reachNumeric(x['constant']);if(y===undefined)continue;(w>y||w===y&&(v['dir']==='gt'||x['dir']==='lt'))&&h['push']('guard\x20\x27'+c+'\x27\x20('+o+'):\x20'+(v['dir']==='gt'?'>':'>=')+'\x20'+String(v['constant'])+'\x20'+('contradicts\x20'+(x['dir']==='lt'?'<':'<=')+'\x20'+String(x['constant'])+'\x20—\x20unsatisfiable'));}}const t=p['filter'](z=>z['dir']==='eq');for(let z=0x0;z<t['length'];z++){for(let A=z+0x1;A<t['length'];A++){const B=t[z],C=t[A],D=reachNumeric(B['constant']),E=reachNumeric(C['constant']),F=typeof B['constant']==='boolean'&&typeof C['constant']==='boolean'&&B['constant']!==C['constant'],G=D!==undefined&&E!==undefined&&D!==E;(F||G)&&h['push']('guard\x20\x27'+c+'\x27\x20('+o+'):\x20==\x20'+String(B['constant'])+'\x20'+('contradicts\x20==\x20'+String(C['constant'])+'\x20—\x20unsatisfiable'));}}for(const H of t){const I=reachNumeric(H['constant']);if(I===undefined)continue;for(const J of q){J['dir']==='gt'&&reachNumeric(J['constant'])===I&&h['push']('guard\x20\x27'+c+'\x27\x20('+o+'):\x20==\x20'+String(H['constant'])+'\x20'+('contradicts\x20>\x20'+String(J['constant'])+'\x20—\x20unsatisfiable'));}for(const K of r){K['dir']==='lt'&&reachNumeric(K['constant'])===I&&h['push']('guard\x20\x27'+c+'\x27\x20('+o+'):\x20==\x20'+String(H['constant'])+'\x20'+('contradicts\x20<\x20'+String(K['constant'])+'\x20—\x20unsatisfiable'));}}}return h;}function guardProjection(a){const b=a['params']['root']??a['params']['logic'],c=collectQueries(b)['map'](d=>d['query']);return{'stepId':a['id'],'queries':c,'acceptedNodes':acceptedProgressNodes(b,a['params']['table']),'table':Array['isArray'](a['params']['table'])?a['params']['table']:[],'upperTimeBoundIds':timeBoundIdentifiers(b,!![])};}function timeBoundIdentifiers(a,b){const c=new Set(),d=e=>{if(Array['isArray'](e)){for(const h of e)d(h);return;}if(typeof e!=='object'||e===null)return;const f=e,g=f['type'];if(typeof g==='string'&&g['includes']('logic_as_u256')&&g['includes'](b?'lesser':'greater'))for(const i of['nodes','left','right','a','b']){const j=f[i],k=Array['isArray'](j)?j:j===undefined?[]:[j];for(const l of k){if(typeof l!=='object'||l===null)continue;const m=l;if(m['type']!=='identifier')continue;const n=Number(m['identifier']);if(Number['isInteger'](n))c['add'](n);}}for(const o of Object['values'](f))d(o);};return d(a),[...c];}function allocatorRows(a){const b=[],c=d=>{if(typeof d==='object'&&d!==null&&!Array['isArray'](d)){const e=d;if(Array['isArray'](e['allocators']))d=e['allocators'];}if(!Array['isArray'](d))return;for(const f of d){if(typeof f!=='object'||f===null)continue;const g=f,h=g['guard'],i=g['guard_key'],j=Array['isArray'](g['sharing'])?g['sharing']:[],k=j['map'](l=>typeof l==='object'&&l!==null?l['who']:undefined)['map'](l=>typeof l==='object'&&l!==null?l['GuardIdentifier']:undefined)['filter'](l=>typeof l==='number');b['push']({'track':typeof g['track']==='string'?g['track']:'settlement','guardStep':isRef(h)?h['$ref']:undefined,'guardKey':typeof i==='string'?i:undefined,'identifierLegs':k});}};for(const d of a['steps']){if(d['op']==='create'&&d['object']==='service')c(d['params']['order_allocators']);if(d['op']==='configure'&&d['method']==='order_allocators')c(d['params']['allocators']);}return b;}function machineProjection(a){const b=createsOf(a,'machine')[0x0];if(b===undefined)return undefined;const c=b['params']['nodes'];if(!Array['isArray'](c))return{'nodes':[],'edges':[],'terminals':[],'optionalNodes':[],'forwardGuardRefs':[],'finalRoleNodes':[],'cancelledNodes':[]};const d=[],e=[],h=o=>({'name':typeof o?.['name']==='string'?o['name']:'','roster':typeof o?.['namedOperator']==='string'?o['namedOperator']:typeof o?.['named_operator']==='string'?o['named_operator']:undefined,'perm':typeof o?.['permissionIndex']==='number'?o['permissionIndex']:typeof o?.['permission_index']==='number'?o['permission_index']:undefined}),i=[],j=[],k=[],l=[];for(const o of c){if(typeof o!=='object'||o===null)continue;const q=o,r=typeof q['name']==='string'?q['name']:undefined;if(r===undefined)continue;d['push'](r);const s=typeof q['role']==='string'?q['role']:undefined;if(s==='final'||s==='cancelled')k['push'](r);if(s==='cancelled')l['push'](r);if(q['optional']===!![])i['push'](r);const t=Array['isArray'](q['pairs'])?q['pairs']:[];for(const u of t){const v=u,w=v?.['prev_node'],x=Array['isArray'](v?.['forwards'])?v['forwards']:[],y=[],z=[],A=[];for(const B of x){const C=B,D=C?.['guard'];isRef(D)&&(y['push'](D['$ref']),j['push'](D['$ref']));if(typeof C?.['name']==='string')z['push'](C['name']);A['push'](h(C));}if(typeof w==='string')e['push']({'prev':w,'next':r,'guards':y,'forwardNames':z,'forwardRails':A});}}const m=b['params']['pairs'];if(Array['isArray'](m))for(const E of m){const F=E;if(typeof F?.['prev_node']==='string'&&typeof F?.['next_node']==='string'){const G=Array['isArray'](F['forwards'])?F['forwards']:[],H=[],I=[],J=[];for(const K of G){const L=K,M=L?.['guard'];isRef(M)&&(H['push'](M['$ref']),j['push'](M['$ref']));if(typeof L?.['name']==='string')I['push'](L['name']);J['push'](h(L));}e['push']({'prev':F['prev_node'],'next':F['next_node'],'guards':H,'forwardNames':I,'forwardRails':J});}}const n=new Set(e['filter'](N=>N['prev']!==''&&N['prev']!==N['next'])['map'](N=>N['prev']));return{'nodes':d,'edges':e,'terminals':d['filter'](N=>!n['has'](N)),'optionalNodes':i,'forwardGuardRefs':j,'finalRoleNodes':k,'cancelledNodes':l};}function pathCountCap2(a,b){const c=new Map();for(const g of a){const h=c['get'](g['prev'])??[];h['push'](g['next']),c['set'](g['prev'],h);}let d=0x0;const f=(i,j)=>{if(d>=0x2)return;if(i===b){d+=0x1;return;}if(j['has'](i))return;const k=new Set(j)['add'](i);for(const l of c['get'](i)??[])f(l,k);};for(const i of c['get']('')??[])f(i,new Set());return d;}const WRITE_ONLY_ENFORCEMENT_SOURCES=[{'object':'service','param':'customer_required','coverQuery':'order.required_info','extract':a=>Array['isArray'](a['params']['customer_required'])&&a['params']['customer_required']['length']>0x0},{'object':'service','param':'sales[].wip','coverQuery':'service.sale.wip','extract':a=>Array['isArray'](a['params']['sales'])&&a['params']['sales']['some'](b=>typeof b==='object'&&b!==null&&typeof b['wip']==='string'&&b['wip']['length']>0x0)}],PROSE_UNIT_MS={'minute':0xea60,'hour':0x36ee80,'hrs':0x36ee80,'hr':0x36ee80,'h':0x36ee80,'day':0x5265c00,'week':0x240c8400},PROSE_DURATION_RE=/(\d+)\s*[-\s]?\s*(minute|hour|hrs|hr|h|day|week)s?\b/gi,WINDOW_CONTEXT_RE=/review|accept|cancel|refund|return|window|claim|bounty|escrow|release|revision|dispute/i;function isPlausibleMsDuration(a){return Number['isFinite'](a)&&a>=0xea60&&a%0x3e8===0x0&&a<=0xa*0x16d*0x5265c00;}function formatMs(a){const b=a/0x5265c00;if(Number['isInteger'](b)&&b>=0x2)return b+'\x20days';const c=a/0x36ee80;if(Number['isInteger'](c)&&c>=0x2)return c+'\x20hours';return a/0xea60+'\x20minutes';}export function extractProseWindowPromises(a){const b=[];for(const c of a['matchAll'](PROSE_DURATION_RE)){const d=Number(c[0x1])*(PROSE_UNIT_MS[c[0x2]['toLowerCase']()]??NaN);if(!Number['isFinite'](d)||d<=0x0||c['index']===undefined)continue;const e=Math['max'](0x0,c['index']-0x50),f=Math['min'](a['length'],c['index']+c[0x0]['length']+0x50);if(!WINDOW_CONTEXT_RE['test'](a['slice'](e,f)))continue;b['push']({'ms':d,'quote':c[0x0]});}return b;}const UNANCHORED_RESTART_RE=/\b(?:restart|reset|renew|start(?:s)? again|begin(?:s)? again)[^.]{0,60}\b(?:window|timer|clock|period)\b|\b(?:window|timer|clock|period)\b[^.]{0,60}\b(?:restart|reset|renew)s?\b/i;function collectEnforcedWindowMs(a){const b=new Set();for(const c of createsOf(a,'guard')){const d=Array['isArray'](c['params']['table'])?c['params']['table']:[];for(const e of d){const f=e;if(f['b_submission']===!![]||f['value_type']!=='U64')continue;const g=f['value'],h=typeof g==='number'?g:typeof g==='string'&&g!==''&&!Number['isNaN'](Number(g))?Number(g):NaN;if(isPlausibleMsDuration(h))b['add'](h);}}return b;}const TIME_CMP_TYPES={'logic_as_u256_greater':'gt','logic_as_u256_greater_or_equal':'ge','logic_as_u256_lesser':'lt','logic_as_u256_lesser_or_equal':'le','logic_as_u256_equal':'eq','logic_equal':'eq'};function isClockContext(a){return a['type']==='context'&&a['context']==='Clock';}function subtreeHasBranch(a){if(Array['isArray'](a))return a['some'](subtreeHasBranch);if(typeof a!=='object'||a===null)return![];const b=a;if(b['type']==='logic_or'||b['type']==='logic_not')return!![];return Object['values'](b)['some'](subtreeHasBranch);}function guardWindowOpen(c){if(typeof c!=='object'||c===null)return!![];if(subtreeHasBranch(c))return!![];let d=![];for(const e of flattenAndChain(c)){const f=TIME_CMP_TYPES[typeof e['type']==='string'?e['type']:''];if(f===undefined)continue;const g=Array['isArray'](e['nodes'])?e['nodes']:undefined;if(g===undefined||g['length']<0x2)continue;const h=g[0x0],i=g[0x1];if(typeof h!=='object'||h===null||typeof i!=='object'||i===null)continue;const j=isClockContext(h),k=isClockContext(i);if(j&&!k){if(f==='lt'||f==='le'||f==='eq')d=!![];}else{if(!j&&k){const l=f==='gt'||f==='ge'?'lt':f==='lt'||f==='le'?'gt':'eq';if(l==='lt')d=!![];}}}return!d;}function collectSlotQueries(a,b=[]){if(Array['isArray'](a)){for(const d of a)collectSlotQueries(d,b);return b;}if(typeof a!=='object'||a===null)return b;const c=a;if(c['type']==='query'&&typeof c['query']==='string'){const e=c['object'],f=typeof e==='object'&&e!==null?e:undefined;b['push']({'query':c['query'],'slot':typeof f?.['identifier']==='number'?f['identifier']:undefined,'witness':typeof f?.['convert_witness']==='string'?f['convert_witness']:undefined});}for(const g of Object['values'](c))collectSlotQueries(g,b);return b;}function tableRows(a){const b=a['params']['table'];if(!Array['isArray'](b))return[];return b['filter'](c=>typeof c==='object'&&c!==null);}function rowIdentifier(a){return typeof a['identifier']==='number'?a['identifier']:undefined;}function servicePinRowIds(a,b){const c=[],d=f=>{const g=f['object'];return f['type']==='query'&&f['query']==='order.service'&&typeof g==='object'&&g!==null&&g['identifier']===b;},e=f=>{if(Array['isArray'](f)){for(const i of f)e(i);return;}if(typeof f!=='object'||f===null)return;const g=f,h=g['nodes'];if(g['type']==='logic_equal'&&Array['isArray'](h)&&h['length']===0x2)for(const [j,k]of[[h[0x0],h[0x1]],[h[0x1],h[0x0]]]){if(typeof j!=='object'||j===null||typeof k!=='object'||k===null)continue;const l=k;d(j)&&l['type']==='identifier'&&typeof l['identifier']==='number'&&c['push'](l['identifier']);}for(const m of Object['values'](g))e(m);};return e(a),c;}function ownServiceIdentities(a){const b=new Set();for(const c of createsOf(a,'service')){b['add'](c['id']);const d=c['params']['name'];if(typeof d==='string')b['add'](d);}return b;}function pinIsExternal(a,b){if(typeof a==='string')return!b['has'](a);if(typeof a==='object'&&a!==null){const c=a;if(typeof c['$ref']==='string')return!b['has'](c['$ref']);const d=c['$late'];if(typeof d==='object'&&d!==null){const e=d['mark'];if(typeof e==='string')return!b['has'](e);}}return!![];}function subtreeBindsOrderSlotToArbCase(a,b){if(Array['isArray'](a))return a['some'](d=>subtreeBindsOrderSlotToArbCase(d,b));if(typeof a!=='object'||a===null)return![];const c=a;if(c['type']==='logic_equal'){const d=Array['isArray'](c['nodes'])?c['nodes']:[],e=g=>{if(typeof g!=='object'||g===null)return![];const h=g;if(h['type']==='identifier'&&h['identifier']===b)return!![];if(h['type']==='query'&&typeof h['query']==='string'&&h['query']['startsWith']('order.')){const i=h['object'];return i!==undefined&&i['identifier']===b;}return![];},f=g=>{if(Array['isArray'](g))return g['some'](f);if(typeof g!=='object'||g===null)return![];const h=g;if(h['type']==='query'&&h['query']==='arb.order')return!![];return Object['values'](h)['some'](f);};if(d['length']===0x2){if(e(d[0x0])&&f(d[0x1])||e(d[0x1])&&f(d[0x0]))return!![];}}return Object['values'](c)['some'](g=>subtreeBindsOrderSlotToArbCase(g,b));}function guardCompositionShapes(a){const b=[],c=ownServiceIdentities(a),d=repositoryWriteGuardIds(a),e=writeOnceKeyedSlots(a);for(const f of createsOf(a,'guard')){const g=f['params']['root']??f['params']['logic'],h=collectSlotQueries(g),i=h['filter'](t=>t['query']['startsWith']('order.')),j=[...new Set(i['map'](t=>t['slot'])['filter'](t=>t!==undefined&&t!==HOST_ORDER_SLOT&&t!==TASK_BINDING_SLOT&&t!==ONCE_SLOT_BYTES))],k=j['length']>0x0&&j['every'](t=>subtreeBindsOrderSlotToArbCase(g,t)),l=tableRows(f),m=new Set(l['filter'](t=>t['b_submission']===![]&&t['value_type']==='Address')['map'](t=>rowIdentifier(t))['filter'](t=>t!==undefined)),n=j['flatMap'](t=>servicePinRowIds(g,t))['filter'](t=>m['has'](t)),o=[...new Set(i['filter'](t=>t['query']==='order.service')['map'](t=>t['slot'])['filter'](t=>t!==undefined))],p=new Map(l['map'](t=>[rowIdentifier(t),t['value']])),q=t=>t['flatMap'](u=>servicePinRowIds(g,u))['filter'](u=>m['has'](u)&&pinIsExternal(p['get'](u),c)),r=q(j)['length']>0x0||d['has'](f['id'])&&q(o)['length']>0x0,s=i['filter'](t=>t['query']==='order.owner')['map'](t=>t['slot']);b['push']({'stepId':f['id'],'foreignSlots':k?[]:j,'paired':subtreeReadsRepositoryRow(g)||l['some'](t=>rowIdentifier(t)===ONCE_SLOT_BYTES&&t['b_submission']===!![])||j['some'](t=>e['get'](f['id'])?.['has'](t)),'pinned':n['length']>0x0,'pinnedRowIds':n,'procurementPin':r,'ownerCrossed':s['includes'](HOST_ORDER_SLOT)&&j['some'](t=>s['includes'](t))});}return b;}function repositoryPoliciesMerged(a){const b=new Map();for(const d of a['steps']){if(d['op']!=='configure'||d['method']!=='policies')continue;const e=d['target'],f=typeof e==='object'&&e!==null&&typeof e['$ref']==='string'?e['$ref']:undefined;if(f===undefined)continue;const g=d['params']['policy'];if(!Array['isArray'](g))continue;const h=b['get'](f)??[];h['push'](...g['filter'](i=>typeof i==='object'&&i!==null)),b['set'](f,h);}const c=[];for(const i of createsOf(a,'repository')){const j=Array['isArray'](i['params']['policies'])?i['params']['policies']:[];c['push']({'step':i,'policies':[...j,...b['get'](i['id'])??[]]});}return c;}function repositoryWriteGuardIds(a){const b=new Set();for(const {policies:c}of repositoryPoliciesMerged(a)){for(const d of c){if(typeof d!=='object'||d===null)continue;const e=d['write_guard'];if(!Array['isArray'](e))continue;for(const f of e){if(typeof f!=='object'||f===null)continue;const h=f['guard'];typeof h==='object'&&h!==null&&typeof h['$ref']==='string'&&b['add'](h['$ref']);}}}return b;}function writeOnceKeyedSlots(a){const b=new Map();for(const {policies:c}of repositoryPoliciesMerged(a)){for(const d of c){if(typeof d!=='object'||d===null)continue;const e=d;if(e['write_once']!==!![])continue;const f=e['write_guard'];if(!Array['isArray'](f))continue;for(const h of f){if(typeof h!=='object'||h===null)continue;const i=h,j=i['id_from_submission'];if(typeof j!=='number'||j===HOST_ORDER_SLOT)continue;const k=i['guard'];if(typeof k!=='object'||k===null)continue;const l=k['$ref'];if(typeof l!=='string')continue;const m=b['get'](l)??new Set();m['add'](j),b['set'](l,m);}}}return b;}function emittedPrimitives(a,b){const c=new Set();for(const d of createsOf(a,'guard')){const e=d['params']['root']??d['params']['logic'];if(subtreeReadsRepositoryRow(e))c['add']('P1');}if(b['some'](f=>f['foreignSlots']['length']>0x0))c['add']('P2');if(b['some'](f=>f['procurementPin']))c['add']('P3');for(const f of createsOf(a,'machine')){const g=f['params']['nodes'];if(!Array['isArray'](g))continue;if(JSON['stringify'](g)['includes']('retained_submission'))c['add']('P3');}if(maxDistinctGuardsPerTrack(a)>0x1)c['add']('P4');if(planHasFormulaSharing(a))c['add']('P5');if(createsOf(a,'reward')['length']>0x0)c['add']('P6');return c;}const HOST_ORDER_SLOT=0x0;function maxDistinctGuardsPerTrack(a){const b=new Map(),c=f=>{const h=f['guard'];if(h!==undefined)return JSON['stringify'](h);if(typeof f['guard_key']==='string')return'key:'+f['guard_key'];return'<unbound>';},d=f=>{if(typeof f==='object'&&f!==null&&!Array['isArray'](f)){const g=f;if(Array['isArray'](g['allocators']))f=g['allocators'];}if(!Array['isArray'](f))return;for(const h of f){if(typeof h!=='object'||h===null)continue;const i=h,j=typeof i['track']==='string'?i['track']:'settlement',k=b['get'](j);if(k===undefined)b['set'](j,new Set([c(i)]));else k['add'](c(i));}};for(const f of a['steps']){if(f['op']==='create'&&f['object']==='service')d(f['params']['order_allocators']);if(f['op']==='configure'&&f['method']==='order_allocators')d(f['params']['allocators']);}let e=0x0;for(const g of b['values']())e=Math['max'](e,g['size']);return e;}function planHasFormulaSharing(a){const b=c=>{if(typeof c==='object'&&c!==null&&!Array['isArray'](c)){const d=c;if(Array['isArray'](d['allocators']))c=d['allocators'];}if(!Array['isArray'](c))return![];return c['some'](e=>{if(typeof e!=='object'||e===null)return![];const f=e['sharing'];if(!Array['isArray'](f))return![];return f['some'](g=>{if(typeof g!=='object'||g===null)return![];const h=g;return h['mode']===0x4||h['formula']!==undefined;});});};for(const c of a['steps']){if(c['op']==='create'&&c['object']==='service'&&b(c['params']['order_allocators']))return!![];if(c['op']==='configure'&&c['method']==='order_allocators'&&b(c['params']['allocators']))return!![];}return![];}function thirdPartyLegs(a){const b=[],c=d=>{if(typeof d==='object'&&d!==null&&!Array['isArray'](d)){const e=d;if(Array['isArray'](e['allocators']))d=e['allocators'];}if(!Array['isArray'](d))return;for(const f of d){if(typeof f!=='object'||f===null)continue;const g=f,h=typeof g['track']==='string'?g['track']:'settlement',i=Array['isArray'](g['sharing'])?g['sharing']:[];for(const j of i){if(typeof j!=='object'||j===null)continue;const k=j['who'];if(typeof k!=='object'||k===null)continue;const l=k;if(l['Entity']!==undefined)b['push']({'track':h,'kind':'Entity'});else{if(l['Signer']!==undefined)b['push']({'track':h,'kind':'Signer'});}}}};for(const d of a['steps']){if(d['op']==='create'&&d['object']==='service')c(d['params']['order_allocators']);if(d['op']==='configure'&&d['method']==='order_allocators')c(d['params']['allocators']);}return b;}function publicFaceStrings(a){const b=[],c={'service':['description','location'],'contact':['description','location'],'proof':['description','proof'],'repository':['description'],'demand':['description']};for(const d of a['steps']){if(d['op']!=='create')continue;const e=c[d['object']];if(e===undefined)continue;for(const h of e){const i=d['params'][h];if(typeof i==='string'&&i['length']>0x0)b['push']({'face':d['object']+'.'+h,'stepId':d['id'],'text':i});}const g=d['params']['sales'];if(Array['isArray'](g))for(const j of g){if(typeof j!=='object'||j===null)continue;const k=j;for(const l of['description','name','title']){const m=k[l];typeof m==='string'&&m['length']>0x0&&b['push']({'face':d['object']+'.sales.'+l,'stepId':d['id'],'text':m});}}}for(const n of a['steps']){if(n['op']!=='configure')continue;const o=JSON['stringify'](n['params']);if(o['includes']('\x22data\x22')){const p=n['params']['data'];typeof p==='string'&&p['length']>0x0&&b['push']({'face':'repository.data','stepId':n['id'],'text':p});}}return b;}const PII_PATTERNS=[{'kind':'email','re':/[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}/},{'kind':'street_number','re':/\b\d{1,6}\s+[A-Za-z\u00c0-\u024f\u4e00-\u9fff]+(?:\s+[A-Za-z\u00c0-\u024f\u4e00-\u9fff]+){0,3}\s+(?:st|street|rd|road|ave|avenue|blvd|ln|lane|dr|drive|way|ct|court|fl|floor|apt|unit|rm|room)\b/i},{'kind':'phone','re':/(?:\+\d{1,3}[\s.-]?)?(?:\(\d{2,4}\)[\s.-]?)?\d{3,4}[\s.-]?\d{4}(?:[\s.-]?\d{2,4})?/,'proseOnly':!![]},{'kind':'national_id','re':/\b\d{15}\b|\b\d{17}[\dXx]\b/,'proseOnly':!![]}];function firstPiiHit(a){for(const b of publicFaceStrings(a)){const c=b['face']!=='repository.data';for(const d of PII_PATTERNS){if(d['proseOnly']===!![]&&!c)continue;if(d['re']['test'](b['text']))return{'face':b['face'],'stepId':b['stepId'],'kind':d['kind']};}}return undefined;}const HASH_SHAPE=/^(?:[a-fA-F0-9]{32}|[a-fA-F0-9]{40}|[a-fA-F0-9]{64}|[A-Za-z0-9+/]{43}={0,1}|[A-Za-z0-9+/]{44})$/,TRACKING_SHAPE=/^(?:[A-Za-z]{2,4}[\s-]?\d{8,15}|\d{1,7}[\s-]\d{4,15})$/;function firstRawTrackingValue(a){for(const b of a['steps']){if(b['op']!=='configure')continue;const c=b['params']['data'];if(typeof c!=='string')continue;const d=c['trim']();if(d['length']===0x0||HASH_SHAPE['test'](d))continue;if(TRACKING_SHAPE['test'](d))return{'stepId':b['id'],'value':d};}return undefined;}function perOrderProofBinding(a){for(const b of createsOf(a,'proof')){const c=JSON['stringify'](b['params']['about']??'');if(c['includes']('order'))return b['id'];}for(const d of a['steps']){if(d['op']!=='configure')continue;if(d['method']!=='required_info'&&d['method']!=='required_info_bind')continue;if(JSON['stringify'](d['params'])['includes']('proof'))return d['id'];}return undefined;}function compositionFacts(a){const b=guardCompositionShapes(a),c=emittedPrimitives(a,b),d=b['filter'](t=>t['foreignSlots']['length']>0x0),e=thirdPartyLegs(a),f=c['has']('P6'),g=typeof a['inputs']?.['composition_variant']==='string'?a['inputs']['composition_variant']:undefined,h=g!==undefined&&g in COMPOSITION_VARIANTS,i=typeof a['inputs']?.['fulfillment_axis']==='string'?a['inputs']['fulfillment_axis']:undefined,j=i??(h?COMPOSITION_VARIANTS[g]['fulfillmentAxis']:undefined),k=j==='merchant_procured'||j==='user_procured'||j==='mixed',l=d['length']>0x0||k,m=e['length']>0x0||f,n=h?primitivesForVariant(g)['filter'](s=>!c['has'](s)):[],o=firstPiiHit(a),p={'composition_primitives_emitted':[...c]['sort']()['join'](',\x20'),'composition_cross_order_guard_count':d['length'],'third_party_fulfilment_present':l,'third_party_payout_leg_present':m,'third_party_leg_count':e['length'],'reward_pool_present':f,...j!==undefined?{'fulfillment_axis':j}:{},...g!==undefined?{'composition_variant':g,'composition_variant_known':h}:{}};if(d['length']>0x0){const s=d['find'](w=>!w['paired']),t=d['find'](w=>!w['pinned']),u=j!=='merchant_procured'&&j!=='mixed',v=u?d['find'](w=>!w['ownerCrossed']):undefined;p['first_cross_order_guard']=d[0x0]['stepId'],p['cross_order_slots_display']=d[0x0]['foreignSlots']['join'](',\x20');s!==undefined&&(p['first_cross_order_guard_unpaired']=s['stepId'],p['cross_order_unpaired_count']=d['filter'](w=>!w['paired'])['length']);if(t!==undefined)p['first_cross_order_guard_unpinned']=t['stepId'];if(v!==undefined)p['first_cross_order_guard_no_owner_cross']=v['stepId'];!u&&d['some'](w=>!w['ownerCrossed'])&&(p['cross_order_owner_tie_not_expressible']=!![]);}l&&!m&&(p['third_party_fulfilment_without_payout']=!![]);h&&n['length']>0x0&&(p['composition_variant_missing_primitives']=n['join'](',\x20'),p['composition_variant_missing_count']=n['length']);g==='V3'&&(p['composition_dual_refund_unblockable']=!![],p['composition_disclosure_count']=disclosuresFor('V3')['length']);o!==undefined&&(p['first_pii_public_face']=o['face'],p['first_pii_public_face_step']=o['stepId'],p['first_pii_kind']=o['kind']);const q=firstRawTrackingValue(a);q!==undefined&&(p['first_raw_tracking_value_step']=q['stepId'],p['first_raw_tracking_value']=q['value']);const r=perOrderProofBinding(a);if(r!==undefined)p['per_order_proof_binding_step']=r;return p;}function guardQualityFacts(a){const b=e=>a['filter'](g=>g['rule']===e),c=e=>'guard\x20\x27'+e['key']+'\x27:\x20'+e['subject'],d=(e,f)=>{const g=b(e);if(g['length']===0x0)return{};return{[f+'_count']:g['length'],['first_'+f]:c(g[0x0]),[f+'_display']:g['map'](c)['join'](';\x20')};};return{...d('GUARD-EQUALITY-DRIFT','guard_equality_drift'),...d('GUARD-THRESHOLD-LITERAL','guard_threshold_literal'),...d('GUARD-SET-COLLAPSE','guard_set_collapse'),...d('GUARD-INPUT-TRUST','guard_input_trust'),...d('GUARD-ABORT-SAFE','guard_abort_unsafe')};}export function planFacts(c){const d=new Map(createsOf(c,'guard')['map'](bD=>[bD['id'],guardProjection(bD)])),f=allocatorRows(c),h=machineProjection(c),l=createsOf(c,'service')['length']>0x0,o=createsOf(c,'repository')['length']>0x0,q=c['steps']['some'](bD=>{if(!(bD['op']==='create'&&bD['object']==='service'||bD['op']==='configure'&&bD['method']==='sales'))return![];const bE=bD['params']['sales'];return Array['isArray'](bE)&&bE['length']>0x0;}),u=new Set();for(const bD of f){const bE=bD['guardStep']===undefined?undefined:d['get'](bD['guardStep']);for(const bF of bE?.['acceptedNodes']??[])u['add'](bF);}const w=new Set(h?.['optionalNodes']??[]),x=(h?.['terminals']??[])['filter'](bG=>!w['has'](bG)),y=new Set(),z=new Set(f['map'](bG=>bG['guardStep'])['filter'](bG=>bG!==undefined));for(const bG of h?.['edges']??[]){if(bG['next']===''||bG['guards']['length']===0x0)continue;for(const bH of bG['guards']){if(!z['has'](bH))continue;if((d['get'](bH)?.['acceptedNodes']['length']??0x0)===0x0)y['add'](bG['next']);}}const A=[];for(const bI of h?.['edges']??[]){const bJ=bI['forwardNames']['find'](bK=>/withdraw/i['test'](bK)&&/claim|dispute/i['test'](bK));if(bJ)A['push']((bI['prev']||'(entry)')+'->'+bI['next']);}const B=x['find'](bK=>!u['has'](bK)&&!y['has'](bK)),C=(h?.['finalRoleNodes']??[])['find'](bK=>!u['has'](bK)&&!y['has'](bK)),D=(h?.['edges']??[])['find'](bK=>(h?.['cancelledNodes']??[])['includes'](bK['prev'])&&(bK['forwardNames']['some'](bL=>/review|reward/i['test'](bL))||/review|reward/i['test'](bK['next']))),E=new Set([...h?.['finalRoleNodes']??[],...u,...y]),F=[[/settle|release|payout|\bband\b/i,'settle'],[/recover|award/i,'recover'],[/refund|return/i,'refund'],[/arb|indemnity|dispute/i,'arb']],G=bK=>{const bL=[bK['next'],...bK['forwardNames'],...bK['guards']['flatMap'](bM=>d['get'](bM)?.['queries']??[])];for(const [bM,bN]of F){if(bL['some'](bO=>bM['test'](bO)))return bN;}return undefined;};let H;for(const bK of h?.['edges']??[]){if(bK['next']===''||!E['has'](bK['next']))continue;for(const bL of bK['forwardRails']){const bM=bL['perm']!==undefined&&bL['perm']>0x0;typeof bL['roster']==='string'&&bL['roster']!==''&&!bM&&(H??=bK['prev']+'->'+bK['next']+'\x20(forward\x20'+bL['name']+')');}}const I=new Map();for(const bN of h?.['edges']??[]){if(bN['next']===''||!E['has'](bN['next']))continue;const bO=G(bN);if(bO===undefined)continue;for(const bP of bN['forwardRails']){if(typeof bP['perm']==='number'&&bP['perm']>0x0){const bQ=I['get'](bP['perm'])??I['set'](bP['perm'],new Set())['get'](bP['perm']);bQ['add'](bO);}}}const J=[...I['entries']()]['find'](([,bR])=>bR['size']>=0x2),K=c['pending_guards']??[],L=K['filter'](bR=>bR['site']==='allocator')['length'],M=K['filter'](bR=>bR['site']==='allocator'||bR['site']==='machine_edge'),N=K['filter'](bR=>bR['site']==='service_buy'),O=M[0x0]?.['key'],P=N[0x0]?.['key'],Q=h?.['nodes']['find'](bR=>/return/i['test'](bR)),R=c['steps']['some'](bR=>{if(bR['op']==='configure'&&bR['method']==='arbitrations'){const bS=bR['params']['objects'];return Array['isArray'](bS)&&bS['length']>0x0;}if(bR['op']==='create'&&bR['object']==='service'){const bT=bR['params']['arbitrations'];return Array['isArray'](bT)&&bT['length']>0x0;}return![];});let S,T=![];for(const bR of c['steps']){if(bR['op']==='configure'&&bR['method']==='compensation_fund_add'){T=!![];const bS=numericAmount(bR['params']['balance']);if(bS!==undefined)S=(S??0x0)+bS;}}let U,V;const W=/free[\s_-]*tier|free[\s_-]*trial|trial|\u8bd5\u7528|\u4f53\u9a8c|\u514d\u8d39/i,X=bT=>{if(!Array['isArray'](bT))return;for(const bU of bT){const bV=bU,bW=numericAmount(bV?.['price']);if(bW!==undefined&&bW>0x0){U=Math['max'](U??0x0,bW);const bX=typeof bV?.['name']==='string'?bV['name']:'';!W['test'](bX)&&(V=V===undefined?bW:Math['min'](V,bW));}}};for(const bT of c['steps']){if(bT['op']==='create'&&bT['object']==='service')X(bT['params']['sales']);if(bT['op']==='configure'&&bT['method']==='sales')X(bT['params']['sales']);}const Y=S!==undefined&&U!==undefined;let Z,a0=0x0,a1=0x0;const a2=bU=>{if(!Array['isArray'](bU))return;for(const bV of bU){const bW=bV?.['name'];if(typeof bW!=='string'||bW==='')continue;const bX=skuNameByteLen(bW);bX>SKU_NAME_MAX_BYTES&&(a1+=0x1,Z===undefined&&(Z=bW,a0=bX));}};for(const bU of c['steps']){if(bU['op']==='create'&&bU['object']==='service')a2(bU['params']['sales']);if(bU['op']==='configure'&&bU['method']==='sales')a2(bU['params']['sales']);}const a3=new Set(),a4=bV=>{if(!Array['isArray'](bV))return;for(const bW of bV){const bX=bW?.['name'];if(typeof bX==='string'&&bX!=='')a3['add'](bX);}};for(const bV of c['steps']){if(bV['op']==='create'&&bV['object']==='service')a4(bV['params']['sales']);if(bV['op']==='configure'&&bV['method']==='sales')a4(bV['params']['sales']);}const a5=[];if(a3['size']>0x0)for(const bW of createsOf(c,'guard')){const bX=bW['params']['root']??bW['params']['logic'];for(const bY of collectWipHashComparisons(bX,bW['params']['table'])){!a3['has'](bY['constant'])&&a5['push']({'guard':bW['id'],'query':bY['query'],'constant':bY['constant']});}}const a6=createsOf(c,'reward')['length']>0x0;let a7,a8;if(a6)for(const bZ of c['steps']){if(bZ['op']==='configure'&&bZ['method']==='guard_add'){const c0=bZ['params']['amount'];if(c0!==undefined&&c0!==null&&c0['type']==='Fixed'){const c1=numericAmount(c0['value']);if(c1!==undefined)a7=Math['max'](a7??0x0,c1);}}if(bZ['op']==='configure'&&bZ['method']==='coin_add'&&/^reward/['test'](bZ['id'])){const c2=numericAmount(bZ['params']['coin']);if(c2!==undefined)a8=(a8??0x0)+c2;}}const a9=a7!==undefined&&V!==undefined,aa=/^(arb\.indemnity|arb\.order|arb\.status|order\.dispute)/,ab=/settled|refunded|reviewed|completed|closed|cancel/i;let ac;if(h!==undefined)for(const c3 of h['edges']){if(c3['next']===''||c3['guards']['length']===0x0)continue;if(!ab['test'](c3['prev']))continue;if(c3['guards']['some'](c4=>d['get'](c4)?.['queries']['some'](c5=>aa['test'](c5)))){ac=c3['prev'];break;}}const ad=ac!==undefined&&(!T||S===0x0),ae=new Map();for(const c4 of createsOf(c,'guard')){ae['set'](c4['id'],c4['params']['root']??c4['params']['logic']);}const af=h?.['edges']??[],ag=c5=>c5['guards']['length']===0x0||c5['guards']['every'](c6=>{const c7=ae['get'](c6);return c7===undefined||guardWindowOpen(c7);});let ah;const ai=new Set(af['filter'](c5=>c5['prev']==='')['map'](c5=>c5['next'])),aj=[];for(const c5 of new Set(af['map'](c6=>c6['prev'])['concat'](af['map'](c6=>c6['next'])))){if(c5===''||ai['has'](c5))continue;const c6=af['filter'](c7=>c7['prev']===c5);if(c6['length']===0x0)continue;if(c6['every'](c7=>!ag(c7)))aj['push'](c5);}for(const c7 of aj){if(c7==='')aj['splice'](aj['indexOf'](c7),0x1);}for(const c8 of af){if(c8['prev']!==''||c8['next']==='')continue;const c9=af['filter'](ca=>ca['prev']===c8['next']);if(c9['length']===0x0)continue;if(c9['every'](ca=>!ag(ca)))ah??=c8['next'];}const ak=[],al=ca=>{if(ca['roster']==='')return!(ca['perm']!==undefined&&ca['perm']>0x0);if(ca['roster']===undefined&&ca['perm']!==undefined)return![];if(typeof ca['roster']==='string'&&ca['roster']!=='')return![];return undefined;};for(const ca of af){if(ca['prev']!==''||ca['next']==='')continue;const cb=af['filter'](ce=>ce['prev']===ca['next']&&ce['prev']!==ce['next']);if(cb['length']===0x0)continue;const cc=cb['flatMap'](ce=>ce['forwardRails']);if(cc['length']===0x0)continue;const cd=cc['map'](al);if(cd['some'](ce=>ce===undefined))continue;if(cd['every'](ce=>ce===!![]))ak['push'](ca['next']);}const am=f['some'](ce=>ce['guardStep']===undefined&&ce['guardKey']!==undefined),an=af['filter'](ce=>ce['guards']['length']>0x0&&ce['guards']['some'](cf=>d['get'](cf)?.['queries']['some'](cg=>aa['test'](cg))));let ao=![];if(an['length']>0x0&&!am){const ce=new Set(an['map'](ch=>ch['next'])['filter'](ch=>ch!=='')),cf=new Set(an['flatMap'](ch=>ch['guards'])),cg=new Set();for(const ch of f){const ci=ch['guardStep']===undefined?undefined:d['get'](ch['guardStep']);if(ci===undefined)continue;if(ci['acceptedNodes']['length']>0x0){for(const cj of ci['acceptedNodes'])cg['add'](cj);}else for(const ck of af){ck['next']!==''&&ck['guards']['includes'](ch['guardStep'])&&cg['add'](ck['next']);}}for(const cl of f){const cm=cl['guardStep']===undefined?undefined:d['get'](cl['guardStep']);if(cm===undefined)continue;if(cm['queries']['some'](cn=>aa['test'](cn))||cf['has'](cl['guardStep'])){ao=!![];break;}}if(!ao)for(const cn of ce){if(cg['has'](cn)){ao=!![];break;}}}const ap=an['length']>0x0&&!ao&&!am,aq=an[0x0]===undefined?undefined:an[0x0]['prev']!==''?an[0x0]['prev']:an[0x0]['next'],ar=[];for(const co of c['steps']){const cp=co['op']==='create'&&co['object']==='service',cq=co['op']==='configure'&&co['method']==='sales';if(!cp&&!cq)continue;const cs=co['params'];if(typeof cs['description']==='string')ar['push'](cs['description']);if(!Array['isArray'](cs['sales']))continue;for(const ct of cs['sales']){if(typeof ct!=='object'||ct===null)continue;for(const cu of Object['values'](ct)){if(typeof cu==='string')ar['push'](cu);}}}const as=ar['flatMap'](cv=>extractProseWindowPromises(cv)),at=collectEnforcedWindowMs(c),au=as['filter'](cv=>!at['has'](cv['ms'])),av=[];for(const cv of ar){const cw=UNANCHORED_RESTART_RE['exec'](cv);if(cw)av['push'](cw[0x0]);}const aw=f['filter'](cx=>cx['track']==='refund');let ax=![];const ay=[];if(h!==undefined)for(const cx of h['edges']){const cy=cx['guards']['some'](cz=>(d['get'](cz)?.['queries']??[])['includes']('order.principal_refunded'));if(!cy)continue;if(cx['next']==='closed_refunded'&&cx['guards']['length']>0x0)ax=!![];ay['push']((cx['prev']||'enter')+'\x20->\x20'+cx['next']+(cx['forwardNames']['length']>0x0?'\x20('+cx['forwardNames']['join'](',\x20')+')':''));}let az=0x0;const aA=[];if(h!==undefined)for(const cz of h['edges']){const cA=cz['forwardNames']['filter'](cB=>cB['endsWith']('_late'));if(cA['length']===0x0)continue;for(const cB of cA){az+=0x1;const cC=cz['guards']['some'](cD=>(d['get'](cD)?.['queries']??[])['some'](cE=>/^permission\.entity\.perm/['test'](cE)));if(!cC)aA['push'](cz['prev']+'\x20->\x20'+cz['next']+'\x20('+cB+')');}}let aB;for(const cD of Object['keys'](c['inputs']??{})){if(/deadline/i['test'](cD)){aB=cD;break;}}let aC=![],aD;if(h!==undefined&&aB!==undefined){const cE=(c['inputs']??{})[aB],cF=cE===undefined?undefined:String(cE),cG='${'+aB+'}';for(const cH of h['edges']){if(cH['prev']!=='')continue;const cI=cH['guards']['some'](cJ=>(d['get'](cJ)?.['table']??[])['some'](cK=>{const cL=cK['value'];if(typeof cL==='string')return cL===cG||cF!==undefined&&cL===cF;return cF!==undefined&&cL!==undefined&&String(cL)===cF;}));!cI&&(aC=!![],aD??=cH['next']);}}let aE=![],aF,aG,aH,aI;if(h!==undefined){const cJ=new Map();for(const cK of h['edges']){if(cK['prev']!=='')continue;for(const cL of cK['guards']){const cM=d['get'](cL);if(cM===undefined||cM['upperTimeBoundIds']['length']===0x0)continue;if(cM['queries']['some'](cN=>isPathDependentTimeQuery(cN)||cN['startsWith']('order.time')))continue;for(const cN of cM['upperTimeBoundIds']){const cO=cM['table']['find'](cQ=>Number(cQ['identifier'])===cN);if(cO===undefined||cO['value']===undefined)continue;const cP=String(cO['value'])['trim']();if(cP==='0')continue;!cJ['has'](cP)&&cJ['set'](cP,{'guard':cL,'node':cK['next']});}}}if(cJ['size']>0x0){const cQ=new Set();for(const cT of createsOf(c,'service')){const cU=cT['params']['buy_guard'];if(isRef(cU))cQ['add'](cU['$ref']);}for(const cV of c['steps']){cV['op']==='configure'&&cV['method']==='buy_guard'&&isRef(cV['params'])&&cQ['add'](cV['params']['$ref']);}const cR=cW=>[...cQ]['some'](cX=>{const cY=d['get'](cX);if(cY===undefined||cY['upperTimeBoundIds']['length']===0x0)return![];return cY['upperTimeBoundIds']['some'](cZ=>{const d0=cY['table']['find'](d3=>Number(d3['identifier'])===cZ);if(d0===undefined||d0['value']===undefined)return![];const d1=String(d0['value'])['trim']();if(d1===cW)return!![];const d2=/^\$\{(.+)\}$/['exec'](d1);return d2!==null&&String((c['inputs']??{})[d2[0x1]])['trim']()===cW;});}),cS=[...cJ['entries']()]['filter'](([cW,cX])=>{const cY=/^\$\{(.+)\}$/['exec'](cW),cZ=cY!==null?String((c['inputs']??{})[cY[0x1]])['trim']():cW;return!(cR(cW)||cZ!==cW&&cR(cZ));});if(cS['length']>0x0){aE=!![];const [cW,cX]=cS[0x0];aG=cX['guard'],aF=cX['node'],aH=cW,aI=cQ['size']===0x0?'no\x20buy_guard\x20bound':'buy_guard\x20('+[...cQ]['join'](',\x20')+')\x20carries\x20no\x20closing\x20window\x20on\x20this\x20instant';}}}let aJ,aK;if(h!==undefined)for(const cY of h['edges']){for(const cZ of cY['guards']){const d0=d['get'](cZ);if(d0===undefined||d0['upperTimeBoundIds']['length']===0x0)continue;const d1=d0['upperTimeBoundIds']['some'](d2=>{const d3=d0['table']['find'](d5=>Number(d5['identifier'])===d2);if(d3===undefined)return![];const d4=d3['value'];if(typeof d4==='number')return d4===0x0;if(typeof d4==='string')return d4['trim']()==='0';return![];});d1&&(aJ??=cY['next'],aK??=cZ);}}const aL=[];let aM=0x0;for(const d2 of f){if(d2['track']!=='settlement')continue;const d3=d2['guardStep']===undefined?[]:d['get'](d2['guardStep'])?.['queries']??[],d4=[];if(d3['includes']('order.owner'))d4['push']('order.owner==signer\x20(buyer)');if(d3['includes']('order.agent'))d4['push']('order.agent\x20has\x20signer');if(d3['includes']('order.service'))d4['push']('order.service\x20binding');if(d3['some'](d6=>/^permission\.(owner|admin)$/['test'](d6)))d4['push']('permission\x20role');const d5=d2['guardStep']??d2['guardKey']??'<unbound>';d4['length']===0x0?aL['push'](d5+':\x20no\x20guard\x20identity\x20face\x20(edge\x20rail:\x20merchant\x20permission\x201000\x20default)'):(d4['every'](d6=>d6['startsWith']('order.owner')||d6['startsWith']('order.agent'))&&!d3['includes']('order.service')&&!d3['some'](d6=>/^permission\./['test'](d6))&&(aM+=0x1),aL['push'](d5+':\x20'+d4['join']('\x20|\x20')));}const aN=new Map();for(const d6 of h?.['edges']??[]){for(const d7 of d6['guards']){const d8=aN['get'](d7)??[];if(d6['prev']!=='')d8['push'](d6['prev']);if(d6['next']!=='')d8['push'](d6['next']);aN['set'](d7,d8);}}let aO,aP=![];for(const d9 of d['values']()){if(d9['queries']['some'](isPathDependentTimeQuery)){aO??=d9['stepId'];if(h!==undefined){const da=[...d9['acceptedNodes'],...aN['get'](d9['stepId'])??[]];for(const db of da){if(pathCountCap2(h['edges'],db)>=0x2){aP=!![],aO=d9['stepId'];break;}}}}if(aP)break;}const aQ=[...d['values']()]['flatMap'](dc=>dc['queries']);let aR;for(const dc of WRITE_ONLY_ENFORCEMENT_SOURCES){for(const dd of createsOf(c,dc['object'])){if(dc['extract'](dd)&&!aQ['some'](de=>de['startsWith'](dc['coverQuery']))){aR=dc['param'];break;}}if(aR!==undefined)break;}const aS=new Set();for(const de of c['steps']){if(de['op']==='create'&&de['object']==='guard')continue;const df=refsOf(de['op']==='publish'?de['target']:de['params']);for(const dg of df)aS['add'](dg);if(de['op']==='configure'){for(const dh of refsOf(de['target']))aS['add'](dh);}}const aT=[...d['keys']()]['find'](di=>!aS['has'](di)),aU=[...d['values']()]['find'](di=>!o&&di['queries']['some'](dj=>dj['startsWith']('repository.')))?.['stepId'];let aV;if(l&&h!==undefined)for(const di of h['forwardGuardRefs']){const dj=d['get'](di);if(dj===undefined)continue;const dk=dj['table']['some'](dl=>dl['identifier']===TASK_BINDING_SLOT&&dl['b_submission']===!![]);if(!dk){aV=di;break;}}let aW;for(const dl of f){if(dl['guardStep']===undefined||dl['identifierLegs']['length']===0x0)continue;const dm=d['get'](dl['guardStep']);if(dm===undefined)continue;for(const dn of dl['identifierLegs']){const dp=dm['table']['find'](dq=>dq['identifier']===dn);if(dp===undefined||dp['b_submission']!==!![]||dp['value_type']!=='Address'){aW='slot\x20'+dn+'\x20of\x20guard\x20\x27'+dl['guardStep']+'\x27';break;}}if(aW!==undefined)break;}const aX=new Set();for(const {policies:dq}of repositoryPoliciesMerged(c)){for(const dr of dq){const ds=dr?.['name'];if(typeof ds==='string')aX['add'](ds);}}const aY=[];if(aX['size']>0x0)for(const dt of createsOf(c,'guard')){const du=Array['isArray'](dt['params']['table'])?dt['params']['table']:[];for(const dv of collectRepoWhereQueries(dt['params']['root']??dt['params']['logic'])){const dw=staticStringOperand(dv['key'],du);if(dw===undefined)continue;if(!isPlanLocalObjectOperand(dv['object'],du))continue;!aX['has'](dw)&&aY['push']('\x27'+dw+'\x27\x20in\x20guard\x20\x27'+dt['id']+'\x27');}}const aZ=[];for(const dx of createsOf(c,'guard')){const dy=Array['isArray'](dx['params']['table'])?dx['params']['table']:[];for(const dz of collectRepoWhereQueries(dx['params']['root']??dx['params']['logic'])){const dA=dz['type'];if(typeof dA!=='string'||!dA['includes']('sum_where'))continue;const dB=dz['object'];if(typeof dB!=='object'||dB===null)continue;const dC=dB['identifier'];if(typeof dC!=='number')continue;const dD=dy['find'](dE=>typeof dE==='object'&&dE!==null&&dE['identifier']===dC);dD!==undefined&&dD['b_submission']===!![]&&aZ['push']('slot\x20'+dC+'\x20of\x20guard\x20\x27'+dx['id']+'\x27');}}const b0=[];{const dE=new Map(createsOf(c,'guard')['map'](dH=>[dH['id'],guardProjection(dH)])),dF=[],dG=dH=>{if(typeof dH==='object'&&dH!==null&&!Array['isArray'](dH)){const dI=dH;if(Array['isArray'](dI['allocators']))dH=dI['allocators'];}if(!Array['isArray'](dH))return;for(const dJ of dH){if(typeof dJ!=='object'||dJ===null)continue;const dK=dJ,dL=[],dM=Array['isArray'](dK['sharing'])?dK['sharing']:[];for(const dP of dM){if(typeof dP!=='object'||dP===null)continue;const dQ=dP['who'];if(typeof dQ!=='object'||dQ===null)continue;const dR=dQ;if(typeof dR['GuardIdentifier']==='number')dL['push']('guard-slot:'+dR['GuardIdentifier']);else{if(typeof dR['Entity']==='string')dL['push']('entity:'+String(dR['Entity'])['toLowerCase']());else{if(dR['Signer']!==undefined)dL['push']('signer');}}}const dN=isRef(dK['guard'])?dK['guard']['$ref']:undefined,dO=dN!==undefined?dE['get'](dN):undefined;dF['push']({'track':typeof dK['track']==='string'?dK['track']:'settlement','guard':dN??'(keyed)','nodes':dO?[...dO['acceptedNodes']]['sort']():[],'payees':[...dL]['sort']()});}};for(const dH of c['steps']){if(dH['op']==='create'&&dH['object']==='service')dG(dH['params']['order_allocators']);if(dH['op']==='configure'&&dH['method']==='order_allocators')dG(dH['params']['allocators']);}for(let dI=0x0;dI<dF['length'];dI++){for(let dJ=dI+0x1;dJ<dF['length'];dJ++){const dK=dF[dI],dL=dF[dJ];if(dK['nodes']['length']===0x0||dL['nodes']['length']===0x0)continue;if(dK['payees']['length']===0x0||dL['payees']['length']===0x0)continue;const dM=dK['nodes']['some'](dO=>dL['nodes']['includes'](dO)),dN=dK['payees']['length']===dL['payees']['length']&&dK['payees']['every']((dO,dP)=>dO===dL['payees'][dP]);dM&&!dN&&b0['push']('row#'+(dI+0x1)+'('+dK['track']+',guard\x20\x27'+dK['guard']+'\x27,pays\x20'+dK['payees']['join']('|')+')\x20vs\x20'+('row#'+(dJ+0x1)+'('+dL['track']+',guard\x20\x27'+dL['guard']+'\x27,pays\x20'+dL['payees']['join']('|')+')\x20share\x20node(s)\x20')+('['+dK['nodes']['filter'](dO=>dL['nodes']['includes'](dO))['join'](',')+']\x20with\x20different\x20payees'));}}}const b1=new Set();for(const {policies:dO}of repositoryPoliciesMerged(c)){for(const dP of dO){const dQ=dP?.['write_guard'];if(!Array['isArray'](dQ))continue;for(const dR of dQ){const dS=dR?.['guard'],dT=isRef(dS)?dS['$ref']:dS;if(typeof dT==='string')b1['add'](dT);}}}let b2,b3=0x0;for(const dU of createsOf(c,'guard')){if(!b1['has'](dU['id']))continue;rootNegatesRepoDataHas(dU['params']['root']??dU['params']['logic'])&&(b3++,b2??=dU['id']);}const b4=[],b5=new Set(),b6=dV=>{if(!Array['isArray'](dV))return[];return dV['filter'](dW=>typeof dW==='object'&&dW!==null)['filter'](dW=>dW['write_once']===!![]&&typeof dW['name']==='string')['map'](dW=>dW['name']);};for(const dV of c['steps']){if(dV['op']==='create'&&dV['object']==='repository'){for(const dZ of b6(dV['params']['policies']))b5['add'](dZ);continue;}if(dV['op']!=='configure'||dV['method']!=='policies')continue;const dW=dV['params'],dX=typeof dW['op']==='string'?dW['op']:'add',dY=(e0,e1)=>{b4['push']('step\x20\x27'+dV['id']+'\x27\x20'+e0+':\x20'+e1['join'](',\x20'));};if(dX==='set'){const e0=new Set(b6(dW['policy'])),e1=[...b5]['filter'](e2=>!e0['has'](e2));if(e1['length']>0x0)dY('REPLACES\x20the\x20policy\x20list\x20and\x20drops\x20write_once\x20attestation(s)',e1);for(const e2 of b6(dW['policy']))b5['add'](e2);}else{if(dX==='remove'){const e3=Array['isArray'](dW['policy'])?dW['policy']['filter'](e5=>typeof e5==='string'):[],e4=e3['filter'](e5=>b5['has'](e5));if(e4['length']>0x0)dY('REMOVES\x20write_once\x20attestation\x20policy/policies',e4);for(const e5 of e4)b5['delete'](e5);}else{if(dX==='clear'){if(b5['size']>0x0)dY('CLEARS\x20the\x20policy\x20list\x20including\x20write_once\x20attestation(s)',[...b5]);b5['clear']();}else{if(Array['isArray'](dW['policy']))for(const e6 of dW['policy']){const e7=e6;if(typeof e7?.['name']!=='string')continue;const e8=e7['name'];if(e7['write_once']===!![])b5['add'](e8);else b5['has'](e8)&&(dY('UPDATES\x20a\x20write_once\x20policy\x20with\x20write_once\x20unset/false\x20(silent\x20downgrade)',[e8]),b5['delete'](e8));}}}}}const b7=new Map(createsOf(c,'guard')['map'](e9=>[e9['id'],e9]));let b8,b9=0x0,ba,bb=0x0,bc;for(const {policies:e9}of repositoryPoliciesMerged(c)){for(const ea of e9){const eb=ea,ec=eb['write_guard'];if(!Array['isArray'](ec))continue;const ed=typeof eb['id_from']==='string'?eb['id_from']['toLowerCase']():'none',ee=ed==='none'?'caller-keyed':ed+'-keyed',ef=typeof eb['description']==='string'?eb['description']:'';for(const eg of ec){const eh=eg?.['guard'],ei=isRef(eh)?eh['$ref']:eh,ej=typeof ei==='string'?b7['get'](ei):undefined;if(ej===undefined)continue;const ek=writeGuardLegClass(ej['params']['root']??ej['params']['logic'],ej['params']['table']);if(!ek['hasSignerLeg']||ek['hasBindingLeg'])continue;const el='guard\x20\x27'+ej['id']+'\x27\x20(policy\x20\x27'+String(eb['name']??'?')+'\x27,\x20'+ee+')';ed==='signer'||ed==='clock'?(bb++,ba??=el):(b9++,b8??=el),WRITE_GUARD_PROMISE_RE['test'](ef)&&!WRITE_GUARD_TAUTOLOGY_DISCLOSURE_RE['test'](ef)&&(bc??=el+'\x20—\x20its\x20description\x20promises\x20a\x20bound\x20writer\x20set\x20the\x20guard\x20legs\x20never\x20encode');}}}let bd,be=0x0;for(const em of createsOf(c,'service')){const en=em['params']['customer_required'];if(!Array['isArray'](en)||en['length']===0x0)continue;em['params']['buy_guard']===undefined&&(be++,bd??=em['id']);}let bf,bg=0x0;for(const eo of h?.['edges']??[]){if(eo['prev']===''||eo['guards']['length']===0x0)continue;for(const ep of eo['guards']){const er=d['get'](ep);if(er===undefined||er['acceptedNodes']['length']===0x0)continue;!er['acceptedNodes']['includes'](eo['prev'])&&(bg++,bf??=ep+'\x20on\x20edge\x20'+eo['prev']+'->'+eo['next']+'\x20(guard\x20pins\x20progress.current\x20in\x20'+('['+er['acceptedNodes']['join'](',\x20')+']\x20—\x20never\x20\x27'+eo['prev']+'\x27)'));}}let bh;if(h!==undefined){const es=(h['edges']['find'](eu=>eu['prev']==='')??{'next':''})['next'],et=new Set([...h['finalRoleNodes'],...h['optionalNodes']]);for(const eu of h['nodes']){if(et['has'](eu)||eu===es)continue;const ev=h['edges']['filter'](ex=>ex['prev']===eu&&ex['next']!==eu);if(ev['length']===0x0)continue;const ew=ev['some'](ex=>ex['guards']['length']===0x0||ex['guards']['some'](ey=>{const ez=d['get'](ey);return ez===undefined||ez['acceptedNodes']['length']===0x0||ez['acceptedNodes']['includes'](eu);}));if(!ew)bh??=eu;}}let bi,bj=0x0,bk,bl=0x0,bm,bn=0x0;{for(const ex of f){if(ex['guardStep']===undefined)continue;const ey=d['get'](ex['guardStep']);if(ey===undefined)continue;const ez=ey['queries']['includes']('order.claimed_by')||ey['queries']['some'](eA=>eA['startsWith']('arb'));if(!ez)continue;bn++,bm??=ex['track']+'\x20row\x20on\x20guard\x20\x27'+(ex['guardKey']??ex['guardStep'])+'\x27\x20('+ex['guardStep']+')\x20—\x20'+'ratio\x20split\x20is\x20award-independent:\x20on\x20a\x20buyer-won\x20award\x20the\x20principal\x20goes\x20wherever\x20this\x20row\x27s\x20'+'guard\x20legs\x20route\x20it,\x20not\x20to\x20the\x20award\x20winner';}}{const eA=new Set(h?.['forwardGuardRefs']??[]);for(const eB of h?.['edges']??[])for(const eC of eB['guards'])eA['add'](eC);for(const eD of f){const eE=/refund|settle|recover/i['test'](eD['track'])||/refund|settle|recover/i['test'](eD['guardKey']??'');if(!eE||eD['guardStep']===undefined)continue;const eF=d['get'](eD['guardStep']);if(eF===undefined)continue;const eG=eF['acceptedNodes']['length']>0x0||eA['has'](eD['guardStep'])||eF['queries']['includes']('order.dispute.open'),eH=eF['queries']['includes']('order.owner')||eF['queries']['includes']('order.agent\x20has')||eF['queries']['includes']('order.service');if(!eG||eH)continue;bl++,bk??=eD['track']+'\x20row\x20on\x20guard\x20\x27'+(eD['guardKey']??eD['guardStep'])+'\x27\x20('+eD['guardStep']+')\x20—\x20'+('state-pinned\x20only'+(eA['has'](eD['guardStep'])?'\x20(edge\x20mount)':eF['acceptedNodes']['length']>0x0?'\x20(nodes:\x20'+eF['acceptedNodes']['join']('/')+')':'\x20(dispute\x20freeze)')+';\x20')+'no\x20order\x20identity\x20leg\x20—\x20any\x20address\x20may\x20drive\x20the\x20rail\x20while\x20the\x20order\x20rests\x20in\x20the\x20pinned\x20state';}}{const eI=new Set(h?.['forwardGuardRefs']??[]);for(const eJ of h?.['edges']??[])for(const eK of eJ['guards'])eI['add'](eK);for(const eL of f){const eM=/refund|settle|recover/i['test'](eL['track'])||/refund|settle|recover/i['test'](eL['guardKey']??'');if(!eM||eL['guardStep']===undefined)continue;const eN=d['get'](eL['guardStep']);if(eN===undefined)continue;const eO=eN['acceptedNodes']['length']>0x0||eI['has'](eL['guardStep'])||eN['queries']['includes']('order.dispute.open'),eP=eN['queries']['includes']('order.owner')||eN['queries']['includes']('order.agent\x20has')||eN['queries']['includes']('order.service');if(eO||eP)continue;bj++,bi??=eL['track']+'\x20row\x20on\x20guard\x20\x27'+(eL['guardKey']??eL['guardStep'])+'\x27\x20('+eL['guardStep']+')\x20—\x20pins\x20no\x20progress\x20node,\x20rides\x20no\x20machine\x20edge,\x20references\x20no\x20order\x20identity\x20or\x20dispute\x20state';}}const bo=[];for(const eQ of createsOf(c,'guard')){const eR=reachLegsOf(eQ);bo['push'](...findReachContradictions(eQ['id'],eR['legs'],eR['selfStrict']));}const bp=[];for(const eS of createsOf(c,'guard')){const eT=eS['params']['root']??eS['params']['logic'],eU=eS['params']['table'],eV=typeof eS['params']['description']==='string'?eS['params']['description']:'',eW=equalityFaceCheck(eS['id'],eV,eT);if(eW!==null)bp['push'](eW);bp['push'](...thresholdLiteralCheck(eS['id'],eU)),bp['push'](...setCollapseCheck(eS['id'],eU)),bp['push'](...submissionRowIdTrustCheck(eS['id'],eT,eU)),bp['push'](...abortSafeVerbCheck(eS['id'],eT));}const bq=new Map();for(const eX of h?.['edges']??[]){const eY=bq['get'](eX['prev'])??[];eY['push'](eX['next']),bq['set'](eX['prev'],eY);}const br=new Map();for(const eZ of findLoopCycles(bq)){const f0=classifyLoopCycle(eZ['cycle']);for(const f1 of eZ['cycle'])br['set'](f1,f0);}const bs=f2=>{const f3=br['get'](f2);return f3==='renewal'||f3==='charge';},bt=[];if(br['size']>0x0)for(const f2 of createsOf(c,'guard')){const f3=f2['params']['root']??f2['params']['logic'];if(f3===undefined)continue;const f4=typeof f2['params']['description']==='string'?f2['params']['description']:'',f5=f6=>{if(!f6||typeof f6!=='object')return;if(Array['isArray'](f6)){f6['forEach'](f5);return;}const f7=f6,f8=typeof f7['type']==='string'?f7['type']:'',f9=f7['where']??null;if(f8['startsWith']('query_progress_history_time')&&f7['find']==='first'&&f9!==null&&typeof f9==='object'){const fa=typeof f9['nextNode']==='string'?f9['nextNode']:undefined;if(fa!==undefined&&bs(fa)){const fb=/\bper[- ]period\b|\bthis period\b|\beach period\b|\bevery period\b|\u6bcf\u671f|\u5f53\u671f|\u672c\u671f/i['test'](f4);bt['push']({'guard':f2['id'],'target':fa,'perPeriodClaim':fb});}}for(const fc of Object['values'](f7))f5(fc);};f5(f3);}const bu=f6=>'guard\x20\x27'+f6['guard']+'\x27\x20anchors\x20a\x20history\x20clock\x20at\x20find:\x22first\x22\x20on\x20PERIODIC\x20node\x20\x27'+f6['target']+'\x27\x20'+'(re-enters\x20per\x20billed\x20period)'+(f6['perPeriodClaim']?'\x20while\x20its\x20description\x20claims\x20per-period\x20semantics\x20—\x20period\x202+\x20reads\x20the\x20FIRST\x20visit\x27s\x20timestamp\x20(ofnz8\x20F-61)':'\x20—\x20intentional\x20once-per-life\x20gate,\x20or\x20the\x20stale-anchor\x20defect\x20(ofnz8\x20F-61)?'),bv=bt['find'](f6=>f6['perPeriodClaim'])??bt[0x0],bw=new Set();for(const f6 of createsOf(c,'reward'))refsOf(f6['params'],bw);for(const f7 of createsOf(c,'repository'))refsOf(f7['params'],bw);const bx=[];if(h!==undefined&&bw['size']>0x0)for(const f8 of bw){const f9=d['get'](f8);if(f9===undefined||f9['acceptedNodes']['length']===0x0)continue;for(const fa of h['edges']){if(!fa['guards']['includes'](f8))continue;if(fa['prev']===''||fa['prev']===fa['next'])continue;if(!f9['acceptedNodes']['includes'](fa['prev']))continue;bx['push']('guard\x20\x27'+f8+'\x27\x20anchors\x20progress.current\x20==\x20\x27'+fa['prev']+'\x27\x20yet\x20also\x20drives\x20the\x20forward\x20'+(fa['prev']+'\x20->\x20'+fa['next'])+(fa['forwardNames']['length']>0x0?'\x20('+fa['forwardNames']['join'](',\x20')+')':'')+'\x20—\x20once\x20that\x20forward\x20fires\x20the\x20anchor\x20is\x20consumed\x20and\x20every\x20later\x20claim/write\x20through\x20this\x20guard\x20aborts\x20forever\x20(split\x20the\x20guard,\x20or\x20claim/write\x20BEFORE\x20forwarding\x20in\x20the\x20same\x20tx)');}}const by=[];if(h!==undefined)for(const fb of h['edges']){if(fb['guards']['length']>0x0)continue;if(fb['prev']==='')continue;by['push'](fb['prev']+'\x20->\x20'+fb['next']+(fb['forwardNames']['length']>0x0?'\x20('+fb['forwardNames']['join'](',\x20')+')':''));}const bz=[];if(h!==undefined){const fc=new Map();for(const fd of h['edges']){for(const fe of fd['guards']){const ff=fc['get'](fe)??[];ff['push']((fd['prev']||'(entry)')+'\x20->\x20'+fd['next']),fc['set'](fe,ff);}}for(const [fg,fh]of fc){if(fh['length']<0x2)continue;const fi=d['get'](fg);if(fi===undefined)continue;if(fi['acceptedNodes']['length']>0x0)continue;bz['push']('guard\x20\x27'+fg+'\x27\x20mounts\x20on\x20'+fh['length']+'\x20edges\x20('+fh['join'](',\x20')+')\x20with\x20NO\x20progress.node\x20leg\x20—\x20it\x20fires\x20in\x20every\x20node\x20context\x20its\x20other\x20legs\x20allow;\x20scope\x20it\x20per-edge\x20or\x20add\x20the\x20node\x20leg');}}const bA=[],bB=[],bC=(fj,fk,fl,fm)=>{if(fk===null||typeof fk!=='object')return;if(Array['isArray'](fk)){fk['forEach']((fn,fo)=>bC(fj,fn,fl+'['+fo+']',fm));return;}for(const [fn,fo]of Object['entries'](fk)){const fp=fl?fl+'.'+fn:fn,fq=typeof fo==='number'&&Number['isFinite'](fo)&&!Number['isInteger'](fo);/_days$/['test'](fn)&&fn!=='campaign_duration_days'&&fq&&bA['push']('step\x20\x27'+fj+'\x27:\x20'+fp+'\x20=\x20'+fo+'\x20—\x20the\x20U64\x20day\x20slot\x20truncates\x20to\x20'+Math['trunc'](fo)+'\x20at\x20BCS\x20encode'),fm&&(/_hours$/['test'](fn)||/_minutes$/['test'](fn))&&fq&&bB['push']('step\x20\x27'+fj+'\x27:\x20'+fp+'\x20=\x20'+fo+'\x20—\x20the\x20U64\x20'+(/_minutes$/['test'](fn)?'minute':'hour')+'\x20slot\x20truncates\x20to\x20'+Math['trunc'](fo)+'\x20at\x20BCS\x20encode'),bC(fj,fo,fp,fm);}};for(const fj of c['steps']){const fk=fj['params'];if(fk!==undefined)bC(fj['id'],fk,'',!![]);}return bC('<plan.inputs>',c['inputs'],'',![]),{...compositionFacts(c),'has_service':l,'has_machine':h!==undefined,'has_repository':o,'sales_step_present':q,'allocator_row_count':f['length'],'refund_row_count':aw['length'],'terminal_count':x['length'],'terminal_nodes_display':x['join'](',\x20'),'pending_allocator_guard_count':L,'pending_guard_total':K['length'],...B===undefined?{}:{'first_uncovered_terminal':B},...C===undefined?{}:{'first_uncovered_final_node':C},...D===undefined?{}:{'first_cancelled_review_bridge':D['prev']+'\x20->\x20'+D['next']+(D['forwardNames']['length']>0x0?'\x20(forward\x20'+D['forwardNames']['join'](',\x20')+')':'')},...H===undefined?{}:{'first_roster_null_perm_edge':H},...J===undefined?{}:{'coarse_perm_bucket_index':J[0x0],'coarse_perm_bucket_classes':[...J[0x1]]['sort']()['join'](',\x20')},...bh===undefined?{}:{'first_pinned_away_exit_node':bh},'direction_blind_pay_edge_count':bj,...bi===undefined?{}:{'first_direction_blind_pay_edge':bi},'state_pinned_identity_blind_pay_edge_count':bl,...bk===undefined?{}:{'first_state_pinned_identity_blind_pay_edge':bk},'arb_gated_money_row_count':bn,...bm===undefined?{}:{'first_arb_gated_money_row':bm},...aO===undefined?{}:{'first_path_dependent_anchor':aO},'path_sensitive':aP,...aR===undefined?{}:{'first_write_only_unenforced_field':aR},...aT===undefined?{}:{'first_orphan_guard':aT},...aU===undefined?{}:{'first_repo_query_without_repository':aU},'repo_write_once_guard_count':b3,...b2===undefined?{}:{'first_repo_write_once_guard':b2},...b4['length']===0x0?{}:{'write_once_removable_count':b4['length'],'first_write_once_removable':b4[0x0],'write_once_removable_display':b4['join'](';\x20')},'tautology_write_guard_count':b9,...b8===undefined?{}:{'first_tautology_write_guard':b8},'keyed_tautology_write_guard_count':bb,...ba===undefined?{}:{'first_keyed_tautology_write_guard':ba},...bc===undefined?{}:{'first_promise_gap_write_guard':bc},'customer_required_unbacked_count':be,...bd===undefined?{}:{'first_customer_required_unbacked':bd},...aV===undefined?{}:{'first_edge_guard_missing_254':aV},'node_mismatched_guard_count':bg,...bf===undefined?{}:{'first_node_mismatched_guard':bf},'guard_reach_contradiction_count':bo['length'],...bo['length']>0x0?{'first_guard_reach_contradiction':bo[0x0],'guard_reach_contradiction_display':bo['join'](';\x20')}:{},...guardQualityFacts(bp),...bt['length']>0x0?{'first_guard_find_polarity':bu(bv),'guard_find_polarity_count':bt['length'],...bt['some'](fl=>fl['perPeriodClaim'])?{'guard_find_polarity_per_period':!![]}:{},'guard_find_polarity_display':bt['map'](bu)['join'](';\x20')}:{},...bx['length']>0x0?{'reward_anchor_conflict_count':bx['length'],'first_reward_anchor_conflict':bx[0x0],'reward_anchor_conflict_display':bx['join'](';\x20')}:{},...c['templateId']===undefined?{'plan_hand_built':!![]}:{},...by['length']>0x0?{'unguarded_rail_count':by['length'],'first_unguarded_rail':by[0x0],'unguarded_rail_display':by['join'](';\x20')}:{},...bz['length']>0x0?{'nodeless_reused_guard_count':bz['length'],'first_nodeless_reused_guard':bz[0x0],'nodeless_reused_guard_display':bz['join'](';\x20')}:{},...ay['length']>0x0?{'convergence_rail_count':ay['length'],'first_convergence_rail':ay[0x0],'convergence_rail_display':ay['join'](';\x20')}:{},...aB!==undefined&&aC?{'deadline_entry_unguarded':!![],'deadline_input_key':aB,'first_entry_edge_node':aD??''}:{},...aE?{'entry_deadline_buy_desync':!![],'entry_deadline_node':aF??'','entry_deadline_guard':aG??'','entry_deadline_value':aH??'','buy_guard_deadline_state':aI??''}:{},...aJ===undefined?{}:{'time_window_closed_at_birth':!![],'closed_window_guard':aK??'','closed_window_node':aJ},...bA['length']>0x0?{'fractional_day_knob_count':bA['length'],'first_fractional_day_knob':bA[0x0],'fractional_day_knob_display':bA['join'](';\x20')}:{},...bB['length']>0x0?{'fractional_hour_knob_count':bB['length'],'first_fractional_hour_knob':bB[0x0],'fractional_hour_knob_display':bB['join'](';\x20')}:{},...aW===undefined?{}:{'first_alloc_slot_missing':aW},...O===undefined?{}:{'first_pending_fund_guard':O,'pending_fund_guard_count':M['length'],'pending_fund_guard_keys_display':M['map'](fl=>fl['key'])['join'](',\x20')},...P===undefined?{}:{'first_pending_buy_guard':P,'pending_buy_guard_count':N['length'],'pending_buy_guard_keys_display':N['map'](fl=>fl['key'])['join'](',\x20')},'has_return_rail':Q!==undefined,...Q===undefined?{}:{'return_rail_node':Q},'has_arbitration_binding':R,'fund_topup_present':T,...S===undefined?{}:{'fund_topup_amount':S},...Y?{'fund_ceiling_breach':S<MAX_INDEMNITY_MULTIPLE*U,'fund_ceiling_basis':MAX_INDEMNITY_MULTIPLE+'x\x20the\x20highest\x20SKU\x20price','fund_concurrent_orders_coverable':Math['floor'](S/(MAX_INDEMNITY_MULTIPLE*U))}:{},'fund_ceiling_unverifiable':T&&!Y,...a7!==undefined?{'reward_bounty_amount':a7,...a8!==undefined?{'reward_funding_amount':a8}:{},...a8!==undefined&&a7>0x0?{'reward_max_claims':Math['floor'](a8/a7)}:{},...a9?{'lowest_sku_price':V,'reward_scale_breach':a7>0.5*V,'reward_scale_ratio_display':(a7/V)['toFixed'](0x2)+'x\x20the\x20cheapest\x20SKU\x20price'}:{'reward_scale_unverifiable':!![]}}:{},...a1>0x0?{'dead_sku_count':a1,'first_dead_sku_name':Z,'first_dead_sku_bytes':a0}:{},...ad?{'first_arb_exit_node':ac,'fund_arb_route_unfunded':!![]}:{},...ah===undefined?{}:{'entry_no_open_exit':!![],'entry_strand_node':ah},...ak['length']===0x0?{}:{'entry_payer_strand_nodes':ak['join'](',\x20'),'entry_payer_strand_count':ak['length']},...aj['length']===0x0?{}:{'window_strand_nodes':aj['join'](',\x20'),'window_strand_count':aj['length']},...ap&&aq!==undefined?{'arb_promise_without_settle_rail':!![],'arb_promise_node':aq}:{},...an['length']>0x0&&am&&aq!==undefined?{'arb_key_plane_opaque':!![],'arb_key_plane_node':aq}:{},...as['length']>0x0?{'prose_window_promise_count':as['length'],'enforced_window_ms_display':[...at]['sort']((fl,fm)=>fl-fm)['map'](formatMs)['join'](',\x20')||'none',...au['length']>0x0?{'prose_time_mismatch_count':au['length'],'first_prose_time_mismatch':au[0x0]['quote'],'prose_time_mismatch_display':au['map'](fl=>fl['quote'])['join'](';\x20')}:{}}:{},...av['length']>0x0?{'unanchored_window_promise_count':av['length'],'first_unanchored_window_promise':av[0x0]}:{},...aX['size']>0x0?{'repo_policy_keys_display':[...aX]['join'](',\x20'),...aY['length']>0x0?{'repo_gate_key_unbacked_count':aY['length'],'first_repo_gate_key_unbacked':aY[0x0],'repo_gate_key_unbacked_display':aY['join'](',\x20')}:{}}:{},...a5['length']>0x0?{'wip_query_totality_count':a5['length'],'first_wip_query_totality':a5[0x0]['guard']+':\x20'+a5[0x0]['query']+'\x20vs\x20\x27'+a5[0x0]['constant']+'\x27','wip_query_totality_display':a5['map'](fl=>fl['guard']+':\x20'+fl['query']+'\x20vs\x20\x27'+fl['constant']+'\x27')['join'](';\x20'),'wip_query_totality_sku_display':[...a3]['join'](',\x20')}:{},...aZ['length']>0x0?{'repo_agg_submitted_count':aZ['length'],'first_repo_agg_submitted':aZ[0x0],'repo_agg_submitted_display':aZ['join'](',\x20')}:{},...b0['length']>0x0?{'alloc_overlap_payee_count':b0['length'],'first_alloc_overlap_payee':b0[0x0],'alloc_overlap_payee_display':b0['join'](';\x20')}:{},...aw['length']>0x0&&!ax?{'refund_convergence_missing':!![]}:{},...az>0x0?{'late_remedy_edge_count':az}:{},...aA['length']>0x0?{'late_remedy_gate_missing':!![],'first_late_remedy_gate_missing':aA[0x0],'late_remedy_gate_missing_display':aA['join'](';\x20')}:{},...A['length']>0x0?{'dispute_withdraw_edge_count':A['length'],'dispute_withdraw_edges':A['join'](';\x20')}:{},...aL['length']>0x0?{'settlement_triggers_display':aL['join'](';\x20'),...aM>0x0?{'settlement_buyer_only_count':aM}:{}}:{}};}function planRuleBook(){const a=getJudgmentDoc()['rules']['domains']['plan'];if(!a)throw new Error('factory\x20rule\x20pack\x20\x27plan\x27\x20missing\x20—\x20broken\x20installation');return a['rules'];}export function auditPlan(a){const b=validatePlan(a),c=planFacts(a),{findings:d}=evaluateRuleBook(planRuleBook(),c),e=b['length']>0x0||d['some'](g=>g['level']==='critical'||g['level']==='high'),f=rulePackDiagnostics();return{'issues':b,'findings':d,'facts':c,'blocking':e,...f['length']>0x0?{'rule_pack_diagnostics':[...f]}:{}};}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{CANONICAL_COMPILE_ORDER,compilePhaseRank}from'../knowledge/object-dependency.js';import{deriveCapabilityModes,emitModeGates}from'./mode-gates.js';import{normalizeCompileInputs,applyConditionalSelectors}from'./input-normalize.js';import{fillGuards}from'./guard-fill.js';import{expandShapeSegments}from'./shape-expand.js';import{auditRepoIntegrityAndCallerLegs,checkAllocatorRails,checkDaysUnitSlots,checkEmittedStepShapes,checkForeignServicePins,checkFundRailReachability,checkWindowTopology,checkWindowTruncation,checkWindowUnitNaming,computeMoneyRailKeys,dropEmptyVecGuards,emitAllocators,emitArbitrationBindings,emitArbitrationHoist,emitEvidenceRepository,emitGuardWave,emitIdentityPhase,emitLoyaltyGate,emitMachine,emitRewardClaimEarly,emitLateRemedyEdges,emitNegotiationRail,emitRefundConvergence,emitSlaCompensation,rewriteQueryTotality,emitExperiencePoolEarly,emitPriceRebatePoolEarly,emitReviewComponent,emitReviewRepositoryEarly,emitSales,emitServiceAllocators,emitServiceConfigure,emitServiceDraft,emitServicePublish,emitSupplyChain,rewritePlanRefs}from'./emit-phases.js';export{normalizeInlineGuardTable}from'./guard-fill.js';export{normalizeCurrency}from'./emit-phases.js';export function compileTemplate(a,b,c={}){const d=(c['nameBase']??a['id'])['replace'](/\//g,'_'),e=c['merchantPermissionIndex']??0x3e8,f=[],g=[],{inputs:h,derivedParams:i,blockers:j}=normalizeCompileInputs(a,b,c['buildTimeMs']);f['push'](...j);const {dropKeys:k,selectorDroppedKeys:l,shape:m,rows:n,blockers:o,selectionReport:p}=applyConditionalSelectors(a,h);f['push'](...o);let q=m;const r=expandShapeSegments({'template':a,'shape':q,'inputs':h});q=r['shape'],f['push'](...r['blockers']);const {guardSpecs:s,resolvedGuards:t,unresolved:u,omitKeys:v,recoverTwinRails:w,declareReasons:x,specByKey:y,slot254Injected:z,injectedOrderHolderKeys:A,edgeBoundKeys:B,derived:{reviewMode:C,rewardMark:D,needsRepository:E,experienceClaimKey:F,priceRebateClaimKey:G},blockers:H}=fillGuards({'template':a,'base':d,'inputs':h,'guardResolutions':{...r['resolutions'],...c['guardResolutions']??{}},'selector':{'dropKeys':k,'selectorDroppedKeys':l,'shape':q,'rows':n,'selectionReport':p}});f['push'](...H);const I=emitLoyaltyGate({'template':a,'base':d,'guardSpecs':s,'resolvedGuards':t});f['push'](...I['blockers']);const J=emitSlaCompensation({'template':a,'base':d,'inputs':h,'shape':q,'guardSpecs':s,'resolvedGuards':t,'specByKey':y});f['push'](...J['blockers']),q=J['shape'];const K=emitNegotiationRail({'template':a,'base':d,'inputs':h,'shape':q,'guardSpecs':s,'resolvedGuards':t,'specByKey':y,'merchantIndex':e});f['push'](...K['blockers']),q=K['shape'];const L=emitRefundConvergence({'template':a,'base':d,'shape':q,'guardSpecs':s,'resolvedGuards':t,'specByKey':y,'merchantIndex':e});f['push'](...L['blockers']),q=L['shape'];const M=emitLateRemedyEdges({'template':a,'base':d,'inputs':h,'shape':q,'guardSpecs':s,'resolvedGuards':t,'specByKey':y});f['push'](...M['blockers']),q=M['shape'];const N=emitIdentityPhase({'template':a,'base':d});g['push'](...N['steps']);const O=N['needsArbitration'],{afterSalesMode:P,acceptanceMode:Q,installmentMode:R,affiliateMode:S,crowdfundingMode:T,logisticsMode:U}=deriveCapabilityModes({'template':a,'inputs':h});g['push'](...emitRewardClaimEarly({'reviewMode':C,'guardSpecs':s,'resolvedGuards':t,'rewardMark':D})['steps']),g['push'](...emitExperiencePoolEarly({'experienceClaimKey':F,'guardSpecs':s,'resolvedGuards':t,'poolMark':d+'_experience_comp'})['steps']),g['push'](...emitPriceRebatePoolEarly({'priceRebateClaimKey':G,'guardSpecs':s,'resolvedGuards':t,'poolMark':d+'_price_rebate'})['steps']),f['push'](...checkDaysUnitSlots({'resolvedGuards':t})['blockers']),f['push'](...checkWindowTruncation({'resolvedGuards':t})['blockers']),f['push'](...checkWindowUnitNaming({'resolvedGuards':t})['blockers']);const V=rewriteQueryTotality({'resolvedGuards':t,'inputs':h});f['push'](...V['blockers']);const W=emitServiceDraft({'template':a,'base':d,'inputs':h});g['push'](...W['steps']),f['push'](...W['blockers']);const X=emitEvidenceRepository({'needsRepository':E,'base':d,'inputs':h,'guardSpecs':s,'resolvedGuards':t});g['push'](...X['steps']),f['push'](...X['blockers']);const Y=emitReviewRepositoryEarly({'reviewMode':C,'base':d,'inputs':h});g['push'](...Y['steps']);const Z=[...X['runtimeWrites'],...Y['runtimeWrites']];rewritePlanRefs({'base':d,'resolvedGuards':t}),f['push'](...dropEmptyVecGuards({'resolvedGuards':t,'guardSpecs':s,'steps':g})['blockers']),g['push'](...emitArbitrationHoist({'needsArbitration':O,'template':a,'base':d,'currency':W['currency']})['steps']),g['push'](...emitGuardWave({'resolvedGuards':t,'specByKey':y,'slot254Injected':z,'repoBoundPolicies':X['repoBoundPolicies'],'repoBoundStepIds':X['repoBoundStepIds'],'goalLatchArm':X['goalLatchArm']})['steps']);const a0=emitMachine({'template':a,'base':d,'shape':q,'resolvedGuards':t,'specByKey':y,'injectedOrderHolderKeys':A,'merchantIndex':e});g['push'](...a0['steps']),f['push'](...a0['blockers']),g['push'](...emitServiceConfigure({'guardSpecs':s,'needsRepository':E})['steps']);const a1=emitAllocators({'template':a,'base':d,'inputs':h,'rowsWithAttachments':n,'resolvedGuards':t,'specByKey':y}),{rows:a2,rowGroups:a3,allocatorRows:a4,externalMarks:a5}=a1;f['push'](...a1['blockers']);const a6=checkAllocatorRails({'rowGroups':a3,'resolvedGuards':t,'shape':q,'recoverTwinRails':w,'declares':x});f['push'](...a6['blockers']);if(a6['disclosures']['length']>0x0||I['disclosure']!==undefined||J['disclosure']!==undefined||K['disclosure']!==undefined||L['disclosure']!==undefined||M['disclosure']!==undefined||V['disclosure']!==undefined){const ai=g['find'](aj=>aj['id']==='machine');if(ai){const aj=[...a6['disclosures'],...I['disclosure']!==undefined?[I['disclosure']]:[],...J['disclosure']!==undefined?[J['disclosure']]:[],...K['disclosure']!==undefined?[K['disclosure']]:[],...L['disclosure']!==undefined?[L['disclosure']]:[],...M['disclosure']!==undefined?[M['disclosure']]:[],...V['disclosure']!==undefined?[V['disclosure']]:[]]['join']('\x20');ai['notes']=ai['notes']!==undefined?ai['notes']+'\x20'+aj:aj;}}g['push'](...emitServiceAllocators({'template':a,'inputs':h,'allocatorRows':a4})['steps']);const a7=emitSales({'template':a,'inputs':h});g['push'](...a7['steps']),f['push'](...a7['blockers']);const a8=emitModeGates({'afterSalesMode':P,'acceptanceMode':Q,'installmentMode':R,'affiliateMode':S,'crowdfundingMode':T,'logisticsMode':U},{'shape':q,'rows':a2,'guardSpecs':s,'buildNotes':a['build_notes']??[],'feeParams':a['fee_params'],'arbitrationMode':a['arbitration_mode'],'inputs':h,'buildTimeMs':c['buildTimeMs']});f['push'](...a8['blockers']);if(a8['disclosures']['length']>0x0){const ak=g['find'](al=>al['id']==='machine');if(ak){const al=a8['disclosures']['join']('\x20');ak['notes']=ak['notes']!==undefined?ak['notes']+'\x20'+al:al;}}const a9=emitReviewComponent({'template':a,'inputs':h,'reviewMode':C,'experienceClaimKey':F,'priceRebateClaimKey':G,'shape':q,'guardSpecs':s,'resolvedGuards':t,'specByKey':y});g['push'](...a9['steps']),f['push'](...a9['blockers']);const aa=emitArbitrationBindings({'template':a,'inputs':h,'needsArbitration':O,'shape':q,'guardSpecs':s,'specByKey':y});g['push'](...aa['steps']),f['push'](...aa['blockers']);if(aa['disclosures']['length']>0x0){const am=g['find'](an=>an['id']==='machine');if(am){const an=aa['disclosures']['join']('\x20');am['notes']=am['notes']!==undefined?am['notes']+'\x20'+an:an;}}g['push'](...emitServicePublish()['steps']),g['push'](...a9['fundingSteps'],...aa['fundingSteps']);const {allocatorBoundKeys:ab,moneyRailKeys:ac}=computeMoneyRailKeys({'rowsWithAttachments':n,'guardSpecs':s});f['push'](...checkForeignServicePins({'resolvedGuards':t,'edgeBoundKeys':B,'moneyRailKeys':ac})['blockers']),f['push'](...auditRepoIntegrityAndCallerLegs({'steps':g,'resolvedGuards':t,'moneyRailKeys':ac,'recoverTwinRails':w})['blockers']);const ad=emitSupplyChain({'supplyChain':c['supplyChain'],'steps':g,'derivedParams':i});f['push'](...ad['blockers']);const {supplyChainEmissions:ae,fulfillmentAxis:af}=ad;{const ao=new Map();g['forEach']((ar,as)=>{const at=compilePhaseRank(ar['id']);if(at>=0x0&&!ao['has'](at))ao['set'](at,as);});let ap=-0x1,aq='';for(let ar=0x0;ar<CANONICAL_COMPILE_ORDER['length'];ar++){const as=ao['get'](ar);if(as===undefined)continue;if(as<ap){f['push']({'code':'COMPILE_ORDER_DRIFT','detail':'Plan\x20emission\x20drifted\x20from\x20the\x20F-05\x20canonical\x20order\x20(object-dependency.ts\x20'+('CANONICAL_COMPILE_ORDER):\x20phase\x20\x27'+CANONICAL_COMPILE_ORDER[ar]['phase']+'\x27\x20first\x20appears\x20at\x20')+('position\x20'+(as+0x1)+',\x20but\x20phase\x20\x27'+aq+'\x27\x20already\x20appeared\x20at\x20position\x20'+(ap+0x1)+'.\x20')+'Restore\x20the\x20canonical\x20emission\x20order\x20in\x20the\x20kernel\x20—\x20the\x20plan\x20must\x20not\x20ship\x20reordered.'});break;}ap=as,aq=CANONICAL_COMPILE_ORDER[ar]['phase'];}}f['push'](...checkEmittedStepShapes({'steps':g})['blockers']),f['push'](...checkFundRailReachability({'steps':g,'resolvedGuards':t})['blockers']);{const at=checkWindowTopology({'template':a});if(at['warnings']['length']>0x0){const au=g['find'](av=>av['id']==='machine');if(au){const av=at['warnings']['join']('\x20');au['notes']=au['notes']!==undefined?au['notes']+'\x20'+av:av;}}}const ag=u['flatMap'](aw=>{const ax=ab['has'](aw['key'])?'allocator':B['has'](aw['key'])?'machine_edge':aw['host']==='service'&&aw['key']==='buy'?'service_buy':undefined;return ax?[{'key':aw['key'],'template_id':aw['template_id'],'host':aw['host'],'site':ax,'purpose':aw['purpose']}]:[];}),ah=(a['keeper_duty']??[])['filter'](aw=>aw['duty_kind']!==undefined&&aw['detector']!==undefined&&aw['anchor']!==undefined&&aw['window_param']!==undefined)['map'](aw=>({'duty_kind':aw['duty_kind'],'detector':aw['detector'],'anchor':aw['anchor'],'window_param':aw['window_param'],'when':aw['when'],'action':aw['action'],'miss_consequence':aw['miss_consequence']}));if(J['keeperDuty']!==undefined)ah['push'](J['keeperDuty']);return{'plan':{'version':0x1,'intent':c['intent']??'compile\x20'+a['id'],'templateId':a['id'],'inputs':af!==undefined?{...h,'fulfillment_axis':af}:h,'steps':g,...a5['size']>0x0?{'external_refs':[...a5]['sort']()}:{},...ag['length']>0x0?{'pending_guards':ag}:{},...i['length']>0x0?{'derived_params':i}:{},...Z['length']>0x0?{'runtime_writes':Z}:{},...ah['length']>0x0?{'keeper_duties':ah}:{},...p['length']>0x0?{'selection_report':p}:{}},'guardSpecs':s,'unresolved':u,'blockers':f,'omitted':[...v],...ae['length']>0x0?{'supplyChain':ae}:{}};}
|
|
1
|
+
import{CANONICAL_COMPILE_ORDER,compilePhaseRank}from'../knowledge/object-dependency.js';import{timeQuantityViolations}from'../knowledge/knob-docs.js';import{deriveCapabilityModes,emitModeGates}from'./mode-gates.js';import{normalizeCompileInputs,applyConditionalSelectors}from'./input-normalize.js';import{fillGuards}from'./guard-fill.js';import{expandShapeSegments}from'./shape-expand.js';import{auditRepoIntegrityAndCallerLegs,checkAllocatorRails,checkDaysUnitSlots,checkEmittedStepShapes,checkForeignServicePins,checkFundRailReachability,checkWindowTopology,checkWindowTruncation,checkWindowUnitNaming,computeMoneyRailKeys,dropEmptyVecGuards,emitAllocators,emitArbitrationBindings,emitArbitrationHoist,emitEvidenceRepository,emitGuardWave,emitIdentityPhase,emitLoyaltyGate,emitMachine,normalizeStaffAddresses,emitRewardClaimEarly,emitLateRemedyEdges,emitNegotiationRail,emitRefundConvergence,emitReviewAmendRail,emitSlaCompensation,rewriteQueryTotality,emitExperiencePoolEarly,emitPriceRebatePoolEarly,emitReviewComponent,emitReviewRepositoryEarly,emitSales,emitServiceAllocators,emitServiceConfigure,emitServiceDraft,emitServicePublish,emitSupplyChain,rewritePlanRefs}from'./emit-phases.js';export{normalizeInlineGuardTable}from'./guard-fill.js';export{normalizeCurrency}from'./emit-phases.js';export function compileTemplate(a,b,c={}){const d=(c['nameBase']??a['id'])['replace'](/\//g,'_'),e=c['merchantPermissionIndex']??0x3e8,f=[],g=[],{inputs:h,derivedParams:i,blockers:j}=normalizeCompileInputs(a,b,c['buildTimeMs'],c['windowProfile']);f['push'](...j);for(const an of timeQuantityViolations([a['fee_params'],h])){f['push']({'code':'TIME_QUANTITY_VIOLATION','detail':'time\x20knob\x20\x27'+an['key']+'\x27\x20answered\x20'+an['value']+'\x20but\x20its\x20quantity\x20is\x20'+an['quantity']['toUpperCase']()+'\x20—\x20'+(an['remedy']+'.\x20Quantity\x20truth:\x20the\x20knob-doc\x20line\x20for\x20this\x20key\x20(knob-docs\x20TIME_QUANTITY\x20authority\x20+\x20duration-stem\x20law);\x20')+'docs\x20and\x20this\x20gate\x20read\x20the\x20SAME\x20table,\x20so\x20they\x20cannot\x20diverge.'});}const {dropKeys:k,selectorDroppedKeys:l,shape:m,rows:n,blockers:o,selectionReport:p}=applyConditionalSelectors(a,h);f['push'](...o);let q=m;const r=expandShapeSegments({'template':a,'shape':q,'inputs':h,'windowProfile':c['windowProfile']});q=r['shape'],f['push'](...r['blockers']);const s=normalizeStaffAddresses(h['arb_panel']);s['invalid']['length']>0x0&&f['push']({'code':'STAFF_ADDRESS_INVALID','detail':'arb_panel\x20entries\x20'+s['invalid']['map'](ao=>'\x27'+ao+'\x27')['join'](',\x20')+'\x20are\x20not\x200x\x20addresses\x20'+'(expected\x200x\x20+\x2020..64\x20hex\x20chars).\x20The\x20arb\x20panel\x20is\x20the\x20venue\x27s\x20voting\x20roster\x20(permission\x20358\x20grant\x20+\x20'+'the\x20party-panel\x20voting\x20guard);\x20fix\x20or\x20drop\x20the\x20malformed\x20entries\x20—\x20they\x20are\x20never\x20silently\x20skipped.'});const {guardSpecs:t,resolvedGuards:u,unresolved:w,omitKeys:x,recoverTwinRails:y,declareReasons:z,specByKey:A,slot254Injected:B,injectedOrderHolderKeys:C,edgeBoundKeys:D,derived:{reviewMode:E,rewardMark:F,needsRepository:G,experienceClaimKey:H,priceRebateClaimKey:I},blockers:J}=fillGuards({'template':a,'base':d,'inputs':h,'arbPanel':s['addresses'],'guardResolutions':{...r['resolutions'],...c['guardResolutions']??{}},'windowProfile':c['windowProfile'],'selector':{'dropKeys':k,'selectorDroppedKeys':l,'shape':q,'rows':n,'selectionReport':p}});f['push'](...J);const K=emitLoyaltyGate({'template':a,'base':d,'guardSpecs':t,'resolvedGuards':u});f['push'](...K['blockers']);const L=emitSlaCompensation({'template':a,'base':d,'inputs':h,'shape':q,'guardSpecs':t,'resolvedGuards':u,'specByKey':A});f['push'](...L['blockers']),q=L['shape'];const M=emitNegotiationRail({'template':a,'base':d,'inputs':h,'shape':q,'guardSpecs':t,'resolvedGuards':u,'specByKey':A,'merchantIndex':e});f['push'](...M['blockers']),q=M['shape'];const N=emitRefundConvergence({'template':a,'base':d,'shape':q,'guardSpecs':t,'resolvedGuards':u,'specByKey':A,'merchantIndex':e});f['push'](...N['blockers']),q=N['shape'];const O=emitLateRemedyEdges({'template':a,'base':d,'inputs':h,'shape':q,'guardSpecs':t,'resolvedGuards':u,'specByKey':A});f['push'](...O['blockers']),q=O['shape'];const P=emitReviewAmendRail({'template':a,'base':d,'inputs':h,'reviewMode':E,'shape':q,'guardSpecs':t,'resolvedGuards':u,'specByKey':A});f['push'](...P['blockers']),q=P['shape'];const Q=emitIdentityPhase({'template':a,'base':d});g['push'](...Q['steps']);const R=Q['needsArbitration'],{afterSalesMode:S,acceptanceMode:T,installmentMode:U,affiliateMode:V,crowdfundingMode:W,logisticsMode:X}=deriveCapabilityModes({'template':a,'inputs':h});g['push'](...emitRewardClaimEarly({'reviewMode':E,'guardSpecs':t,'resolvedGuards':u,'rewardMark':F})['steps']),g['push'](...emitExperiencePoolEarly({'experienceClaimKey':H,'guardSpecs':t,'resolvedGuards':u,'poolMark':d+'_experience_comp'})['steps']),g['push'](...emitPriceRebatePoolEarly({'priceRebateClaimKey':I,'guardSpecs':t,'resolvedGuards':u,'poolMark':d+'_price_rebate'})['steps']),f['push'](...checkDaysUnitSlots({'resolvedGuards':u})['blockers']),f['push'](...checkWindowTruncation({'resolvedGuards':u})['blockers']),f['push'](...checkWindowUnitNaming({'resolvedGuards':u})['blockers']);const Y=rewriteQueryTotality({'resolvedGuards':u,'inputs':h});f['push'](...Y['blockers']);const Z=emitServiceDraft({'template':a,'base':d,'inputs':h});g['push'](...Z['steps']),f['push'](...Z['blockers']);const a0=emitEvidenceRepository({'needsRepository':G,'base':d,'inputs':h,'guardSpecs':t,'resolvedGuards':u,'shape':q});g['push'](...a0['steps']),f['push'](...a0['blockers']);const a1=emitReviewRepositoryEarly({'reviewMode':E,'base':d,'inputs':h});g['push'](...a1['steps']);const a2=[...a0['runtimeWrites'],...a1['runtimeWrites']];rewritePlanRefs({'base':d,'resolvedGuards':u}),f['push'](...dropEmptyVecGuards({'resolvedGuards':u,'guardSpecs':t,'steps':g})['blockers']),g['push'](...emitArbitrationHoist({'needsArbitration':R,'template':a,'base':d,'currency':Z['currency']})['steps']),g['push'](...emitGuardWave({'resolvedGuards':u,'specByKey':A,'slot254Injected':B,'repoBoundPolicies':a0['repoBoundPolicies'],'repoBoundStepIds':a0['repoBoundStepIds'],'goalLatchArm':a0['goalLatchArm']})['steps']);const a3=normalizeStaffAddresses(h['staff_addresses']);a3['invalid']['length']>0x0&&f['push']({'code':'STAFF_ADDRESS_INVALID','detail':'staff_addresses\x20entries\x20'+a3['invalid']['map'](ao=>'\x27'+ao+'\x27')['join'](',\x20')+'\x20are\x20not\x200x\x20addresses\x20'+'(expected\x200x\x20+\x2020..64\x20hex\x20chars).\x20Staff\x20addresses\x20arm\x20the\x20F-19\x20permission\x20grants\x20(the\x20store\x27s\x20'+'keeper/operator\x20roster\x20at\x20deploy);\x20fix\x20or\x20drop\x20the\x20malformed\x20entries\x20—\x20they\x20are\x20never\x20silently\x20skipped.'});const a4=normalizeStaffAddresses(h['arb_executors']);a4['invalid']['length']>0x0&&f['push']({'code':'STAFF_ADDRESS_INVALID','detail':'arb_executors\x20entries\x20'+a4['invalid']['map'](ao=>'\x27'+ao+'\x27')['join'](',\x20')+'\x20are\x20not\x200x\x20addresses\x20'+'(expected\x200x\x20+\x2020..64\x20hex\x20chars).\x20Arb\x20executors\x20are\x20the\x20independent\x20ruling-execution\x20roster\x20granted\x20on\x20'+'the\x20tpl_forward_arb_*\x20rails\x20at\x20deploy\x20(P0-3);\x20fix\x20or\x20drop\x20the\x20malformed\x20entries\x20—\x20they\x20are\x20never\x20'+'silently\x20skipped.'});const a5=emitMachine({'template':a,'base':d,'shape':q,'resolvedGuards':u,'specByKey':A,'injectedOrderHolderKeys':C,'merchantIndex':e,'staffAddresses':a3['addresses'],'arbExecutors':a4['addresses']});g['push'](...a5['steps']),f['push'](...a5['blockers']),g['push'](...emitServiceConfigure({'guardSpecs':t,'needsRepository':G})['steps']);const a6=emitAllocators({'template':a,'base':d,'inputs':h,'currency':Z['currency'],'rowsWithAttachments':n,'resolvedGuards':u,'specByKey':A}),{rows:a7,rowGroups:a8,allocatorRows:a9,externalMarks:aa}=a6;f['push'](...a6['blockers']);const ab=checkAllocatorRails({'rowGroups':a8,'resolvedGuards':u,'shape':q,'recoverTwinRails':y,'declares':z});f['push'](...ab['blockers']);if(ab['disclosures']['length']>0x0||a6['disclosures']['length']>0x0||K['disclosure']!==undefined||L['disclosure']!==undefined||M['disclosure']!==undefined||N['disclosure']!==undefined||O['disclosure']!==undefined||P['disclosure']!==undefined||Y['disclosure']!==undefined){const ao=g['find'](ap=>ap['id']==='machine');if(ao){const ap=[...ab['disclosures'],...a6['disclosures'],...K['disclosure']!==undefined?[K['disclosure']]:[],...L['disclosure']!==undefined?[L['disclosure']]:[],...M['disclosure']!==undefined?[M['disclosure']]:[],...N['disclosure']!==undefined?[N['disclosure']]:[],...O['disclosure']!==undefined?[O['disclosure']]:[],...P['disclosure']!==undefined?[P['disclosure']]:[],...Y['disclosure']!==undefined?[Y['disclosure']]:[]]['join']('\x20');ao['notes']=ao['notes']!==undefined?ao['notes']+'\x20'+ap:ap;}}g['push'](...emitServiceAllocators({'template':a,'inputs':h,'allocatorRows':a9})['steps']);const ac=emitSales({'template':a,'inputs':h,'rewardTrackPresent':E==='review_reward'||t['some'](aq=>aq['host']==='reward')});g['push'](...ac['steps']),f['push'](...ac['blockers']);const ad=emitModeGates({'afterSalesMode':S,'acceptanceMode':T,'installmentMode':U,'affiliateMode':V,'crowdfundingMode':W,'logisticsMode':X},{'shape':q,'rows':a7,'guardSpecs':t,'buildNotes':a['build_notes']??[],'feeParams':a['fee_params'],'arbitrationMode':a['arbitration_mode'],'inputs':h,'buildTimeMs':c['buildTimeMs']});f['push'](...ad['blockers']);if(ad['disclosures']['length']>0x0){const aq=g['find'](ar=>ar['id']==='machine');if(aq){const ar=ad['disclosures']['join']('\x20');aq['notes']=aq['notes']!==undefined?aq['notes']+'\x20'+ar:ar;}}const ae=emitReviewComponent({'template':a,'inputs':h,'reviewMode':E,'experienceClaimKey':H,'priceRebateClaimKey':I,'shape':q,'guardSpecs':t,'resolvedGuards':u,'specByKey':A});g['push'](...ae['steps']),f['push'](...ae['blockers']);const af=emitArbitrationBindings({'template':a,'inputs':h,'needsArbitration':R,'shape':q,'guardSpecs':t,'specByKey':A,'arbPanel':s['addresses']});g['push'](...af['steps']),f['push'](...af['blockers']);if(af['disclosures']['length']>0x0){const as=g['find'](at=>at['id']==='machine');if(as){const at=af['disclosures']['join']('\x20');as['notes']=as['notes']!==undefined?as['notes']+'\x20'+at:at;}}g['push'](...emitServicePublish()['steps']),g['push'](...ae['fundingSteps'],...af['fundingSteps']);const {allocatorBoundKeys:ag,moneyRailKeys:ah}=computeMoneyRailKeys({'rowsWithAttachments':n,'guardSpecs':t});f['push'](...checkForeignServicePins({'resolvedGuards':u,'edgeBoundKeys':D,'moneyRailKeys':ah})['blockers']),f['push'](...auditRepoIntegrityAndCallerLegs({'steps':g,'resolvedGuards':u,'moneyRailKeys':ah,'recoverTwinRails':y})['blockers']);const ai=emitSupplyChain({'supplyChain':c['supplyChain'],'steps':g,'derivedParams':i,'windowProfile':c['windowProfile']});f['push'](...ai['blockers']);const {supplyChainEmissions:aj,fulfillmentAxis:ak}=ai;{const au=new Map();g['forEach']((ax,ay)=>{const az=compilePhaseRank(ax['id']);if(az>=0x0&&!au['has'](az))au['set'](az,ay);});let av=-0x1,aw='';for(let ax=0x0;ax<CANONICAL_COMPILE_ORDER['length'];ax++){const ay=au['get'](ax);if(ay===undefined)continue;if(ay<av){f['push']({'code':'COMPILE_ORDER_DRIFT','detail':'Plan\x20emission\x20drifted\x20from\x20the\x20F-05\x20canonical\x20order\x20(object-dependency.ts\x20'+('CANONICAL_COMPILE_ORDER):\x20phase\x20\x27'+CANONICAL_COMPILE_ORDER[ax]['phase']+'\x27\x20first\x20appears\x20at\x20')+('position\x20'+(ay+0x1)+',\x20but\x20phase\x20\x27'+aw+'\x27\x20already\x20appeared\x20at\x20position\x20'+(av+0x1)+'.\x20')+'Restore\x20the\x20canonical\x20emission\x20order\x20in\x20the\x20kernel\x20—\x20the\x20plan\x20must\x20not\x20ship\x20reordered.'});break;}av=ay,aw=CANONICAL_COMPILE_ORDER[ax]['phase'];}}f['push'](...checkEmittedStepShapes({'steps':g})['blockers']),f['push'](...checkFundRailReachability({'steps':g,'resolvedGuards':u})['blockers']);{const az=checkWindowTopology({'template':a});if(az['warnings']['length']>0x0){const aA=g['find'](aB=>aB['id']==='machine');if(aA){const aB=az['warnings']['join']('\x20');aA['notes']=aA['notes']!==undefined?aA['notes']+'\x20'+aB:aB;}}}const al=w['flatMap'](aC=>{const aD=ag['has'](aC['key'])?'allocator':D['has'](aC['key'])?'machine_edge':aC['host']==='service'&&aC['key']==='buy'?'service_buy':undefined;return aD?[{'key':aC['key'],'template_id':aC['template_id'],'host':aC['host'],'site':aD,'purpose':aC['purpose']}]:[];}),am=(a['keeper_duty']??[])['filter'](aC=>aC['duty_kind']!==undefined&&aC['detector']!==undefined&&aC['anchor']!==undefined&&aC['window_param']!==undefined)['map'](aC=>({'duty_kind':aC['duty_kind'],'detector':aC['detector'],'anchor':aC['anchor'],'window_param':aC['window_param'],'when':aC['when'],'action':aC['action'],'miss_consequence':aC['miss_consequence']}));if(L['keeperDuty']!==undefined)am['push'](L['keeperDuty']);return{'plan':{'version':0x1,'intent':c['intent']??'compile\x20'+a['id'],'templateId':a['id'],'inputs':ak!==undefined?{...h,'fulfillment_axis':ak}:h,'steps':g,...aa['size']>0x0?{'external_refs':[...aa]['sort']()}:{},...al['length']>0x0?{'pending_guards':al}:{},...i['length']>0x0?{'derived_params':i}:{},...a2['length']>0x0?{'runtime_writes':a2}:{},...am['length']>0x0?{'keeper_duties':am}:{},...p['length']>0x0?{'selection_report':p}:{}},'guardSpecs':t,'unresolved':w,'blockers':f,'omitted':[...x],...aj['length']>0x0?{'supplyChain':aj}:{}};}
|