@wowok/agent-mcp 3.4.0 → 3.4.1
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/README.md +8 -0
- package/dist/chain-semantics/composition-truth.d.ts +102 -0
- package/dist/chain-semantics/composition-truth.js +1 -0
- package/dist/chain-semantics/eval-order.js +1 -1
- package/dist/chain-semantics/fund-flow.js +1 -1
- package/dist/chain-semantics/index.d.ts +1 -0
- package/dist/chain-semantics/index.js +1 -1
- package/dist/composition/audit.js +1 -1
- package/dist/composition/blueprint-view.d.ts +3 -3
- package/dist/composition/blueprint-view.js +1 -1
- package/dist/composition/compile.d.ts +24 -3
- package/dist/composition/compile.js +1 -1
- package/dist/composition/emit-phases.d.ts +206 -0
- package/dist/composition/emit-phases.js +1 -0
- package/dist/composition/generate.d.ts +40 -0
- package/dist/composition/generate.js +1 -0
- package/dist/composition/guard-fill.d.ts +44 -0
- package/dist/composition/guard-fill.js +1 -0
- package/dist/composition/inflight.d.ts +20 -2
- package/dist/composition/inflight.js +1 -1
- package/dist/composition/input-normalize.d.ts +15 -0
- package/dist/composition/input-normalize.js +1 -0
- package/dist/composition/materialize.d.ts +18 -13
- package/dist/composition/materialize.js +1 -1
- package/dist/composition/mode-gates.d.ts +35 -0
- package/dist/composition/mode-gates.js +1 -0
- package/dist/composition/param-disclosure.js +1 -1
- package/dist/composition/plan-retry-ledger.d.ts +21 -0
- package/dist/composition/plan-retry-ledger.js +1 -0
- package/dist/composition/plan.d.ts +7 -2
- package/dist/composition/plan.js +1 -1
- package/dist/composition/product-card.d.ts +94 -0
- package/dist/composition/product-card.js +1 -0
- package/dist/composition/supply-chain-emit.d.ts +46 -0
- package/dist/composition/supply-chain-emit.js +1 -0
- package/dist/config/config-audit.spec.js +1 -1
- package/dist/config/config-warnings.d.ts +2 -0
- package/dist/config/config-warnings.js +1 -0
- package/dist/config/exposure.d.ts +2 -2
- package/dist/config/judgment.d.ts +31 -5
- package/dist/config/judgment.js +1 -1
- package/dist/config/judgment.spec.js +1 -1
- package/dist/config/match-policy-file.d.ts +34 -0
- package/dist/config/match-policy-file.js +1 -0
- package/dist/config/match-policy-file.spec.d.ts +1 -0
- package/dist/config/match-policy-file.spec.js +1 -0
- package/dist/config/rule-engine.d.ts +5 -5
- package/dist/config/rule-engine.js +1 -1
- package/dist/config/runtime.d.ts +0 -1
- package/dist/config/runtime.js +1 -1
- package/dist/config/severity.d.ts +0 -2
- package/dist/config/severity.js +1 -1
- package/dist/config/store-policy.spec.js +1 -1
- package/dist/config/template-params.d.ts +42 -0
- package/dist/config/template-params.js +1 -0
- package/dist/config/template-params.spec.d.ts +1 -0
- package/dist/config/template-params.spec.js +1 -0
- package/dist/data/api/api.spec.js +1 -1
- package/dist/data/api/server.js +1 -1
- package/dist/data/projection/store.d.ts +2 -1
- package/dist/data/projection/store.js +1 -1
- package/dist/data/projection/types.d.ts +22 -0
- package/dist/data/sync/cdc.d.ts +1 -2
- package/dist/data/sync/cdc.js +1 -1
- package/dist/evaluation/acceptance.d.ts +8 -0
- package/dist/evaluation/acceptance.js +1 -1
- package/dist/evaluation/builtins/demand-match.js +1 -1
- package/dist/evaluation/builtins/graph-service.spec.js +1 -1
- package/dist/evaluation/capability.d.ts +2 -0
- package/dist/evaluation/category-match-rules.d.ts +0 -1
- package/dist/evaluation/category-match-rules.js +1 -1
- package/dist/evaluation/composer.d.ts +25 -0
- package/dist/evaluation/composer.js +1 -1
- package/dist/evaluation/engine.js +1 -1
- package/dist/evaluation/extract.d.ts +7 -0
- package/dist/evaluation/extract.js +1 -1
- package/dist/evaluation/game-strategy.d.ts +0 -3
- package/dist/evaluation/game-strategy.js +1 -1
- package/dist/evaluation/match-operation.d.ts +9 -0
- package/dist/evaluation/match-operation.js +1 -1
- package/dist/evaluation/match-policy-resolver.d.ts +9 -0
- package/dist/evaluation/match-policy-resolver.js +1 -0
- package/dist/evaluation/match-policy.d.ts +3 -1
- package/dist/evaluation/match-policy.js +1 -1
- package/dist/evaluation/region.d.ts +0 -6
- package/dist/evaluation/region.js +1 -1
- package/dist/evaluation/standards.d.ts +2 -1
- package/dist/evaluation/standards.js +1 -1
- package/dist/evaluation/structured-lines.d.ts +8 -0
- package/dist/evaluation/structured-lines.js +1 -0
- package/dist/evaluation/types.d.ts +6 -0
- package/dist/experience/realtime-feedback.js +1 -1
- package/dist/extensions/capability-manifest.d.ts +1 -0
- package/dist/extensions/capability-manifest.js +1 -1
- package/dist/extensions/capability.d.ts +91 -0
- package/dist/extensions/capability.js +1 -0
- package/dist/extensions/industry-audit.spec.js +1 -1
- package/dist/extensions/industry-pack.d.ts +13 -0
- package/dist/extensions/industry-pack.js +1 -1
- package/dist/extensions/modes.js +1 -1
- package/dist/extensions/registry.d.ts +0 -2
- package/dist/extensions/registry.js +1 -1
- package/dist/goal/GoalEngine.js +1 -1
- package/dist/graph/onchain/analyze.js +1 -1
- package/dist/graph/onchain/expand.js +1 -1
- package/dist/graph/onchain/exposure.js +1 -1
- package/dist/graph/onchain/facts.js +1 -1
- package/dist/graph/onchain/order-status.d.ts +0 -1
- package/dist/graph/onchain/order-status.js +1 -1
- package/dist/harness/recover.js +1 -1
- package/dist/harness/verify.d.ts +0 -3
- package/dist/harness/verify.js +1 -1
- package/dist/intent/types.d.ts +0 -1
- package/dist/intent/types.js +1 -1
- package/dist/keeper/detectors.js +1 -1
- package/dist/keeper/types.d.ts +0 -1
- package/dist/keeper/types.js +1 -1
- package/dist/knowledge/allocation-risk.d.ts +1 -0
- package/dist/knowledge/allocation-risk.js +1 -1
- package/dist/knowledge/allocator-rail-verifier.d.ts +6 -1
- package/dist/knowledge/allocator-rail-verifier.js +1 -1
- package/dist/knowledge/arbitration-ledger.js +1 -1
- package/dist/knowledge/arbitration-puzzle.js +1 -1
- package/dist/knowledge/audit-rules.d.ts +2 -2
- package/dist/knowledge/audit-rules.js +1 -1
- package/dist/knowledge/baselines/judgment-baselines.json +21 -2
- package/dist/knowledge/baselines/rules/oracle.json +120 -0
- package/dist/knowledge/baselines/rules/plan.json +384 -17
- package/dist/knowledge/baselines/rules/progress.json +20 -2
- package/dist/knowledge/builtin-templates.d.ts +12 -1
- package/dist/knowledge/builtin-templates.js +1 -1
- package/dist/knowledge/component-schema.js +1 -1
- package/dist/knowledge/contact-templates.d.ts +0 -1
- package/dist/knowledge/contact-templates.js +1 -1
- package/dist/knowledge/dynamic-pricing.js +1 -1
- package/dist/knowledge/fee-param-bindings.js +1 -1
- package/dist/knowledge/fund-layer.d.ts +1 -0
- package/dist/knowledge/fund-layer.js +1 -1
- package/dist/knowledge/game-scenarios.js +1 -1
- package/dist/knowledge/getting-started.js +1 -1
- package/dist/knowledge/guard-binding-table.d.ts +52 -0
- package/dist/knowledge/guard-binding-table.js +1 -0
- package/dist/knowledge/guard-binding-verifier.d.ts +30 -0
- package/dist/knowledge/guard-binding-verifier.js +1 -0
- package/dist/knowledge/guard-bindings.js +1 -1
- package/dist/knowledge/guard-blueprint.d.ts +68 -0
- package/dist/knowledge/guard-blueprint.js +1 -0
- package/dist/knowledge/guard-design-patterns.d.ts +1 -1
- package/dist/knowledge/guard-design-patterns.js +1 -1
- package/dist/knowledge/guard-field-cognition.js +1 -1
- package/dist/knowledge/guard-host-context.d.ts +24 -0
- package/dist/knowledge/guard-host-context.js +1 -0
- package/dist/knowledge/guard-lint.js +1 -1
- package/dist/knowledge/guard-node-gates.d.ts +3 -0
- package/dist/knowledge/guard-node-gates.js +1 -1
- package/dist/knowledge/guard-puzzle.js +1 -1
- package/dist/knowledge/guard-render.js +1 -1
- package/dist/knowledge/guard-risk.js +1 -1
- package/dist/knowledge/guard-submission-prompt.d.ts +11 -0
- package/dist/knowledge/guard-submission-prompt.js +1 -1
- package/dist/knowledge/guard-templates.d.ts +1 -1
- package/dist/knowledge/guard-templates.js +1 -1
- package/dist/knowledge/guard-translation.js +1 -1
- package/dist/knowledge/index.d.ts +1 -1
- package/dist/knowledge/index.js +1 -1
- package/dist/knowledge/industry-generalizer.d.ts +6 -1
- package/dist/knowledge/industry-generalizer.js +1 -1
- package/dist/knowledge/industry-registry.js +1 -1
- package/dist/knowledge/jsonrpc-enum.d.ts +38 -0
- package/dist/knowledge/jsonrpc-enum.js +1 -1
- package/dist/knowledge/machine-topology.js +1 -1
- package/dist/knowledge/machine-translation.js +1 -1
- package/dist/knowledge/object-dependency.d.ts +31 -0
- package/dist/knowledge/object-dependency.js +1 -0
- package/dist/knowledge/onchain-constants.d.ts +2 -0
- package/dist/knowledge/onchain-constants.js +1 -1
- package/dist/knowledge/param-schema.d.ts +23 -0
- package/dist/knowledge/param-schema.js +1 -1
- package/dist/knowledge/param-tiers.js +1 -1
- package/dist/knowledge/passport-ledger.js +1 -1
- package/dist/knowledge/path-oracle/coverage.d.ts +16 -0
- package/dist/knowledge/path-oracle/coverage.js +1 -0
- package/dist/knowledge/path-oracle/index.d.ts +5 -0
- package/dist/knowledge/path-oracle/index.js +1 -0
- package/dist/knowledge/path-oracle/products/food-delivery.d.ts +2 -0
- package/dist/knowledge/path-oracle/products/food-delivery.js +1 -0
- package/dist/knowledge/path-oracle/schema.d.ts +188 -0
- package/dist/knowledge/path-oracle/schema.js +1 -0
- package/dist/knowledge/pattern-resolutions.d.ts +2 -0
- package/dist/knowledge/pattern-resolutions.js +1 -1
- package/dist/knowledge/progress-ledger.js +1 -1
- package/dist/knowledge/progress-risk.js +1 -1
- package/dist/knowledge/projection.spec.js +1 -1
- package/dist/knowledge/protocol-facts.js +1 -1
- package/dist/knowledge/requirement-families.d.ts +13 -0
- package/dist/knowledge/requirement-families.js +1 -0
- package/dist/knowledge/reward-ledger.js +1 -1
- package/dist/knowledge/scenario-modes.d.ts +1 -0
- package/dist/knowledge/scenario-modes.js +1 -1
- package/dist/knowledge/semantic-ir.d.ts +4 -0
- package/dist/knowledge/semantic-ir.js +1 -1
- package/dist/knowledge/service-ledger.d.ts +1 -1
- package/dist/knowledge/service-ledger.js +1 -1
- package/dist/knowledge/sku-name-gate.d.ts +17 -0
- package/dist/knowledge/sku-name-gate.js +1 -0
- package/dist/knowledge/supply-chain.d.ts +9 -0
- package/dist/knowledge/supply-chain.js +1 -1
- package/dist/knowledge/template-loader.d.ts +14 -6
- package/dist/knowledge/template-loader.js +1 -1
- package/dist/knowledge/template-nav.d.ts +3 -1
- package/dist/knowledge/template-nav.js +1 -1
- package/dist/knowledge/template-prose.d.ts +1 -1
- package/dist/knowledge/template-registry.js +1 -1
- package/dist/knowledge/template-scanner.d.ts +62 -0
- package/dist/knowledge/template-scanner.js +1 -1
- package/dist/knowledge/template-test-profiles.js +1 -1
- package/dist/knowledge/tools-reference.js +1 -1
- package/dist/knowledge/workflow-guidance.d.ts +5 -0
- 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/participation/time-window.js +1 -1
- package/dist/persona/address-format.d.ts +0 -1
- package/dist/persona/address-format.js +1 -1
- package/dist/persona/bridge.js +1 -1
- package/dist/persona/index.d.ts +0 -2
- package/dist/persona/index.js +1 -1
- package/dist/persona/model.js +1 -1
- package/dist/persona/persona-audit.spec.js +1 -1
- package/dist/persona/types.d.ts +6 -0
- package/dist/playbooks/service-build/business-puzzle.js +1 -1
- package/dist/playbooks/service-build/game-theory.d.ts +2 -2
- package/dist/playbooks/service-build/intent-analyzer.js +1 -1
- package/dist/playbooks/service-build/machine-panorama.js +1 -1
- package/dist/playbooks/service-build/merchant-guide.d.ts +50 -23
- package/dist/playbooks/service-build/merchant-guide.js +1 -1
- package/dist/playbooks/service-build/migration-planner.d.ts +2 -0
- package/dist/playbooks/service-build/migration-planner.js +1 -1
- package/dist/playbooks/service-build/mode-actions.js +1 -1
- package/dist/playbooks/service-build/object-panorama.d.ts +8 -0
- 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/reverse-mapping.d.ts +6 -0
- package/dist/playbooks/service-build/reverse-mapping.js +1 -1
- package/dist/playbooks/service-build/service-panorama.d.ts +1 -0
- package/dist/playbooks/service-build/service-panorama.js +1 -1
- package/dist/playbooks/service-build/service-quote.js +1 -1
- package/dist/playbooks/service-build/service-quote.spec.js +1 -1
- package/dist/playbooks/service-build/workflow-design-assessment.d.ts +10 -1
- package/dist/playbooks/service-build/workflow-design-assessment.js +1 -1
- package/dist/review/index.js +1 -1
- package/dist/review/repository.js +1 -1
- package/dist/safety/confirm-gate.js +1 -1
- package/dist/schema/benchmark-migration/index.d.ts +104 -0
- package/dist/schema/benchmark-migration/index.js +1 -1
- package/dist/schema/call/allocation.d.ts +15 -6
- package/dist/schema/call/allocation.js +1 -1
- package/dist/schema/call/base.d.ts +256 -0
- package/dist/schema/call/base.js +1 -1
- package/dist/schema/call/bridge.d.ts +32 -6
- package/dist/schema/call/demand.d.ts +15 -6
- package/dist/schema/call/demand.js +1 -1
- package/dist/schema/call/guard.d.ts +8 -8
- package/dist/schema/call/guard.js +1 -1
- package/dist/schema/call/handler.d.ts +3 -0
- package/dist/schema/call/handler.js +1 -1
- package/dist/schema/call/machine.d.ts +32 -8
- package/dist/schema/call/machine.js +1 -1
- package/dist/schema/call/order.d.ts +26 -8
- package/dist/schema/call/order.js +1 -1
- package/dist/schema/call/payment.d.ts +20 -8
- package/dist/schema/call/payment.js +1 -1
- package/dist/schema/call/permission-handler.js +1 -1
- package/dist/schema/call/permission.d.ts +330 -114
- package/dist/schema/call/permission.js +1 -1
- package/dist/schema/call/personal.d.ts +10 -4
- package/dist/schema/call/personal.js +1 -1
- package/dist/schema/call/progress.d.ts +16 -4
- package/dist/schema/call/reward.d.ts +10 -4
- package/dist/schema/call/reward.js +1 -1
- package/dist/schema/call/semantic.d.ts +1 -0
- package/dist/schema/call/semantic.js +1 -1
- package/dist/schema/call/service.d.ts +128 -40
- package/dist/schema/call/service.js +1 -1
- package/dist/schema/call/treasury.d.ts +15 -6
- package/dist/schema/call/treasury.js +1 -1
- package/dist/schema/common/index.js +1 -1
- package/dist/schema/config/index.d.ts +61 -0
- package/dist/schema/config/index.js +1 -1
- package/dist/schema/envelope-unify.d.ts +4 -0
- package/dist/schema/envelope-unify.js +1 -0
- package/dist/schema/evaluation/index.d.ts +216 -19
- package/dist/schema/evaluation/index.js +1 -1
- package/dist/schema/goal/index.d.ts +47 -0
- package/dist/schema/goal/planning.d.ts +115 -1
- package/dist/schema/goal/planning.js +1 -1
- package/dist/schema/industry-pack/index.d.ts +137 -6
- package/dist/schema/industry-pack/index.js +1 -1
- package/dist/schema/industry-pack/modes.d.ts +6 -6
- package/dist/schema/keeper/index.d.ts +26 -0
- package/dist/schema/local/index.d.ts +137 -0
- package/dist/schema/local/index.js +1 -1
- package/dist/schema/local/wip.d.ts +6 -0
- package/dist/schema/local/wip.js +1 -1
- package/dist/schema/messenger/index.d.ts +26 -0
- package/dist/schema/operations.d.ts +342 -83
- package/dist/schema/operations.js +1 -1
- package/dist/schema/persona/index.d.ts +2907 -640
- package/dist/schema/persona/index.js +1 -1
- package/dist/schema/query/bi.d.ts +145 -4
- package/dist/schema/query/bi.js +1 -1
- package/dist/schema/query/index.d.ts +266 -73
- package/dist/schema/query/index.js +1 -1
- package/dist/schema/schema-query/index.d.ts +1 -1
- package/dist/schema/schema-query/index.js +1 -1
- package/dist/schema/schema-version.js +1 -1
- package/dist/schema/utils/permission-machine-check.d.ts +2 -0
- package/dist/schema/utils/permission-machine-check.js +1 -1
- package/dist/schema/watch/index.d.ts +16 -0
- package/dist/schema/watch/index.js +1 -1
- package/dist/schema/workflow/index.d.ts +2 -2
- package/dist/schema/workflow/index.js +1 -1
- package/dist/schema-query-impl/index.d.ts +1 -1
- package/dist/schema-query-impl/index.js +1 -1
- package/dist/schemas/account_operation.output.json +94 -0
- package/dist/schemas/benchmark_migration_operation.output.json +338 -9
- package/dist/schemas/benchmark_migration_operation.schema.json +26 -1
- package/dist/schemas/bridge_operation.output.json +94 -0
- package/dist/schemas/config_operation.output.json +352 -0
- package/dist/schemas/config_operation.schema.json +20 -2
- package/dist/schemas/evaluation_operation.output.json +570 -4
- package/dist/schemas/evaluation_operation.schema.json +194 -3
- package/dist/schemas/goal_operation.schema.json +183 -0
- package/dist/schemas/index.json +1 -1
- package/dist/schemas/industry_pack_operation.output.json +621 -0
- package/dist/schemas/industry_pack_operation.schema.json +20 -2
- package/dist/schemas/keeper_operation.output.json +94 -0
- package/dist/schemas/local_cache_operation.output.json +94 -0
- package/dist/schemas/local_history_operation.output.json +94 -0
- package/dist/schemas/local_info_operation.output.json +94 -0
- package/dist/schemas/local_mark_operation.output.json +94 -0
- package/dist/schemas/messenger_operation.output.json +94 -0
- package/dist/schemas/monitor_events.output.json +94 -0
- package/dist/schemas/monitor_subscription.output.json +94 -0
- package/dist/schemas/onchain_events.output.json +94 -0
- package/dist/schemas/onchain_operations.output.json +313 -1
- package/dist/schemas/onchain_operations.schema.json +1248 -664
- package/dist/schemas/onchain_operations_allocation.schema.json +30 -15
- package/dist/schemas/onchain_operations_arbitration.schema.json +9 -2
- package/dist/schemas/onchain_operations_contact.schema.json +8 -1
- package/dist/schemas/onchain_operations_demand.schema.json +29 -14
- package/dist/schemas/onchain_operations_gen_passport.schema.json +8 -1
- package/dist/schemas/onchain_operations_guard.schema.json +290 -105
- package/dist/schemas/onchain_operations_machine.schema.json +49 -34
- package/dist/schemas/onchain_operations_order.schema.json +63 -40
- package/dist/schemas/onchain_operations_payment.schema.json +26 -11
- package/dist/schemas/onchain_operations_permission.schema.json +362 -235
- package/dist/schemas/onchain_operations_personal.schema.json +27 -15
- package/dist/schemas/onchain_operations_progress.schema.json +45 -30
- package/dist/schemas/onchain_operations_proof.schema.json +8 -1
- package/dist/schemas/onchain_operations_repository.schema.json +8 -1
- package/dist/schemas/onchain_operations_reward.schema.json +32 -17
- package/dist/schemas/onchain_operations_service.schema.json +221 -124
- package/dist/schemas/onchain_operations_treasury.schema.json +32 -17
- package/dist/schemas/onchain_table_data.output.json +258 -6
- package/dist/schemas/onchain_table_data.schema.json +92 -52
- package/dist/schemas/persona_operation.output.json +7752 -0
- package/dist/schemas/persona_operation.schema.json +1232 -4
- package/dist/schemas/query_toolkit.output.json +756 -116
- package/dist/schemas/query_toolkit.schema.json +138 -7
- package/dist/schemas/schema_query.schema.json +1 -1
- package/dist/schemas/watch_operation.output.json +83 -0
- package/dist/schemas/wip_file.output.json +8 -0
- package/dist/schemas/workflow_operation.schema.json +2 -2
- package/dist/tools/handlers/benchmark-migration.d.ts +11 -3
- package/dist/tools/handlers/benchmark-migration.js +1 -1
- package/dist/tools/handlers/config.js +1 -1
- package/dist/tools/handlers/evaluation.js +1 -1
- package/dist/tools/handlers/evaluation.spec.js +1 -1
- package/dist/tools/handlers/industry-pack.js +1 -1
- package/dist/tools/handlers/onchain.d.ts +20 -0
- package/dist/tools/handlers/onchain.js +1 -1
- package/dist/tools/handlers/persona.js +1 -1
- package/dist/tools/handlers/query.d.ts +8 -0
- package/dist/tools/handlers/query.js +1 -1
- package/dist/tools/handlers/winner-derivation.d.ts +20 -0
- package/dist/tools/handlers/winner-derivation.js +1 -0
- package/dist/tools/handlers/wip-upload.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/config.js +1 -1
- package/dist/tools/registry/evaluation.js +1 -1
- package/dist/tools/registry/identity.js +1 -1
- package/dist/tools/registry/query.js +1 -1
- package/dist/tools/transport-integrity.d.ts +7 -0
- package/dist/tools/transport-integrity.js +1 -0
- package/dist/tools/upgrade-check.js +1 -1
- package/dist/tools/wrap.d.ts +5 -0
- package/dist/tools/wrap.js +1 -1
- package/package.json +2 -2
- package/dist/extensions/business-modules.d.ts +0 -54
- package/dist/extensions/business-modules.js +0 -1
- package/dist/schemas/guard-templates.json +0 -379
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{SV2_UNARMED_PRESCRIPTION}from'../knowledge/protocol-facts.js';import{verifyAllocatorRails}from'../knowledge/allocator-rail-verifier.js';import{TASK_BINDING_SLOT}from'../knowledge/onchain-constants.js';import{rootHasRewardRecordGate}from'../knowledge/template-scanner.js';import{guardTemplateHasIdentityLeg}from'../knowledge/builtin-templates.js';import{numericAmount}from'../knowledge/audit-rules.js';import{emitSupplyChainPromise}from'./supply-chain-emit.js';import{P,ref}from'./plan.js';function lowestSalePrice(a){if(!Array['isArray'](a))return undefined;let b;for(const c of a){const d=numericAmount(c?.['price']);if(d!==undefined&&d>0x0)b=b===undefined?d:Math['min'](b,d);}return b;}function toByteVector(a){if(Array['isArray'](a))return a['every'](c=>typeof c==='number'&&Number['isInteger'](c)&&c>=0x0&&c<=0xff)?a:undefined;if(typeof a==='string'&&a['length']>0x0)return Array['from'](new TextEncoder()['encode'](a));return undefined;}const CANONICAL_CURRENCY='0x2::wow::WOW',QUALIFIED_TYPE_RE=/^0x[0-9a-fA-F]{1,64}::[a-zA-Z_][a-zA-Z0-9_]*::[A-Za-z_][A-Za-z0-9_]*$/;export function normalizeCurrency(a){const b=a['trim']();if(QUALIFIED_TYPE_RE['test'](b))return b;if(/^\$?wow$/i['test'](b))return CANONICAL_CURRENCY;return undefined;}const capUtf8=(a,b)=>{const c=new TextEncoder();if(c['encode'](a)['length']<=b)return a;let d=a;while(d['length']>0x0&&c['encode'](d+'…')['length']>b)d=d['slice'](0x0,-0x1);return d+'…';};function offTaskSlotIdentityLegs(a){const b=new Set(['order.owner','order.agent\x20has']),c=new Set(['query_order_named_operator_member']),d=new Set(),e=[],f=g=>{if(g===null||typeof g!=='object')return;const h=g;if(h['type']==='logic_equal'&&Array['isArray'](h['nodes'])){const l=h['nodes']['filter'](m=>m!==null&&typeof m==='object'&&m['type']==='identifier'&&typeof m['identifier']==='number');if(l['some'](m=>m['identifier']===TASK_BINDING_SLOT)){for(const m of l)d['add'](m['identifier']);}}const i=h['object'],j=typeof h['query']==='string'&&b['has'](h['query'])||typeof h['type']==='string'&&c['has'](h['type']);if(j&&i!==null&&typeof i==='object'&&typeof i['identifier']==='number'){const o=i['identifier'],p=typeof h['query']==='string'?h['query']:h['type'];if(o!==TASK_BINDING_SLOT)e['push']({'query':p,'identifier':o});}if(Array['isArray'](h['nodes'])){for(const q of h['nodes'])f(q);}if(h['node']!==undefined&&typeof h['node']==='object')f(h['node']);};return f(a),e['filter'](g=>!d['has'](g['identifier']));}const MODE_MAP={'amount':'Amount','rate':'Rate','surplus':'Surplus'};export function emitIdentityPhase({template:a,base:b}){const c=[];c['push']({'op':'create','id':'permission','object':'permission','params':{'name':b+'_permission'}});const d=a['arbitration_mode']!==undefined&&a['arbitration_mode']!=='none';return d&&c['push']({'op':'create','id':'permission_arb','object':'permission','params':{'name':b+'_arb_permission'},...a['arbitration_mode']==='third_party'?{'account':'arb_controller'}:{},'notes':'MUST\x20be\x20created\x20by\x20a\x20different\x20account\x20than\x20the\x20service\x20permission\x20'+'(E_ARBITRATION_PERMISSION_CONFLICT=33):\x20dispute\x20neutrality.\x20'+'third_party\x20builds\x20declare\x20account\x20\x27arb_controller\x27\x20—\x20provide\x20'+'accounts.arb_controller\x20to\x20plan_execute.'}),c['push']({'op':'create','id':'contact','object':'contact','params':{'name':b+'_contact'},'notes':'R8:\x20customer-service\x20channel;\x20mandatory\x20when\x20customer_required\x20is\x20set.\x20'+'required_info\x20is\x20SELF-ATTESTED\x20—\x20the\x20chain\x20stores\x20the\x20buyer\x27s\x20claim\x20verbatim\x20and\x20nothing\x20verifies\x20it\x20'+'(the\x20bind\x20path\x20only\x20proves\x20the\x20claim\x20came\x20from\x20this\x20order\x27s\x20owner).\x20A\x20genuine\x20credential\x20gate\x20requires\x20'+'a\x20Proof-backed\x20delivery\x20guard\x20(see\x20the\x20privacy-delivery\x20design;\x20not\x20wired\x20by\x20default).'}),{'steps':c,'needsArbitration':d};}const rewardRowIdentifiers=a=>{const b=new Set(),c=d=>{if(Array['isArray'](d)){for(const f of d)c(f);return;}if(typeof d!=='object'||d===null)return;const e=d;if(typeof e['type']==='string'&&e['type']['startsWith']('query_reward_record')){const g=e['object'];if(g!==undefined&&typeof g['identifier']==='number')b['add'](g['identifier']);}for(const h of Object['values'](e))c(h);};return c(a),b;};export function emitRewardClaimEarly({reviewMode:a,guardSpecs:b,resolvedGuards:c,rewardMark:d}){const e=[],f=a==='review_reward'?b['find'](g=>g['host']==='reward'):undefined;if(a==='review_reward'&&f?.['step_id']!==undefined){const g=c['get'](f['key']);if(g!==undefined){const h=rewardRowIdentifiers(g['root']);c['set'](f['key'],{...g,'table':g['table']['map'](i=>{const j=i;if(j['b_submission']===!![]||!h['has'](j['identifier']))return i;return{...j,'value':ref('reward_review')};})});}e['push']({'op':'create','id':'reward_review','object':'reward','params':P({'name':d,'description':'Review\x20incentive\x20pool\x20(sale-time\x20planned;\x20terms\x20disclosed\x20at\x20quote/buy):\x20claim\x20gated\x20by\x20guard\x20\x27'+f['key']+'\x27.'}),'notes':'REVIEW-COMPONENT:\x20the\x20funded\x20reward\x20must\x20be\x20perceivable\x20by\x20the\x20buyer\x20BEFORE\x20ordering\x20—\x20the\x20full\x20terms\x20ride\x20the\x20quote/buy\x20surface\x20(REVIEW-COMPONENT-PLAN\x20§4).\x20'+'[ZR-08:\x20created\x20BEFORE\x20its\x20claim\x20guard\x20—\x20the\x20guard\x27s\x20Reward-address\x20row\x20freezes\x20at\x20creation\x20and\x20binds\x20this\x20pool\x20by\x20plan\x20ref\x20{\x22$ref\x22:\x22reward_review\x22}]'});}return{'steps':e};}export function checkDaysUnitSlots({resolvedGuards:a}){const b=[];{const c=0x5265c00,d=e=>{const f=e['value'],h=typeof f==='number'?f:typeof f==='string'?Number(f):NaN;return Number['isFinite'](h)?h:undefined;};for(const [e,f]of a){const h=f['table'],i=h['filter'](m=>typeof m?.['name']==='string'&&/day/i['test'](m['name'])),j=i['find'](m=>/ms[_\s]?per[_\s]?day/i['test'](m['name']));if(j===undefined)continue;const k=d(j);if(k===undefined||k===c)continue;const l=i['some'](m=>m!==j&&(d(m)??0x0)>0xe42);if(!l)continue;b['push']({'code':'DAYS_SLOT_UNIT_MISMATCH','detail':'guard\x20\x27'+e+'\x27:\x20a\x20day-denominated\x20slot\x20is\x20stuffed\x20with\x20MILLISECONDS\x20while\x20its\x20ms_per_day\x20row\x20reads\x20'+k+'\x20'+'(tbpr7\x20F-V3-04:\x20DAYS\x20slots\x20carrying\x20173000/864000\x20beside\x20ms_per_day\x20=\x201).\x20Guards\x20are\x20immutable\x20—\x20a\x20wrong\x20'+'unit\x20is\x20PERMANENT:\x20the\x20window\x20runs\x20~6\x20orders\x20of\x20magnitude\x20long\x20(or\x20short)\x20and\x20no\x20keeper\x20call\x20can\x20fix\x20it.\x20'+'Day\x20slots\x20carry\x20DAY\x20COUNTS\x20(twin\x20templates\x20scale\x20by\x2086400000\x20at\x20compile;\x20on-chain\x20day\x20twins\x20keep\x20the\x20'+'ms_per_day\x20=\x2086400000\x20row):\x20set\x20ms_per_day\x20back\x20to\x2086400000\x20and\x20re-derive\x20the\x20day\x20slots\x20via\x20fee-param\x20bindings.'});}}return{'blockers':b};}export function checkWindowTruncation({resolvedGuards:a}){const b=[],c=0x5265c00,d=e=>{const f=e['value'],h=typeof f==='number'?f:typeof f==='string'?Number(f):NaN;return Number['isFinite'](h)?h:undefined;};for(const [e,f]of a){const h=new Map();for(const m of f['table']){if(!m||typeof m!=='object'||Array['isArray'](m))continue;const n=m;typeof n['identifier']==='number'&&n['b_submission']!==!![]&&h['set'](n['identifier'],n);}const i=o=>typeof o==='number'?h['get'](o):undefined,j=o=>{const p=[];for(const q of['nodes','and','or','left','right']){const s=o[q];if(Array['isArray'](s))p['push'](...s);else{if(s!==undefined)p['push'](s);}}return p;},k=o=>{if(!o||typeof o!=='object'||Array['isArray'](o))return{'multiplies':0x0,'total':0x0};const p=o,q=typeof p['type']==='string'?p['type']:'';if(q==='calc_number_multiply'&&Array['isArray'](p['nodes'])&&p['nodes']['length']===0x2){const [u,w]=p['nodes'],x=u!==null&&typeof u==='object'&&u['type']==='identifier'?i(u['identifier']):undefined,y=w!==null&&typeof w==='object'&&w['type']==='identifier'?i(w['identifier']):undefined;if(x===undefined||y===undefined)return undefined;const z=d(x)===c?x:d(y)===c?y:undefined;if(z===undefined)return undefined;const A=z===x?y:x;if(A['value_type']!=='U64'||z['value_type']!=='U64')return undefined;const B=d(A);if(B===undefined)return undefined;return{'multiplies':0x1,'total':B};}let s=0x0,t=0x0;for(const C of j(p)){const D=k(C);if(D===undefined)return undefined;s+=D['multiplies'],t+=D['total'];}return{'multiplies':s,'total':t};},l=(o,p)=>{if(!o||typeof o!=='object'||Array['isArray'](o))return;const q=o,s=typeof q['type']==='string'?q['type']:'',t=s['includes']('lesser')?!![]:s['includes']('greater')?![]:p;if(s['includes']('lesser')){const u=q['nodes'],v=Array['isArray'](u)?u[0x1]:undefined,w=v!==undefined?k(v):{'multiplies':0x0,'total':0x0};w!==undefined&&w['multiplies']>0x0&&w['total']<0x1&&b['push']({'code':'WINDOW_TRUNCATION_ZERO','detail':'guard\x20\x27'+e+'\x27:\x20a\x20CLOSING\x20window\x27s\x20day\x20slots\x20total\x20'+String(w['total'])+'\x20day(s)\x20—\x20a\x20zero\x20(or\x20'+'sub-1\x20fraction,\x20which\x20the\x20U64\x20slot\x20truncates\x20to\x200\x20at\x20BCS\x20encode)\x20makes\x20the\x20leg\x20compute\x20'+'anchor\x20+\x200\x20×\x2086400000\x20on-chain,\x20so\x20the\x20`<=`\x20window\x20welds\x20shut\x20the\x20instant\x20its\x20anchor\x20entry\x20'+'lands\x20and\x20never\x20reopens\x20(Guards\x20are\x20immutable;\x20the\x20live\x20run\x20compiled\x20a\x200.002-day\x20test\x20window\x20'+'into\x20exactly\x20this\x20shape).\x20Pass\x20whole\x20days,\x20or\x20switch\x20the\x20window\x20to\x20a\x20millisecond-denominated\x20'+'slot\x20pair\x20(duration\x20in\x20ms\x20beside\x20ms_per_day\x20=\x201)\x20for\x20sub-day\x20test\x20windows.'});}for(const x of j(q))l(x,t);};l(f['root'],![]);}return{'blockers':b};}export function emitServiceDraft({template:a,base:b,inputs:c}){const d=[],e=[],f=typeof c['currency']==='string'?c['currency']['trim']():'',g=f===''?CANONICAL_CURRENCY:normalizeCurrency(f);g===undefined&&e['push']({'code':'CURRENCY_UNRESOLVED','detail':'inputs.currency\x20\x27'+String(c['currency'])+'\x27\x20is\x20not\x20a\x20resolvable\x20token\x20type.\x20Pass\x20the\x20'+'fully-qualified\x20form\x20\x270x2::wow::WOW\x27\x20or\x20the\x20bare\x20symbol\x20\x27WOW\x27\x20(aliased\x20here).\x20The\x20plan\x20carries\x20the\x20'+'canonical\x20default\x20so\x20the\x20shape\x20stays\x20inspectable,\x20but\x20the\x20verdict\x20is\x20blocked:\x20an\x20unqualified\x20symbol\x20'+'aborts\x20at\x20the\x20service\x20create\x20(type_parameter\x20validation)\x20AFTER\x20earlier\x20steps\x20already\x20ran\x20—\x20plan_execute\x20'+'is\x20not\x20transactional\x20(algr9\x20F-03:\x204\x20orphan\x20objects\x20behind\x20the\x20failed\x20step).'});const h=g??CANONICAL_CURRENCY;return d['push']({'op':'create','id':'service','object':'service','params':P({'name':b+'_service','type_parameter':h,'permission':ref('permission'),'um':ref('contact'),'description':a['id']+'\x20—\x20compiled\x20by\x20the\x20composition\x20compiler',...Array['isArray'](c['customer_required'])?{'customer_required':c['customer_required']}:{}}),'notes':'Draft\x20first\x20(F-01):\x20registers\x20the\x20LocalMark\x20name\x20every\x20guard\x20resolves\x20at\x20runtime.\x20'+'machine/repositories/buy_guard\x20attach\x20in\x20configure\x20steps\x20after\x20machine_publish\x20'+'(schema-sanctioned\x20phased\x20build;\x20machine/order_allocators\x20remain\x20publish-frozen).'}),{'steps':d,'currency':h,'blockers':e};}export function emitEvidenceRepository({needsRepository:a,base:b,inputs:c,guardSpecs:d,resolvedGuards:e}){const f=[],g=[],h=[],i=[];if(a){const j=Array['isArray'](c['repository_policies'])?c['repository_policies']['filter'](m=>typeof m==='object'&&m!==null):[],k=j['map'](m=>Array['isArray'](m['write_guard'])?m:{'write_guard':[],...m});for(const m of j){const n=typeof m['id_from']==='string'?m['id_from']['toLowerCase']():'none',o=Array['isArray'](m['write_guard'])?m['write_guard']['length']:0x0;n==='none'&&o===0x0&&g['push']({'code':'REPO_POLICY_WRITE_GUARD_REQUIRED','detail':'repository_policies\x20entry\x20\x27'+String(m['name']??'(unnamed)')+'\x27\x20declares\x20id_from\x20'+'\x27none\x27\x20(caller-supplied\x20row\x20key)\x20with\x20NO\x20write_guard\x20—\x20the\x20chain\x20aborts\x20policy\x20'+'creation\x20with\x20E_POLICY_WRITE_GUARD_REQUIRED\x20=\x2022\x20at\x20the\x20create\x20step\x20or\x20at\x20any\x20later\x20'+'policy\x20add\x20(the\x20id\x20is\x20caller-chosen,\x20so\x20an\x20ungated\x20rule\x20'+'would\x20let\x20anyone\x20write\x20the\x20row).\x20Attach\x20a\x20write_guard:[{guard:...}]\x20leg,\x20or\x20switch\x20'+'the\x20policy\x20to\x20id_from\x20\x22signer\x22/\x22clock\x22\x20if\x20the\x20row\x20key\x20may\x20be\x20derived\x20from\x20the\x20writer.'});}const l=new Set(j['map'](q=>q['name']));for(const p of d){if(p['host']!=='repository'||p['step_id']===undefined)continue;const q='host:\x22repository\x22\x20guard\x20\x27'+p['key']+'\x27\x20(step\x20\x27'+p['step_id']+'\x27)';if(p['policy']===undefined){g['push']({'code':'REPO_GUARD_POLICY_MISSING','detail':q+'\x20declares\x20no\x20policy\x20on\x20the\x20guards[]\x20entry.\x20Its\x20Repository\x20policy\x20'+'(name\x20/\x20id_from\x20/\x20value_type)\x20is\x20business\x20data\x20the\x20kernel\x20must\x20not\x20fabricate,\x20'+'and\x20an\x20unbound\x20repository\x20guard\x20is\x20an\x20orphan\x20create\x20that\x20leaves\x20the\x20Repository\x20'+'open\x20to\x20any\x20writer.\x20Add\x20policy:{name,\x20id_from,\x20value_type}\x20to\x20the\x20spec,\x20or\x20bind\x20'+'the\x20guard\x20through\x20repository_policies\x20inputs\x20with\x20this\x20guard\x27s\x20own\x20write_guard\x20shape.'});continue;}const r=p['policy']['name']??p['key'],s=(p['policy']['id_from']??'none')['toLowerCase'](),t=p['policy']['id_from_submission'],u=p['policy']['data_from_submission'];t!==undefined&&(s==='signer'||s==='clock')&&g['push']({'code':'REPO_GUARD_SUBMISSION_ID_FORBIDDEN','detail':q+'\x20declares\x20id_from_submission\x20'+t+'\x20while\x20its\x20policy\x20id_from\x20is\x20'+('\x27'+s+'\x27\x20—\x20the\x20row\x20id\x20is\x20AUTO-generated\x20from\x20the\x20'+s+'\x20there,\x20and\x20a\x20')+'submission-derived\x20id\x20conflicts\x20with\x20that\x20routing\x20(the\x20chain\x20aborts\x20policy\x20creation\x20'+'with\x20E_POLICY_ID_FROM_SUBMISSION_FORBIDDEN\x20=\x2023\x20—\x20at\x20the\x20create\x20step\x20or\x20at\x20any\x20later\x20'+'permission-102\x20policy\x20add\x20—\x20so\x20this\x20must\x20be\x20fixed,\x20BK15-F13).\x20Drop\x20id_from_submission\x20'+'(keep\x20data_from_submission\x20—\x20the\x20value\x20leg\x20is\x20legal\x20under\x20signer\x20routing),\x20or\x20switch\x20'+'the\x20policy\x20to\x20id_from\x20\x22none\x22\x20(caller-supplied\x20row\x20key,\x20guarded\x20by\x20this\x20write_guard).'});{const w=e['get'](p['key']),x=[['id_from_submission',t],['data_from_submission',u]];for(const [y,z]of x){if(z===undefined)continue;const A=w?.['table']['find'](B=>B['identifier']===z);(w===undefined||A===undefined||A['b_submission']!==!![])&&g['push']({'code':'REPO_GUARD_SUBMISSION_SLOT_UNKNOWN','detail':q+'\x20declares\x20'+y+'\x20'+z+',\x20but\x20the\x20resolved\x20guard\x20table\x20has\x20'+'NO\x20b_submission=true\x20row\x20at\x20that\x20identifier\x20—\x20the\x20passport\x20builder\x20DROPS\x20'+'undeclared\x20slots,\x20so\x20this\x20pairing\x20leg\x20would\x20silently\x20derive\x20nothing\x20at\x20write\x20'+'time\x20(the\x20write\x20aborts\x20or\x20writes\x20caller-free\x20values,\x20BK15-F13).\x20Declare\x20a\x20'+('b_submission=true\x20table\x20row\x20at\x20identifier\x20'+z+'\x20on\x20the\x20guard,\x20or\x20point\x20')+(y+'\x20at\x20an\x20existing\x20submission\x20slot.')});}}if(l['has'](r))continue;const v={'name':r,'description':capUtf8(p['policy']['description']??p['purpose'],0x1f4),'id_from':p['policy']['id_from']??'none','value_type':p['policy']['value_type']??'String','write_once':p['policy']['write_once']??![]};h['push']({...v,'write_guard':[{'guard':ref(p['step_id']),...t!==undefined?{'id_from_submission':t}:{},...u!==undefined?{'data_from_submission':u}:{}}]}),i['push'](p['step_id']);}f['push']({'op':'create','id':'repository','object':'repository','params':P({'name':b+'_evidence',...k['length']>0x0?{'policies':k}:{}}),'notes':'Evidence\x20rows\x20(tracking\x20hash,\x20receipts,\x20WTS\x20proofs).\x20Created\x20BEFORE\x20the\x20guard\x20wave\x20so\x20the\x20guards\x27\x20table\x20rows\x20reach\x20this\x20repository\x20by\x20plan\x20ref.\x20[F-BS5-03\x20(bst5-mn-261101):\x20the\x20create\x20ships\x20ONLY\x20caller-supplied\x20policies\x20that\x20are\x20legal\x20at\x20construction\x20—\x20every\x20guard-derived\x20policy\x20lands\x20at\x20the\x20repository_write_guards\x20configure\x20step\x20right\x20after\x20the\x20wave,\x20in\x20its\x20credential-bound\x20(write_guard-attached)\x20form,\x20the\x20ONLY\x20legal\x20shape\x20for\x20id_from=none.]'});}return{'steps':f,'repoBoundPolicies':h,'repoBoundStepIds':i,'blockers':g};}export function emitReviewRepositoryEarly({reviewMode:a,base:b,inputs:c}){const d=[];return a!=='none'&&d['push']({'op':'create','id':'repository_review','object':'repository','params':P({'name':b+'_review','description':'Structured\x20buyer\x20reputation\x20rows\x20(AR-1:\x20emitted\x20by\x20the\x20build\x20plan\x20—\x20no\x20manual\x20setup).',...c['buyer_review_enabled']===!![]?{'policies':[{'name':'buyer_review','description':'Merchant-side\x20structured\x20feedback\x20on\x20the\x20order/buyer\x20(D-R7\x20bidirectional\x20reputation,\x20opt-in).\x20One\x20immutable\x20row\x20per\x20writer\x20(id_from=Signer;\x20write-once\x20—\x20a\x20rewrite\x20attempt\x20aborts\x20on-chain,\x20K3(a)).\x20NO\x20write\x20guard\x20by\x20design:\x20merchant\x20authority\x20is\x20verified\x20at\x20READ\x20time\x20(the\x20writer\x20must\x20control\x20the\x20order\x27s\x20service\x20—\x20graph\x20ControlIndex).\x20Payload:\x20JSON\x20text\x20{rating,\x20tags?,\x20orderRef?}.','id_from':'signer','value_type':'String','write_once':!![],'write_guard':[]}]}:{}}),'notes':'REVIEW-COMPONENT\x20AR-1\x20(F-05\x20early\x20form):\x20the\x20review\x20TEXT\x20still\x20rides\x20the\x20forward\x20message\x20(D-R1\x20dual\x20carrier);\x20this\x20repository\x20carries\x20ONLY\x20the\x20structured\x20row.\x20The\x20buyer\x20writes\x20BOTH\x20rows\x20at\x20review\x20time,\x20both\x20ORDER-KEYED\x20(F09):\x20\x27review\x27\x20(text\x20JSON,\x20id\x20=\x20the\x20ORDER\x20address)\x20AND\x20\x27rating\x27\x20(U64\x20stars,\x20id\x20=\x20the\x20ORDER\x20address).\x20The\x20\x27rating\x27\x20row\x20is\x20what\x20a\x20reward\x20good-review\x20leg\x20reads\x20(F-62).\x20Buyers\x20resolve\x20this\x20object\x20by\x20name\x20(workspace/onchain_objects)\x20—\x20never\x20guess\x20an\x20address.\x20[F-BS5-03\x20(bst5-mn-261101):\x20the\x20\x27review\x27/\x27rating\x27\x20policies\x20(id_from=none,\x20order-keyed)\x20ship\x20ONLY\x20on\x20the\x20repository_review_write_guards\x20configure\x20step\x20in\x20their\x20credential-bound\x20form\x20—\x20an\x20id_from=none\x20policy\x20without\x20a\x20write_guard\x20aborts\x20the\x20create\x20on-chain\x20(the\x20chain\x20requires\x20a\x20non-empty\x20write_guard\x20on\x20BOTH\x20the\x20create\x20path\x20and\x20every\x20later\x20policy\x20add).\x20buyer_review\x20(id_from=signer)\x20is\x20the\x20one\x20create-legal\x20policy.]'}),{'steps':d};}export function rewritePlanRefs({base:a,resolvedGuards:b}){{const c=new Map([[a+'_service','service'],[a+'_evidence','repository'],[a+'_review','repository_review'],[a+'_arbitration','arbitration']]);for(const [,d]of b){for(const e of d['table']){const f=e,h=typeof f['value']==='string'?c['get'](f['value']):undefined;if(h!==undefined)f['value']=ref(h);}}}}export function dropEmptyVecGuards({resolvedGuards:a,guardSpecs:b,steps:c}){const d=[],e=[];{const f=new Map();for(const [i,j]of a){const k=new Set();for(const l of j['table']){const m=l;m['b_submission']===![]&&Array['isArray'](m['value'])&&m['value']['length']===0x0&&typeof m['identifier']==='number'&&k['add'](m['identifier']);}if(k['size']>0x0)f['set'](i,k);}const h=(n,o)=>{if(n===null||typeof n!=='object')return![];const p=n;if(p['type']!=='vec_contains_address'||!Array['isArray'](p['nodes']))return![];const q=p['nodes']['find'](s=>s['type']==='identifier');return q!==undefined&&typeof q['identifier']==='number'&&o['has'](q['identifier']);};for(const [n,o]of f){const p=a['get'](n),q=p['root'],s=b['find'](v=>v['key']===n),t=q['type']==='logic_not'&&h(q['node'],o);if(t&&s?.['host']==='service'&&n==='buy'){a['delete'](n),s['step_id']=undefined,e['push'](n);continue;}const u=[...o]['map'](String);d['push']({'code':'GUARD_EMPTY_VEC_ROW','detail':'guard\x20\x27'+n+'\x27\x20declares\x20static\x20vec\x20row(s)\x20'+u['join'](',\x20')+'\x20with\x20an\x20EMPTY\x20array\x20—\x20'+'the\x20executor\x20refuses\x20empty\x20static\x20vec\x20slots\x20(LE-10:\x20the\x20chain\x27s\x20table\x20builder\x20silently\x20DROPS\x20empty\x20'+'vectors,\x20so\x20the\x20created\x20Guard\x20would\x20diverge\x20from\x20the\x20reviewed\x20spec\x20—\x20mainnet\x207\x20submitted\x20->\x206\x20stored).\x20'+'Two\x20legal\x20exits:\x20(a)\x20arm\x20the\x20list\x20with\x20at\x20least\x20one\x20address\x20(the\x20blocklist\x20twin\x27s\x20intended\x20armed\x20form:\x20'+'list\x20the\x20provider-side\x20account(s)\x20to\x20ban\x20self-purchase);\x20or\x20(b)\x20if\x20the\x20empty\x20list\x20IS\x20the\x20intended\x20open\x20'+('polarity,\x20omit\x20the\x20guard:\x20guard_resolutions\x20{\x22'+n+'\x22:\x20{\x22kind\x22:\x20\x22omit\x22}}\x20—\x20the\x20compile\x20honors\x20omission\x20')+'and\x20the\x20attached\x20rail\x20ships\x20un-gated\x20(there\x20is\x20no\x20constant-true\x20Guard\x20object\x20to\x20fabricate).'});}}if(e['length']>0x0){const v=c['find'](w=>w['op']==='create'&&w['id']==='service');v!==undefined&&(v['notes']=(v['notes']??'')+'\x20[F-04\x20open-store\x20drop:\x20the\x20blocklist\x20buy\x20guard\x20('+e['join'](',\x20')+')\x20resolved\x20to\x20an\x20EMPTY\x20blocklist\x20—\x20NOT(vec_contains(empty))\x20is\x20constant\x20true,\x20a\x20no-op\x20gate,\x20and\x20the\x20executor\x20refuses\x20empty\x20vec\x20rows\x20(LE-10)\x20—\x20so\x20the\x20guard\x20and\x20its\x20buy\x20mount\x20are\x20OMITTED:\x20this\x20store\x20ships\x20OPEN.\x20To\x20arm\x20the\x20self-purchase\x20ban,\x20fill\x20the\x20blocklist\x20at\x20generation.]');}return{'blockers':d};}export function emitArbitrationHoist({needsArbitration:a,template:b,base:c,currency:d}){const e=[];return a&&e['push']({'op':'create','id':'arbitration','object':'arbitration',...b['arbitration_mode']==='third_party'?{'account':'arb_controller'}:{},'params':P({'name':c+'_arbitration','permission':ref('permission_arb'),'type_parameter':d,'pause':![]}),'notes':'Independent\x20venue\x20(R2);\x20activates\x20atomically\x20(create+unpause\x20same\x20PTB).\x20[W5-05:\x20created\x20BEFORE\x20the\x20guard\x20wave\x20so\x20arb-ruling\x20guard\x20tables\x20bind\x20it\x20by\x20plan\x20ref]'}),{'steps':e};}export function emitGuardWave({resolvedGuards:a,specByKey:b,slot254Injected:c,repoBoundPolicies:d,repoBoundStepIds:e}){const f=[],g=h=>{const i=a['get'](h),j=b['get'](h)?.['purpose'];return{'op':'create','id':i['stepId'],'object':'guard','params':P({'description':i['description'],'table':i['table'],'root':i['root']}),'notes':c['has'](h)?(j??'Guard')+'\x20[kernel:\x20protocol\x20slot\x20254\x20(task\x20binding)\x20auto-declared]':j};};for(const [h]of a)f['push'](g(h));return d['length']>0x0&&f['push']({'op':'configure','id':'repository_write_guards','target':ref('repository'),'method':'policies','params':P({'op':'add','policy':d}),'requires':['repository',...e],'notes':'F-BS5-03\x20(bst5-mn-261101):\x20the\x20ONLY\x20landing\x20place\x20for\x20the\x20evidence\x20repository\x27s\x20guard-derived\x20policies\x20—\x20the\x20create\x20cannot\x20carry\x20them\x20(an\x20id_from=none\x20policy\x20without\x20a\x20write_guard\x20aborts\x20on-chain:\x20the\x20chain\x20requires\x20a\x20non-empty\x20write_guard\x20on\x20the\x20create\x20path\x20too),\x20so\x20the\x20credential-bound\x20forms\x20(write_guard\x20attached)\x20are\x20added\x20to\x20the\x20live\x20repository\x20here,\x20now\x20that\x20the\x20guards\x20exist\x20(the\x20plan-ref\x20rewrite\x20closed\x20the\x20double-object\x20cycle).'}),{'steps':f};}export function emitMachine({template:a,base:b,shape:c,resolvedGuards:d,specByKey:e,injectedOrderHolderKeys:f,merchantIndex:h}){const i=[],j=[],k=new Set(c['map'](q=>q['name'])),l=new Set((a['allocator']?.['rows']??[])['filter'](q=>q['track']==='settlement')['map'](q=>q['guard_key'])['filter'](q=>typeof q==='string'&&q['trim']()!=='')),n=[],p=new Set();for(const q of c){if(q['from']===undefined||q['from']['length']===0x0){j['push']({'code':'MACHINE_EDGES_MISSING','detail':'machine_shape\x20node\x20\x27'+q['name']+'\x27\x20declares\x20no\x20\x27from\x27\x20edges.\x20Edges\x20are\x20data\x20'+'(REPORT\x20#10\x20A-2:\x20a\x20missing\x20paid->closed_cancel\x20edge\x20bricks\x20the\x20shop\x20at\x20publish).\x20'+'Annotate\x20the\x20node\x20with\x20from:\x20[...]\x20(use\x20prev:\x20\x22\x22\x20for\x20the\x20entry\x20edge).'});continue;}const r=[],s=new Map(),t=new Map();for(const v of q['from']){const w=typeof v==='string'?{'prev':v}:v;if(w['prev']!==''&&!k['has'](w['prev'])){j['push']({'code':'EDGE_UNKNOWN_PREV','detail':'node\x20\x27'+q['name']+'\x27\x20edge\x20prev\x20\x27'+w['prev']+'\x27\x20is\x20not\x20a\x20machine_shape\x20node'});continue;}const x=w['operator']??q['operator']??(w['prev']===''?'order_payer':'merchant'),y=w['named_operator']??q['named_operator'],z=w['forward']??(w['prev']===''?'enter_'+q['name']:w['prev']+'_to_'+q['name']);w['permission_index']!==undefined&&x==='order_payer'&&j['push']({'code':'PERMISSION_INDEX_DROPPED','detail':'edge\x20\x27'+w['prev']+'\x27->\x27'+q['name']+'\x27\x20declares\x20permission_index\x20'+w['permission_index']+'\x20on\x20operator\x20\x27order_payer\x27.\x20'+'The\x20two\x20are\x20contradictory\x20rails:\x20\x27order_payer\x27\x20compiles\x20to\x20the\x20on-chain\x20order-holder\x20check\x20(namedOperator\x20\x22\x22),\x20which\x20the\x20chain\x20evaluates\x20FIRST,\x20'+'so\x20the\x20declared\x20permission\x20index\x20is\x20silently\x20dropped\x20and\x20the\x20forward\x20remains\x20open\x20to\x20EVERY\x20order\x20agent\x20—\x20the\x20opposite\x20of\x20the\x20entity-only\x20intent\x20'+'(alg2-tn-261025\x20T8e:\x20the\x20provider\x20self-advanced\x20the\x20evaluation\x20forward\x20and\x20settled\x20the\x20escrow\x20to\x20itself).\x20Pick\x20ONE\x20rail:\x20remove\x20permission_index\x20to\x20keep\x20the\x20'+('buyer\x20rail,\x20or\x20remove\x20the\x20\x27order_payer\x27\x20operator\x20(node-level\x20or\x20edge-level)\x20so\x20this\x20forward\x20binds\x20permission_index\x20'+w['permission_index']+'\x20only')});y!==undefined&&w['permission_index']!==undefined&&j['push']({'code':'NAMED_OPERATOR_RAIL_CONFLICT','detail':'edge\x20\x27'+w['prev']+'\x27->\x27'+q['name']+'\x27\x20declares\x20named_operator\x20\x27'+y+'\x27\x20AND\x20permission_index\x20'+w['permission_index']+'.\x20'+'namedOperator\x20and\x20permissionIndex\x20are\x20OR-options\x20in\x20the\x20on-chain\x20pre-check\x20(namedOperator\x20first),\x20so\x20both\x20rails\x20on\x20one\x20forward\x20'+'is\x20a\x20widening\x20ambiguity\x20—\x20the\x20forward\x20stays\x20open\x20to\x20whichever\x20rail\x20matches\x20and\x20neither\x20the\x20roster-only\x20nor\x20the\x20entity-only\x20intent\x20binds.\x20'+'Pick\x20ONE\x20rail:\x20drop\x20permission_index\x20to\x20keep\x20the\x20named\x20roster\x20rail,\x20or\x20drop\x20named_operator\x20to\x20keep\x20the\x20permission\x20entity\x20rail'});y!==undefined&&(w['operator']==='order_payer'||q['operator']==='order_payer')&&j['push']({'code':'NAMED_OPERATOR_RAIL_CONFLICT','detail':'edge\x20\x27'+w['prev']+'\x27->\x27'+q['name']+'\x27\x20declares\x20named_operator\x20\x27'+y+'\x27\x20on\x20an\x20EXPLICIT\x20operator:\x27order_payer\x27.\x20'+'Both\x20ride\x20the\x20namedOperator\x20rail\x20with\x20different\x20payloads\x20—\x20the\x20buyer\x20self-advance\x20(\x27\x27\x20resolves\x20to\x20the\x20order\x20payer)\x20and\x20the\x20'+('third-party\x20namespace\x20(\x27'+y+'\x27\x20resolves\x20to\x20the\x20per-order\x20roster)\x20cannot\x20share\x20one\x20forward;\x20one\x20of\x20them\x20would\x20silently\x20lose.\x20')+'Pick\x20ONE\x20rail:\x20drop\x20the\x20operator\x20declaration\x20to\x20keep\x20the\x20named\x20roster\x20rail,\x20or\x20drop\x20named_operator\x20to\x20keep\x20the\x20buyer\x20self-advance'});const A=w['guard_key']!==undefined&&w['guard_key']['trim']()!==''&&l['has'](w['guard_key'])||/settle|release|payout/i['test'](z);{A&&w['permission_index']===undefined&&y===undefined&&x!=='order_payer'&&j['push']({'code':'RELEASE_EDGE_PERMISSIONLESS','detail':'settlement\x20edge\x20\x27'+w['prev']+'\x27->\x27'+q['name']+'\x27\x20(forward\x20\x27'+z+'\x27,\x20guard\x20\x27'+(w['guard_key']??'none')+'\x27)\x20binds\x20NO\x20permission_index\x20and\x20NO\x20named_operator\x20rail\x20—\x20it\x20compiles\x20PERMISSIONLESS:\x20the\x20on-chain\x20permission\x20layer\x20checks\x20namedOperator\x20then\x20permissionIndex,\x20and\x20with\x20neither\x20present\x20ANYONE\x20with\x20a\x20valid\x20order\x20passport\x20can\x20advance\x20the\x20release\x20and\x20move\x20the\x20escrow\x20(5R-07①\x20F-56,\x20tbp\x20T17\x20live:\x20an\x20unrelated\x20buyer\x27s\x20wallet\x20executed\x20the\x20payout).\x20Bind\x20ONE\x20rail:\x20permission_index\x201002\x20(the\x20keeper\x20or\x20merchant\x20release\x20slot\x20—\x20recommended\x20default\x20C:\x20the\x20time-lock\x20guard\x20+\x20keeper\x20duty\x20+\x20bounty\x20schedule\x20the\x20release)\x20or\x20a\x20stricter\x20merchant-approval\x20rail\x20for\x20high-ticket\x20builds\x20(default\x20A:\x20the\x20merchant\x27s\x20own\x20approval\x20BEFORE\x20the\x20escrow\x20moves).\x20Pair\x20the\x20rail\x20with\x20the\x20guard\x27s\x20identity\x20leg\x20(Signer\x20binding)\x20as\x20defense\x20in\x20depth\x20—\x20declared\x20in\x20the\x20guard\x20table,\x20verified\x20by\x20the\x20audit\x20face'});}const B={'name':z,'weight':0x1,...y!==undefined?{'namedOperator':y}:x==='order_payer'?{'namedOperator':''}:{'permissionIndex':w['permission_index']??h}};if(w['guard_key']!==undefined){const F=e['get'](w['guard_key']);if(F===undefined)j['push']({'code':'GUARD_KEY_UNKNOWN','detail':'edge\x20\x27'+w['prev']+'\x27->\x27'+q['name']+'\x27\x20binds\x20unknown\x20guard_key\x20\x27'+w['guard_key']+'\x27'});else{for(const H of F['purpose']['matchAll'](/progress\.current\s*==\s*([a-z0-9_]+)/g)){const I=H[0x1];k['has'](I)&&I!==w['prev']&&j['push']({'code':'FORWARD_GUARD_PINNED_TO_NON_PREV','detail':'edge\x20\x27'+w['prev']+'\x27->\x27'+q['name']+'\x27\x20guard\x20\x27'+F['key']+'\x27\x20pins\x20progress.current\x20==\x20\x27'+I+'\x27,\x20but\x20a\x20'+('forward\x20guard\x20evaluates\x20BEFORE\x20the\x20advance\x20(progress.current\x20==\x20prev\x20\x27'+w['prev']+'\x27),\x20so\x20the\x20pin\x20')+'can\x20never\x20pass\x20—\x20dead\x20rail\x20(bkng\x20F22).\x20Keep\x20the\x20pin\x20on\x20the\x20allocator\x20row\x20(evaluated\x20at\x20alloc,\x20'+'current\x20=\x20the\x20reached\x20node);\x20put\x20only\x20time/identity\x20legs\x20on\x20the\x20forward.'});}const G=F['template_id']==='pattern.identity_check_order_holder'||F['template_id']==='tpl_forward_order_holder'||F['template_id']==='tpl_forward_order_holder_or_time'||F['template_id']==='tpl_time_window_upper_order_holder'||F['template_id']==='tpl_time_window_band_abs_order_holder'||F['template_id']==='tpl_forward_order_holder_time_lock_absolute';if(G&&y!==undefined)j['push']({'code':'FORWARD_GUARD_IDENTITY_NAMED_CONFLICT','detail':'edge\x20\x27'+w['prev']+'\x27->\x27'+q['name']+'\x27\x20guard\x20\x27'+F['key']+'\x27\x20is\x20an\x20order-holder\x20(buyer)\x20identity\x20'+('check\x20but\x20the\x20forward\x20rides\x20a\x20named_operator\x20rail\x20(\x27'+y+'\x27\x20—\x20a\x20third\x20party\x20that\x20is\x20')+'neither\x20the\x20merchant\x20entity\x20nor\x20the\x20buyer).\x20The\x20identity\x20layer\x20runs\x20BEFORE\x20the\x20guard\x20and\x20the\x20'+'roster\x20signer\x20is\x20never\x20the\x20order\x20owner\x20—\x20nobody\x20can\x20pass\x20both.\x20Move\x20the\x20buyer-identity\x20leg\x20'+'off\x20this\x20forward\x20(the\x20roster\x20forward\x20may\x20carry\x20only\x20evidence/time\x20guards),\x20or\x20split\x20the\x20hop.'});else G&&x!=='order_payer'&&j['push']({'code':'FORWARD_GUARD_IDENTITY_PERM_CONFLICT','detail':'edge\x20\x27'+w['prev']+'\x27->\x27'+q['name']+'\x27\x20guard\x20\x27'+F['key']+'\x27\x20is\x20an\x20order-holder\x20(buyer)\x20identity\x20'+'check\x20but\x20the\x20forward\x20rides\x20a\x20permissionIndex\x20rail\x20(merchant-side\x20slot).\x20The\x20identity\x20layer\x20'+'runs\x20BEFORE\x20the\x20guard,\x20and\x20the\x20two\x20signer\x20sets\x20are\x20disjoint\x20—\x20nobody\x20can\x20pass\x20both\x20(bkng\x20F23).\x20'+'Use\x20operator\x20\x27order_payer\x27\x20(namedOperator\x20\x22\x22\x20—\x20the\x20buyer\x20self-advance)\x20for\x20this\x20edge.'});{const J=d['get'](F['key']);if(J!==undefined){const K=J['table']['some'](M=>M['identifier']===TASK_BINDING_SLOT),L=offTaskSlotIdentityLegs(J['root'])['filter'](M=>{if(!K)return![];const N=J['table']['find'](O=>O['identifier']===M['identifier']);return N!==undefined&&N['b_submission']===!![];});for(const M of L){j['push']({'code':'GUARD_IDENTITY_SLOT_NOT_TASKBOUND','detail':'edge\x20\x27'+w['prev']+'\x27->\x27'+q['name']+'\x27\x20guard\x20\x27'+F['key']+'\x27\x20reads\x20'+M['query']+'\x20off\x20free\x20'+('submission\x20slot\x20'+M['identifier']+'\x20—\x20hijackable\x20(rex-mn-261021\x20T10):\x20the\x20caller\x20fills\x20free\x20')+'slots,\x20so\x20an\x20attacker\x20submits\x20their\x20OWN\x20order\x20there\x20(signer\x20==\x20order.owner\x20passes\x20against\x20'+('their\x20own\x20order)\x20and\x20advances\x20the\x20VICTIM\x27s\x20order\x20carried\x20by\x20slot\x20'+TASK_BINDING_SLOT+';\x20with\x20')+'namedOperator\x20\x22\x22\x20the\x20permission\x20layer\x20passes\x20for\x20anyone,\x20so\x20this\x20'+('guard\x20is\x20the\x20only\x20identity\x20leg.\x20Anchor\x20the\x20'+M['query']+'\x20query\x20on\x20identifier\x20')+(TASK_BINDING_SLOT+'\x20(the\x20task-binding\x20order\x20anchor\x20—\x20the\x20order\x20the\x20forward\x20actually\x20mutates).')});}}}if(F['step_id']!==undefined){B['guard']=ref(F['step_id']);if(A&&x==='order_payer'&&y===undefined){const N=d['get'](F['key']);N!==undefined&&!guardTemplateHasIdentityLeg(N['root'])&&j['push']({'code':'RELEASE_EDGE_NO_IDENTITY','detail':'settlement\x20edge\x20\x27'+w['prev']+'\x27->\x27'+q['name']+'\x27\x20(forward\x20\x27'+z+'\x27,\x20guard\x20'+('\x27'+F['key']+'\x27,\x20design\x20\x27'+F['template_id']+'\x27)\x20rides\x20the\x20buyer\x20rail\x20(operator\x20')+'\x27order_payer\x27\x20→\x20namedOperator\x20\x22\x22\x20with\x20NO\x20permissionIndex)\x20and\x20its\x20guard\x20carries\x20NO\x20'+'order-holder\x20identity\x20leg\x20—\x20on\x20a\x20guard-bound\x20forward\x20the\x20chain\x20skips\x20the\x20'+'permission\x20assert,\x20so\x20ANY\x20signer\x20holding\x20a\x20passport\x20for\x20this\x20guard\x20can\x20drive\x20the\x20'+'settlement\x20(gfm35-tn-261029\x20F02\x20live:\x20an\x20outsider\x20force-released\x20and\x20settled\x20order).\x20'+'Bind\x20a\x20guard\x20whose\x20root\x20carries\x20the\x20owner/agent\x20identity\x20legs\x20over\x20slot\x20254\x20—\x20e.g.\x20'+'tpl_forward_order_holder_time_lock_absolute\x20for\x20a\x20deadline\x20self-heal\x20(split\x20guard\x20'+'key:\x20keep\x20the\x20pure\x20time\x20lock\x20on\x20the\x20keeper/merchant\x20edge),\x20'+'tpl_time_window_upper_absolute_ms\x20for\x20a\x20closing\x20window.\x20The\x20STATE_AUTHORIZING\x20'+'exemption\x20covers\x20keeper/merchant\x20rails\x20only,\x20never\x20the\x20buyer\x20release\x20rail'});}}}}if(B['guard']===undefined&&x==='order_payer'&&y===undefined){const O=f['get'](z);if(O!==undefined){const Q=e['get'](O);Q?.['step_id']!==undefined&&(B['guard']=ref(Q['step_id']));}}const C=s['get'](w['prev']);C!==undefined?C['push'](B):s['set'](w['prev'],[B]);const D=t['get'](w['prev']),E=y!==undefined?'namedOperator:'+y:x==='order_payer'?'namedOperator:':'permissionIndex:'+(w['permission_index']??h);y!==undefined&&p['add'](y),D!==undefined?D['add'](E):t['set'](w['prev'],new Set([E]));}const u=q['threshold']??0x0;for(const [R,S]of s){u>S['length']&&j['push']({'code':'PAIR_THRESHOLD_UNREACHABLE','detail':'node\x20\x27'+q['name']+'\x27\x20pair\x20from\x20\x27'+(R===''?'(entry)':R)+'\x27\x20declares\x20threshold\x20'+u+'\x20'+('but\x20the\x20pair\x20merges\x20only\x20'+S['length']+'\x20forward(s)\x20at\x20weight\x201\x20each\x20—\x20the\x20pair\x20can\x20never\x20')+'migrate\x20and\x20the\x20publish\x20aborts.\x20Add\x20one\x20distinct-operator\x20forward\x20per\x20required\x20signature,\x20or\x20'+'lower\x20the\x20threshold\x20to\x20the\x20forward\x20count.'});if(u>=0x2){const T=t['get'](R)?.['size']??0x0;T<0x2&&j['push']({'code':'PAIR_THRESHOLD_SINGLE_OPERATOR','detail':'node\x20\x27'+q['name']+'\x27\x20pair\x20from\x20\x27'+(R===''?'(entry)':R)+'\x27\x20declares\x20threshold\x20'+u+'\x20'+'but\x20every\x20forward\x20rides\x20the\x20SAME\x20operator\x20rail\x20—\x20one\x20party\x20can\x20tap\x20all\x20of\x20them\x20and\x20the\x20'+'declared\x20dual\x20confirmation\x20silently\x20dissolves\x20(each\x20forward\x20locks\x20to\x20its\x20first\x20operator).\x20'+'Give\x20each\x20required\x20signature\x20its\x20own\x20rail\x20(e.g.\x20permission_index\x201001\x20+\x20operator\x20\x27order_payer\x27).'});}r['push']({'prev_node':R,'threshold':u,'forwards':S});}n['push']({'name':q['name'],...q['semantic_role']!==undefined?{'role':q['semantic_role']}:{},...q['optional']===!![]?{'optional':!![]}:{},'pairs':r});}if(p['size']>0x0){const U=/(named[-_ ]?operator|operator roster|\broster\b|dispatch|permission.{0,12}221)/i,V=(a['build_notes']??[])['some'](W=>U['test'](W));!V&&j['push']({'code':'NAMED_OPERATOR_ROSTER_UNDISCLOSED','detail':'machine_shape\x20binds\x20a\x20named\x20third-party\x20operator\x20namespace\x20('+[...p]['map'](W=>'\x27'+W+'\x27')['join'](',\x20')+')\x20'+'but\x20no\x20build_note\x20discloses\x20the\x20roster\x20management.\x20The\x20per-order\x20NamedOperator\x20roster\x20(max\x2060\x20rosters\x20/\x2080\x20addresses)\x20is\x20written\x20at\x20'+'runtime\x20by\x20the\x20account\x20holding\x20permission\x20index\x20221\x20—\x20without\x20a\x20disclosed\x20dispatch\x20duty\x20the\x20forward\x20compiles\x20but\x20nobody\x20can\x20ever\x20'+'pass\x20it\x20(silent\x20brick).\x20Add\x20a\x20build_note\x20stating\x20WHO\x20writes\x20the\x20roster,\x20WHEN\x20(per\x20order?\x20per\x20shift?),\x20and\x20what\x20happens\x20on\x20a\x20miss\x20'+'(e.g.\x20\x22namedOperator\x20\x27delivery_team\x27\x20roster\x20is\x20written\x20per\x20order\x20by\x20the\x20dispatch\x20keeper\x20via\x20permission\x20221;\x20an\x20unassigned\x20order\x20'+'waits\x20until\x20the\x20keeper\x20assigns\x20a\x20courier\x22).\x20K-4\x20stance:\x20dispatch\x20assignment\x20is\x20an\x20OFF-CHAIN\x20keeper\x20optimization,\x20never\x20a\x20chain\x20scheduler'});}return i['push']({'op':'create','id':'machine','object':'machine','params':P({'name':b+'_machine','permission':ref('permission'),'nodes':n})}),i['push']({'op':'publish','id':'machine_publish','target':ref('machine'),'preflight':[{'check':'machine_publish','status':'pending'},{'check':'TASKBIND-01','status':'pending'}]}),{'steps':i,'blockers':j};}export function emitServiceConfigure({guardSpecs:a,needsRepository:b}){const c=[],d=a['find'](e=>e['host']==='service'&&e['key']==='buy');return c['push']({'op':'configure','id':'service_machine','target':ref('service'),'method':'machine','params':ref('machine'),'requires':['machine_publish']}),b&&c['push']({'op':'configure','id':'service_repository','target':ref('service'),'method':'repositories','params':P({'op':'add','objects':[ref('repository')]}),'requires':['service','repository']}),d?.['step_id']!==undefined&&c['push']({'op':'configure','id':'service_buy_guard','target':ref('service'),'method':'buy_guard','params':ref(d['step_id']),'requires':['service',d['step_id']]}),{'steps':c};}export function emitAllocators({template:a,base:b,inputs:c,rowsWithAttachments:d,resolvedGuards:e,specByKey:f}){const h=[],i=d['length']>0x0?d:[{'track':'settlement','recipient':a['allocator']['recipient']==='fixed'?'entity':a['allocator']['recipient'],'recipient_key':a['allocator']['recipient_key'],'mode':a['allocator']['mode'],'value':a['allocator']['mode']==='rate'?0x2710:a['allocator']['mode']==='surplus'?'0':undefined}],j=[],k=new Map();for(const n of i){if(n['guard_key']!==undefined){let o=k['get'](n['guard_key']);o===undefined&&(o={'key':n['guard_key'],'rows':[]},k['set'](n['guard_key'],o),j['push'](o)),o['rows']['push'](n);}else j['push']({'rows':[n]});}const l=[],m=new Set();for(const p of j){const q=[];let r;for(const w of p['rows']){let x=w['value'];x===undefined&&w['value_from']!==undefined&&(x=c[w['value_from']]??a['fee_params'][w['value_from']]);if(x===undefined&&w['value_from_complement']!==undefined){const A=w['value_from_complement'],B=c[A]??a['fee_params'][A],C=typeof B==='number'?B:typeof B==='string'&&/^\d+(?:\.\d+)?$/['test'](B['trim']())?Number(B):undefined;if(w['mode']!=='rate'){h['push']({'code':'ALLOCATOR_COMPLEMENT_INVALID','detail':'allocator\x20row\x20('+w['track']+'/'+(w['recipient_key']??w['recipient'])+')\x20declares\x20value_from_complement\x20\x27'+A+'\x27\x20but\x20'+('mode\x20\x27'+w['mode']+'\x27\x20—\x20the\x20complement\x20is\x20RATE-domain\x20only\x20(10000\x20-\x20bps).\x20Use\x20value/value_from\x20for\x20Amount\x20rows.')});continue;}if(C===undefined||!Number['isFinite'](C)||C<0x0||C>0x2710){h['push']({'code':'ALLOCATOR_COMPLEMENT_INVALID','detail':'allocator\x20row\x20('+w['track']+'/'+(w['recipient_key']??w['recipient'])+')\x20value_from_complement\x20\x27'+A+'\x27\x20resolves\x20to\x20'+('\x27'+String(B)+'\x27\x20—\x20not\x20a\x20bps\x20value\x20in\x20[0,\x2010000];\x20the\x20complement\x20leg\x20cannot\x20be\x20computed.')});continue;}x=0x2710-C;}if(x===undefined&&w['mode']!=='surplus'){h['push']({'code':'ALLOCATOR_VALUE_MISSING','detail':'allocator\x20row\x20('+w['track']+'/'+w['recipient']+')\x20has\x20neither\x20value\x20nor\x20a\x20resolvable\x20value_from'});continue;}(w['fix']!==undefined||w['fix_from']!==undefined)&&h['push']({'code':'ALLOCATOR_FIX_UNSUPPORTED','detail':'allocator\x20row\x20('+w['track']+'/'+w['recipient']+')\x20declares\x20fix/fix_from\x20—\x20the\x20chain\x20has\x20no\x20holdback\x20'+'parameter:\x20fix\x20is\x20computed\x20on-chain\x20as\x20the\x20sum\x20of\x20the\x20Amount\x20legs\x20and\x20those\x20legs\x20are\x20PAID\x20'+'in\x20full\x20at\x20release,\x20and\x20the\x20allocator-registration\x20call\x20surface\x20(guard,\x20sharing,\x20max)\x20has\x20no\x20fix\x20'+'argument,\x20so\x20this\x20value\x20never\x20reaches\x20the\x20chain.\x20To\x20keep\x20funds\x20in\x20the\x20pool,\x20do\x20not\x20distribute\x20them\x20'+'(a\x20separate\x20Allocation\x20object,\x20or\x20a\x20later\x20guard-gated\x20allocator);\x20to\x20combine\x20fixed\x20fees\x20with\x20a\x20'+'proportional\x20split,\x20use\x20explicit\x20Amount\x20legs\x20plus\x20Rate\x20legs\x20summing\x2010000.'});r??=w['note'];let y;if(w['recipient']==='entity'){const D=w['recipient_key']??'merchant';m['add'](D),y={'Entity':{'name_or_address':{'$late':{'by':'local_name','mark':D}}}};}else{if(w['recipient']==='guard_identifier'){const E=Number(w['recipient_key']??0x0);y={'GuardIdentifier':E};const F=p['key']!==undefined?e['get'](p['key']):undefined;if(F!==undefined){const G=F['table']['find'](H=>H['identifier']===E);(G===undefined||G['b_submission']!==!![]||G['value_type']!=='Address')&&h['push']({'code':'GUARD_SLOT_UNKNOWN','detail':'allocator\x20leg\x20{GuardIdentifier:\x20'+E+'}\x20on\x20guard\x20\x27'+p['key']+'\x27\x20of\x20\x27'+b+'\x27:\x20the\x20bound\x20'+('Guard\x20table\x20has\x20no\x20slot\x20'+E+'\x20Address\x20submission\x20row\x20(b_submission:\x20true).\x20On\x20chain\x20the\x20leg\x20')+('reads\x20slot\x20'+E+'\x20as\x20its\x20payee\x20and\x20asserts\x20it\x20equals\x20the\x20paying\x20order\x20')+'(payment_info.for_object)\x20—\x20an\x20undeclared\x20or\x20STATIC\x20slot\x20aborts\x20at\x20alloc\x20time\x20with\x20code\x2015\x20'+'(ERECIPIENT_NOT_FOR_OBJECT)\x20and\x20the\x20leg\x27s\x20funds\x20stranded\x20'+'(az3/abnb7\x20mainnet\x20261013:\x20static\x20GuardIdentifier\x20legs\x20bricked\x20every\x20refund\x20rail).\x20'+'Guard/allocators/forwards\x20are\x20all\x20publish-frozen.\x20Declare\x20'+('{identifier:\x20'+E+',\x20b_submission:\x20true,\x20value_type:\x20\x22Address\x22}\x20in\x20the\x20Guard\x20table\x20')+'(templates\x20anchor\x20refund\x20rails\x20on\x20user\x20slot\x200\x20and\x20submit\x20the\x20Order\x20address\x20there).\x20Protocol\x20'+'slot\x20254\x20is\x20the\x20task-binding/once\x20slot:\x20naming\x20it\x20as\x20the\x20payee\x20arms\x20once-per-order,\x20so\x20a\x20'+'second\x20fire\x20aborts\x20E_ONCE_TRIGGERED\x20(16).'});}}else y='Signer';}const z=typeof x==='number'?x===0x0:typeof x==='string'&&/^\s*0+(?:\.0+)?\s*$/['test'](x);q['push']({'who':y,'sharing':String(x??'0'),'mode':MODE_MAP[w['mode']],'zeroEntityRate':w['recipient']==='entity'&&w['mode']==='rate'&&z});}const s=q['filter'](H=>H['zeroEntityRate']),t=s['length']>0x0&&s['length']<q['length']?q['filter'](H=>!H['zeroEntityRate']):q,u=t['map'](H=>({'who':H['who'],'sharing':H['sharing'],'mode':H['mode']}));if(u['length']===0x0)continue;if(t['length']>0x0&&t['every'](H=>H['mode']==='Rate')){const H=t['map'](I=>/^\d+$/['test'](I['sharing']['trim']())?Number(I['sharing']):Number['NaN']);if(H['every'](I=>Number['isFinite'](I))){const I=H['reduce']((J,K)=>J+K,0x0);if(I!==0x2710){const J=K=>{if(typeof K==='string')return K;const L=K;if(L['GuardIdentifier']!==undefined)return'GuardIdentifier('+String(L['GuardIdentifier'])+')';const M=L['Entity']?.['name_or_address']?.['$late']?.['mark'];return M!==undefined?'Entity('+M+')':JSON['stringify'](K);};h['push']({'code':'RATE_SUM_INVALID','detail':'Rate\x20group\x20\x27'+(p['key']??p['rows'][0x0]['track']+'/signer')+'\x27\x20sums\x20to\x20'+I+'\x20bps,\x20not\x2010000\x20'+('('+t['map'](K=>J(K['who'])+'='+K['sharing'])['join']('\x20+\x20')+').\x20The\x20chain\x20aborts\x20the\x20')+'allocator\x20with\x20ERATE_NOT_10000\x20at\x20apply\x20time,\x20when\x20the\x20plan\x20is\x20already\x20publish-frozen\x20—\x20fix\x20'+'the\x20split\x20now:\x20the\x20legs\x20of\x20one\x20guard_key\x20must\x20add\x20up\x20to\x20the\x20whole\x20pool\x20(a\x20two-party\x20split\x20'+'leaves\x20the\x20remainder\x20to\x20value_from_complement,\x20never\x20to\x20a\x20guessed\x20literal).'});}}}const v=p['key']!==undefined?f['get'](p['key'])?.['step_id']:undefined;p['key']!==undefined&&!f['has'](p['key'])&&h['push']({'code':'GUARD_KEY_UNKNOWN','detail':'allocator\x20row\x20('+p['rows'][0x0]['track']+')\x20binds\x20unknown\x20guard_key\x20\x27'+p['key']+'\x27'}),l['push']({...v!==undefined?{'guard':ref(v)}:{},...p['key']!==undefined?{'guard_key':p['key']}:{},'track':p['rows'][0x0]['track'],'sharing':u,...r!==undefined?{'note':r}:{}});}return{'rows':i,'rowGroups':j,'allocatorRows':l,'externalMarks':m,'blockers':h};}export function checkAllocatorRails({rowGroups:a,resolvedGuards:b,shape:c,recoverTwinRails:d,declares:e}){const g=[],h=a['map'](j=>{if(j['key']===undefined)return undefined;const k=b['get'](j['key']);return{'key':j['key'],'track':j['rows'][0x0]['track'],'table':k?.['table']??[],'root':k?.['root'],'recoverTwin':d['has'](j['key'])};})['filter'](j=>j!==undefined),i=[];if(h['length']>0x0){const j=verifyAllocatorRails(h,c['map'](m=>({'name':m['name'],'semanticRole':m['semantic_role'],'fromNodes':(m['from']??[])['map'](o=>typeof o==='string'?o:o['prev'])['filter'](o=>typeof o==='string'&&o!=='')})),{'declaredKeys':new Set(e['keys']())}),k=a['map'](m=>m['key'])['filter'](m=>m!==undefined&&!b['has'](m)),l=k['length']>0x0?'\x20UNRESOLVED\x20ALLOCATOR\x20GUARD\x20REFS\x20(likely\x20the\x20real\x20cause\x20—\x20these\x20guard_keys\x20match\x20no\x20resolved\x20guard,\x20e.g.\x20a\x20name\x20typo):\x20'+k['join'](',\x20')+'.':'';for(const m of j){if(m['level']==='info'&&m['railKey']!==undefined&&e['has'](m['railKey'])){i['push']('merchant-declared\x20exemption:\x20rail\x20\x27'+m['railKey']+'\x27\x20ships\x20without\x20a\x20caller\x20identity\x20leg\x20—\x20'+e['get'](m['railKey']));continue;}m['level']==='critical'&&g['push']({'code':m['code'],'detail':m['detail']+l});}}return{'blockers':g,'disclosures':i};}export function emitServiceAllocators({template:a,inputs:b,allocatorRows:c}){const d=[];return d['push']({'op':'configure','id':'service_allocators','target':ref('service'),'method':'order_allocators','params':P({'description':a['allocator']['description'],'threshold':Number(b['threshold']??b['monthly_rent_amount']??a['fee_params']['threshold']??a['fee_params']['monthly_rent_amount']??0x0)||0x0,'allocators':c}),'requires':['machine_publish']}),{'steps':d};}export function emitSales({inputs:a}){const b=[],c=[];if(Array['isArray'](a['sales'])&&a['sales']['length']>0x0){for(const d of a['sales']){const e=numericAmount(d?.['price']);e===0x0&&c['push']({'code':'SALE_ZERO_PRICE','detail':'sales\x20SKU\x20\x27'+String(d?.['name']??'?')+'\x27\x20lists\x20price\x20\x220\x22\x20—\x20a\x20zero-priced\x20'+'LISTING\x20is\x20refused\x20(E_ZERO_TOTAL_ORDER=42:\x20a\x20zero-total\x20order\x20carries\x20an\x20empty\x20'+'escrow\x20and\x20nothing\x20to\x20settle).\x20The\x20sanctioned\x20free\x20tier:\x20price\x20the\x20SKU\x20at\x201\x20smallest\x20unit\x20'+'(the\x20minimum\x20buyable\x20price),\x20or\x20deliver\x20it\x20outside\x20the\x20sales\x20rails.'});}b['push']({'op':'configure','id':'service_sales','target':ref('service'),'method':'sales','params':{'op':'add','sales':a['sales']}});}return{'steps':b,'blockers':c};}export function emitReviewComponent({template:a,inputs:b,reviewMode:c,shape:d,guardSpecs:f,resolvedGuards:g,specByKey:h}){const i=[],j=[],k=[];if(c!=='none'){const l=d['some'](v=>/review/i['test'](v['name']));c==='review'&&!l&&k['push']({'code':'REVIEW_NODE_MISSING','detail':'review_mode\x20\x27'+c+'\x27\x20declares\x20the\x20buyer\x20review\x20reputation\x20rail,\x20but\x20machine_shape\x20has\x20no\x20'+'\x27reviewed\x27\x20node.\x20Add\x20a\x20buyer-advanced\x20review\x20node\x20(operator\x20order_payer)\x20with\x20an\x20EXIT\x20edge\x20back\x20to\x20the\x20'+'settlement\x20rail\x20(R-DEAD-END:\x20a\x20zero-exit\x20review\x20node\x20strands\x20the\x20escrow),\x20or\x20anchor\x20the\x20claim\x20on\x20the\x20'+'delivered\x20terminal\x20via\x20a\x20host:\x22reward\x22\x20guard\x20(review_mode\x20\x22review_reward\x22\x20variant).'});const m=f['find'](v=>v['host']==='reward'),o=v=>{const w=new Set(),x=v!==undefined?g['get'](v):undefined;if(x===undefined)return w;const y=new Map();for(const A of x['table']){typeof A['identifier']==='number'&&typeof A['value']==='string'&&y['set'](A['identifier'],A['value']);}const z=B=>{if(Array['isArray'](B)){for(const D of B)z(D);return;}if(B===null||typeof B!=='object')return;const C=B;if(Array['isArray'](C['nodes'])){const [E,F]=C['nodes'];if(E?.['query']==='progress.current'&&typeof F?.['identifier']==='number'){const G=y['get'](F['identifier']);if(G!==undefined)w['add'](G);}z(C['nodes']);}};return z(x['root']),w;},p=d['find'](v=>/review/i['test'](v['name']))?.['name'];let q,s,t=[];if(p!==undefined){const v=[];for(const E of d){for(const F of E['from']??[]){const G=typeof F==='string'?{'prev':F,'guard_key':undefined}:F;v['push']({'prev':G['prev'],'guard_key':G['guard_key'],'target':E['name']});}}const w=v['filter'](H=>H['target']===p&&H['prev']!=='');t=[...new Set(w['map'](H=>H['prev']))];const x=[...new Set(w['flatMap'](H=>H['guard_key']!==undefined?[H['guard_key']]:[]))],y=x['length']===0x1?x[0x0]:x['length']===0x0?v['find'](H=>H['prev']===p&&H['guard_key']!==undefined)?.['guard_key']:undefined,z=o(y),A=z['size']===0x0||z['size']===0x1&&t['length']===0x1&&t[0x0]===[...z][0x0],B=A?y:undefined,C=B!==undefined?h['get'](B):undefined,D=C?.['template_id']==='tpl_review_submit_content_gate';q=D?undefined:C?.['step_id'],s=D?undefined:B;}if(q===undefined){const H=[...new Set([...d['filter'](O=>/review/i['test'](O['name'])||O['semantic_role']==='final')['map'](O=>O['name']),...t])],I={'type':'logic_or','nodes':[{'type':'logic_equal','nodes':[{'type':'query','query':'order.owner','object':{'identifier':0x0},'parameters':[]},{'type':'context','context':'Signer'}]},{'type':'query','query':'order.agent\x20has','object':{'identifier':0x0},'parameters':[{'type':'context','context':'Signer'}]}]},J={'type':'logic_equal','nodes':[{'type':'query','query':'order.service','object':{'identifier':0x0},'parameters':[]},{'type':'identifier','identifier':0x1}]},K=H['map']((O,Q)=>({'type':'logic_equal','nodes':[{'type':'query','query':'progress.current','object':{'identifier':0x0,'convert_witness':'OrderProgress'},'parameters':[]},{'type':'identifier','identifier':0x2+Q}]})),L=K['length']===0x1?K[0x0]:K['length']>0x1?{'type':'logic_or','nodes':K}:undefined,M=d['find'](O=>O['semantic_role']==='delivered'&&!/review/i['test'](O['name']))?.['name'],N=M===undefined?undefined:{'type':'logic_as_u256_greater_or_equal','nodes':[{'type':'query_progress_history_find','object':{'identifier':0x0,'convert_witness':'OrderProgress'},'where':{'nextNode':M},'find':'last'},{'type':'identifier','identifier':0x2+H['length']}]};i['push']({'op':'create','id':'guard_review_write','object':'guard','params':P({'description':'Review\x20write\x20credential\x20(AR-3,\x20kernel-emitted):\x20the\x20signer\x20owns\x20or\x20administers\x20an\x20order\x20of\x20THIS\x20service'+(L!==undefined?',\x20anchored\x20on\x20the\x20order\x20having\x20reached\x20'+H['join']('\x20/\x20'):'')+(N!==undefined?',\x20and\x20the\x20order\x20must\x20have\x20ENTERED\x20the\x20\x27'+M+'\x27\x20node\x20at\x20least\x20once\x20(history\x20probe\x20—\x20a\x20never-delivered\x20order\x20cannot\x20write\x20the\x20rating\x20row,\x20ksk4\x20F-04).\x20':'.\x20')+'Gates\x20the\x20\x27review\x27\x20and\x20\x27rating\x27\x20policies\x20of\x20the\x20plan-created\x20review\x20repository\x20—\x20reads\x20nothing\x20from\x20that\x20repository,\x20so\x20the\x20write\x20path\x20is\x20satisfiable\x20by\x20construction\x20(no\x20credential\x20cycle).','table':[{'identifier':0x0,'b_submission':!![],'value_type':'Address','name':'order_being_reviewed'},{'identifier':0x1,'b_submission':![],'value_type':'Address','value':ref('service'),'name':'this_service'},...H['map']((O,Q)=>({'identifier':0x2+Q,'b_submission':![],'value_type':'String','value':O})),...N!==undefined?[{'identifier':0x2+H['length'],'b_submission':![],'value_type':'U64','value':'0'}]:[]],'root':{'type':'logic_and','nodes':[...L!==undefined?[L]:[],...N!==undefined?[N]:[],I,J]}}),'notes':'AR-3\x20review\x20write\x20credential\x20(service\x20pinned\x20by\x20plan\x20ref\x20—\x20survives\x20permission\x20rotation).\x20The\x20buyer\x20writes\x20both\x20rows\x20at\x20review\x20time:\x20repository.data_add\x20{name:\x27review\x27|\x27rating\x27,\x20items:[{write_guard:\x27<this\x20guard>\x27,\x20data:[{id:<order\x20address>,\x20data:<stars/text>}]}]}\x20with\x20a\x20passport\x20submission\x20carrying\x20the\x20order.\x20Ordering\x20(F-05):\x20repository_review\x27s\x20create\x20is\x20EARLY\x20(pre-wave,\x20unguarded);\x20THIS\x20credential\x20exists\x20before\x20the\x20repository_review_write_guards\x20configure\x20step\x20that\x20freezes\x20the\x20credential\x20ref\x20(HOST-GRAPH-01).'}),q='guard_review_write',s='review_write';}const u=b['review_decision_enabled']===!![]&&c==='review_reward'&&m?.['step_id']!==undefined&&q!==undefined;u&&i['push']({'op':'create','id':'guard_review_decision','object':'guard','params':P({'description':'Merchant\x20review-decision\x20write\x20credential:\x20only\x20the\x20service\x20provider\x20(permission\x20owner\x20or\x20admin)\x20may\x20write\x20U64\x20decision\x20rows\x20(row\x20id\x20=\x20order\x20address,\x20value\x20=\x20approved\x20payout)\x20under\x20the\x20review\x20repository\x27s\x20\x27review_decision\x27\x20policy.','table':[{'identifier':0x0,'b_submission':!![],'value_type':'Address','name':'order_being_approved'},{'identifier':0x1,'b_submission':![],'value_type':'Address','value':ref('service'),'name':'this_service'},{'identifier':0x2,'b_submission':!![],'value_type':'Address','name':'service_permission'}],'root':{'type':'logic_and','nodes':[{'type':'logic_equal','nodes':[{'type':'query','query':'order.service','object':{'identifier':0x0},'parameters':[]},{'type':'identifier','identifier':0x1}]},{'type':'logic_equal','nodes':[{'type':'query','query':'service.permission','object':{'identifier':0x1},'parameters':[]},{'type':'identifier','identifier':0x2}]},{'type':'logic_or','nodes':[{'type':'logic_equal','nodes':[{'type':'query','query':'permission.owner','object':{'identifier':0x2},'parameters':[]},{'type':'context','context':'Signer'}]},{'type':'query','query':'permission.admin\x20has','object':{'identifier':0x2},'parameters':[{'type':'context','context':'Signer'}]}]}]}}),'notes':'REVIEW-DECISION\x20write\x20credential\x20(allocator\x20dynamic-permission\x20shape,\x20service\x20pinned\x20by\x20plan\x20ref\x20—\x20survives\x20permission\x20rotation).\x20The\x20decision\x20write\x20itself:\x20repository.data_add\x20'+'{name:\x27review_decision\x27,\x20items:[{write_guard:\x27<this\x20guard>\x27,\x20data:[{id:<order\x20address>,\x20data:<approved\x20payout\x20U64>}]}]}\x20with\x20a\x20passport\x20submission\x20carrying\x20the\x20order\x20and\x20the\x20permission.'});if(q!==undefined){const O=[{'guard':ref(q)}];i['push']({'op':'configure','id':'repository_review_write_guards','target':ref('repository_review'),'method':'policies','params':P({'op':'add','policy':[{'name':'review','description':'One\x20immutable\x20row\x20per\x20ORDER\x20(id_from=None;\x20row\x20id\x20=\x20the\x20order\x20address\x20—\x20F09\x20yfd-ln-261024:\x20a\x20repeat\x20buyer\x20must\x20be\x20able\x20to\x20review\x20every\x20order;\x20the\x20old\x20Signer-keyed\x20row\x20made\x20order\x20#2\x20unwritable).\x20Write-once\x20—\x20a\x20rewrite\x20attempt\x20aborts\x20on-chain,\x20K3(a).\x20Writes\x20require\x20the\x20review\x20credential\x20(guard\x20key\x20\x27'+s+'\x27).\x20Payload:\x20JSON\x20text\x20{rating,\x20tags?,\x20orderRef?}.','write_guard':O,'id_from':'none','value_type':'String','write_once':!![]},{'name':'rating','description':'Order-keyed\x20numeric\x20rating\x20(F-62):\x20one\x20U64\x20row\x20per\x20ORDER\x20(id_from=None;\x20row\x20id\x20=\x20the\x20order\x20address;\x20value\x20=\x20stars,\x20e.g.\x201..5;\x20write-once\x20—\x20a\x20rewrite\x20attempt\x20aborts\x20on-chain,\x20K3(a)).\x20Writes\x20require\x20the\x20same\x20review\x20credential\x20as\x20the\x20\x27review\x27\x20text\x20policy\x20—\x20a\x20verified\x20completed-order\x20buyer.\x20This\x20—\x20not\x20the\x20\x27review\x27\x20text\x20row\x20(same\x20order\x20key,\x20String\x20payload)\x20—\x20is\x20the\x20row\x20a\x20reward\x20good-review\x20leg\x20must\x20query\x20(query\x20repository.data:\x20the\x20policy-name\x20row\x20+\x20the\x20order-address\x20identifier\x20row,\x20compared\x20against\x20the\x20rating\x20floor).\x20The\x20text\x20row\x20is\x20display;\x20this\x20row\x20is\x20payout\x20authority.','write_guard':O,'id_from':'none','value_type':'U64','write_once':!![]},...u?[{'name':'review_decision','description':'Merchant\x20approval\x20ledger\x20for\x20the\x20review\x20bounty\x20(professional\x20form):\x20one\x20U64\x20row\x20per\x20order\x20(id_from=None;\x20row\x20id\x20=\x20the\x20order\x20address;\x20value\x20=\x20approved\x20payout\x20in\x20smallest\x20units).\x20A\x20row\x20whose\x20value\x20>=\x20the\x20promised\x20payout\x20IS\x20the\x20approval\x20the\x20claim\x20guard\x27s\x20decision\x20leg\x20reads\x20(tpl_repository_review_decision_gate).\x20Writes\x20REQUIRE\x20the\x20merchant\x20decision\x20credential\x20(guard\x20step\x20\x27guard_review_decision\x27);\x20buyers\x20hold\x20no\x20write\x20path.','write_guard':[{'guard':ref('guard_review_decision')}],'id_from':'none','value_type':'U64'}]:[]]}),'requires':['repository_review',q,...u?['guard_review_decision']:[]],'notes':'F-BS5-03\x20(bst5-mn-261101):\x20the\x20credential-bound\x20and\x20ONLY\x20forms\x20of\x20the\x20review\x20repository\x27s\x20\x27review\x27/\x27rating\x27\x20policies\x20—\x20the\x20early\x20create\x20(pre-wave)\x20cannot\x20carry\x20them\x20(an\x20id_from=none\x20policy\x20without\x20a\x20write_guard\x20aborts\x20the\x20create\x20on-chain:\x20the\x20chain\x20requires\x20a\x20non-empty\x20write_guard\x20on\x20the\x20create\x20path\x20too),\x20so\x20they\x20land\x20here\x20now\x20that\x20the\x20credential\x20guards\x20exist.\x20The\x20buyer\x20writes\x20BOTH\x20rows\x20at\x20review\x20time\x20(repository.data_add\x20{name:\x27rating\x27,\x20items:[{data:[{id:<order\x20address>,\x20data:<stars>}]}]}\x20with\x20the\x20same\x20passport\x20as\x20the\x20forward);\x20a\x20good-review\x20bounty\x20claim\x20guard\x20must\x20query\x20the\x20order-keyed\x20U64\x20\x27rating\x27\x20row,\x20never\x20the\x20text\x20row.'+(u?'\x20[review_decision\x27s\x20write\x20credential\x20frozen\x20AFTER\x20guard_review_decision\x20—\x20HOST-GRAPH-01\x20discipline.]':'')}),i['push']({'op':'configure','id':'service_review_repository','target':ref('service'),'method':'repositories','params':P({'op':'add','objects':[ref('repository_review')]}),'requires':['service','repository_review']});}if(c==='review_reward'){const Q=m;if(Q===undefined||Q['step_id']===undefined)k['push']({'code':'REVIEW_REWARD_GUARD_MISSING','detail':'review_mode\x20\x27review_reward\x27\x20promises\x20a\x20claim\x20reward,\x20but\x20no\x20RESOLVED\x20host:\x22reward\x22\x20guard\x20spec\x20'+'exists\x20to\x20gate\x20the\x20claim.\x20Mount\x20a\x20reward\x20claim\x20guard\x20(e.g.\x20pattern.progress_state_check\x20anchored\x20'+'on\x20the\x20review\x20node\x20or\x20the\x20delivered\x20terminal\x20+\x20review\x20evidence\x20hash)\x20and\x20keep\x20it\x20resolvable\x20—\x20'+'an\x20unguarded\x20incentive\x20promise\x20must\x20not\x20publish\x20(INV-4).\x20The\x20root\x20must\x20also\x20carry\x20the\x20BKN-P2\x20'+'positive-amount\x20leg\x20(order.amount\x20>=\x201)\x20so\x20zero-total\x20orders\x20can\x20never\x20claim.'});else{const R=b['reward_funding'],S=Q['params']?.['reward_claim_amount'];let T=S!==undefined&&S!==null?S:b['reward_claim_amount'],U='';if(T===undefined){const a0=b['review_reward_per_claim'];a0!==undefined&&a0!==null&&Number(a0)>0x0&&(T=a0,U='input\x20review_reward_per_claim');}if(T===undefined){const a1=a['fee_params']?.['review_reward_per_claim'];typeof a1==='number'&&a1>0x0&&(T=a1,U='template\x20fee_param\x20review_reward_per_claim\x20(override\x20with\x20the\x20reward_claim_amount\x20input)');}if(T===undefined){const a2=lowestSalePrice(b['sales']);a2!==undefined&&(T=String(Math['max'](Math['floor'](a2*0.02),0x1)),U='derived:\x202%\x20of\x20the\x20cheapest\x20SKU\x20('+a2+'\x20smallest\x20units),\x20floored\x20at\x201\x20(T-02)');}let V='';if(T!==undefined){const a3=numericAmount(String(T)),a4=lowestSalePrice(b['sales']);if(a3!==undefined&&a4!==undefined&&a4>0x0&&a3>0.5*a4){const a5=numericAmount(String(b['reward_funding']??'')),a6=a5!==undefined&&a3>0x0?'\x20the\x20reward_funding\x20pool\x20covers\x20~'+Math['floor'](a5/a3)+'\x20claim(s)':'';V='\x20⚠\x20T-02\x20SCALE:\x20the\x20per-claim\x20bounty\x20('+a3+')\x20exceeds\x20half\x20the\x20cheapest\x20SKU\x20price\x20('+a4+')\x20—\x20'+('each\x20claimed\x20order\x20pays\x20out\x20more\x20than\x20the\x20sale\x20earns;\x20a\x20low-price\x20SKU\x20makes\x20the\x20rail\x20a\x20bounty-farm\x20target.'+a6);}}const W=g['get'](Q['key']);W!==undefined&&!rootHasRewardRecordGate(W['root'])&&k['push']({'code':'REVIEW_REWARD_UNARMED','detail':'review_reward\x20claim\x20guard\x20\x27'+Q['key']+'\x27\x20carries\x20no\x20record-gate:\x20Reward.claim\x20has\x20no\x20order\x20binding\x20of\x20its\x20own\x20'+'(OFN-C1),\x20so\x20a\x20funded\x20pool\x20behind\x20this\x20guard\x20is\x20a\x20replay-drain\x20target.\x20'+SV2_UNARMED_PRESCRIPTION+'\x20—\x20wrapped\x20in\x20'+'logic_and\x20with\x20the\x20identity\x20leg\x20(Signer\x20==\x20order.owner),\x20the\x20BKN-P2\x20positive-amount\x20'+'leg\x20(order.amount\x20>=\x201\x20—\x20zero-total\x20orders\x20must\x20never\x20claim)\x20and\x20the\x20existing\x20checks\x20'+'(see\x20tpl_reward_one_time_claim\x20v55\x20notes;\x20guard-risk\x20R-X1-14\x20audits\x20the\x20built\x20guard).\x20'+'Professional\x20approval\x20form\x20(F10\x20opt-in):\x20set\x20review_decision_enabled=true\x20to\x20have\x20this\x20'+'plan\x20emit\x20the\x20decision\x20channel\x20(guard\x20step\x20\x27guard_review_decision\x27\x20+\x20the\x20repository\x27s\x20'+'\x27review_decision\x27\x20policy),\x20then\x20compose\x20the\x20decision\x20leg\x20from\x20'+'tpl_repository_review_decision_gate\x20into\x20the\x20root\x20(find_where\x20over\x20\x27review_decision\x27\x20'+'with\x20vec_contains_address\x20pinning\x20the\x20submitted\x20order)\x20so\x20the\x20bounty\x20pays\x20only\x20'+'merchant-approved\x20orders.\x20'+'Until\x20armed,\x20do\x20not\x20fund\x20the\x20pool.'});let X;if(W!==undefined&&rootHasRewardRecordGate(W['root']))for(const a7 of W['table']){const a8=a7;if(a8['b_submission']===!![]&&String(a8['value_type']??'')['toLowerCase']()==='address'&&(String(a8['object_type']??'')==='Order'||/order/i['test'](String(a8['name']??'')))){X=a8['identifier'];break;}}const Y=Q['params']?.['evidence']??b['review_claim_evidence'];let Z;if(Y!==undefined&&Y!==null&&typeof Y==='object'){const a9=Y,aa=toByteVector(a9['key']),ab=toByteVector(a9['predicate']);aa!==undefined&&ab!==undefined&&(X===undefined?k['push']({'code':'REVIEW_REWARD_EVIDENCE_NO_STAMP','detail':'review_reward\x20resolved\x20an\x20evidence\x20binding\x20request,\x20but\x20the\x20claim\x20guard\x20mount\x20carries\x20no\x20'+'store_from_id\x20stamp\x20slot\x20—\x20the\x20evidence\x20binding\x20reads\x20THE\x20store_from\x20row\x20(the\x20submitted\x20'+'Order\x20address),\x20so\x20the\x20chain\x20refuses\x20the\x20guard\x20at\x20build\x20time\x20(reward::evidence_bind,\x20'+'E_EVIDENCE_NEEDS_STORE_FROM).\x20Give\x20the\x20claim\x20guard\x27s\x20table\x20an\x20address-typed\x20Order\x20'+'submission\x20row\x20(b_submission)\x20so\x20the\x20mount\x20can\x20pin\x20store_from_id,\x20then\x20rebuild.'}):Z={'repo':ref('repository_review'),'key':aa,'predicate':ab});}T===undefined&&k['push']({'code':'REVIEW_REWARD_AMOUNT_MISSING','detail':'review_mode\x20\x27review_reward\x27\x20resolved\x20a\x20claim\x20guard\x20but\x20no\x20per-claim\x20bounty\x20was\x20provided\x20or\x20derivable.\x20'+'The\x20reward\x20guard_add\x20mount\x20REQUIRES\x20an\x20amount\x20(schema-required)\x20—\x20a\x20plan\x20step\x20emitted\x20without\x20'+'it\x20fails\x20mid-execution.\x20Pass\x20\x27reward_claim_amount\x27\x20(a\x20display\x20string\x20with\x20the\x20token\x20'+'symbol\x20like\x20\x271WOW\x27,\x20or\x20a\x20smallest-unit\x20integer\x20like\x20\x27100000000\x27),\x20set\x20it\x20in\x20the\x20guard\x20'+'spec\x27s\x20params,\x20or\x20include\x20a\x20parseable\x20sales\x20catalog\x20(inputs.sales\x20with\x20numeric\x20prices)\x20so\x20the\x20'+'T-02\x20default\x20applies\x20(2%\x20of\x20the\x20cheapest\x20SKU,\x20floored\x20at\x201\x20smallest\x20unit).'}),i['push']({'op':'configure','id':'reward_review_guard_add','target':ref('reward_review'),'method':'guard_add','params':P({'guard':ref(Q['step_id']),'recipient':{'Signer':'signer'},...T!==undefined?{'amount':{'type':'Fixed','value':String(T)}}:{},...X!==undefined?{'store_from_id':X}:{},...Z!==undefined?{'evidence':Z}:{}}),'requires':['reward_review'],'notes':'RECIPIENT\x20(crs-mn-261015\x20F-12):\x20recipient\x20is\x20pinned\x20to\x20{Signer:\x27signer\x27}\x20—\x20the\x20claim\x20entry\x20'+'requires\x20recipient\x20==\x20the\x20transaction\x20sender\x20(E_CLAIM_RECIPIENT_NOT_SIGNER\x20otherwise);\x20a\x20GuardIdentifier\x20recipient\x20'+'resolves\x20to\x20the\x20submitted\x20Order\x20and\x20can\x20never\x20be\x20paid.'+(T!==undefined?'\x20AMOUNT\x20(BK15-F09):\x20per-claim\x20bounty\x20pinned\x20at\x20plan\x20time\x20('+String(T)+')'+(U?'\x20—\x20'+U+';\x20override\x20with\x20the\x20reward_claim_amount\x20input':'')+'\x20—\x20no\x20execution-time\x20fill\x20needed.'+V:'')+(X!==undefined?'\x20SV-2\x20entry\x20stamp:\x20store_from_id\x20pins\x20the\x20per-order\x20stamp\x20slot\x20(the\x20submitted\x20Order\x20'+'address)\x20so\x20claim\x20records\x20key\x20per\x20order\x20—\x20once\x20per\x20buyer\x20per\x20order\x20(azx7-mn-261014\x20T8).':'')+(Z!==undefined?'\x20EVIDENCE\x20(ksk9d2-tn-261026\x20F-01):\x20the\x20guard\x20carries\x20an\x20evidence\x20binding\x20—\x20at\x20claim\x20the\x20'+'chain\x20counts\x20repository\x20rows\x20under\x20the\x20binding\x27s\x20(repo,\x20key)\x20matching\x20the\x20predicate\x20for\x20'+'THIS\x20claim\x27s\x20own\x20store_from\x20value\x20(the\x20submitted\x20order)\x20and\x20aborts\x2015\x20'+'(E_EVIDENCE_NOT_OWNED)\x20when\x20none:\x20a\x20borrowed\x20foreign\x20row\x20can\x20never\x20satisfy\x20the\x20bounty;\x20'+'the\x20order\x27s\x20attestation\x20row\x20must\x20exist\x20before\x20the\x20claim.'+'\x20PACKAGE\x20AVAILABILITY\x20(ksr-tn-261026\x20Q8-F04):\x20the\x20native\x20evidence-pinning\x20entry\x20is\x20'+'UNAVAILABLE\x20on\x20the\x20currently\x20deployed\x20package\x20—\x20batch\x20guard_add\x20submissions\x20silently\x20'+'DROP\x20the\x20pin\x20and\x20the\x20direct\x20face\x20hard-fails\x20with\x20a\x20missing-entry\x20error\x20(classified\x20'+'capability_unavailable,\x20non-retryable).\x20The\x20reward\x20guard_add\x20read-back\x20contract\x20'+'reports\x20EVIDENCE\x20BINDING\x20VERIFIED\x20/\x20NOT\x20ON\x20CHAIN\x20after\x20the\x20landed\x20call\x20—\x20treat\x20NOT\x20ON\x20'+'CHAIN\x20as\x20the\x20truth:\x20fall\x20back\x20to\x20the\x20repository-floor\x20guard\x20leg\x20and\x20disclose\x20that\x20it\x20'+'proves\x20only\x20\x27a\x20qualifying\x20row\x20exists\x20for\x20this\x20order\x27,\x20not\x20who\x20wrote\x20it.\x20Do\x20not\x20'+'re-send\x20guard_add\x20to\x20\x27fix\x27\x20a\x20dropped\x20pin.':'')}),i['push']({'op':'configure','id':'service_rewards','target':ref('service'),'method':'rewards','params':P({'op':'add','objects':[ref('reward_review')]}),'requires':['service']}),typeof R==='string'||typeof R==='number'?j['push']({'op':'configure','id':'reward_review_coin_add','target':ref('reward_review'),'method':'coin_add','params':{'balance':typeof R==='number'?R:String(R)},'requires':['reward_review']}):k['push']({'code':'REVIEW_REWARD_UNFUNDED','detail':'review_mode\x20\x27review_reward\x27\x20without\x20a\x20\x27reward_funding\x27\x20input\x20(INV-4\x20R-REWARD-FUNDED):\x20the\x20incentive\x20'+'is\x20a\x20marketing\x20promise\x20that\x20must\x20be\x20FUNDED\x20when\x20the\x20Service\x20is\x20built\x20(sale-time\x20planning\x20—\x20pool\x20>=\x20'+'expected\x20orders\x20x\x20per-order\x20reward,\x20benchmark\x20fee_param\x20review_reward_pool).\x20Pass\x20reward_funding\x20'+'(smallest-unit\x20string)\x20to\x20fund\x20the\x20Reward\x20object,\x20or\x20drop\x20to\x20review_mode\x20\x22review\x22.'});}}}return{'steps':i,'fundingSteps':j,'blockers':k};}export function emitArbitrationBindings({template:a,inputs:b,needsArbitration:c,shape:d,guardSpecs:e,specByKey:f}){const g=[],h=[],i=[];if(c){g['push']({'op':'configure','id':'service_arbitrations','target':ref('service'),'method':'arbitrations','params':P({'op':'add','objects':[ref('arbitration')]})});const j=e['find'](l=>l['template_id']==='tpl_voting_guard_open_vote'&&l['step_id']!==undefined);j?.['step_id']!==undefined&&g['push']({'op':'configure','id':'arbitration_voting_guard','target':ref('arbitration'),'method':'voting_guard','params':P({'op':'set','guards':[{'guard':ref(j['step_id']),'vote_weight':{'FixedValue':0x1}}]}),...a['arbitration_mode']==='third_party'?{'account':'arb_controller'}:{}});const k=b['compensation_fund'];if(typeof k==='string'||typeof k==='number')h['push']({'op':'configure','id':'service_compensation','target':ref('service'),'method':'compensation_fund_add','params':{'balance':String(k)}});else{const l=d['some'](m=>{if(m['semantic_role']!=='final')return![];for(const o of m['from']??[]){if(typeof o==='string')continue;const p=o['guard_key']===undefined?undefined:f['get'](o['guard_key']);if(p?.['template_id']==='tpl_forward_arb_ruling_won')return!![];}return![];});l&&i['push']({'code':'COMPENSATION_FUND_REQUIRED','detail':'This\x20build\x20routes\x20a\x20POST-settlement\x20arbitration\x20re-route\x20(an\x20arb-ruling-won\x20guard\x20on\x20an\x20edge\x20'+'leaving\x20a\x20settled\x20terminal):\x20the\x20escrow\x20is\x20already\x20drained\x20when\x20that\x20ruling\x20lands,\x20so\x20the\x20buyer\x27s\x20'+'only\x20remedy\x20is\x20the\x20compensation\x20fund\x20—\x20which\x20this\x20build\x20never\x20creates.\x20Pass\x20'+'inputs.compensation_fund\x20(>=\x20the\x20largest\x20single-order\x20exposure)\x20so\x20the\x20indemnity\x20is\x20real,\x20'+'or\x20rebuild\x20on\x20a\x20template\x20without\x20the\x20post-settlement\x20arb\x20edge.'});}}return{'steps':g,'fundingSteps':h,'blockers':i};}export function emitServicePublish(){const a=[];return a['push']({'op':'publish','id':'service_publish','target':ref('service'),'preflight':[{'check':'service_publish','status':'pending'},{'check':'FUND-EXIT-01','status':'pending'},{'check':'PLAN-ALLOC-01','status':'pending'},{'check':'TASKBIND-02','status':'pending'}]}),{'steps':a};}export function computeMoneyRailKeys({rowsWithAttachments:a,guardSpecs:b}){const c=new Set(a['map'](f=>f['guard_key'])['filter'](f=>typeof f==='string')),d=new Set(b['filter'](f=>f['host']==='reward'&&f['step_id']!==undefined)['map'](f=>f['key'])),e=new Set([...c,...d]);return{'allocatorBoundKeys':c,'moneyRailKeys':e};}export function checkForeignServicePins({resolvedGuards:a,edgeBoundKeys:b,moneyRailKeys:c}){const d=[],e=/^0x[0-9a-fA-F]{20,64}$/,f=h=>{const i=a['get'](h);if(i===undefined)return[];const j=new Set(),k=m=>{if(Array['isArray'](m)){for(const o of m)k(o);return;}if(m===null||typeof m!=='object')return;const n=m;if(n['type']==='logic_equal'){const p=Array['isArray'](n['nodes'])?n['nodes']:n['left']!==undefined||n['right']!==undefined?[n['left'],n['right']]:[],s=p['find'](u=>u!==null&&typeof u==='object'&&typeof u['query']==='string'&&u['query']['startsWith']('order.service')),t=p['find'](u=>u!==s);s!==undefined&&t!==undefined&&t!==null&&typeof t==='object'&&t['type']==='identifier'&&j['add'](String(t['identifier']));}for(const u of Object['values'](n))k(u);};k(i['root']);const l=[];for(const m of i['table']){const n=m;if(n['b_submission']===!![]||n['value_type']!=='Address')continue;const o=n['value'];if(typeof o!=='string'||!e['test'](o))continue;if(!j['has'](String(n['identifier']??'?')))continue;l['push'](String(n['identifier']??'?'));}return l;};for(const g of a['keys']()){if(!b['has'](g)&&!c['has'](g))continue;for(const h of f(g)){d['push']({'code':'GUARD_FOREIGN_SERVICE','detail':'guard\x20\x27'+g+'\x27\x20pins\x20the\x20Service\x20by\x20on-chain\x20address\x20literal\x20(table\x20slot\x20'+h+'\x20on\x20an\x20'+'order.service\x20comparison\x20leg)\x20while\x20bound\x20into\x20this\x20build.\x20'+'The\x20plan\x27s\x20Service\x20is\x20created\x20BY\x20this\x20plan\x20and\x20cannot\x20equal\x20a\x20pre-existing\x20address,\x20so\x20the\x20pin\x20names\x20a\x20foreign\x20or\x20'+'stale\x20object:\x20each\x20object\x20is\x20well-formed\x20alone,\x20but\x20the\x20cross-object\x20identity\x20assert\x20aborts\x20every\x20guarded\x20forward\x20'+'(klook\x20B11\x20class),\x20and\x20Guard\x20+\x20machine\x20are\x20both\x20create/publish-frozen\x20—\x20unrepairable.\x20'+'Bind\x20by\x20plan\x20reference\x20({\x22$ref\x22:\x22service\x22})\x20or\x20by\x20the\x20P16\x20circular\x20service\x20NAME\x20instead.\x20'+'(A\x200x\x20literal\x20in\x20a\x20NON-service\x20slot\x20—\x20e.g.\x20a\x20judge\x20account\x20pin,\x20R-C4-04\x20—\x20is\x20a\x20legal\x20business\x20pin\x20and\x20not\x20flagged.)'});}}return{'blockers':d};}export function auditRepoIntegrityAndCallerLegs({steps:a,resolvedGuards:b,moneyRailKeys:c,recoverTwinRails:d}){const e=[],f=new Map(),h=new Map(),i=(v,w)=>{for(const x of w){const y=typeof x['name']==='string'?x['name']:undefined;if(y!==undefined)v['keys']['add'](y);const z=Array['isArray'](x['write_guard'])?x['write_guard']:[];for(const A of z){const B=A['guard'],C=typeof B==='string'?B:B!==null&&typeof B==='object'&&typeof B['$ref']==='string'?B['$ref']:undefined;if(C===undefined||y===undefined)continue;const D=v['writeGuards']['get'](y)??new Set();D['add'](C),v['writeGuards']['set'](y,D);}}};for(const v of a){if(v['op']!=='create'||v['object']!=='repository')continue;const w=v['params'],x={'keys':new Set(),'writeGuards':new Map()};i(x,Array['isArray'](w['policies'])?w['policies']:[]),f['set'](v['id'],x);if(typeof w['name']==='string')h['set'](w['name'],x);}for(const y of a){if(y['op']!=='configure'||y['method']!=='policies')continue;const z=y['target'],A=z!==null&&typeof z==='object'&&typeof z['$ref']==='string'?z['$ref']:undefined,B=A!==undefined?f['get'](A):undefined;if(B===undefined)continue;const C=y['params']['policy'];i(B,Array['isArray'](C)?C:[]);}const j=(D,E)=>E===undefined?undefined:D['find'](F=>F['identifier']===E),k=(D,E)=>{const F=j(D,E)?.['value'];if(F!==null&&typeof F==='object'&&typeof F['$ref']==='string')return f['get'](F['$ref']);return typeof F==='string'?h['get'](F):undefined;},l=(D,E)=>{const F=j(D,E)?.['value'];return typeof F==='string'?F:undefined;},m=new Map([['vec_contains_string',![]],['vec_indexof_string',![]],['vec_contains_string_nocase',!![]],['vec_indexof_string_nocase',!![]]]),n=new Set(['query_repository_data_keys_where','query_repository_policies_keys']),o=(D,E)=>{const F=[],G=I=>{const J=I?.['identifier'];return typeof J==='number'?J:undefined;},H=I=>{if(I===null||typeof I!=='object')return;if(Array['isArray'](I)){for(const L of I)H(L);return;}const J=I;if(J['type']==='query_repository_data_find_where'||J['type']==='query_repository_data_count_where'||J['type']==='query_repository_data_sum_where'||J['type']==='query_repository_data_sum_where_bound'){const M=k(D,G(J['object'])),N=l(D,G(J['key']));if(M!==undefined&&N!==undefined)F['push']({'repo':M,'key':N,'nocase':![]});}if(J['type']==='query'&&typeof J['query']==='string'&&/^repository\.data\b/i['test'](J['query'])){const O=k(D,G(J['object'])),Q=Array['isArray'](J['parameters'])?J['parameters']:[],R=l(D,G(Q[0x0]));if(O!==undefined&&R!==undefined)F['push']({'repo':O,'key':R,'nocase':![]});}if(J['type']==='query_repository_data'||J['type']==='query_repository_data_has'){const S=k(D,G(J['object'])),T=typeof J['key']==='string'?J['key']:undefined;if(S!==undefined&&T!==undefined)F['push']({'repo':S,'key':T,'nocase':![]});}const K=typeof J['type']==='string'?m['get'](J['type']):undefined;if(K!==undefined){const U=Array['isArray'](J['nodes'])?J['nodes']:[J['nodeLeft'],J['nodeRight']],V=U[0x0];if(V!==null&&typeof V==='object'&&typeof V['type']==='string'&&n['has'](V['type'])){const W=k(D,G(V['object']));if(W!==undefined)for(const X of U['slice'](0x1)){const Y=l(D,G(X));if(Y!==undefined)F['push']({'repo':W,'key':Y,'nocase':K});}}}for(const Z of Object['keys'](J))H(J[Z]);};return H(E),F;},p=(D,E,F)=>F?[...D['keys']]['some'](G=>G['toLowerCase']()===E['toLowerCase']()):D['keys']['has'](E),q=(D,E,F)=>F?[...D['writeGuards']]['find'](([G])=>G['toLowerCase']()===E['toLowerCase']())?.[0x1]:D['writeGuards']['get'](E);for(const [D,E]of b){if(E['stepId']===undefined)continue;for(const F of o(E['table'],E['root'])){!p(F['repo'],F['key'],F['nocase'])&&e['push']({'code':'POLICY_KEY_UNRESOLVED','detail':'guard\x20\x27'+D+'\x27\x20reads\x20repository\x20policy\x20key\x20\x27'+F['key']+'\x27,\x20but\x20NO\x20repository\x20create\x20step\x20in\x20this\x20'+'plan\x20defines\x20that\x20policy\x20—\x20as\x20built\x20the\x20read\x20'+'is\x20identically\x20ZERO\x20or\x20an\x20empty\x20key\x20list\x20(REPO-GATE-KEY-01):\x20the\x20gated\x20forward\x20never\x20opens\x20and\x20every\x20order\x20freezes\x20mid-rail\x20(bsx\x20BSX-F01:\x20'+'the\x20delivery\x20gate\x20read\x20\x27license_grant\x27\x20while\x20the\x20repository\x20stored\x20\x27grant\x27).\x20Policies\x20are\x20NOT\x20chain-frozen\x20—\x20'+'the\x20repository\x27s\x20policy-management\x20permission\x20(index\x20102)\x20can\x20add\x20the\x20missing\x20key\x20post-publish\x20—\x20but\x20do\x20not\x20ship\x20the\x20dead\x20rail:\x20'+'align\x20the\x20guard\x27s\x20row\x20'+'key\x20with\x20a\x20policy\x20name\x20this\x20plan\x20actually\x20creates.'}),q(F['repo'],F['key'],F['nocase'])?.['has'](E['stepId'])&&e['push']({'code':'CREDENTIAL_CYCLE','detail':'guard\x20\x27'+D+'\x27\x20is\x20a\x20write\x20credential\x20of\x20a\x20repository\x20policy\x20it\x20also\x20READS\x20(\x27'+F['key']+'\x27)\x20—\x20to\x20write\x20'+'the\x20row\x20you\x20must\x20first\x20pass\x20a\x20guard\x20requiring\x20the\x20row.\x20Unsatisfiable\x20by\x20construction\x20(bsn7\x20T-01\x20/\x20'+'bsx\x20BSX-F02:\x20the\x20review\x20write\x20credential\x20fell\x20back\x20to\x20the\x20reward-claim\x20guard,\x20which\x20requires\x20the\x20'+'rating\x20row\x20it\x20gates).\x20The\x20write\x20credential\x20must\x20be\x20an\x20identity/progress\x20credential\x20that\x20reads\x20'+'nothing\x20from\x20that\x20repository.'});}}const r=(G,H)=>{let I=![];const J=K=>{if(I||K===null||typeof K!=='object')return;if(Array['isArray'](K)){for(const M of K)J(M);return;}const L=K;if(L['type']==='context'&&L['context']===H)I=!![];for(const N of Object['keys'](L))J(L[N]);};return J(G),I;},u=G=>{let H=![];const I=J=>{if(H||J===null||typeof J!=='object')return;if(Array['isArray'](J)){for(const L of J)I(L);return;}const K=J;K['type']==='query'&&typeof K['query']==='string'&&/named_operator|permission|arb\./i['test'](K['query'])&&(H=!![]);for(const M of Object['keys'](K))I(K[M]);};return I(G),H;};for(const G of b['keys']()){if(!c['has'](G))continue;if(d['has'](G)||/recover/i['test'](G))continue;const H=b['get'](G);if(r(H['root'],'Signer'))continue;if(u(H['root']))continue;if(r(H['root'],'Clock'))continue;e['push']({'code':'MONEY_RAIL_CALLER_LEG_MISSING','detail':'money\x20rail\x20\x27'+G+'\x27\x20(allocator\x20row\x20or\x20reward\x20claim)\x20has\x20NO\x20caller-authorization\x20leg:\x20'+'alloc_by_guard\x20and\x20Reward\x20claims\x20are\x20NOT\x20forwards\x20—\x20'+'the\x20chain\x20injects\x20the\x20order-holder\x20rail\x20on\x20forward\x20ops\x20only\x20and\x20neither\x20op\x20has\x20a\x20'+'chain-side\x20caller\x20check,\x20so\x20this\x20rail\x20is\x20driveable\x20by\x20ANY\x20passport\x20holder\x20(gf30\x20A2\x20'+'settle_BY_OUTSIDER_v2\x20drained\x20o4;\x20rex5\x20T-27\x20rex-buy2\x20drained\x20a\x20third\x20party\x27s\x20escrow).\x20Bind\x20one:\x20'+'order.owner\x20==\x20Signer\x20OR\x20order.agent\x20has\x20Signer\x20(buyer),\x20or\x20the\x20dynamic-permission\x20leg\x20—\x20'+'service.permission\x20==\x20a\x20submitted\x20Permission\x20slot,\x20then\x20permission.owner\x20==\x20Signer\x20OR\x20'+'permission.admin\x20has\x20Signer\x20(merchant\x20or\x20keeper,\x20survives\x20rotation;\x20K-4).\x20State-determined\x20'+'exception\x20stays\x20open:\x20context\x20Clock\x20(time\x20gates).\x20Decision\x2011:\x20order.claimed_by\x20is\x20NEVER\x20an\x20'+'authorization\x20on\x20a\x20fund\x20rail\x20—\x20a\x20claimed_by\x20leg\x20there\x20is\x20the\x20RAIL_CLAIMED_BY_LEG\x20critical,\x20'+'blocked\x20by\x20the\x20rail\x20verifier\x20regardless\x20of\x20caller\x20identity.'});}return{'blockers':e};}export function emitSupplyChain({supplyChain:a,steps:b,derivedParams:c}){const d=[],e=[];let f;if(a!==undefined&&a['length']>0x0){const g=b['find'](n=>n['op']==='create'&&n['object']==='service'),h=g!==undefined&&g['op']==='create'&&typeof g['params']['name']==='string'?g['params']['name']:'',i=new Set(b['map'](n=>n['id'])),j=new Set(),k=new Set(),l=((()=>{for(let n=b['length']-0x1;n>=0x0;n-=0x1){const o=b[n];if(o['op']==='publish'&&o['target']['$ref']==='service')return n;}return b['length'];})());let m=0x0;a['forEach']((n,o)=>{const p=n['id_prefix']??(o===0x0?'sc':'sc'+String(o+0x1)),q='supply-chain\x20promise\x20#'+String(o+0x1)+'\x20(\x27'+(n['sub_service']||'unset\x20provider')+'\x27,\x20'+String(n['axis'])+')';if(n['service_step_id']!==undefined&&n['service_step_id']!=='service'){d['push']({'code':'SUPPLY_CHAIN_ID_CONFLICT','detail':q+':\x20service_step_id\x20\x27'+n['service_step_id']+'\x27\x20names\x20no\x20step\x20in\x20this\x20plan.\x20Compile\x20'+'attaches\x20a\x20promise\x20to\x20its\x20own\x20Service\x20create,\x20whose\x20id\x20is\x20always\x20\x27service\x27\x20—\x20drop\x20the\x20field\x20'+'or\x20pass\x20\x27service\x27.'});return;}let r=n['repository_name'];if(r!==undefined&&j['has'](r)){d['push']({'code':'SUPPLY_CHAIN_ID_CONFLICT','detail':q+':\x20repository_name\x20\x27'+r+'\x27\x20is\x20already\x20created\x20by\x20an\x20earlier\x20promise\x20—\x20one\x20'+('Repository\x20cannot\x20be\x20created\x20twice.\x20Pass\x20\x27repository:\x20'+r+'\x27\x20on\x20this\x20promise\x20to\x20')+'REUSE\x20the\x20shared\x20ledger\x20instead\x20of\x20creating\x20it.'});return;}if(n['repository']===undefined&&r===undefined){const u=(n['service_name']||h||'service')+'_supply_chain';if(j['has'](u))r=u+'_'+p;}const s=emitSupplyChainPromise({...n,'service_name':n['service_name']||h,'service_step_id':'service','id_prefix':p,...r!==undefined?{'repository_name':r}:{}});for(const v of s['blockers'])d['push']({'code':v['code'],'detail':q+':\x20'+v['detail']});const t=s['steps']['find'](w=>i['has'](w['id']));if(t!==undefined){d['push']({'code':'SUPPLY_CHAIN_ID_CONFLICT','detail':q+':\x20emitted\x20step\x20id\x20\x27'+t['id']+'\x27\x20already\x20exists\x20in\x20the\x20plan.\x20Each\x20promise\x20names\x20its\x20'+'objects\x20\x27<prefix>_gate\x27\x20/\x20\x27_write\x27\x20/\x20\x27_ack\x27\x20/\x20\x27_rendezvous\x27\x20/\x20\x27_bind_repository\x27\x20/\x20\x27_alloc\x27,\x20'+'so\x20give\x20this\x20promise\x20a\x20distinct\x20id_prefix.'});return;}for(const w of s['steps']){i['add'](w['id']),w['op']==='create'&&w['object']==='repository'&&typeof w['params']['name']==='string'&&j['add'](w['params']['name']);}b['splice'](l+m,0x0,...s['steps']),m+=s['steps']['length'],c['push'](...s['derived_params']??[]);if(s['steps']['length']===0x0)return;e['push'](s),k['add'](n['axis']);});if(k['size']>0x0){const n=[...k];f=n['length']===0x1?n[0x0]:'mixed';}}return{'supplyChainEmissions':e,'fulfillmentAxis':f,'blockers':d};}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { type CapabilityId, type CapabilityEvidenceReport } from "../extensions/capability.js";
|
|
2
|
+
import type { SupplyChainEmission, SupplyChainPromise } from "./supply-chain-emit.js";
|
|
3
|
+
import type { JsonValue, Plan } from "./plan.js";
|
|
4
|
+
import type { PlanAuditResult } from "./audit.js";
|
|
5
|
+
export interface CompositionGenerationInput {
|
|
6
|
+
intent: string;
|
|
7
|
+
selections?: CapabilityId[];
|
|
8
|
+
supplyChain?: SupplyChainPromise[];
|
|
9
|
+
inputs?: Record<string, JsonValue>;
|
|
10
|
+
nameBase?: string;
|
|
11
|
+
preferredChain?: string;
|
|
12
|
+
buildTimeMs?: number;
|
|
13
|
+
}
|
|
14
|
+
export interface GeneratedAdoption {
|
|
15
|
+
id: CapabilityId;
|
|
16
|
+
via: "selection" | "intent_signal";
|
|
17
|
+
evidence?: CapabilityEvidenceReport;
|
|
18
|
+
}
|
|
19
|
+
export interface GeneratedBlocker {
|
|
20
|
+
code: string;
|
|
21
|
+
detail: string;
|
|
22
|
+
}
|
|
23
|
+
export interface CompositionGeneration {
|
|
24
|
+
plan?: Plan;
|
|
25
|
+
feasibility: "ready" | "infeasible";
|
|
26
|
+
chain?: string;
|
|
27
|
+
carrier?: string;
|
|
28
|
+
adopted: GeneratedAdoption[];
|
|
29
|
+
blockers: GeneratedBlocker[];
|
|
30
|
+
audit?: PlanAuditResult;
|
|
31
|
+
templates_version: number;
|
|
32
|
+
supplyChain?: SupplyChainEmission[];
|
|
33
|
+
}
|
|
34
|
+
export interface PilotChainPreset {
|
|
35
|
+
chain: string;
|
|
36
|
+
carrier: string;
|
|
37
|
+
signals: CapabilityId[];
|
|
38
|
+
}
|
|
39
|
+
export declare const PILOT_CHAINS: PilotChainPreset[];
|
|
40
|
+
export declare function generateCompositionPlan(input: CompositionGenerationInput): CompositionGeneration;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{compileTemplate}from'./compile.js';import{reflux}from'./reflux.js';import{getBuiltinTemplate,BUILTIN_TEMPLATES_VERSION}from'../knowledge/builtin-templates.js';import{templateCatalogDigest}from'../knowledge/template-loader.js';import{ALL_CAPABILITIES,capabilityIntentEvidence,getCapability}from'../extensions/capability.js';export const PILOT_CHAINS=[{'chain':'chain.data_subscription','carrier':'subscription/creator-membership','signals':['subscription_with_proof','wip_provenance','dynamic_pricing_formula']},{'chain':'chain.standard_ecommerce','carrier':'delivery/restaurant-marketplace','signals':['logistics_fulfillment','fulfillment_self','fulfillment_procured','fulfillment_user_procured','cross_order_gate','discount_lifecycle','praise_incentive']}];export function generateCompositionPlan(a){const b=a['intent']['trim'](),c=[],d=[],e=[];for(const m of a['selections']??[]){const n=getCapability(m);if(!n){c['push']({'code':'COMPOSE-UNKNOWN-CAPABILITY','detail':'\x27'+m+'\x27\x20is\x20not\x20a\x20registered\x20capability\x20—\x20list\x20them\x20via\x20'+'industry_pack_operation\x20action=\x27capability_list\x27'});continue;}e['push'](n['id']),d['push']({'id':n['id'],'via':'selection'});}for(const o of ALL_CAPABILITIES){if(e['includes'](o['id']))continue;const p=capabilityIntentEvidence(o,b);p['matched']&&d['push']({'id':o['id'],'via':'intent_signal','evidence':p});}for(const q of d['map'](r=>r['id'])){const r=getCapability(q);for(const s of r['requires']){!d['some'](t=>t['id']===s)&&c['push']({'code':'COMPOSE-REQUIRES-MISSING','detail':'\x27'+q+'\x27\x20requires\x20\x27'+s+'\x27\x20in\x20the\x20same\x20adoption\x20set'});}for(const t of r['excludes']){d['some'](u=>u['id']===t)&&c['push']({'code':'COMPOSE-EXCLUDES-CONFLICT','detail':'\x27'+q+'\x27\x20and\x20\x27'+t+'\x27\x20cannot\x20coexist\x20in\x20one\x20build\x20(mutual\x20exclusion)'});}}if(d['length']===0x0)return c['push']({'code':'COMPOSE-NO-CAPABILITY-EVIDENCE','detail':'the\x20intent\x20matched\x20no\x20capability\x27s\x20intentSignals\x20and\x20no\x20selection\x20was\x20given\x20—\x20'+'name\x20the\x20business\x20intent\x20concretely\x20(subscription,\x20delivery,\x20milestone,\x20refund,\x20...)\x20'+'or\x20pass\x20explicit\x20selections;\x20the\x20generator\x20never\x20guesses\x20a\x20template'}),infeasible(d,c);const f=d['map'](u=>u['id']),g=PILOT_CHAINS['filter'](u=>u['signals']['some'](v=>f['includes'](v)));let h;if(g['length']===0x1)h=g[0x0];else{if(g['length']>0x1)h=g['find'](u=>u['chain']===a['preferredChain'])??g[0x0];else return c['push']({'code':'COMPOSE-CHAIN-UNMAPPED','detail':'adopted\x20['+f['join'](',\x20')+']\x20map\x20onto\x20neither\x20pilot\x20chain\x20'+('('+PILOT_CHAINS['map'](u=>u['chain'])['join'](',\x20')+')\x20—\x20the\x20G-A\x20pilot\x20carries\x20only\x20')+'these\x20two;\x20extend\x20PILOT_CHAINS\x20or\x20use\x20merchant_guide\x20for\x20a\x20template\x20build'}),infeasible(d,c);}const i=getBuiltinTemplate(h['carrier']);if(!i)return c['push']({'code':'COMPOSE-CARRIER-UNKNOWN','detail':'chain\x20preset\x20\x27'+h['chain']+'\x27\x20names\x20carrier\x20\x27'+h['carrier']+'\x27\x20which\x20is\x20not\x20in\x20the\x20builtin\x20catalog'}),infeasible(d,c);const j=compileTemplate(i,a['inputs']??{},{'nameBase':a['nameBase']??h['carrier'],'intent':b,...a['supplyChain']!==undefined&&a['supplyChain']['length']>0x0?{'supplyChain':a['supplyChain']}:{},...a['buildTimeMs']!==undefined?{'buildTimeMs':a['buildTimeMs']}:{}});c['push'](...compileBlockers(j['blockers']));const k=reflux(j['plan']);for(const u of k['audit']['findings']){(u['level']==='critical'||u['level']==='high')&&c['push']({'code':'REVIEW-'+u['rule_id'],'detail':'plan\x20audit\x20'+u['level']+':\x20'+u['title']+'\x20—\x20'+u['description']});}if(c['length']>0x0)return infeasible(d,c);const l=templateCatalogDigest(k['plan']['templateId']??'');return{'plan':{...k['plan'],...l!==undefined?{'template_digest':l}:{}},'feasibility':'ready','chain':h['chain'],'carrier':h['carrier'],'adopted':d,'blockers':[],'audit':k['audit'],'templates_version':BUILTIN_TEMPLATES_VERSION,...j['supplyChain']!==undefined?{'supplyChain':j['supplyChain']}:{}};}function infeasible(a,b){return{'feasibility':'infeasible','adopted':a,'blockers':b,'templates_version':BUILTIN_TEMPLATES_VERSION};}function compileBlockers(a){return a['map'](c=>({'code':c['code'],'detail':c['detail']}));}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { JsonValue } from "./plan.js";
|
|
2
|
+
import type { CompilableTemplate, CompileBlocker, GuardResolution, GuardSpec } from "./compile.js";
|
|
3
|
+
import type { ConditionalSelection } from "./input-normalize.js";
|
|
4
|
+
export declare function normalizeInlineGuardTable(table: unknown[], base: string): unknown[];
|
|
5
|
+
export interface ResolvedGuard {
|
|
6
|
+
stepId: string;
|
|
7
|
+
description: string;
|
|
8
|
+
table: unknown[];
|
|
9
|
+
root: unknown;
|
|
10
|
+
}
|
|
11
|
+
export declare function normalizeGuardRowNames(table: unknown[], description: unknown, maxDescriptionContentBytes: number): {
|
|
12
|
+
table: unknown[];
|
|
13
|
+
description: unknown;
|
|
14
|
+
};
|
|
15
|
+
export type GuardFillReviewMode = NonNullable<CompilableTemplate["review_mode"]> | "none";
|
|
16
|
+
export type GuardBindingCensus = Set<string>;
|
|
17
|
+
export interface GuardFillInputs {
|
|
18
|
+
template: CompilableTemplate;
|
|
19
|
+
base: string;
|
|
20
|
+
inputs: Record<string, JsonValue>;
|
|
21
|
+
guardResolutions: Record<string, GuardResolution>;
|
|
22
|
+
selector: Omit<ConditionalSelection, "blockers">;
|
|
23
|
+
}
|
|
24
|
+
export interface GuardFillDerived {
|
|
25
|
+
reviewMode: GuardFillReviewMode;
|
|
26
|
+
rewardMark: string;
|
|
27
|
+
needsRepository: boolean;
|
|
28
|
+
}
|
|
29
|
+
export interface GuardFillResult {
|
|
30
|
+
guardSpecs: GuardSpec[];
|
|
31
|
+
resolutions: Record<string, GuardResolution>;
|
|
32
|
+
resolvedGuards: Map<string, ResolvedGuard>;
|
|
33
|
+
unresolved: GuardSpec[];
|
|
34
|
+
omitKeys: Set<string>;
|
|
35
|
+
recoverTwinRails: Set<string>;
|
|
36
|
+
declareReasons: Map<string, string>;
|
|
37
|
+
specByKey: Map<string, GuardSpec>;
|
|
38
|
+
slot254Injected: Set<string>;
|
|
39
|
+
injectedOrderHolderKeys: Map<string, string>;
|
|
40
|
+
edgeBoundKeys: GuardBindingCensus;
|
|
41
|
+
derived: GuardFillDerived;
|
|
42
|
+
blockers: CompileBlocker[];
|
|
43
|
+
}
|
|
44
|
+
export declare function fillGuards(deps: GuardFillInputs): GuardFillResult;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{fillGuardTemplate,getTemplateById}from'../knowledge/guard-templates.js';import{hasCallerIdentityLeg}from'../knowledge/allocator-rail-verifier.js';import{applyFeeParamBindings}from'../knowledge/fee-param-bindings.js';import{identityDefaultResolution,patternDefaultResolution,progressStateDefaultResolution,timeInstantiationFor}from'../knowledge/pattern-resolutions.js';import{GUARD_DESIGN_PATTERNS}from'../knowledge/guard-design-patterns.js';import{lookupBinding}from'../knowledge/guard-binding-table.js';import{TASK_BINDING_SLOT}from'../knowledge/onchain-constants.js';import{feeParamCouplingMismatches,windowMathMismatches,incentiveRatingFloorClaims,rewardWindowDayClaims}from'../knowledge/template-scanner.js';import{ref}from'./plan.js';function safeId(a){return a['replace'](/[^a-zA-Z0-9_]/g,'_');}function normalizeLogicArity(a){if(Array['isArray'](a))return a['map'](normalizeLogicArity);if(a===null||typeof a!=='object')return a;const b=a,c={};for(const [d,e]of Object['entries'](b))c[d]=normalizeLogicArity(e);if((c['type']==='logic_and'||c['type']==='logic_or')&&Array['isArray'](c['nodes'])){const f=c['nodes'];if(f['length']===0x1)return f[0x0];}return c;}export function normalizeInlineGuardTable(a,b){const c=b+'_service',d=f=>f['replace'](/\//g,'_'),e=d(c);return a['map'](f=>{if(f===null||typeof f!=='object'||Array['isArray'](f))return f;const g={...f};typeof g['value']==='string'&&d(g['value'])===e&&(g['value']=ref('service'));if(g['b_submission']===undefined)g['b_submission']=![];return g;});}function shortRowLabel(a,b){const c=a['search'](/:| \(| — /),d=c>0x0?a['slice'](0x0,c)['trim']():'';if(d['length']>0x0&&Buffer['byteLength'](d,'utf8')<=b)return d;let e=a;while(e['length']>0x0&&Buffer['byteLength'](e+'...','utf8')>b)e=e['slice'](0x0,-0x1);return e+'...';}const MAX_GUARD_DESCRIPTION_CONTENT=0xf9e;export function normalizeGuardRowNames(a,b,c){const d=0x3f,e=[],f=a['map'](j=>{if(!j||typeof j!=='object')return j;const k=j,l=k['name'];if(typeof l!=='string')return j;const m=l['startsWith']('0x')?'n_'+l:l;if(Buffer['byteLength'](m,'utf8')<=d)return m===l?j:{...k,'name':m};return e['push']('slot\x20'+String(k['identifier']??'?')+':\x20'+m),{...k,'name':shortRowLabel(m,d)};});if(e['length']===0x0)return{'table':f,'description':b};const g=typeof b==='string'?b:'';let h=g+'\x0a\x0aRow\x20labels\x20(the\x20on-chain\x20name\x20column\x20is\x20capped\x20at\x2064\x20BCS\x20bytes,\x20so\x20each\x20long\x20label\x20is\x20spelled\x20out\x20here):',i=0x0;for(const j of e){const k=h+'\x0a-\x20'+j;if(Buffer['byteLength'](k,'utf8')>c)break;h=k,i+=0x1;}return{'table':f,'description':i===0x0?b:h};}export function fillGuards(a){const {template:b,base:c,inputs:e,guardResolutions:f}=a,{dropKeys:h,selectorDroppedKeys:i,shape:j,rows:k}=a['selector'],l=[],o={},p=new Set();b['guards']['forEach']((Z,a0)=>{const a1=Z['key']??Z['template_id']+'#'+a0;if(i['has'](a1))return;const a2=patternDefaultResolution(b['id'],a1)??progressStateDefaultResolution(b,Z)??identityDefaultResolution(b,Z);if(a2!==undefined)o[a1]=a2;}),Object['assign'](o,Object['fromEntries'](Object['entries'](f??{})['filter'](([,Z])=>Z?.['kind']!=='declare')));const q=[];for(const [Z,a0]of Object['entries'](f??{})){if(a0?.['kind']==='omit')q['push'](Z);}const s=new Set();if(q['length']>0x0){const a1=new Set(j['flatMap'](a3=>(a3['from']??[])['map'](a4=>typeof a4==='string'?undefined:a4['guard_key'])['filter'](a4=>typeof a4==='string'))),a2=new Set(k['map'](a3=>a3['guard_key'])['filter'](a3=>typeof a3==='string'));for(const a3 of q){const a4=b['guards']['find']((a6,a7)=>(a6['key']??a6['template_id']+'#'+a7)===a3);if(a4===undefined)continue;const a5=[];if(a1['has'](a3))a5['push']('a\x20machine\x20forward\x20edge\x20(guard_key)');if(a2['has'](a3))a5['push']('an\x20allocator\x20rail\x20row\x20(guard_key)');if(a4['policy']!==undefined)a5['push']('a\x20Repository\x20write-policy\x20credential\x20(policy)');if(a4['host']==='service'&&a3==='buy')a5['push']('the\x20Service\x20buy\x20gate\x20(buy_guard)');a5['length']>0x0?l['push']({'code':'GUARD_OMIT_UNSUPPORTED','detail':'guard_resolutions[\x27'+a3+'\x27]\x20=\x20{kind:\x27omit\x27}\x20refused:\x20this\x20design\x20is\x20bound\x20to\x20'+a5['join']('\x20and\x20')+'\x20—\x20'+'omitting\x20it\x20would\x20orphan\x20the\x20binding\x20(open\x20rail\x20/\x20open\x20write\x20/\x20ungated\x20purchase).\x20'+'Fold\x20the\x20design\x27s\x20intent\x20into\x20the\x20bound\x20site\x20instead,\x20or\x20keep\x20the\x20guard\x20resolved.'}):s['add'](a3);}}const t=new Set(k['map'](a6=>a6['guard_key'])['filter'](a6=>typeof a6==='string')),u=new Map();b['guards']['forEach']((a6,a7)=>{const a8=a6['key']??a6['template_id']+'#'+a7,a9=a6['identity_leg_exempt'];typeof a9==='string'&&a9['trim']()!==''&&t['has'](a8)&&u['set'](a8,a9['trim']());});for(const [a6,a7]of Object['entries'](f??{})){if(a7?.['kind']!=='declare')continue;const a8=typeof a7['reason']==='string'?a7['reason']['trim']():'';if(a8===''){l['push']({'code':'GUARD_DECLARE_UNSUPPORTED','detail':'guard_resolutions[\x27'+a6+'\x27]\x20=\x20{kind:\x27declare\x27}\x20refused:\x20the\x20reason\x20field\x20is\x20mandatory\x20and\x20'+'must\x20be\x20non-empty\x20—\x20the\x20disclosure\x20that\x20ships\x20with\x20the\x20exemption\x20quotes\x20it\x20verbatim,\x20and\x20an\x20'+'unexplained\x20legless\x20money\x20rail\x20is\x20exactly\x20what\x20the\x20gate\x20exists\x20to\x20prevent\x20(ks11).'});continue;}const a9=b['guards']['find']((aa,ab)=>(aa['key']??aa['template_id']+'#'+ab)===a6);if(a9===undefined)continue;if(!t['has'](a6)){l['push']({'code':'GUARD_DECLARE_UNSUPPORTED','detail':'guard_resolutions[\x27'+a6+'\x27]\x20=\x20{kind:\x27declare\x27}\x20refused:\x20the\x20declare\x20channel\x20is\x20honored\x20ONLY\x20for\x20'+('allocator-rail-bound\x20designs\x20(a\x20spec\x20mounted\x20on\x20an\x20allocator\x20row),\x20and\x20\x27'+a6+'\x27\x20is\x20bound\x20to\x20no\x20')+'allocator\x20row.\x20An\x20identity-less\x20forward/policy/buy\x20gate\x20is\x20a\x20different\x20violation\x20family\x20'+'(RELEASE_EDGE_NO_IDENTITY\x20/\x20REPO_GUARD_POLICY_MISSING)\x20with\x20its\x20own\x20remedy\x20—\x20declare\x20does\x20not\x20reach\x20it.'});continue;}u['set'](a6,a8);}const w=b['guards']['map']((aa,ab)=>{const ac=aa['key']??aa['template_id']+'#'+ab,ad=applyFeeParamBindings(aa['params'],b['id'],ac,e,b['fee_params']);return{'key':ac,'template_id':aa['template_id'],'host':aa['host'],'purpose':aa['purpose'],'policy':aa['policy'],'params':ad};})['filter'](aa=>!h['has'](aa['key'])&&!s['has'](aa['key'])),x=new Map();{const aa=new Set(w['map'](ac=>ac['key'])),ab=ac=>{if(ac===undefined)return![];const ad=w['find'](af=>af['key']===ac);if(ad===undefined)return![];const ae=o[ac];if(ae?.['kind']==='inline'||ae?.['kind']==='template'||ad['template_id']['startsWith']('tpl_'))return!![];if(ae?.['kind']==='omit'&&s['has'](ac))return![];return lookupBinding(ad,b)!==undefined;};for(const ac of j){for(const ad of ac['from']??[]){const ae=typeof ad==='string'?{'prev':ad}:ad,af=ae['operator']??ac['operator']??(ae['prev']===''?'order_payer':'merchant');if(af!=='order_payer')continue;if(ae['guard_key']!==undefined&&ab(ae['guard_key']))continue;const ag=ae['forward']??(ae['prev']===''?'enter_'+ac['name']:ae['prev']+'_to_'+ac['name']);if(x['has'](ag))continue;let ah='order_holder_'+ag;while(aa['has'](ah))ah=ah+'_x';aa['add'](ah),x['set'](ag,ah);const ai=ae['guard_key']===undefined?'Declare\x20an\x20explicit\x20order-holder\x20guard_key\x20on\x20the\x20edge\x20to\x20replace\x20this\x20auto\x20key\x20with\x20a\x20named\x20credential.':'The\x20edge\x20DOES\x20declare\x20guard_key\x20\x27'+ae['guard_key']+'\x27,\x20but\x20that\x20design\x20does\x20not\x20resolve\x20to\x20a\x20Guard\x20object,\x20so\x20the\x20forward\x20would\x20otherwise\x20ship\x20unguarded;\x20resolve\x20\x27'+ae['guard_key']+'\x27\x20(guard_resolutions,\x20or\x20re-point\x20the\x20spec\x20at\x20an\x20instantiable\x20tpl_*\x20id)\x20to\x20carry\x20the\x20richer\x20condition\x20—\x20this\x20identity\x20leg\x20stays\x20bound\x20either\x20way.';w['push']({'key':ah,'template_id':'tpl_forward_order_holder','host':'machine','purpose':'F05\x20kernel-injected\x20order-holder\x20identity\x20binding\x20for\x20the\x20buyer-exclusive\x20forward\x20'+('\x27'+ag+'\x27\x20(edge\x20\x27'+ae['prev']+'\x27->\x27'+ac['name']+'\x27):\x20namedOperator\x20\x22\x22\x20passes\x20for\x20')+'anyone\x20at\x20the\x20permission\x20layer,\x20so\x20without\x20this\x20guard\x20the\x20'+'buyer\x20rail\x20is\x20advanceable\x20by\x20ANY\x20passport\x20holder\x20attached\x20to\x20the\x20order\x20—\x20takeover\x20'+('risk.\x20'+ai)});}}}if(b['arbitration_mode']==='third_party'&&!w['some'](aj=>aj['template_id']['startsWith']('tpl_voting_guard_'))){let aj='arbitration_vote_open';const ak=new Set(w['map'](al=>al['key']));while(ak['has'](aj))aj=aj+'_x';w['push']({'key':aj,'template_id':'tpl_voting_guard_open_vote','host':'arbitration','purpose':'F-cu\x20kernel-injected\x20open-vote\x20surface\x20for\x20the\x20third_party\x20venue:\x20an\x20EMPTY\x20'+'voting_guard\x20is\x20NOT\x20open\x20voting\x20—\x20plain\x20votes\x20hard-require\x20permission\x20358\x20'+'(admin-only\x20by\x20default),\x20so\x20disputes\x20dead-lock\x20when\x20the\x20arb\x20admin\x20is\x20'+'unresponsive\x20(crs9-F-36).\x20Every\x20Passport\x20holder\x20may\x20vote\x20at\x20flat\x20weight\x201;\x20'+'a\x20deliberately\x20closed\x20panel\x20re-declares\x20tpl_voting_guard_numeric_weight.','params':{'vote_weight':0x1}});}const y=new Map(w['map'](al=>[al['key'],al])),z=e['review_mode'],A=z==='review'||z==='review_reward'||z==='none'?z:undefined,B=A??b['review_mode']??'none',C=c+'_review_reward',D=al=>{const am=e[al]??b['fee_params'][al];if(typeof am==='number'&&Number['isFinite'](am))return am;if(typeof am==='string'&&am['trim']()!==''&&Number['isFinite'](Number(am)))return Number(am);return undefined;},E=0x4,F=D('reward_rating_floor'),G=F??E,H=D('reward_claim_opens_after_days'),I=D('reward_claim_closes_after_days'),J=0xe,K=0xe,L=b['fee_params']['return_window_days']??b['fee_params']['review_window_days'],M=typeof L==='number'&&Number['isFinite'](L)&&L>0x0?L:0x0,N=Math['max'](J,M+0x1),O=H??N,P=I??K;if(B==='review_reward'){const al=w['find'](ap=>ap['host']==='reward'),am=al!==undefined?o[al['key']]:undefined,an=am!==undefined&&(am['kind']==='template'||am['kind']==='inline'),ao=al!==undefined&&(al['template_id']['startsWith']('tpl_')||an);if(al===undefined||!ao){const ap=/deliver|complet|receiv|fulfil|finish/i,aq=/fund|pledge|back/i,ar=j['find'](ax=>/review/i['test'](ax['name'])),as=j['find'](ax=>ap['test'](ax['name'])),at=j['filter'](ax=>ax['semantic_role']==='final')['map'](ax=>ax['name']),au=ar?.['name']??as?.['name']??at[0x0],av=as!==undefined?at['filter'](ax=>!aq['test'](ax)):at,aw=[...new Set([au,...av])]['slice'](0x0,0x4);if(au!==undefined){const ax=new Set([au,...av])['size']>0x4,ay='Claim-set\x20default\x20(ks7\x20F-25):\x20the\x20bounty\x20anchors\x20on\x20the\x20review\x20node,\x20else\x20a\x20delivery-class\x20node,\x20else\x20the\x20first\x20terminal'+(as!==undefined?',\x20and\x20funding-class\x20settlement\x20terminals\x20are\x20EXCLUDED\x20—\x20a\x20funding\x20release\x20(funded_released\x20family)\x20precedes\x20physical\x20fulfillment,\x20so\x20a\x20window\x20measured\x20there\x20ships\x20the\x20bounty\x20permanently\x20unclaimable;\x20hosting\x20the\x20bounty\x20on\x20a\x20funding\x20terminal\x20requires\x20an\x20explicit\x20host:\x22reward\x22\x20spec\x20(the\x20named-design\x20escape\x20hatch).':'\x20(this\x20shape\x20mounts\x20no\x20delivery-class\x20node,\x20so\x20funding-class\x20terminals\x20stay\x20IN\x20the\x20default\x20set);\x20an\x20explicit\x20host:\x22reward\x22\x20spec\x20can\x20pin\x20any\x20claim\x20set.'),az=G>0x0,aA=az?'Rating\x20leg\x20ARMED\x20on\x20the\x20plan-created\x20\x27'+c+'_review\x27\x20repository\x20/\x20\x27rating\x27\x20policy\x20(order-keyed\x20U64):\x20pays\x20only\x20at\x20rating\x20>=\x20'+G+'\x20(reward_rating_floor\x20input'+(F===undefined?'\x20—\x20S14\x20default\x20'+E+',\x20no\x20input\x20given':'')+').':'No\x20rating\x20leg\x20—\x20reward_rating_floor\x20was\x20EXPLICITLY\x20set\x20to\x200\x20(plain\x20praise\x20bounty\x20opt-out,\x20S14\x20default\x20is\x20'+E+').',aB=H!==undefined?'Claim\x20window:\x20opens\x20'+O+'\x20day(s)\x20after\x20the\x20claim-allowed\x20entry\x20(reward_claim_opens_after_days\x20input;\x20overrides\x20the\x20after-sales-expiry\x20derivation\x20—\x20keep\x20it\x20ABOVE\x20the\x20store\x27s\x20return/review\x20window\x20or\x20the\x20claim-and-return\x20arbitrage\x20re-opens,\x20tbs7\x20F-04),\x20claimable\x20for\x20a\x20further\x20'+P+'\x20day(s)\x20(bsw4\x20F-11\x20close).':'Claim\x20window:\x20opens\x20'+O+'\x20day(s)\x20after\x20the\x20claim-allowed\x20entry\x20(derived\x20after-sales\x20expiry\x20+\x201d,\x20floored\x20at\x2014d\x20—\x20tbs7\x20F-04:\x20the\x20bounty\x20opens\x20only\x20after\x20the\x20return/review\x20window\x20closed),\x20claimable\x20for\x20a\x20further\x20'+P+'\x20day(s)\x20(bsw4\x20F-11:\x20the\x20window\x20CLOSES\x20—\x20a\x20real\x20deadline,\x20counted\x20from\x20the\x20open).',aC={'reward_address':'review_pool','expected_pre_claim_node':aw[0x0],'expected_pre_claim_node_alt':aw[0x1]??au,'expected_pre_claim_node_alt2':aw[0x2]??au,'expected_pre_claim_node_alt3':aw[0x3]??au,...az?{'rating_repository':c+'_review','rating_policy_name':'rating','rating_floor':String(G)}:{'rating_repository':''},'opens_after_days':String(O),'closes_after_days':String(P)};if(al===undefined){let aD='reward_claim_default';while(w['some'](aE=>aE['key']===aD))aD=aD+'_x';w['push']({'key':aD,'template_id':'tpl_reward_one_time_claim','host':'reward','purpose':'4R-02\x20kernel-injected\x20DEFAULT\x20claim\x20guard\x20for\x20review_mode\x20\x27review_reward\x27\x20(the\x20template\x20'+('declares\x20no\x20reward\x20spec):\x20claim-allowed\x20SET\x20{'+aw['join'](',\x20')+'}'+(ax?'\x20(TRUNCATED\x20to\x20the\x204\x20template\x20slots\x20—\x20the\x20shape\x20carries\x20more\x20terminals;\x20declare\x20an\x20explicit\x20host:\x22reward\x22\x20spec)':'')+',\x20')+'bounty\x20derived\x20T-02\x20(2%\x20of\x20the\x20cheapest\x20SKU,\x20floored\x20at\x201),\x20funding\x20fail-closed\x20'+('(REVIEW_REWARD_UNFUNDED).\x20'+aA+'\x20'+aB+'\x20'+ay+'\x20W5-03\x20mutual\x20exclusion:\x20the\x20claim\x20set\x20')+'carries\x20NO\x20cancelled-role\x20node\x20—\x20a\x20refunded\x20order\x20cannot\x20reach\x20this\x20bounty\x20(a\x20chain-level\x20'+'\x27was\x20ever\x20refunded\x27\x20boolean\x20does\x20not\x20exist;\x20mounting\x20a\x20review/reward\x20advance\x20on\x20a\x20cancelled\x20'+'terminal\x20is\x20blocked\x20by\x20audit\x20STATE-REFUNDED-REWARD-01).\x20Declare\x20an\x20explicit\x20host:\x22reward\x22\x20guard\x20spec\x20to\x20replace\x20this\x20'+'default\x20with\x20a\x20named\x20design.','params':aC});}else{const aE=al['template_id'];al['template_id']='tpl_reward_one_time_claim',al['params']=aC,al['purpose']='4R-02\x20default\x20assembly\x20replaced\x20the\x20unresolved\x20design\x20reference\x20(was\x20\x27'+aE+'\x27\x20with\x20no\x20'+('caller\x20resolution):\x20claim-allowed\x20SET\x20{'+aw['join'](',\x20')+'}'+(ax?'\x20(TRUNCATED\x20to\x20the\x204\x20template\x20slots\x20—\x20declare\x20an\x20explicit\x20spec\x20or\x20resolve\x20this\x20key\x20to\x20cover\x20every\x20terminal)':'')+'.\x20')+(aA+'\x20'+aB+'\x20'+ay+'\x20Resolve\x20this\x20key\x20via\x20guard_resolutions\x20(kind\x20\x27inline\x27\x20or\x20\x27template\x27)\x20to\x20override\x20the\x20')+'default\x20mount\x20per\x20build.';}}}}const Q=new Set(['wip_provenance','subscription_with_proof']),R=Array['isArray'](e['adopted_module_ids'])?e['adopted_module_ids']['filter'](aF=>typeof aF==='string'):[],S=w['some'](aF=>aF['host']==='repository'||aF['template_id']==='pattern.repository_data_check'||aF['template_id']==='pattern.repository_write_authorization'||aF['template_id']==='tpl_repository_row_present'||aF['template_id']==='tpl_repository_row_present_signer'||aF['template_id']==='tpl_repository_row_equals_order_field'||aF['template_id']==='tpl_holder_confirm_evidence_gate')||R['some'](aF=>Q['has'](aF)),T=new Map(),U=[],V=w['map'](aF=>aF['key']);for(const aF of Object['keys'](f??{})){if(s['has'](aF))continue;!y['has'](aF)&&l['push']({'code':'GUARD_RESOLUTION_UNKNOWN','detail':'guard_resolutions\x20key\x20\x27'+aF+'\x27\x20matches\x20no\x20guard\x20spec\x20key\x20declared\x20by\x20\x27'+c+'\x27.\x20'+('Legal\x20keys:\x20'+(V['length']>0x0?V['join'](',\x20'):'(none\x20—\x20this\x20template\x20declares\x20no\x20keyed\x20guards)')+'.\x20')+'An\x20unknown\x20key\x20was\x20previously\x20dropped\x20silently,\x20leaving\x20the\x20intended\x20guard\x20pending\x20while\x20the\x20build\x20looked\x20resolved.'});}for(const aG of w){const aH='guard_'+safeId(aG['key']),aI=o[aG['key']];let aJ=aG['purpose'],aK,aL;if(aI?.['kind']==='inline')aK=normalizeInlineGuardTable(aI['table'],c),aL=aI['root'],aJ=aI['description']??aG['purpose'];else{const aM=aI===undefined||aI['kind']==='omit'&&!s['has'](aG['key'])||aI['kind']==='declare'?lookupBinding(aG,b):undefined,aN=aI?.['kind']==='template'?aI['template_id']:aG['template_id']['startsWith']('tpl_')?aG['template_id']:aM?.['template_id'];if(aN!==undefined){if(aN==='tpl_allocator_node_gate_recover')p['add'](aG['key']);const aO={'service_name':c+'_service',...S?{'repository_name':c+'_evidence'}:{},...B!=='none'?{'review_repository':c+'_review'}:{},...b['arbitration_mode']!==undefined&&b['arbitration_mode']!=='none'?{'arbitration_name':c+'_arbitration'}:{},...b['fee_params'],...e,...aG['params'],...aM!==undefined?aM['params']:{},...aI?.['kind']==='template'?aI['params']:{}},aP=fillGuardTemplate(aN,aO);!aP['ok']?l['push']({'code':'GUARD_TEMPLATE_PARAMS','detail':'guard\x20\x27'+aG['key']+'\x27\x20('+aN+'):\x20'+aP['error']}):(aK=aP['table'],aL=aP['root']);}}if(aK!==undefined){const aQ=u['has'](aG['key'])&&aL!==undefined&&!hasCallerIdentityLeg(aL);T['set'](aG['key'],{'stepId':aH,'description':aQ?aJ+'\x20(merchant-declared\x20exemption:\x20rail\x20\x27'+aG['key']+'\x27\x20ships\x20without\x20a\x20caller\x20identity\x20leg\x20—\x20'+u['get'](aG['key'])+')':aJ,'table':aK,'root':normalizeLogicArity(aL)}),aG['step_id']=aH;}else!aG['template_id']['startsWith']('tpl_')&&getTemplateById(aG['template_id'])===undefined&&!GUARD_DESIGN_PATTERNS['some'](aR=>aR['id']===aG['template_id'])&&l['push']({'code':'GUARD_PATTERN_UNKNOWN','detail':'guard\x20\x27'+aG['key']+'\x27\x20of\x20\x27'+c+'\x27\x20references\x20design\x20\x27'+aG['template_id']+'\x27,\x20which\x20exists\x20in\x20neither\x20the\x20Guard\x20design-pattern\x20catalog\x20nor\x20the\x20guard-template\x20registry\x20—\x20'+'no\x20resolution\x20path\x20can\x20ever\x20fill\x20it\x20(guide\x20confirm,\x20guard_resolutions\x20and\x20module\x20plumbing\x20all\x20key\x20off\x20real\x20ids).\x20'+'Keeping\x20it\x20as\x20a\x20pending\x20design\x20would\x20leave\x20its\x20bound\x20path\x20UNGUARDED\x20behind\x20a\x20plausible\x20pending\x20label\x20'+'(bs-mn-261022\x20TPL-01:\x20nine\x20such\x20specs\x20compiled\x20into\x20a\x20machine\x20with\x20no\x20guards\x20on\x20the\x20grant-lifecycle\x20forwards).\x20'+'Correct\x20the\x20template\x27s\x20guard\x20spec\x20id\x20to\x20a\x20known\x20pattern,\x20or\x20resolve\x20this\x20spec\x20explicitly\x20(guard_resolutions\x20with\x20kind\x20\x27inline\x27).'}),U['push'](aG);}for(const aR of feeParamCouplingMismatches(b)){l['push']({'code':'FEE_PARAM_COUPLING_MISMATCH','detail':'guard\x20\x27'+aR['key']+'\x27\x20('+aR['template_id']+')\x20claims\x20to\x20mirror\x20fee_param\x20\x27'+aR['param']+'\x27\x20('+aR['declared']+')\x20but\x20carries\x20no\x20matching\x20'+('numeric\x20literal\x20(params:\x20'+(aR['literals']['length']>0x0?aR['literals']['join'](',\x20'):'none')+').\x20The\x20guard\x20literal\x20is\x20the\x20ONLY\x20value\x20that\x20')+'becomes\x20on-chain\x20—\x20the\x20fee\x20param\x20the\x20merchant\x20sets\x20stays\x20decorative\x20(rex5-tn-261028\x20T-02).\x20'+('Re-sync\x20the\x20literal\x20with\x20fee_param\x20\x27'+aR['param']+'\x27\x20or\x20drop\x20the\x20coupling\x20claim\x20from\x20the\x20purpose.')});}for(const aS of windowMathMismatches(b)){l['push']({'code':'WINDOW_MATH_MISMATCH','detail':aS['rule']==='R-WINDOW-MATH-ZERO'?'settlement\x20window\x20fee_param\x20\x27'+aS['settle_param']+'\x27\x20=\x20'+aS['settle_value']+':\x20the\x20escrow\x20releases\x20the\x20moment\x20the\x20anchor\x20node\x20is\x20entered,\x20so\x20every\x20buyer\x20window\x20is\x20structurally\x20dead\x20from\x20the\x20first\x20order\x20(ksk4\x20F-35).\x20'+'Set\x20it\x20to\x20a\x20positive\x20duration\x20that\x20covers\x20the\x20after-sales\x20schedule.':'settlement\x20window\x20fee_param\x20\x27'+aS['settle_param']+'\x27\x20('+aS['settle_value']+')\x20opens\x20the\x20release\x20before\x20buyer\x20window\x20'+aS['violates']+'\x20closes\x20—\x20the\x20refund\x20rail\x20is\x20structurally\x20dead\x20from\x20the\x20release\x20moment,\x20since\x20settlement\x20drains\x20the\x20allocation\x20balance\x20and\x20every\x20later\x20refund\x20leg\x20aborts\x20on\x20empty\x20(ktt3\x20F-05).\x20'+'Raise\x20the\x20settlement\x20window\x20to\x20>=\x20the\x20largest\x20buyer\x20window,\x20or\x20shorten\x20the\x20buyer\x20window\x20to\x20match\x20the\x20real\x20policy;\x20re-sync\x20guards[].params\x20with\x20the\x20new\x20fee_params\x20value\x20(FEE_PARAM_COUPLING_MISMATCH).'});}const W=incentiveRatingFloorClaims(b);if(W['length']>0x0){const aT=[...new Set(W['map'](aV=>'\x27'+aV['excerpt']+'\x27\x20('+aV['field']+')'))]['join'](',\x20'),aU=[...new Set(W['map'](aV=>aV['claimed']))];if(B!=='review_reward')l['push']({'code':'INCENTIVE_RATING_FLOOR_MISMATCH','detail':'incentive\x20prose\x20promises\x20a\x20rating\x20floor\x20('+aT+')\x20but\x20review_mode\x20is\x20\x27'+B+'\x27\x20—\x20no\x20reward\x20track\x20'+'exists,\x20so\x20the\x20promise\x20pays\x20nothing\x20regardless\x20of\x20rating\x20(ktt3\x20F02/F12\x20residual).\x20'+('Build\x20with\x20review_mode\x20\x27review_reward\x27\x20and\x20reward_rating_floor\x20=\x20'+aU['join']('/')+',\x20or\x20drop\x20the\x20promise\x20from\x20the\x20prose.')});else{const aV=w['find'](b2=>b2['host']==='reward'),aW=aV!==undefined?o[aV['key']]:undefined,aX=aW?.['kind']==='template'&&aW['params']?{...aV?.['params']??{},...aW['params']}:aV?.['params']??{},aY=aX['rating_floor'],aZ=typeof aY==='number'&&Number['isFinite'](aY)?aY:typeof aY==='string'&&aY['trim']()!==''&&Number['isFinite'](Number(aY))?Number(aY):undefined,b0=Math['max'](0x0,...W['filter'](b2=>b2['kind']==='praise')['map'](b2=>b2['claimed'])),b1=[...new Set(W['filter'](b2=>b2['kind']==='numeric')['map'](b2=>b2['claimed']))];if(aZ===undefined||aZ<=0x0){const b2=aW?.['kind']==='inline'?'the\x20claim\x20guard\x20is\x20a\x20hand-designed\x20inline\x20root\x20compile\x20cannot\x20statically\x20parse\x20—\x20verify\x20its\x20rating\x20leg\x20yourself':'the\x20reward\x20track\x20carries\x20NO\x20rating\x20leg\x20(reward_rating_floor:\x200\x20explicit\x20opt-out,\x20or\x20a\x20reward\x20spec\x20without\x20rating_floor\x20—\x20the\x20S14\x20default\x20only\x20arms\x20the\x20kernel\x20DEFAULT\x20assembly)';l['push']({'code':'INCENTIVE_RATING_FLOOR_MISMATCH','detail':'incentive\x20prose\x20promises\x20a\x20rating\x20floor\x20('+aT+')\x20but\x20the\x20compiled\x20reward\x20track\x20carries\x20NO\x20statically\x20visible\x20'+('rating\x20leg:\x20'+b2+'\x20—\x20the\x20bounty\x20pays\x20even\x20at\x20rating\x201\x20while\x20the\x20store\x20page\x20advertises\x20the\x20floor\x20')+('(ktt3\x20F02/F12\x20residual;\x20S14\x20default\x20arms\x20'+E+').\x20Pass\x20reward_rating_floor\x20=\x20'+aU['join']('/')+'\x20to\x20arm\x20it,\x20or\x20drop\x20the\x20promise\x20from\x20the\x20prose.')});}else{if(b0>0x0&&aZ<b0)l['push']({'code':'INCENTIVE_RATING_FLOOR_MISMATCH','detail':'incentive\x20prose\x20promises\x20a\x20GOOD-review\x20reward\x20('+aT+')\x20—\x20a\x20praise\x20promise\x20derives\x20to\x20floor\x20'+(b0+'\x20(good\x20==\x204+,\x20S14)\x20—\x20but\x20the\x20armed\x20floor\x20is\x20'+aZ+':\x20ratings\x20between\x20'+aZ+'\x20')+('and\x20'+(b0-0x1)+'\x20would\x20PAY\x20while\x20the\x20store\x20page\x20advertises\x20a\x20good-review-only\x20bounty\x20')+('(ktt3\x20F02/F12\x20residual,\x20S14\x20praise\x20shape).\x20Raise\x20reward_rating_floor\x20to\x20>=\x20'+b0+',\x20or\x20rewrite\x20the\x20prose.')});else b1['length']>0x0&&!b1['includes'](aZ)&&l['push']({'code':'INCENTIVE_RATING_FLOOR_MISMATCH','detail':'incentive\x20prose\x20promises\x20rating\x20floor\x20'+b1['join']('/')+'\x20('+aT+')\x20but\x20the\x20armed\x20floor\x20is\x20'+aZ+'\x20—\x20'+'orders\x20at\x20the\x20promised\x20rating\x20would\x20be\x20REJECTED\x20by\x20the\x20claim\x20guard\x20while\x20the\x20store\x20page\x20advertises\x20it\x20'+'(ktt3\x20F02/F12\x20residual).\x20Align\x20reward_rating_floor\x20with\x20the\x20prose,\x20or\x20rewrite\x20the\x20prose.'});}}}if(B==='review_reward'){const b3=rewardWindowDayClaims(b);if(b3['length']>0x0){const b4=w['find'](b6=>b6['host']==='reward'),b5=b4!==undefined?o[b4['key']]:undefined;if(b4!==undefined&&b5?.['kind']!=='inline'){const b6=b5?.['kind']==='template'&&b5['params']?{...b4['params']??{},...b5['params']}:b4['params']??{},b7=bc=>typeof bc==='number'&&Number['isFinite'](bc)?bc:typeof bc==='string'&&bc['trim']()!==''&&Number['isFinite'](Number(bc))?Number(bc):undefined,b8=b7(b6['closes_after_days']),b9=b8??P,ba=[...new Set(b3['map'](bc=>bc['claimed']))],bb=[...new Set(b3['map'](bc=>'\x27'+bc['excerpt']+'\x27\x20('+bc['field']+')'))]['join'](',\x20');!ba['includes'](b9)&&l['push']({'code':'INCENTIVE_WINDOW_MISMATCH','detail':'incentive\x20prose\x20promises\x20a\x20claimable\x20span\x20of\x20'+ba['join']('/')+'\x20day(s)\x20('+bb+')\x20but\x20the\x20compiled\x20'+('claim\x20window\x20closes\x20'+b9+'\x20day(s)\x20after\x20it\x20opens\x20(closes_after_days')+(b8!==undefined?'\x20from\x20the\x20declared\x20reward\x20spec\x20params)':'\x20—\x20kernel\x20default\x20assembly,\x20bsw4\x20F-11\x20span\x20'+K)+'):\x20orders\x20claimed\x20inside\x20the\x20ADVERTISED\x20window\x20would\x20abort\x20E_GUARD_EXPIRED\x20while\x20the\x20store\x20page\x20advertises\x20it\x20'+'(h1w9\x20F-15:\x20\x227\x20days\x20to\x20claim\x22\x20advertising\x20vs\x20the\x20compiled\x2014d).\x20Align\x20the\x20window\x20—\x20pass\x20'+('reward_claim_closes_after_days\x20=\x20'+ba['join']('/')+'\x20(kernel\x20default\x20assembly)\x20or\x20pin\x20the\x20reward\x20spec\x27s\x20')+'closes_after_days\x20param\x20to\x20it\x20—\x20or\x20rewrite\x20the\x20prose.'});}}}const X=new Set(j['flatMap'](bc=>(bc['from']??[])['map'](bd=>typeof bd==='string'?undefined:bd['guard_key'])['filter'](bd=>typeof bd==='string')));for(const bc of k){typeof bc['guard_key']==='string'&&bc['recipient']==='guard_identifier'&&bc['recipient_key']===String(TASK_BINDING_SLOT)&&X['add'](bc['guard_key']);}const Y=new Set();for(const bd of w){if(!X['has'](bd['key'])&&!p['has'](bd['key']))continue;const be=T['get'](bd['key']);if(be===undefined)continue;const bf=be['table']['some'](bg=>bg['identifier']===TASK_BINDING_SLOT);if(bf)continue;T['set'](bd['key'],{...be,'table':[...be['table'],{'identifier':TASK_BINDING_SLOT,'b_submission':!![],'value_type':'Address','name':'task_binding\x20order\x20anchor\x20(protocol\x20slot\x20254;\x20written\x20by\x20order\x20creation)'}]}),Y['add'](bd['key']);}{const bg=b['settlement_window_merge'];if(bg!==undefined&&bg['length']>0x0){const bh=b['fee_params'],bi=bm=>{const bn=e[bm]??bh[bm];if(bn===undefined||bn===null)return undefined;const bo=typeof bn==='number'?bn:Number(bn);return Number['isFinite'](bo)&&bo>=0x0?bo:undefined;};let bj=0x0;for(const bm of bg){const bn=bi(bm);if(bn===undefined){bj=undefined;break;}bj+=bn;}const bk='settlement_window_merge\x20['+bg['join']('\x20+\x20')+']',bl=w['find'](bo=>{const bp=timeInstantiationFor(b['id'],bo['key']);return bp!==undefined&&bp['direction']==='lower'&&bp['days']!==undefined&&bg['includes'](bp['days']);});if(bj===undefined)l['push']({'code':'MERGED_LOCK_MISMATCH','detail':bk+':\x20a\x20merged\x20window\x20has\x20no\x20readable\x20day\x20value,\x20so\x20the\x20effective\x20release\x20lock\x20cannot\x20be\x20'+'determined.\x20Declare\x20every\x20merged\x20key\x20as\x20a\x20numeric\x20fee_param\x20(or\x20supply\x20it\x20as\x20an\x20input).'});else{if(bl===undefined)l['push']({'code':'MERGED_LOCK_MISMATCH','detail':bk+'\x20(=\x20'+bj+'\x20days)\x20declares\x20a\x20merged\x20release\x20lock,\x20but\x20no\x20compiled\x20settlement\x20gate\x20'+'(\x22lower\x22\x20time\x20instantiation\x20whose\x20day\x20knob\x20is\x20one\x20of\x20the\x20merged\x20keys)\x20carries\x20it\x20—\x20the\x20'+'declaration\x20would\x20be\x20prose\x20while\x20the\x20escrow\x20releases\x20before\x20the\x20merged\x20windows\x20finish.'});else{if(o[bl['key']]?.['kind']!=='inline'&&T['has'](bl['key'])){const bo=T['get'](bl['key'])['table'];let bp;for(const bq of bo){if(bq['identifier']!==0x3)continue;const br=bq['value'],bs=typeof br==='number'?br:Number(br);if(Number['isFinite'](bs))bp=bs;}bp!==bj&&l['push']({'code':'MERGED_LOCK_MISMATCH','detail':bk+'\x20=\x20'+bj+'\x20days\x20by\x20declaration,\x20but\x20guard\x20\x27'+bl['key']+'\x27\x20compiled\x20its\x20length\x20'+('literal\x20to\x20'+(bp===undefined?'(none)':bp+'\x20days')+'.\x20The\x20escrow\x20would\x20')+'release\x20early\x20while\x20a\x20merged\x20buyer\x20window\x20can\x20still\x20draw\x20it.'});}}}}}for(const [bt,bu]of T){const bv=normalizeGuardRowNames(bu['table'],bu['description'],MAX_GUARD_DESCRIPTION_CONTENT);(bv['table']!==bu['table']||bv['description']!==bu['description'])&&T['set'](bt,{...bu,'table':bv['table'],'description':typeof bv['description']==='string'?bv['description']:bu['description']});}return{'guardSpecs':w,'resolutions':o,'resolvedGuards':T,'unresolved':U,'omitKeys':s,'recoverTwinRails':p,'declareReasons':u,'specByKey':y,'slot254Injected':Y,'injectedOrderHolderKeys':x,'edgeBoundKeys':X,'derived':{'reviewMode':B,'rewardMark':C,'needsRepository':S},'blockers':l};}
|
|
@@ -22,16 +22,31 @@ export declare function parkUnknownOutcomeMarker(op: string, data: unknown, env?
|
|
|
22
22
|
account?: string;
|
|
23
23
|
dry_run?: boolean;
|
|
24
24
|
}, submission?: unknown): void;
|
|
25
|
+
interface IdempotencyKeyRecord {
|
|
26
|
+
op: string;
|
|
27
|
+
status: "pending" | "unknown";
|
|
28
|
+
first_seen: number;
|
|
29
|
+
sender?: string;
|
|
30
|
+
verify_events_since?: string;
|
|
31
|
+
digests: string[];
|
|
32
|
+
}
|
|
33
|
+
export declare function idempotencyKeyGate(key: string, op: string, dryRun?: boolean): IdempotencyKeyRecord | undefined;
|
|
34
|
+
export declare function idempotencyKeyObserveUnknown(key: string, op: string, kit?: {
|
|
35
|
+
sender?: string;
|
|
36
|
+
verify_events_since?: string;
|
|
37
|
+
digests?: string[];
|
|
38
|
+
}): void;
|
|
39
|
+
export declare function idempotencyKeyClear(key: string): void;
|
|
25
40
|
export declare function markerOpFor(op: string, data: unknown): string;
|
|
26
41
|
export declare function recordInFlightOutcome(markerId: string, result: unknown): void;
|
|
27
|
-
interface LandedTombstone {
|
|
42
|
+
export interface LandedTombstone {
|
|
28
43
|
op: string;
|
|
29
44
|
digest: string;
|
|
30
45
|
at: number;
|
|
31
46
|
}
|
|
32
47
|
export declare function recentLandedTombstone(): LandedTombstone | undefined;
|
|
33
48
|
export declare function clearInFlightMarkers(): number;
|
|
34
|
-
interface ReturnedDigest {
|
|
49
|
+
export interface ReturnedDigest {
|
|
35
50
|
digest: string;
|
|
36
51
|
op: string;
|
|
37
52
|
at: number;
|
|
@@ -65,4 +80,7 @@ export interface RecentOrderCandidate {
|
|
|
65
80
|
items?: unknown;
|
|
66
81
|
}
|
|
67
82
|
export declare function matchRecentOrder(marker: InFlightRecord, cand: RecentOrderCandidate): string | undefined;
|
|
83
|
+
export declare function listInFlightMarkers(): InFlightRecord[];
|
|
84
|
+
export declare function recentReturnedDigests(limit?: number): ReturnedDigest[];
|
|
85
|
+
export declare function recentLandedTombstones(): LandedTombstone[];
|
|
68
86
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const MAX_RECORDS=0x32,MAX_AGE_MS=0x2*0x3c*0x3c*0x3e8,records=new Map();let seq=0x0;function hash(a){let b=0x1505;for(let c=0x0;c<a['length'];c++)b=(b<<0x5)+b+a['charCodeAt'](c)>>>0x0;return b['toString'](0x10);}function prune(){const a=Date['now']();for(const [b,c]of records){if(a-c['started_at']>MAX_AGE_MS)records['delete'](b);}while(records['size']>MAX_RECORDS){const d=records['keys']()['next']()['value'];if(d===undefined)break;records['delete'](d);}}function addr(a){return typeof a==='string'&&a['startsWith']('0x')?a:undefined;}export function isDeterministicOutcomeMessage(a){return/MoveAbort|abort code|has been deleted|new guard check failed|guard verification would fail on-chain/i['test'](a)||/cannot derive total_pay|buy\.total_pay is (omitted|REQUIRED)/i['test'](a);}export function beginInFlight(a,b,c,d,e){if(c?.['dry_run']===!![])return'';const f=b,g=f?.['order_new']?.['buy'],h=f?.['alloc_by_guard']!=null,i=g?.['total_pay']!=null&&typeof g['total_pay']==='object'?g['total_pay']['balance']:undefined,j=Array['isArray'](g?.['items'])?g['items']['map'](l=>typeof l?.['name']==='string'?l['name']:'')['filter'](Boolean):undefined,k={'marker_id':'ifl_'+Date['now']()['toString'](0x10)+'_'+(seq++)['toString'](0x10),'op':a,'service':h?undefined:addr(f?.['object'])??addr(g?.['service']),'allocation':h?addr(f?.['object']):undefined,'buyer':addr(c?.['account']),'items_count':Array['isArray'](g?.['items'])?g['items']['length']:undefined,...typeof i==='string'&&i!==''?{'total_pay':i}:{},...j&&j['length']>0x0?{'item_names':j}:{},'params_hash':inFlightParamsHash(b,d,c?.['account']),'started_at':e??Date['now'](),'digests':[],'status':'in_flight'};return records['set'](k['marker_id'],k),prune(),k['marker_id'];}const UNKNOWN_OUTCOME_BACKDATE_MS=0x3c*0x3e8;export function parkUnknownOutcomeMarker(a,b,c,d){if(c?.['dry_run']===!![])return;if(lastInFlightMarker(a,inFlightParamsHash(b,d,c?.['account'])))return;beginInFlight(a,b,c,d,Date['now']()-UNKNOWN_OUTCOME_BACKDATE_MS);}export function markerOpFor(a,b){const c=b;if(c?.['order_new']!=null)return'order_new';if(c?.['alloc_by_guard']!=null)return'alloc_by_guard';return a;}export function recordInFlightOutcome(a,b){const c=records['get'](a);if(!c)return;const d=b?.['digest'];typeof d==='string'&&d&&(recordLandedTombstone(c['op'],d),records['delete'](a));}const MAX_TOMBSTONES=0xa,TOMBSTONE_MAX_AGE_MS=0xa*0x3c*0x3e8,tombstones=[];function recordLandedTombstone(a,b){tombstones['push']({'op':a,'digest':b,'at':Date['now']()});while(tombstones['length']>MAX_TOMBSTONES)tombstones['shift']();}export function recentLandedTombstone(){const a=Date['now']();while(tombstones['length']>0x0&&a-tombstones[0x0]['at']>TOMBSTONE_MAX_AGE_MS)tombstones['shift']();return tombstones['length']>0x0?tombstones[tombstones['length']-0x1]:undefined;}export function clearInFlightMarkers(){const a=records['size']+tombstones['length'];return records['clear'](),tombstones['length']=0x0,a;}const MAX_RETURNED_DIGESTS=0x200,returnedDigests=[];export function noteReturnedDigest(a,b){if(!a||a['startsWith']('dry_run:'))return;if(returnedDigests['some'](c=>c['digest']===a))return;returnedDigests['push']({'digest':a,'op':b,'at':Date['now']()});while(returnedDigests['length']>MAX_RETURNED_DIGESTS)returnedDigests['shift']();}export function priorReturnOfDigest(a){if(!a)return undefined;for(let b=returnedDigests['length']-0x1;b>=0x0;b--){if(returnedDigests[b]['digest']===a)return returnedDigests[b];}return undefined;}export function attachInFlightDigest(a,b,c){const d=lastInFlightMarker(a,b);if(!d)return;if(!d['digests']['includes'](c))d['digests']['push'](c);}export function inFlightParamsHash(a,b,c){const d=typeof c==='string'?c['trim']()['toLowerCase']():'';return hash(JSON['stringify'](a??{})+'\x00'+JSON['stringify'](b??null)+'\x00'+d);}export function describeLastInFlight(a,b){let c;for(const f of records['values']()){if(f['op']!==a)continue;if(b!==undefined&&f['params_hash']!==b)continue;c=f;}if(!c)return undefined;const d=[c['service']?'service='+c['service']:undefined,c['allocation']?'allocation='+c['allocation']:undefined,c['buyer']?'buyer='+c['buyer']:undefined,c['items_count']!==undefined?'items='+c['items_count']:undefined]['filter'](Boolean)['join']('\x20'),e=c['digests']['length']>0x0?'\x0aReported\x20submission\x20digest(s):\x20'+c['digests']['join'](',\x20')+'\x20—\x20verify\x20THE\x20DIGEST\x20FIRST\x20'+'(onchain_transaction\x20by\x20digest):\x20an\x20executed\x20status\x20means\x20the\x20operation\x20LANDED\x20—\x20adopt\x20the\x20'+'created\x20object(s)\x20and\x20stop;\x20a\x20failure\x20status\x20is\x20FINAL\x20(its\x20bytes\x20are\x20consumed\x20—\x20fix\x20the\x20cause\x20'+'and\x20build\x20a\x20fresh\x20transaction);\x20a\x20digest\x20that\x20does\x20not\x20resolve\x20means\x20nothing\x20landed\x20and\x20a\x20'+'resubmit\x20is\x20safe.':'';return'IN-FLIGHT\x20MARKER\x20'+c['marker_id']+':\x20op='+c['op']+'\x20'+d+'\x20started\x20'+new Date(c['started_at'])['toISOString']()+'\x20'+'—\x20this\x20operation\x20is\x20observability-non-atomic:\x20a\x20transport\x20drop\x20after\x20submit\x20leaves\x20the\x20commit\x20state\x20'+'open.\x20Before\x20resubmitting,\x20first\x20verify\x20whether\x20an\x20order\x20with\x20this\x20exact\x20signature\x20already\x20landed\x20'+'(query\x20the\x20sender\x27s\x20recent\x20on-chain\x20objects\x20or\x20onchain_events\x20for\x20this\x20service);\x20adopt\x20it\x20if\x20present,\x20'+'resubmit\x20only\x20if\x20confirmed\x20absent.'+e;}export function lastInFlightMarker(a,b){let c;for(const d of records['values']()){if(d['op']!==a)continue;if(b!==undefined&&d['params_hash']!==b)continue;c=d;}return c;}export function consumeInFlightMarker(a,b){let c=0x0;for(const [d,e]of records){e['op']===a&&e['params_hash']===b&&(records['delete'](d),c++);}return c;}const RESEND_INTERCEPT_WINDOW_MS=0x78*0x3e8;export function pendingInFlightResend(a,b,c,d){if(d?.['dry_run']===!![])return undefined;const e=lastInFlightMarker(a,inFlightParamsHash(b,c,d?.['account']));if(!e)return undefined;if(Date['now']()-e['started_at']>=RESEND_INTERCEPT_WINDOW_MS)return undefined;const f=e['allocation']??e['service']??'the\x20object\x20referenced\x20by\x20this\x20call',g=new Date(e['started_at']+RESEND_INTERCEPT_WINDOW_MS)['toISOString'](),h=e['allocation']?'query\x20the\x20Allocation\x20object\x20and\x20the\x20Payment\x20object(s)\x20it\x20produced\x20'+'(onchain_objects\x20/\x20onchain_events\x20for\x20this\x20allocation)':'query\x20the\x20object(s)\x20this\x20exact\x20call\x20creates\x20or\x20mutates,\x20and\x20the\x20signing\x20'+'account\x27s\x20recent\x20events\x20(query_toolkit\x20onchain_objects\x20/\x20onchain_events\x20for\x20the\x20sender)';return'THIS\x20EXACT\x20CALL\x20WAS\x20SUBMITTED\x20MOMENTS\x20AGO\x20AND\x20ITS\x20OUTCOME\x20WAS\x20NEVER\x20OBSERVED\x20'+('(in-flight\x20marker\x20'+e['marker_id']+',\x20started\x20'+new Date(e['started_at'])['toISOString']()+',\x20')+('op='+e['op']+',\x20'+f+').\x20The\x20call\x20is\x20observability-non-atomic:\x20a\x20transport\x20drop\x20after\x20submit\x20')+'leaves\x20the\x20commit\x20state\x20open,\x20and\x20resubmitting\x20the\x20same\x20payload\x20without\x20checking\x20may\x20move\x20the\x20funds\x20'+'a\x20second\x20time.\x20Before\x20doing\x20anything\x20else,\x20verify\x20whether\x20the\x20previous\x20submission\x20already\x20landed:\x20'+(h+'\x20—\x20if\x20a\x20result\x20already\x20landed,\x20adopt\x20it\x20and\x20stop;\x20')+'only\x20resubmit\x20once\x20you\x20have\x20confirmed\x20on-chain\x20that\x20nothing\x20landed.\x20'+'Scope\x20of\x20this\x20check:\x20it\x20holds\x20ONLY\x20this\x20exact\x20payload\x20(data\x20+\x20submission\x20envelope\x20together),\x20and\x20'+('only\x20until\x20'+g+'\x20('+Math['round'](RESEND_INTERCEPT_WINDOW_MS/0x3e8)+'s\x20from\x20the\x20marker\x20start)\x20—\x20')+'past\x20that\x20moment\x20the\x20identical\x20call\x20goes\x20through\x20unchanged.\x20A\x20changed\x20payload\x20(different\x20amounts,\x20'+'recipients,\x20targets,\x20or\x20a\x20corrected\x20submission\x20envelope)\x20is\x20never\x20affected:\x20fixing\x20the\x20envelope\x20and\x20'+'retrying\x20right\x20away\x20is\x20always\x20allowed.';}export function matchOrderLandedEvent(a,b){const c=a['started_at']-0xf*0x3e8,d=Number(b?.['time']);if(Number['isFinite'](d)&&d<c)return undefined;if(priorReturnOfDigest(b?.['digest']))return undefined;if(a['total_pay']!=null&&b?.['amount']!=null&&amountMatches(a['total_pay'],b['amount'])===![])return undefined;const e=!!(a['service']&&b?.['service']&&b['service']===a['service']),f=!!(a['buyer']&&b?.['sender']&&b['sender']['toLowerCase']()===a['buyer']['toLowerCase']());if(!e&&!f)return undefined;if(a['buyer']&&b?.['sender']&&!f)return undefined;const g=b?.['digest']??'unknown';return'AUTO-VERIFIED\x20ON-CHAIN:\x20this\x20order\x20DID\x20land\x20despite\x20the\x20error\x20above\x20—\x20order='+(b?.['order']??'?')+((b?.['progress']?'\x20progress='+b['progress']:'')+'\x20digest='+g+'.\x20ADOPT\x20this\x20order\x20object;\x20')+'resubmitting\x20the\x20same\x20call\x20would\x20escrow\x20a\x20SECOND\x20time.';}function amountMatches(c,d){try{const e=BigInt(String(c)),f=BigInt(String(d));return e===f;}catch{return undefined;}}export function matchRecentOrder(a,b){const c=a['started_at']-0xf*0x3e8,d=Number(b?.['time']);if(!Number['isFinite'](d)||d<c)return undefined;if(a['buyer']&&b?.['owner']&&b['owner']['toLowerCase']()!==a['buyer']['toLowerCase']())return undefined;const e=amountMatches(a['total_pay'],b?.['amount']);if(e===![])return undefined;const f=Array['isArray'](b?.['items'])?b['items']['map'](k=>typeof k?.['name']==='string'?k['name']['toLowerCase']():'')['filter'](Boolean)['sort']():undefined,g=(a['item_names']??[])['map'](k=>k['toLowerCase']())['sort'](),h=g['length']>0x0&&f!==undefined;if(h&&JSON['stringify'](g)!==JSON['stringify'](f))return undefined;const i=[a['buyer']&&b?.['owner']?'owner-verified':undefined,e===!![]?'amount-verified':undefined,h?'items-verified':undefined]['filter'](Boolean),j=i['length']>0x0?',\x20'+i['join'](',\x20'):'';return'AUTO-VERIFIED\x20ON-CHAIN:\x20this\x20order\x20DID\x20land\x20despite\x20the\x20error\x20above\x20—\x20order='+(b?.['order']??'?')+'\x20'+('(service\x20recent_orders\x20reverse\x20lookup'+j+').\x20ADOPT\x20this\x20order\x20object;\x20')+'resubmitting\x20the\x20same\x20call\x20would\x20escrow\x20a\x20SECOND\x20time.';}
|
|
1
|
+
const MAX_RECORDS=0x32,MAX_AGE_MS=0x2*0x3c*0x3c*0x3e8,records=new Map();let seq=0x0;function hash(a){let b=0x1505;for(let c=0x0;c<a['length'];c++)b=(b<<0x5)+b+a['charCodeAt'](c)>>>0x0;return b['toString'](0x10);}function prune(){const a=Date['now']();for(const [b,c]of records){if(a-c['started_at']>MAX_AGE_MS)records['delete'](b);}while(records['size']>MAX_RECORDS){const d=records['keys']()['next']()['value'];if(d===undefined)break;records['delete'](d);}}function addr(a){return typeof a==='string'&&a['startsWith']('0x')?a:undefined;}export function isDeterministicOutcomeMessage(a){return/MoveAbort|abort code|has been deleted|new guard check failed|guard verification would fail on-chain/i['test'](a)||/cannot derive total_pay|buy\.total_pay is (omitted|REQUIRED)/i['test'](a);}export function beginInFlight(a,b,c,d,e){if(c?.['dry_run']===!![])return'';const f=b,g=f?.['order_new']?.['buy'],h=f?.['alloc_by_guard']!=null,i=g?.['total_pay']!=null&&typeof g['total_pay']==='object'?g['total_pay']['balance']:undefined,j=Array['isArray'](g?.['items'])?g['items']['map'](l=>typeof l?.['name']==='string'?l['name']:'')['filter'](Boolean):undefined,k={'marker_id':'ifl_'+Date['now']()['toString'](0x10)+'_'+(seq++)['toString'](0x10),'op':a,'service':h?undefined:addr(f?.['object'])??addr(g?.['service']),'allocation':h?addr(f?.['object']):undefined,'buyer':addr(c?.['account']),'items_count':Array['isArray'](g?.['items'])?g['items']['length']:undefined,...typeof i==='string'&&i!==''?{'total_pay':i}:{},...j&&j['length']>0x0?{'item_names':j}:{},'params_hash':inFlightParamsHash(b,d,c?.['account']),'started_at':e??Date['now'](),'digests':[],'status':'in_flight'};return records['set'](k['marker_id'],k),prune(),k['marker_id'];}const UNKNOWN_OUTCOME_BACKDATE_MS=0x3c*0x3e8;export function parkUnknownOutcomeMarker(a,b,c,d){if(c?.['dry_run']===!![])return;if(lastInFlightMarker(a,inFlightParamsHash(b,d,c?.['account'])))return;beginInFlight(a,b,c,d,Date['now']()-UNKNOWN_OUTCOME_BACKDATE_MS);}const MAX_IDEM_KEYS=0x64,IDEM_PENDING_TTL_MS=0x3c*0x3c*0x3e8,IDEM_UNKNOWN_TTL_MS=0xf*0x3c*0x3e8,idemKeys=new Map();function pruneIdemKeys(){const a=Date['now']();for(const [b,c]of idemKeys){const d=c['status']==='unknown'?IDEM_UNKNOWN_TTL_MS:IDEM_PENDING_TTL_MS;if(a-c['first_seen']>d)idemKeys['delete'](b);}while(idemKeys['size']>MAX_IDEM_KEYS){const e=idemKeys['keys']()['next']()['value'];if(e===undefined)break;idemKeys['delete'](e);}}export function idempotencyKeyGate(a,b,c){if(c===!![])return idemKeys['get'](a);pruneIdemKeys();const d=idemKeys['get'](a);if(d)return d;return idemKeys['set'](a,{'op':b,'status':'pending','first_seen':Date['now'](),'digests':[]}),undefined;}export function idempotencyKeyObserveUnknown(a,b,c){pruneIdemKeys(),idemKeys['set'](a,{'op':b,'status':'unknown','first_seen':idemKeys['get'](a)?.['first_seen']??Date['now'](),...c?.['sender']?{'sender':c['sender']}:{},...c?.['verify_events_since']?{'verify_events_since':c['verify_events_since']}:{},...c?.['digests']&&c['digests']['length']>0x0?{'digests':c['digests']}:{'digests':[]}});}export function idempotencyKeyClear(a){idemKeys['delete'](a);}export function markerOpFor(a,b){const c=b;if(c?.['order_new']!=null)return'order_new';if(c?.['alloc_by_guard']!=null)return'alloc_by_guard';return a;}export function recordInFlightOutcome(a,b){const c=records['get'](a);if(!c)return;const d=b?.['digest'];typeof d==='string'&&d&&(recordLandedTombstone(c['op'],d),records['delete'](a));}const MAX_TOMBSTONES=0xa,TOMBSTONE_MAX_AGE_MS=0xa*0x3c*0x3e8,tombstones=[];function recordLandedTombstone(a,b){tombstones['push']({'op':a,'digest':b,'at':Date['now']()});while(tombstones['length']>MAX_TOMBSTONES)tombstones['shift']();}export function recentLandedTombstone(){const a=Date['now']();while(tombstones['length']>0x0&&a-tombstones[0x0]['at']>TOMBSTONE_MAX_AGE_MS)tombstones['shift']();return tombstones['length']>0x0?tombstones[tombstones['length']-0x1]:undefined;}export function clearInFlightMarkers(){const a=records['size']+tombstones['length'];return records['clear'](),tombstones['length']=0x0,a;}const MAX_RETURNED_DIGESTS=0x200,returnedDigests=[];export function noteReturnedDigest(a,b){if(!a||a['startsWith']('dry_run:'))return;if(returnedDigests['some'](c=>c['digest']===a))return;returnedDigests['push']({'digest':a,'op':b,'at':Date['now']()});while(returnedDigests['length']>MAX_RETURNED_DIGESTS)returnedDigests['shift']();}export function priorReturnOfDigest(a){if(!a)return undefined;for(let b=returnedDigests['length']-0x1;b>=0x0;b--){if(returnedDigests[b]['digest']===a)return returnedDigests[b];}return undefined;}export function attachInFlightDigest(a,b,c){const d=lastInFlightMarker(a,b);if(!d)return;if(!d['digests']['includes'](c))d['digests']['push'](c);}export function inFlightParamsHash(a,b,c){const d=typeof c==='string'?c['trim']()['toLowerCase']():'';return hash(JSON['stringify'](a??{})+'\x00'+JSON['stringify'](b??null)+'\x00'+d);}export function describeLastInFlight(a,b){let c;for(const f of records['values']()){if(f['op']!==a)continue;if(b!==undefined&&f['params_hash']!==b)continue;c=f;}if(!c)return undefined;const d=[c['service']?'service='+c['service']:undefined,c['allocation']?'allocation='+c['allocation']:undefined,c['buyer']?'buyer='+c['buyer']:undefined,c['items_count']!==undefined?'items='+c['items_count']:undefined]['filter'](Boolean)['join']('\x20'),e=c['digests']['length']>0x0?'\x0aReported\x20submission\x20digest(s):\x20'+c['digests']['join'](',\x20')+'\x20—\x20verify\x20THE\x20DIGEST\x20FIRST\x20'+'(onchain_transaction\x20by\x20digest):\x20an\x20executed\x20status\x20means\x20the\x20operation\x20LANDED\x20—\x20adopt\x20the\x20'+'created\x20object(s)\x20and\x20stop;\x20a\x20failure\x20status\x20is\x20FINAL\x20(its\x20bytes\x20are\x20consumed\x20—\x20fix\x20the\x20cause\x20'+'and\x20build\x20a\x20fresh\x20transaction);\x20a\x20digest\x20that\x20does\x20not\x20resolve\x20means\x20nothing\x20landed\x20and\x20a\x20'+'resubmit\x20is\x20safe.':'';return'IN-FLIGHT\x20MARKER\x20'+c['marker_id']+':\x20op='+c['op']+'\x20'+d+'\x20started\x20'+new Date(c['started_at'])['toISOString']()+'\x20'+'—\x20this\x20operation\x20is\x20observability-non-atomic:\x20a\x20transport\x20drop\x20after\x20submit\x20leaves\x20the\x20commit\x20state\x20'+'open.\x20Before\x20resubmitting,\x20first\x20verify\x20whether\x20an\x20order\x20with\x20this\x20exact\x20signature\x20already\x20landed\x20'+'(query\x20the\x20sender\x27s\x20recent\x20on-chain\x20objects\x20or\x20onchain_events\x20for\x20this\x20service);\x20adopt\x20it\x20if\x20present,\x20'+'resubmit\x20only\x20if\x20confirmed\x20absent.'+e;}export function lastInFlightMarker(a,b){let c;for(const d of records['values']()){if(d['op']!==a)continue;if(b!==undefined&&d['params_hash']!==b)continue;c=d;}return c;}export function consumeInFlightMarker(a,b){let c=0x0;for(const [d,e]of records){e['op']===a&&e['params_hash']===b&&(records['delete'](d),c++);}return c;}const RESEND_INTERCEPT_WINDOW_MS=0x78*0x3e8;export function pendingInFlightResend(a,b,c,d){if(d?.['dry_run']===!![])return undefined;const e=lastInFlightMarker(a,inFlightParamsHash(b,c,d?.['account']));if(!e)return undefined;if(Date['now']()-e['started_at']>=RESEND_INTERCEPT_WINDOW_MS)return undefined;const f=e['allocation']??e['service']??'the\x20object\x20referenced\x20by\x20this\x20call',g=new Date(e['started_at']+RESEND_INTERCEPT_WINDOW_MS)['toISOString'](),h=e['allocation']?'query\x20the\x20Allocation\x20object\x20and\x20the\x20Payment\x20object(s)\x20it\x20produced\x20'+'(onchain_objects\x20/\x20onchain_events\x20for\x20this\x20allocation)':'query\x20the\x20object(s)\x20this\x20exact\x20call\x20creates\x20or\x20mutates,\x20and\x20the\x20signing\x20'+'account\x27s\x20recent\x20events\x20(query_toolkit\x20onchain_objects\x20/\x20onchain_events\x20for\x20the\x20sender)';return'THIS\x20EXACT\x20CALL\x20WAS\x20SUBMITTED\x20MOMENTS\x20AGO\x20AND\x20ITS\x20OUTCOME\x20WAS\x20NEVER\x20OBSERVED\x20'+('(in-flight\x20marker\x20'+e['marker_id']+',\x20started\x20'+new Date(e['started_at'])['toISOString']()+',\x20')+('op='+e['op']+',\x20'+f+').\x20The\x20call\x20is\x20observability-non-atomic:\x20a\x20transport\x20drop\x20after\x20submit\x20')+'leaves\x20the\x20commit\x20state\x20open,\x20and\x20resubmitting\x20the\x20same\x20payload\x20without\x20checking\x20may\x20move\x20the\x20funds\x20'+'a\x20second\x20time.\x20Before\x20doing\x20anything\x20else,\x20verify\x20whether\x20the\x20previous\x20submission\x20already\x20landed:\x20'+(h+'\x20—\x20if\x20a\x20result\x20already\x20landed,\x20adopt\x20it\x20and\x20stop;\x20')+'only\x20resubmit\x20once\x20you\x20have\x20confirmed\x20on-chain\x20that\x20nothing\x20landed.\x20'+'Scope\x20of\x20this\x20check:\x20it\x20holds\x20ONLY\x20this\x20exact\x20payload\x20(data\x20+\x20submission\x20envelope\x20together),\x20and\x20'+('only\x20until\x20'+g+'\x20('+Math['round'](RESEND_INTERCEPT_WINDOW_MS/0x3e8)+'s\x20from\x20the\x20marker\x20start)\x20—\x20')+'past\x20that\x20moment\x20the\x20identical\x20call\x20goes\x20through\x20unchanged.\x20A\x20changed\x20payload\x20(different\x20amounts,\x20'+'recipients,\x20targets,\x20or\x20a\x20corrected\x20submission\x20envelope)\x20is\x20never\x20affected:\x20fixing\x20the\x20envelope\x20and\x20'+'retrying\x20right\x20away\x20is\x20always\x20allowed.';}export function matchOrderLandedEvent(a,b){const c=a['started_at']-0xf*0x3e8,d=Number(b?.['time']);if(Number['isFinite'](d)&&d<c)return undefined;if(priorReturnOfDigest(b?.['digest']))return undefined;if(a['total_pay']!=null&&b?.['amount']!=null&&amountMatches(a['total_pay'],b['amount'])===![])return undefined;const e=!!(a['service']&&b?.['service']&&b['service']===a['service']),f=!!(a['buyer']&&b?.['sender']&&b['sender']['toLowerCase']()===a['buyer']['toLowerCase']());if(!e&&!f)return undefined;if(a['buyer']&&b?.['sender']&&!f)return undefined;const g=b?.['digest']??'unknown';return'AUTO-VERIFIED\x20ON-CHAIN:\x20this\x20order\x20DID\x20land\x20despite\x20the\x20error\x20above\x20—\x20order='+(b?.['order']??'?')+((b?.['progress']?'\x20progress='+b['progress']:'')+'\x20digest='+g+'.\x20ADOPT\x20this\x20order\x20object;\x20')+'resubmitting\x20the\x20same\x20call\x20would\x20escrow\x20a\x20SECOND\x20time.';}function amountMatches(c,d){try{const e=BigInt(String(c)),f=BigInt(String(d));return e===f;}catch{return undefined;}}export function matchRecentOrder(a,b){const c=a['started_at']-0xf*0x3e8,d=Number(b?.['time']);if(!Number['isFinite'](d)||d<c)return undefined;if(a['buyer']&&b?.['owner']&&b['owner']['toLowerCase']()!==a['buyer']['toLowerCase']())return undefined;const e=amountMatches(a['total_pay'],b?.['amount']);if(e===![])return undefined;const f=Array['isArray'](b?.['items'])?b['items']['map'](k=>typeof k?.['name']==='string'?k['name']['toLowerCase']():'')['filter'](Boolean)['sort']():undefined,g=(a['item_names']??[])['map'](k=>k['toLowerCase']())['sort'](),h=g['length']>0x0&&f!==undefined;if(h&&JSON['stringify'](g)!==JSON['stringify'](f))return undefined;const i=[a['buyer']&&b?.['owner']?'owner-verified':undefined,e===!![]?'amount-verified':undefined,h?'items-verified':undefined]['filter'](Boolean),j=i['length']>0x0?',\x20'+i['join'](',\x20'):'';return'AUTO-VERIFIED\x20ON-CHAIN:\x20this\x20order\x20DID\x20land\x20despite\x20the\x20error\x20above\x20—\x20order='+(b?.['order']??'?')+'\x20'+('(service\x20recent_orders\x20reverse\x20lookup'+j+').\x20ADOPT\x20this\x20order\x20object;\x20')+'resubmitting\x20the\x20same\x20call\x20would\x20escrow\x20a\x20SECOND\x20time.';}export function listInFlightMarkers(){return Array['from'](records['values']())['map'](a=>({...a,'digests':[...a['digests']]}));}export function recentReturnedDigests(a=0x14){return returnedDigests['slice'](-a)['reverse']();}export function recentLandedTombstones(){return recentLandedTombstone(),[...tombstones];}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { JsonValue, DerivedParam } from "./plan.js";
|
|
2
|
+
import type { AllocatorRowData, CompilableTemplate, CompileBlocker } from "./compile.js";
|
|
3
|
+
export declare function normalizeCompileInputs(template: CompilableTemplate, inputs: Record<string, JsonValue>, buildTimeMs?: number): {
|
|
4
|
+
inputs: Record<string, JsonValue>;
|
|
5
|
+
derivedParams: DerivedParam[];
|
|
6
|
+
blockers: CompileBlocker[];
|
|
7
|
+
};
|
|
8
|
+
export interface ConditionalSelection {
|
|
9
|
+
dropKeys: Set<string>;
|
|
10
|
+
selectorDroppedKeys: Set<string>;
|
|
11
|
+
shape: CompilableTemplate["machine_shape"];
|
|
12
|
+
rows: AllocatorRowData[];
|
|
13
|
+
blockers: CompileBlocker[];
|
|
14
|
+
}
|
|
15
|
+
export declare function applyConditionalSelectors(template: CompilableTemplate, inputs: Record<string, JsonValue>): ConditionalSelection;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export function normalizeCompileInputs(a,b,c){const d=[],e=[];b['review_reward_pool']!==undefined&&b['reward_funding']===undefined&&(b={...b,'reward_funding':b['review_reward_pool']});{const f=a['fee_params'],g=f['campaign_deadline_ms']!==undefined,h=f['campaign_duration_days']!==undefined,i=b['campaign_duration_hours']!==undefined;if(g&&(h||i)){const j=w=>{if(w===undefined||w===null||w==='')return undefined;const x=typeof w==='number'?w:Number(w);return Number['isFinite'](x)?x:undefined;},l=j(b['campaign_deadline_ms']),m=j(b['campaign_duration_days']),o=j(b['campaign_duration_hours']),p=j(f['campaign_deadline_ms']),q=j(f['campaign_duration_days']),r=m!==undefined?m*0x5265c00:o!==undefined?o*0x36ee80:q!==undefined?q*0x5265c00:undefined,s=m!==undefined?'campaign_duration_days':o!==undefined?'campaign_duration_hours':'campaign_duration_days',t=m??o??q??0x0,u=l!==undefined&&l>0x0?l:p,v=m!==undefined||o!==undefined||u===undefined||u===0x0;if(c!==undefined&&r!==undefined&&r>0x0&&v){const w=Math['round'](c+r),x=m!==undefined?Math['round'](c+m*0x5265c00):undefined,y=o!==undefined?Math['round'](c+o*0x36ee80):undefined,z=[u!==undefined&&u>0x0?u:undefined,x,y]['filter'](A=>A!==undefined);new Set(z)['size']>0x1?d['push']({'code':'CAMPAIGN_DEADLINE_CONFLICT','detail':'the\x20campaign\x20answers\x20name\x20different\x20instants:\x20'+[m!==undefined?'campaign_duration_days\x20('+m+'\x20d\x20→\x20'+x+'\x20at\x20this\x20build\x20instant)':undefined,o!==undefined?'campaign_duration_hours\x20('+o+'\x20h\x20→\x20'+y+'\x20at\x20this\x20build\x20instant)':undefined,u!==undefined&&u>0x0?'campaign_deadline_ms\x20('+u+')':undefined]['filter'](Boolean)['join'](',\x20')+'.\x20ONE\x20campaign\x20has\x20ONE\x20deadline:\x20pass\x20ONE\x20length\x20(days\x20OR\x20hours)\x20or\x20the\x20absolute\x20timestamp,\x20and\x20drop\x20the\x20others\x20(0\x20=\x20unset\x20is\x20not\x20a\x20deadline).'}):(b={...b,'campaign_deadline_ms':w},e['push']({'param':'campaign_deadline_ms','from':s,'input':t,'value':w,'at_ms':c,'note':'converted\x20at\x20generation:\x20'+t+'\x20'+(s==='campaign_duration_hours'?'hour(s)':'day(s)')+'\x20after\x20the\x20build\x20instant\x20'+('('+new Date(c)['toISOString']()+')\x20became\x20the\x20ABSOLUTE\x20campaign\x20')+('deadline\x20epoch-ms\x20'+w+'\x20—\x20the\x20value\x20every\x20deadline\x20gate\x20and\x20the\x20pre-deadline\x20')+'withdrawal\x20window\x20now\x20read\x20on\x20chain'}));}}}{const A=a['fee_params'];for(const [B,C]of Object['entries'](b)){if(!/_days$/['test'](B)||B==='campaign_duration_days'||!(B in A))continue;const D=typeof C==='number'?C:typeof C==='string'&&C['trim']()!==''?Number(C):NaN;Number['isFinite'](D)&&!Number['isInteger'](D)&&d['push']({'code':'WINDOW_TRUNCATION_ZERO','detail':'input\x20\x27'+B+'\x27\x20=\x20'+String(C)+'\x20is\x20a\x20FRACTIONAL\x20day\x20count\x20—\x20the\x20knob\x20lands\x20in\x20a\x20guard-table\x20'+('U64\x20slot\x20as\x20a\x20DAY\x20COUNT,\x20which\x20BCS\x20truncates\x20to\x20'+String(Math['trunc'](D))+':\x20any\x20`<=`\x20closing\x20window\x20')+'it\x20feeds\x20computes\x20anchor\x20+\x200\x20and\x20welds\x20shut\x20the\x20instant\x20its\x20anchor\x20entry\x20lands\x20(Guards\x20are\x20'+'immutable\x20—\x20the\x20live\x20run\x20compiled\x20a\x200.002-day\x20test\x20window\x20into\x20a\x20permanently\x20closed\x20review\x20rail).\x20'+'Pass\x20whole\x20days,\x20or\x20express\x20sub-day\x20precision\x20as\x20a\x20millisecond\x20duration\x20in\x20a\x20'+'ms-denominated\x20slot\x20pair\x20(duration\x20in\x20ms\x20beside\x20ms_per_day\x20=\x201).'});}}return{'inputs':b,'derivedParams':e,'blockers':d};}export function applyConditionalSelectors(a,b){const d=[],e=new Set();for(const k of a['conditional_guards']??[]){const l=b[k['param']]??a['fee_params'][k['param']];if(l!==k['emit_value'])e['add'](k['guard_key']);}{const m=new Map();for(const n of a['conditional_guards']??[]){const o=m['get'](n['param']);if(o===undefined)m['set'](n['param'],new Set(n['values']??[]));else{for(const p of n['values']??[])o['add'](p);}}for(const [q,r]of m){if(r['size']===0x0)continue;const s=b[q];if(s===undefined||s===null||s==='')continue;const t=String(s);if(r['has'](t))continue;d['push']({'code':'SELECTOR_VALUE_UNKNOWN','detail':'build\x20input\x20\x27'+q+'\x27\x20=\x20\x27'+t+'\x27\x20is\x20outside\x20the\x20value\x20set\x20this\x20template\x20accepts\x20'+('('+[...r]['join']('\x20|\x20')+').\x20The\x20param\x20drives\x20a\x20conditional\x20guard\x20emission,\x20so\x20an\x20out-of-set\x20answer\x20')+'used\x20to\x20compile\x20the\x20DEFAULT\x20business\x20model\x20silently\x20instead\x20of\x20the\x20one\x20asked\x20for\x20—\x20on\x20the\x20'+'storefront_mode\x20/\x20deposit_exit_policy\x20families\x20that\x20means\x20a\x20public\x20storefront\x20or\x20a\x20refunded\x20deposit\x20'+'with\x20no\x20warning\x20at\x20all.\x20Answer\x20one\x20of\x20the\x20accepted\x20values,\x20or\x20drop\x20the\x20input\x20to\x20take\x20the\x20declared\x20'+('default\x20(\x27'+String(a['fee_params'][q]??'none')+'\x27).')});}}const f=new Map();for(const u of a['conditional_guards']??[]){f['set'](u['param'],(f['get'](u['param'])??0x0)+0x1);}const g=new Set((a['conditional_guards']??[])['filter'](w=>(f['get'](w['param'])??0x0)>0x1)['map'](w=>w['guard_key'])),h=new Set([...e]['filter'](w=>g['has'](w))),i=h['size']>0x0?a['machine_shape']['map'](w=>({...w,'from':(w['from']??[])['filter'](x=>typeof x==='string'||x['guard_key']===undefined||!h['has'](x['guard_key']))})):a['machine_shape'],j=h['size']>0x0?(a['allocator']['rows']??[])['filter'](w=>w['guard_key']===undefined||!h['has'](w['guard_key'])):a['allocator']['rows']??[];return{'dropKeys':e,'selectorDroppedKeys':h,'shape':i,'rows':j,'blockers':d};}
|