@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
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type CreateStep, type LateQuery, type Plan } from "./plan.js";
|
|
1
|
+
import { type CreateStep, type LateQuery, type Plan, type StepId } from "./plan.js";
|
|
2
2
|
import { type PlanAuditResult } from "./audit.js";
|
|
3
3
|
export interface ExecOutcome {
|
|
4
4
|
outcome: "executed" | "failed" | "pending_input";
|
|
@@ -27,6 +27,23 @@ export declare function preflightPlan(plan: Plan): {
|
|
|
27
27
|
plan: Plan;
|
|
28
28
|
audit: PlanAuditResult;
|
|
29
29
|
};
|
|
30
|
+
export interface BindAuditOffense {
|
|
31
|
+
step: StepId;
|
|
32
|
+
slot: string;
|
|
33
|
+
kind: "intra_plan_bare_name" | "undeclared_external";
|
|
34
|
+
value: string;
|
|
35
|
+
}
|
|
36
|
+
export declare function bindAuditPlan(plan: Plan): BindAuditOffense[];
|
|
37
|
+
export interface BindRecoveryEntry {
|
|
38
|
+
step: string;
|
|
39
|
+
kind?: string;
|
|
40
|
+
object?: string;
|
|
41
|
+
address?: string;
|
|
42
|
+
funded?: string;
|
|
43
|
+
retrieval?: string;
|
|
44
|
+
}
|
|
45
|
+
export declare function bindRecoveryList(plan: Plan, executed?: Record<string, string>): BindRecoveryEntry[];
|
|
46
|
+
export declare function bindAuditReport(offenses: BindAuditOffense[], recovery: BindRecoveryEntry[]): string;
|
|
30
47
|
export type StepStatus = "executed" | "failed" | "blocked";
|
|
31
48
|
export interface StepResult {
|
|
32
49
|
stepId: string;
|
|
@@ -56,16 +73,4 @@ export interface ReadbackReport {
|
|
|
56
73
|
ok: boolean;
|
|
57
74
|
checks: ReadbackCheck[];
|
|
58
75
|
}
|
|
59
|
-
interface SharingRow {
|
|
60
|
-
mode?: string;
|
|
61
|
-
sharing?: string | number;
|
|
62
|
-
}
|
|
63
|
-
interface AllocatorRowLike {
|
|
64
|
-
track?: string;
|
|
65
|
-
guard?: unknown;
|
|
66
|
-
sharing?: SharingRow[];
|
|
67
|
-
}
|
|
68
|
-
export declare function planAllocatorRows(plan: Plan): AllocatorRowLike[];
|
|
69
76
|
export declare function conservationCheck(plan: Plan): ReadbackCheck[];
|
|
70
|
-
export declare function verifyMaterialization(plan: Plan, outputs: ReadonlyMap<string, string>, io: Pick<MaterializeIO, "read" | "env">): Promise<ReadbackReport>;
|
|
71
|
-
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{CREATABLE_OBJECTS,createsOf,isRef,resolveValue}from'./plan.js';import{auditPlan}from'./audit.js';function deriveCreated(a){if(Array['isArray'](a['created']))return a['created'];const b=Array['isArray'](a['objectChanges'])?a['objectChanges']:[];return b['filter'](d=>d?.['type']==='created'&&typeof d?.['objectId']==='string')['map'](d=>({'object':d['objectId'],'type_raw':d['objectType']}));}export function handlerExecutor(a){return async(b,c)=>{const {handleOnchainOperations:d}=await import('../tools/handlers/onchain.js'),e=await d({'operation_type':b,'data':c,'env':a}),f=e['structuredContent']??{},g=f['result']!==undefined&&f['result']['data']!==undefined?f['result']:f,h=g['data']?.['result']??g['result']??g,i=g['outcome']??g['data']?.['outcome']??f['outcome']??f['status'];return{'outcome':i==='executed'||i==='success'?'executed':i==='pending_input'?'pending_input':'failed','digest':h['digest']??g['digest'],'created':deriveCreated(h),'error':h['error']??g['error']};};}function normalizeGuardTableNames(a){if(!Array['isArray'](a))return a;return a['map'](b=>{if(!b||typeof b!=='object')return b;const c=b,d=c['name'];if(typeof d!=='string')return b;let e=d['startsWith']('0x')?'n_'+d:d;if(Buffer['byteLength'](e,'utf8')>0x3f){while(Buffer['byteLength'](e+'...','utf8')>0x3f)e=e['slice'](0x0,-0x1);e=e+'...';}return e===d?b:{...c,'name':e};});}const MAX_DESCRIPTION_CONTENT=0xf9e;function truncateToBytes(a,b){if(Buffer['byteLength'](a,'utf8')<=b)return a;let c=a;while(c['length']>0x0&&Buffer['byteLength'](c,'utf8')>b)c=c['slice'](0x0,-0x1);return c;}function truncateDescription(a){if(typeof a!=='string')return a;if(Buffer['byteLength'](a,'utf8')>MAX_DESCRIPTION_CONTENT)return truncateToBytes(a,MAX_DESCRIPTION_CONTENT-0x3)+'...';return a;}export function adaptConfigureParams(a,b){if(a==='guard_add'&&b!==null&&typeof b==='object'&&!Array['isArray'](b))return[b];if(a==='coin_add'&&b!==null&&typeof b==='object'&&!Array['isArray'](b)){const c=b,d=c['coin'];if(c['balance']===undefined&&(typeof d==='number'||typeof d==='string'&&/^[0-9]+$/['test'](d)))return{'balance':d};}if(a==='order_allocators'&&b!==null&&typeof b==='object'){const e=b,f=e['allocators'];if(Array['isArray'](f)){const g=f['map'](h=>{const i=h,j=i['sharing'];if(!Array['isArray'](j))return h;return{...i,'sharing':j['map'](k=>{const m=k,n=m['who'];if(n&&typeof n['Entity']==='string')return{...m,'who':{'Entity':{'name_or_address':n['Entity']}}};return k;})};});return{...e,'allocators':g};}}if(a==='sales'&&b!==null&&typeof b==='object'){const h=b,i=h['sales'];if(Array['isArray'](i)){const j=i['map'](k=>{if(!k||typeof k!=='object')return k;const l=k,m=l['stock']??l['quantity']??0x0;return{'suspension':![],'wip':'','wip_hash':'',...l,'stock':m};});return{...h,'sales':j};}}return b;}export function adaptCreateData(a,b){const {name:c,permission:d,type_parameter:e,nodes:f,...g}=b;if(g['description']!==undefined)g['description']=truncateDescription(g['description']);switch(a['object']){case'service':case'arbitration':return{'object':{'name':c,'type_parameter':e,'permission':d},...g};case'machine':return{'object':{'name':c,...d!==undefined?{'permission':d}:{}},...g['description']!==undefined?{'description':g['description']}:{},'node':{'op':'add','nodes':f,'bReplace':!![]}};case'guard':return{...b,'description':truncateDescription(b['description']),'table':normalizeGuardTableNames(b['table'])};case'permission':case'contact':case'repository':default:{const h=g['policies'];return{'object':{'name':c,...d!==undefined?{'permission':d}:{}},...g,...a['object']==='repository'&&Array['isArray'](h)?{'policies':{'op':'set','policy':h['map'](i=>{if(!i||typeof i!=='object')return i;const j=i;return typeof j['description']==='string'?{...j,'description':truncateToBytes(j['description'],0x1f4)}:j;})}}:{}};}}}export function preflightPlan(a){const b=auditPlan(a),c=new Set(b['findings']['map'](g=>g['rule_id'])),d=c['has']('ARB-KEY-PLANE-01'),e=b['issues']['length']===0x0&&!b['findings']['some'](g=>g['level']==='critical')&&!d,f=a['steps']['map'](g=>{if(g['op']!=='publish')return g;const h=g['preflight']['map'](i=>{const j=i['check']['endsWith']('_publish')?e:!c['has'](i['check']);return{...i,'status':j?'pass':'fail'};});return{...g,'preflight':h};});return{'plan':{...a,'steps':f},'audit':b};}function stripGenerics(a){return a['replace'](/<.*>$/,'');}function matchCreated(a,b){const c=stripGenerics(b);return a['created']['find'](d=>{if(typeof d['type_raw']!=='string'||typeof d['object']!=='string')return![];return stripGenerics(d['type_raw'])['endsWith']('::'+c);})?.['object'];}const DEFAULT_LATE=a=>{if(a['by']==='address')return a['address'];throw new Error('unresolved\x20late\x20binding\x20(no\x20resolver\x20injected):\x20local_name\x20\x27'+a['mark']+'\x27');};export async function materializePlan(a,b,c){const {plan:d,audit:f}=preflightPlan(a),g=new Map(Object['entries'](c?.['outputs']??{})),h=new Set(c?.['completedSteps']??[]),i=[],j=b['resolveLate']??DEFAULT_LATE,k=new Map(d['steps']['filter'](t=>t['op']==='create')['map'](t=>[t['id'],t['object']])),l=s=>resolveValue(s,g,j),m=s=>{if(s['account']===undefined)return b['env'];const t=b['envByAccount']?.[s['account']];if(t===undefined)throw new Error('step\x20\x27'+s['id']+'\x27\x20declares\x20account\x20\x27'+s['account']+'\x27\x20but\x20no\x20env\x20was\x20provided\x20for\x20it\x20—\x20'+('re-run\x20plan_execute\x20with\x20accounts[\x22'+s['account']+'\x22]\x20(a\x20declared\x20account\x20never\x20falls\x20back\x20')+'to\x20the\x20default\x20signer:\x20the\x20controller\x20identity\x20is\x20the\x20point)');return t;};let n=![],o='halted\x20by\x20earlier\x20failure/blocked\x20publish';const p=b['timeoutMs']!==undefined&&b['timeoutMs']>0x0?Date['now']()+b['timeoutMs']:undefined;let q=![];for(const s of d['steps']){if(n){i['push']({'stepId':s['id'],'status':'blocked','error':o});continue;}if(h['has'](s['id'])){const t=g['get'](s['id']);if(t===undefined){i['push']({'stepId':s['id'],'status':'failed','error':'resumed\x20step\x20has\x20no\x20recorded\x20output\x20—\x20pass\x20it\x20in\x20previous_outputs'}),n=!![];continue;}i['push']({'stepId':s['id'],'status':'executed','address':t,'error':'resumed\x20from\x20a\x20prior\x20run\x20(adopted,\x20not\x20re-executed)'});continue;}if(p!==undefined&&Date['now']()>=p){q=!![],n=!![],o='time\x20budget\x20('+b['timeoutMs']+'ms)\x20exhausted\x20before\x20this\x20step\x20—\x20RESUME,\x20not\x20re-run:\x20send\x20plan_execute\x20again\x20with\x20completed_steps\x20=\x20every\x20stepId\x20whose\x20status\x20is\x20\x27executed\x27,\x20previous_outputs\x20=\x20outputs',i['push']({'stepId':s['id'],'status':'blocked','error':o});continue;}try{if(s['op']==='publish'){const x=s['preflight']['filter'](A=>A['status']==='fail');if(x['length']>0x0){i['push']({'stepId':s['id'],'status':'blocked','error':'preflight\x20failed:\x20'+x['map'](A=>A['check'])['join'](',\x20')+'\x20(refusing\x20to\x20publish\x20—\x20A-2)'});continue;}const y=l(s['target']),z=await b['execute'](k['get'](s['target']['$ref'])??'',{'object':y,'publish':!![]},m(s));if(z['outcome']!=='executed'){i['push']({'stepId':s['id'],'status':'failed',...z['digest']!==undefined?{'digest':z['digest']}:{},'error':z['error']??z['outcome']}),n=!![];continue;}i['push']({'stepId':s['id'],'status':'executed','digest':z['digest'],'address':y});continue;}const u=Object['fromEntries'](Object['entries'](s['params'])['map'](([A,B])=>[A,l(B)]));if(s['op']==='create'){const A=adaptCreateData(s,u),B=await b['execute'](s['object'],A,m(s));if(B['outcome']!=='executed'){i['push']({'stepId':s['id'],'status':'failed',...B['digest']!==undefined?{'digest':B['digest']}:{},'error':B['error']??B['outcome']}),n=!![];continue;}const C=matchCreated(B,CREATABLE_OBJECTS[s['object']]);if(C===undefined){i['push']({'stepId':s['id'],'status':'failed',...B['digest']!==undefined?{'digest':B['digest']}:{},'error':'created\x20'+s['object']+'\x20not\x20found\x20in\x20transaction\x20result'}),n=!![];continue;}g['set'](s['id'],C),i['push']({'stepId':s['id'],'status':'executed','digest':B['digest'],'address':C});continue;}const v=l(s['target']),w=await b['execute'](k['get'](isRef(s['target'])?s['target']['$ref']:'')??'',{'object':v,[s['method']]:adaptConfigureParams(s['method'],u)},m(s));if(w['outcome']!=='executed'){i['push']({'stepId':s['id'],'status':'failed',...w['digest']!==undefined?{'digest':w['digest']}:{},'error':w['error']??w['outcome']}),n=!![];continue;}i['push']({'stepId':s['id'],'status':'executed','digest':w['digest'],'address':v});}catch(D){const E=D?.['digest'];i['push']({'stepId':s['id'],'status':'failed',...typeof E==='string'&&E?{'digest':E}:{},'error':D instanceof Error?D['message']:String(D)}),n=!![];}}const r=await verifyMaterialization(d,g,b);return{'steps':i,'outputs':Object['fromEntries'](g),'completed':i['every'](F=>F['status']==='executed'),'budgetExhausted':q,'preflight':f,'readback':r};}export function planAllocatorRows(a){const b=[],c=d=>{if(typeof d==='object'&&d!==null&&!Array['isArray'](d)){const e=d;if(Array['isArray'](e['allocators']))d=e['allocators'];}if(!Array['isArray'](d))return;for(const f of d){if(typeof f==='object'&&f!==null)b['push'](f);}};for(const d of a['steps']){if(d['op']==='create'&&d['object']==='service')c(d['params']['order_allocators']);if(d['op']==='configure'&&d['method']==='order_allocators')c(d['params']['allocators']);}return b;}export function conservationCheck(a){const b=planAllocatorRows(a);if(b['length']===0x0)return[{'name':'allocator_conservation','ok':![],'detail':'no\x20allocator\x20rows\x20(PLAN-ALLOC-01)'}];const c=[];return b['forEach']((d,e)=>{const f=d['track']??'settlement',g=typeof d['guard']==='object'&&d['guard']!==null?String(d['guard']['$ref']??JSON['stringify'](d['guard'])['slice'](0x0,0x28)):String(d['guard']??'?'),h='conservation:'+f+'['+e+']'+(g!=='?'?'('+g+')':''),i=(d['sharing']??[])['map'](l=>l['mode']);if(i['some'](l=>l==='Amount')){c['push']({'name':h,'ok':!![],'detail':'contains\x20Amount-mode\x20row(s)\x20—\x20fixed\x20payouts\x20are\x20not\x20statically\x20verifiable\x20against\x20the\x20escrow\x20total'});return;}let j=0x0;for(const l of d['sharing']??[]){if(l['mode']==='Rate'||l['mode']==='RateGross')j+=Number(l['sharing']??0x0);}const k=i['some'](n=>n==='Surplus');if(j>0x2710)c['push']({'name':h,'ok':![],'detail':'rate\x20sum\x20'+j+'\x20>\x2010000\x20—\x20row\x20pays\x20out\x20MORE\x20than\x20it\x20holds'});else j<0x2710&&!k?c['push']({'name':h,'ok':![],'detail':'rate\x20sum\x20'+j+'\x20<\x2010000\x20and\x20no\x20Surplus\x20row\x20—\x20the\x20remainder\x20has\x20no\x20fund\x20exit'}):c['push']({'name':h,'ok':!![],'detail':k?'rate\x20sum\x20'+j+'\x20+\x20Surplus\x20row\x20absorbs\x20the\x20remainder':'rate\x20sum\x20'+j+'\x20==\x2010000'});}),c;}export async function verifyMaterialization(a,b,c){const d=[...conservationCheck(a)];if(c['read']!==undefined)for(const f of createsOf(a,'service')){const g=b['get'](f['id']);if(g===undefined)continue;try{const h=await c['read'](g,'service',c['env']);if(h===undefined||h===null){d['push']({'name':'readback:'+f['id'],'ok':![],'detail':'service\x20'+g+'\x20not\x20readable\x20after\x20creation'});continue;}const i=planAllocatorRows(a)['length'],j=h['order_allocators']?.['allocators']?.['length']??(Array['isArray'](h['order_allocators'])?h['order_allocators']['length']:undefined);j!==undefined&&d['push']({'name':'readback:'+f['id']+':allocators','ok':j>=i,'detail':'on-chain\x20allocator\x20rows\x20'+j+'\x20vs\x20plan\x20'+i});}catch(k){d['push']({'name':'readback:'+f['id'],'ok':![],'detail':k instanceof Error?k['message']:String(k)});}}return{'ok':d['every'](l=>l['ok']),'checks':d};}
|
|
1
|
+
import{CREATABLE_OBJECTS,createsOf,isLate,isRef,resolveValue}from'./plan.js';import{auditPlan}from'./audit.js';import{normalizeGuardRowNames}from'./guard-fill.js';function deriveCreated(a){if(Array['isArray'](a['created']))return a['created'];const b=Array['isArray'](a['objectChanges'])?a['objectChanges']:[];return b['filter'](d=>d?.['type']==='created'&&typeof d?.['objectId']==='string')['map'](d=>({'object':d['objectId'],'type_raw':d['objectType']}));}export function handlerExecutor(a){return async(b,c)=>{const {handleOnchainOperations:d}=await import('../tools/handlers/onchain.js'),e=await d({'operation_type':b,'data':c,'env':a}),f=e['structuredContent']??{},g=f['result']!==undefined&&f['result']['data']!==undefined?f['result']:f,h=g['data']?.['result']??g['result']??g,i=g['outcome']??g['data']?.['outcome']??f['outcome']??f['status'];return{'outcome':i==='executed'||i==='success'?'executed':i==='pending_input'?'pending_input':'failed','digest':h['digest']??g['digest'],'created':deriveCreated(h),'error':h['error']??g['error']};};}function normalizeGuardTable(a,b){if(!Array['isArray'](a))return{'table':a,'description':b};return normalizeGuardRowNames(a,b,MAX_DESCRIPTION_CONTENT);}const MAX_DESCRIPTION_CONTENT=0xf9e,MAX_POLICY_DESCRIPTION_BYTES=0x1f4;function truncateToBytes(a,b){if(Buffer['byteLength'](a,'utf8')<=b)return a;let c=a;while(c['length']>0x0&&Buffer['byteLength'](c,'utf8')>b)c=c['slice'](0x0,-0x1);return c;}function truncateDescription(a){if(typeof a!=='string')return a;if(Buffer['byteLength'](a,'utf8')>MAX_DESCRIPTION_CONTENT)return truncateToBytes(a,MAX_DESCRIPTION_CONTENT-0x3)+'...';return a;}export function adaptConfigureParams(a,b){if(a==='pause'&&b!==null&&typeof b==='object'&&!Array['isArray'](b))return b['pause'];if(a==='guard_add'&&b!==null&&typeof b==='object'&&!Array['isArray'](b))return[b];if(a==='coin_add'&&b!==null&&typeof b==='object'&&!Array['isArray'](b)){const c=b,d=c['coin'];if(c['balance']===undefined&&(typeof d==='number'||typeof d==='string'&&/^[0-9]+$/['test'](d)))return{'balance':d};}if(a==='order_allocators'&&b!==null&&typeof b==='object'){const e=b,f=e['allocators'];if(Array['isArray'](f)){const g=f['map'](h=>{const i=h,j=i['sharing'];if(!Array['isArray'](j))return h;return{...i,'sharing':j['map'](k=>{const m=k,n=m['who'];if(n&&typeof n['Entity']==='string')return{...m,'who':{'Entity':{'name_or_address':n['Entity']}}};return k;})};});return{...e,'allocators':g};}}if(a==='sales'&&b!==null&&typeof b==='object'){const h=b,i=h['sales'];if(Array['isArray'](i)){const j=i['map'](k=>{if(!k||typeof k!=='object')return k;const l=k,m=l['stock']??l['quantity']??0x0;return{'suspension':![],'wip':'',...l,'stock':m};});return{...h,'sales':j};}}if(a==='policies'&&b!==null&&typeof b==='object'&&!Array['isArray'](b)){const k=b,l=k['policy'];if(Array['isArray'](l))return{...k,'policy':l['map'](m=>{if(!m||typeof m!=='object')return m;const n=m;return{...Array['isArray'](n['write_guard'])?null:{'write_guard':[]},...n,...typeof n['description']==='string'?{'description':truncateToBytes(n['description'],MAX_POLICY_DESCRIPTION_BYTES)}:{}};})};}return b;}export function adaptCreateData(a,b){const {name:c,permission:d,type_parameter:e,nodes:f,...g}=b;if(g['description']!==undefined)g['description']=truncateDescription(g['description']);switch(a['object']){case'service':case'arbitration':return{'object':{'name':c,'type_parameter':e,'permission':d},...g};case'machine':return{'object':{'name':c,...d!==undefined?{'permission':d}:{}},...g['description']!==undefined?{'description':g['description']}:{},'node':{'op':'add','nodes':f,'bReplace':!![]}};case'guard':{const h=normalizeGuardTable(b['table'],b['description']);return{...b,'description':truncateDescription(h['description']),'table':h['table']};}case'permission':case'contact':case'repository':default:{const i=g['policies'];return{'object':{'name':c,...d!==undefined?{'permission':d}:{}},...g,...a['object']==='repository'&&Array['isArray'](i)?{'policies':{'op':'set','policy':i['map'](j=>{if(!j||typeof j!=='object')return j;const k=j;return{...Array['isArray'](k['write_guard'])?null:{'write_guard':[]},...k,...typeof k['description']==='string'?{'description':truncateToBytes(k['description'],MAX_POLICY_DESCRIPTION_BYTES)}:{}};})}}:{}};}}}export function preflightPlan(a){const b=auditPlan(a),c=new Set(b['findings']['map'](g=>g['rule_id'])),d=c['has']('ARB-KEY-PLANE-01'),e=b['issues']['length']===0x0&&!b['findings']['some'](g=>g['level']==='critical')&&!d,f=a['steps']['map'](g=>{if(g['op']!=='publish')return g;const h=g['preflight']['map'](i=>{const j=i['check']['endsWith']('_publish')?e:!c['has'](i['check']);return{...i,'status':j?'pass':'fail'};});return{...g,'preflight':h};});return{'plan':{...a,'steps':f},'audit':b};}export function bindAuditPlan(a){const b=new Map();for(const h of a['steps']){if(h['op']!=='create')continue;const i=h['params']['name'];if(typeof i==='string'&&i['length']>0x0)b['set'](i,h['id']);}const c=new Set(a['external_refs']??[]),d=[],e=new Set(['value','Entity','name_or_address','objects','coin']),f=(j,k,l,m)=>{if(!e['has'](l))return;b['has'](m)&&d['push']({'step':j,'slot':k,'kind':'intra_plan_bare_name','value':m});},g=(j,k,l)=>{if(b['has'](l))d['push']({'step':j,'slot':k,'kind':'intra_plan_bare_name','value':l});else!c['has'](l)&&d['push']({'step':j,'slot':k,'kind':'undeclared_external','value':l});};for(const j of a['steps']){if(j['op']==='configure'){const m=j['target'];if(typeof m==='string')f(j['id'],'target','value',m);else{if(isLate(m)){const n=m['$late'];if(n['by']==='local_name')g(j['id'],'target',n['mark']);}}}if(j['op']==='publish')continue;const k=j['params'];if(typeof k==='string')f(j['id'],'params','value',k);const l=(o,p,r)=>{if(o===null||o===undefined)return;if(Array['isArray'](o)){o['forEach']((u,w)=>l(u,p,r+'['+String(w)+']'));return;}if(typeof o==='object'){if(isRef(o))return;if(isLate(o)){const u=o['$late'];if(u['by']==='local_name')g(j['id'],r,u['mark']);return;}for(const [w,x]of Object['entries'](o)){l(x,w,r==='params'?'params.'+w:r+'.'+w);}return;}if(typeof o==='string')f(j['id'],r,p,o);};l(k,'','params');}return d;}function retrievalFor(a){if(a==='service')return'stop\x20new\x20orders\x20first\x20(onchain_operations\x20data\x20key\x20\x27pause\x27),\x20then\x20take\x20the\x20fund\x20back\x20'+'(data\x20key\x20\x27compensation_fund_withdraw\x27,\x20owner\x20signer\x20—\x20the\x20pool\x20returns\x20to\x20the\x20owner)';if(a==='reward')return'drain\x20the\x20pool\x20(onchain_operations\x20data\x20key\x20\x27withdraw\x27,\x20owner\x20signer;\x20'+'confirm\x20the\x20pool\x20balance\x20first\x20—\x20a\x20short\x20pool\x20aborts\x20cleanly\x20without\x20paying)';return'holds\x20no\x20build-time\x20money;\x20create-frozen\x20—\x20it\x20cannot\x20be\x20deleted\x20or\x20unbound.\x20'+'Remove\x20its\x20LocalMark\x20name\x20(local_mark_operation)\x20so\x20later\x20runs\x20never\x20bind\x20it\x20by\x20name';}export function bindRecoveryList(a,b){const c=new Map(a['steps']['map'](g=>[g['id'],g])),d=new Map();for(const g of a['steps']){if(g['op']!=='configure')continue;if(g['method']!=='coin_add'&&g['method']!=='compensation_fund_add')continue;const h=g['target'],i=h!==null&&typeof h==='object'?h['$ref']:undefined,j=g['params']?.['balance'];typeof i==='string'&&(typeof j==='string'||typeof j==='number')&&d['set'](i,String(j));}const e=[],f=(k,l)=>{const m=c['get'](k),n=m?.['op']==='create'?m:undefined,o=n?.['object'],p=n?String(n['params']['name']??''):'',q=d['get'](k);e['push']({'step':k,...o!==undefined?{'kind':o}:{},...p?{'object':p}:{},...l?{'address':l}:{},...q!==undefined?{'funded':q}:{},...o!==undefined?{'retrieval':retrievalFor(o)}:{}});};if(b)for(const [k,l]of Object['entries'](b)){f(k,typeof l==='string'&&l['length']>0x0?l:undefined);}else{for(const m of a['steps'])if(m['op']==='create')f(m['id']);}return e;}function teardownPlan(a){if(a['length']===0x0)return'';const b=[],c=a['find'](d=>d['kind']==='service');c!==undefined&&b['push']('\x20\x201.\x20stop\x20new\x20orders:\x20onchain_operations\x20on\x20the\x20Service'+(c['address']?'\x20'+c['address']:'')+'\x20with\x20data\x20key\x20\x27pause\x27.','\x20\x202.\x20take\x20the\x20compensation\x20fund\x20back:\x20the\x20same\x20Service,\x20data\x20key\x20\x27compensation_fund_withdraw\x27\x20(owner\x20signer\x20—\x20the\x20pool\x20returns\x20to\x20the\x20owner;\x20real\x20money\x20only\x20if\x20the\x20money-in\x20step\x20ran\x20—\x20confirm\x20the\x20balance\x20first).');for(const d of a['filter'](e=>e['kind']==='reward')){b['push']('\x20\x20'+(b['length']+0x1)+'.\x20drain\x20the\x20reward\x20pool'+(d['address']?'\x20'+d['address']:'')+':\x20data\x20key\x20\x27withdraw\x27\x20(owner\x20signer;\x20confirm\x20the\x20pool\x20balance\x20first\x20—\x20a\x20short\x20pool\x20aborts\x20cleanly).');}return a['some'](e=>e['kind']!==undefined&&e['kind']!=='service'&&e['kind']!=='reward')&&b['push']('\x20\x20'+(b['length']+0x1)+'.\x20frozen\x20leftovers\x20(guards,\x20machine,\x20repositories)\x20cannot\x20be\x20deleted\x20or\x20unbound\x20—\x20they\x20stay\x20inert\x20on\x20chain;\x20remove\x20their\x20LocalMark\x20names\x20(local_mark_operation)\x20so\x20later\x20runs\x20never\x20bind\x20them\x20by\x20name.'),'\x0aTEARDOWN\x20PLAN\x20(abandon\x20this\x20run\x27s\x20store\x20—\x20execute\x20top\x20to\x20bottom):\x0a'+b['join']('\x0a');}export function bindAuditReport(a,b){const c=a['slice'](0x0,0xc)['map'](e=>'\x20\x20•\x20step\x20\x27'+e['step']+'\x27\x20'+e['slot']+'\x20->\x20\x27'+e['value']+'\x27\x20('+(e['kind']==='intra_plan_bare_name'?'names\x20an\x20object\x20THIS\x20plan\x20creates\x20—\x20must\x20be\x20{\x22$ref\x22:\x20\x22<create_step_id>\x22}':'undeclared\x20external\x20local_name\x20—\x20declare\x20it\x20in\x20plan.external_refs\x20or\x20bind\x20a\x20plan\x20ref')+')'),d=b['length']>0x0?b['map'](e=>{const f=e['object']!==undefined?(e['kind']??'object')+':\x20'+e['object']:e['kind']??'';return'\x20\x20•\x20'+e['step']+(f?'\x20('+f+')':'')+(e['address']!==undefined?'\x20@'+e['address']:'\x20—\x20no\x20address\x20recorded\x20—\x20find\x20the\x20object\x20by\x20its\x20name\x20(workspace/onchain_objects)\x20or\x20its\x20create\x20digest')+(e['funded']!==undefined?';\x20plan-funded\x20'+e['funded']+'\x20raw\x20(confirm\x20the\x20live\x20balance\x20before\x20relying\x20on\x20it)':'')+(e['retrieval']!==undefined?';\x20take\x20back:\x20'+e['retrieval']:'');})['join']('\x0a'):'\x20\x20•\x20(none\x20—\x20nothing\x20was\x20executed\x20in\x20this\x20run;\x20no\x20funds\x20or\x20objects\x20to\x20recover)';return'Offending\x20slots:\x0a'+c['join']('\x0a')+(a['length']>0xc?'\x0a\x20\x20…\x20+'+(a['length']-0xc)+'\x20more':'')+'\x0a'+('RECOVERY\x20LIST\x20(objects\x20already\x20created\x20by\x20this\x20run\x20—\x20id\x20+\x20digest/address\x20—\x20so\x20you\x20can\x20recover\x20funds/objects):\x0a'+d)+teardownPlan(b);}function stripGenerics(a){return a['replace'](/<.*>$/,'');}function matchCreated(a,b){const c=stripGenerics(b);return a['created']['find'](d=>{if(typeof d['type_raw']!=='string'||typeof d['object']!=='string')return![];return stripGenerics(d['type_raw'])['endsWith']('::'+c);})?.['object'];}const DEFAULT_LATE=a=>{if(a['by']==='address')return a['address'];throw new Error('unresolved\x20late\x20binding\x20(no\x20resolver\x20injected):\x20local_name\x20\x27'+a['mark']+'\x27');};export async function materializePlan(a,b,c){const {plan:d,audit:f}=preflightPlan(a),g=new Map(Object['entries'](c?.['outputs']??{})),h=new Set(c?.['completedSteps']??[]),i=[],j=b['resolveLate']??DEFAULT_LATE,k=new Map(d['steps']['filter'](t=>t['op']==='create')['map'](t=>[t['id'],t['object']])),l=s=>resolveValue(s,g,j),m=s=>{if(s['account']===undefined)return b['env'];const t=b['envByAccount']?.[s['account']];if(t===undefined)throw new Error('step\x20\x27'+s['id']+'\x27\x20declares\x20account\x20\x27'+s['account']+'\x27\x20but\x20no\x20env\x20was\x20provided\x20for\x20it\x20—\x20'+('re-run\x20plan_execute\x20with\x20accounts[\x22'+s['account']+'\x22]\x20(a\x20declared\x20account\x20never\x20falls\x20back\x20')+'to\x20the\x20default\x20signer:\x20the\x20controller\x20identity\x20is\x20the\x20point)');return t;};let n=![],o='halted\x20by\x20earlier\x20failure/blocked\x20publish';const p=b['timeoutMs']!==undefined&&b['timeoutMs']>0x0?Date['now']()+b['timeoutMs']:undefined;let q=![];for(const s of d['steps']){if(n){i['push']({'stepId':s['id'],'status':'blocked','error':o});continue;}if(h['has'](s['id'])){if(k['has'](s['id'])){const t=g['get'](s['id']);if(t===undefined){i['push']({'stepId':s['id'],'status':'failed','error':'resumed\x20create\x20step\x20has\x20no\x20recorded\x20output\x20—\x20pass\x20its\x20created\x20address\x20in\x20previous_outputs'}),n=!![];continue;}i['push']({'stepId':s['id'],'status':'executed','address':t,'error':'resumed\x20from\x20a\x20prior\x20run\x20(adopted,\x20not\x20re-executed)'});continue;}i['push']({'stepId':s['id'],'status':'executed','error':'resumed\x20from\x20a\x20prior\x20run\x20(adopted,\x20not\x20re-executed)'});continue;}if(p!==undefined&&Date['now']()>=p){q=!![],n=!![],o='time\x20budget\x20('+b['timeoutMs']+'ms)\x20exhausted\x20before\x20this\x20step\x20—\x20RESUME,\x20not\x20re-run:\x20send\x20plan_execute\x20again\x20with\x20completed_steps\x20=\x20every\x20stepId\x20whose\x20status\x20is\x20\x27executed\x27,\x20previous_outputs\x20=\x20outputs',i['push']({'stepId':s['id'],'status':'blocked','error':o});continue;}try{if(s['op']==='publish'){const y=s['preflight']['filter'](B=>B['status']==='fail');if(y['length']>0x0){i['push']({'stepId':s['id'],'status':'blocked','error':'preflight\x20failed:\x20'+y['map'](B=>B['check'])['join'](',\x20')+'\x20(refusing\x20to\x20publish\x20—\x20A-2)'});continue;}const z=l(s['target']),A=await b['execute'](k['get'](s['target']['$ref'])??'',{'object':z,'publish':!![]},m(s));if(A['outcome']!=='executed'){i['push']({'stepId':s['id'],'status':'failed',...A['digest']!==undefined?{'digest':A['digest']}:{},'error':A['error']??A['outcome']}),n=!![];continue;}i['push']({'stepId':s['id'],'status':'executed','digest':A['digest'],'address':z});continue;}const u=isRef(s['params'])?l(s['params']):Object['fromEntries'](Object['entries'](s['params'])['map'](([B,C])=>[B,l(C)]));if(s['op']==='create'){const B=adaptCreateData(s,u),C=await b['execute'](s['object'],B,m(s));if(C['outcome']!=='executed'){i['push']({'stepId':s['id'],'status':'failed',...C['digest']!==undefined?{'digest':C['digest']}:{},'error':C['error']??C['outcome']}),n=!![];continue;}const D=matchCreated(C,CREATABLE_OBJECTS[s['object']]);if(D===undefined){i['push']({'stepId':s['id'],'status':'failed',...C['digest']!==undefined?{'digest':C['digest']}:{},'error':'created\x20'+s['object']+'\x20not\x20found\x20in\x20transaction\x20result'}),n=!![];continue;}g['set'](s['id'],D),i['push']({'stepId':s['id'],'status':'executed','digest':C['digest'],'address':D});continue;}const v=l(s['target']),w=k['get'](isRef(s['target'])?s['target']['$ref']:'')??'';if(w===''){i['push']({'stepId':s['id'],'status':'failed','error':'PLAN_TARGET_REF_REQUIRED:\x20step\x20\x27'+s['id']+'\x27\x20target\x20does\x20not\x20trace\x20to\x20a\x20create\x20step\x20in\x20this\x20plan\x20—\x20'+'configure\x20targets\x20must\x20be\x20{\x22$ref\x22:\x20\x22<create_step_id>\x22}\x20(a\x20bare\x20name\x20binds\x20the\x20global\x20mark\x20namespace\x20across\x20runs,\x20W5-05)'}),n=!![];continue;}const x=await b['execute'](w,{'object':v,[s['method']]:adaptConfigureParams(s['method'],u)},m(s));if(x['outcome']!=='executed'){i['push']({'stepId':s['id'],'status':'failed',...x['digest']!==undefined?{'digest':x['digest']}:{},'error':x['error']??x['outcome']}),n=!![];continue;}i['push']({'stepId':s['id'],'status':'executed','digest':x['digest'],'address':v});}catch(E){const F=E?.['digest'];i['push']({'stepId':s['id'],'status':'failed',...typeof F==='string'&&F?{'digest':F}:{},'error':E instanceof Error?E['message']:String(E)}),n=!![];}}const r=await verifyMaterialization(d,g,b);return{'steps':i,'outputs':Object['fromEntries'](g),'completed':i['every'](G=>G['status']==='executed'),'budgetExhausted':q,'preflight':f,'readback':r};}function planAllocatorRows(a){const b=[],c=d=>{if(typeof d==='object'&&d!==null&&!Array['isArray'](d)){const e=d;if(Array['isArray'](e['allocators']))d=e['allocators'];}if(!Array['isArray'](d))return;for(const f of d){if(typeof f==='object'&&f!==null)b['push'](f);}};for(const d of a['steps']){if(d['op']==='create'&&d['object']==='service')c(d['params']['order_allocators']);if(d['op']==='configure'&&d['method']==='order_allocators')c(d['params']['allocators']);}return b;}export function conservationCheck(a){const b=planAllocatorRows(a);if(b['length']===0x0)return[{'name':'allocator_conservation','ok':![],'detail':'no\x20allocator\x20rows\x20(PLAN-ALLOC-01)'}];const c=[];return b['forEach']((d,e)=>{const f=d['track']??'settlement',g=typeof d['guard']==='object'&&d['guard']!==null?String(d['guard']['$ref']??JSON['stringify'](d['guard'])['slice'](0x0,0x28)):String(d['guard']??'?'),h='conservation:'+f+'['+e+']'+(g!=='?'?'('+g+')':''),i=(d['sharing']??[])['map'](l=>l['mode']);if(i['some'](l=>l==='Amount')){c['push']({'name':h,'ok':!![],'detail':'contains\x20Amount-mode\x20row(s)\x20—\x20fixed\x20payouts\x20are\x20not\x20statically\x20verifiable\x20against\x20the\x20escrow\x20total'});return;}let j=0x0;for(const l of d['sharing']??[]){if(l['mode']==='Rate'||l['mode']==='RateGross')j+=Number(l['sharing']??0x0);}const k=i['some'](n=>n==='Surplus');if(j>0x2710)c['push']({'name':h,'ok':![],'detail':'rate\x20sum\x20'+j+'\x20>\x2010000\x20—\x20row\x20pays\x20out\x20MORE\x20than\x20it\x20holds'});else j<0x2710&&!k?c['push']({'name':h,'ok':![],'detail':'rate\x20sum\x20'+j+'\x20<\x2010000\x20and\x20no\x20Surplus\x20row\x20—\x20the\x20remainder\x20has\x20no\x20fund\x20exit'}):c['push']({'name':h,'ok':!![],'detail':k?'rate\x20sum\x20'+j+'\x20+\x20Surplus\x20row\x20absorbs\x20the\x20remainder':'rate\x20sum\x20'+j+'\x20==\x2010000'});}),c;}async function verifyMaterialization(a,b,c){const d=[...conservationCheck(a)];if(c['read']!==undefined)for(const f of createsOf(a,'service')){const g=b['get'](f['id']);if(g===undefined)continue;try{const h=await c['read'](g,'service',c['env']);if(h===undefined||h===null){d['push']({'name':'readback:'+f['id'],'ok':![],'detail':'service\x20'+g+'\x20not\x20readable\x20after\x20creation'});continue;}const i=planAllocatorRows(a)['length'],j=h['order_allocators']?.['allocators']?.['length']??(Array['isArray'](h['order_allocators'])?h['order_allocators']['length']:undefined);j!==undefined&&d['push']({'name':'readback:'+f['id']+':allocators','ok':j>=i,'detail':'on-chain\x20allocator\x20rows\x20'+j+'\x20vs\x20plan\x20'+i});}catch(k){d['push']({'name':'readback:'+f['id'],'ok':![],'detail':k instanceof Error?k['message']:String(k)});}}return{'ok':d['every'](l=>l['ok']),'checks':d};}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { JsonValue } from "./plan.js";
|
|
2
|
+
import type { AllocatorRowData, CompilableTemplate, CompileBlocker, GuardSpec } from "./compile.js";
|
|
3
|
+
type AfterSalesMode = NonNullable<CompilableTemplate["after_sales_mode"]>;
|
|
4
|
+
type AcceptanceMode = NonNullable<CompilableTemplate["acceptance_mode"]>;
|
|
5
|
+
type InstallmentMode = NonNullable<CompilableTemplate["installment_mode"]>;
|
|
6
|
+
type AffiliateMode = NonNullable<CompilableTemplate["affiliate_mode"]>;
|
|
7
|
+
type CrowdfundingMode = NonNullable<CompilableTemplate["crowdfunding_mode"]>;
|
|
8
|
+
type LogisticsMode = NonNullable<CompilableTemplate["logistics_mode"]>;
|
|
9
|
+
export interface ModeGateContext {
|
|
10
|
+
shape: CompilableTemplate["machine_shape"];
|
|
11
|
+
rows: AllocatorRowData[];
|
|
12
|
+
guardSpecs: GuardSpec[];
|
|
13
|
+
buildNotes: string[];
|
|
14
|
+
feeParams: CompilableTemplate["fee_params"];
|
|
15
|
+
arbitrationMode: CompilableTemplate["arbitration_mode"];
|
|
16
|
+
inputs: Record<string, JsonValue>;
|
|
17
|
+
buildTimeMs?: number;
|
|
18
|
+
}
|
|
19
|
+
export interface ModeGateAxes {
|
|
20
|
+
afterSalesMode: AfterSalesMode;
|
|
21
|
+
acceptanceMode: AcceptanceMode;
|
|
22
|
+
installmentMode: InstallmentMode;
|
|
23
|
+
affiliateMode: AffiliateMode;
|
|
24
|
+
crowdfundingMode: CrowdfundingMode;
|
|
25
|
+
logisticsMode: LogisticsMode;
|
|
26
|
+
}
|
|
27
|
+
export declare function emitModeGates(axes: ModeGateAxes, ctx: ModeGateContext): {
|
|
28
|
+
blockers: CompileBlocker[];
|
|
29
|
+
disclosures: string[];
|
|
30
|
+
};
|
|
31
|
+
export declare function deriveCapabilityModes({ template, inputs }: {
|
|
32
|
+
template: CompilableTemplate;
|
|
33
|
+
inputs: Record<string, JsonValue>;
|
|
34
|
+
}): ModeGateAxes;
|
|
35
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{afterSalesRailRegex as a21a,afterSalesRailNodeMatches}from'../knowledge/template-scanner.js';import{TWO_TX_RENEW_RECIPE}from'../knowledge/protocol-facts.js';function emitAfterSalesGates(a,b){const c=[];if(a==='none')return c;const d=a21a(a),e=b['shape']['some'](f=>afterSalesRailNodeMatches(a,f['name']));return!e&&c['push']({'code':'AFTER_SALES_RAIL_MISSING','detail':'after_sales_mode\x20\x27'+a+'\x27\x20declares\x20a\x20buyer\x20after-sales\x20remedy,\x20but\x20machine_shape\x20has\x20no\x20'+('backing\x20rail\x20(no\x20node\x20matching\x20'+d+').\x20Add\x20the\x20'+a+'\x20node\x20family\x20')+'(e.g.\x20return_requested\x20->\x20returned\x20for\x20\x27return\x27)\x20as\x20a\x20node-gated\x20fund\x20rail\x20(decision\x2011:\x20NEVER\x20a\x20'+'claimed_by\x20leg\x20—\x20RAIL_CLAIMED_BY_LEG\x20critical)\x20anchored\x20on\x20the\x20delivered\x20ENTRY\x20time\x20'+'(INV-C2,\x20TIME-ANCHOR-01);\x20refund\x20and\x20award\x20are\x20independent\x20tracks\x20and\x20any\x20overlap\x20is\x20disclosed\x20'+'at\x20the\x20dual-payout\x20gate\x20(DUAL-RAIL-01).\x20Or\x20set\x20after_sales_mode\x20\x27none\x27\x20if\x20this\x20shop\x20ships\x20no\x20such\x20remedy.'}),c;}function emitAcceptanceGates(a,b){const c=[],d=[];if(a==='none')return{'blockers':c,'disclosures':d};const e=a==='contest'||a==='bounty'||a==='agent';e&&b['arbitrationMode']!=='third_party'&&c['push']({'code':'ACCEPTANCE_JUDGE_NOT_INDEPENDENT','detail':'acceptance_mode\x20\x27'+a+'\x27\x20is\x20a\x20judge-decided\x20acceptance\x20(a\x20third\x20party\x20rules\x20on\x20'+('release),\x20but\x20arbitration_mode\x20is\x20\x27'+(b['arbitrationMode']??'none')+'\x27,\x20not\x20\x27third_party\x27.\x20')+'The\x20party\x20owing\x20the\x20payout\x20must\x20not\x20also\x20decide\x20whether\x20it\x20is\x20owed\x20(merchant\x20self-adjudication,\x20'+'INV-A3).\x20Set\x20arbitration_mode\x20\x27third_party\x27\x20so\x20an\x20independent\x20venue/judge\x20Permission\x20rules\x20'+'(R2;\x20enforced\x20at\x20publish\x20by\x20controller-disjointness),\x20or\x20use\x20acceptance_mode\x20\x27milestone\x27\x20if\x20the\x20'+'buyer\x20genuinely\x20self-adjudicates.'});const f=b['feeParams']['revision_rounds_max'],g=typeof f==='number'||typeof f==='string'&&f['trim']()!==''&&/^\d+$/['test'](f['trim']());if(g){const h=b['guardSpecs']['some'](i=>i['host']==='repository'||/repository/i['test'](i['template_id']));!h&&c['push']({'code':'ACCEPTANCE_REVISION_UNBOUNDED','detail':'acceptance_mode\x20\x27'+a+'\x27\x20declares\x20a\x20bounded\x20revision\x20loop\x20'+('(fee_params.revision_rounds_max\x20=\x20'+String(f)+'),\x20but\x20no\x20counter-backed\x20Repository\x20')+'guard\x20exists.\x20The\x20chain\x20caps\x20EDGE\x20count\x20(MAX_FORWARD\x20/\x20MAX_NODE_PAIR),\x20never\x20VISIT\x20count,\x20'+'so\x20a\x20finite\x20cap\x20in\x20fee_params\x20alone\x20is\x20a\x20promise\x20the\x20chain\x20cannot\x20keep\x20(INV-A1).\x20Either\x20declare\x20'+'revision_rounds_max\x20\x27unlimited\x27\x20(the\x20honest\x20form\x20—\x20the\x20revision\x20loop\x20is\x20then\x20genuinely\x20'+'unbounded)\x20or\x20mount\x20a\x20counter-backed\x20Repository\x20guard\x20(pattern.repository_data_check\x20reading\x20a\x20'+'per-order\x20revision\x20tally\x20written\x20via\x20pattern.repository_write_authorization)\x20that\x20gates\x20the\x20'+'redelivery\x20forward\x20once\x20the\x20tally\x20reaches\x20the\x20cap.'});}if(a==='contest')d['push']('Winner\x20rule\x20(first-to-node):\x20the\x20winner\x20is\x20the\x20first\x20account\x20whose\x20forward\x20completes\x20entry\x20into\x20'+'the\x20adjudication\x20node\x20—\x20computable\x20from\x20the\x20order\x27s\x20Progress\x20history\x20(first\x20matching\x20entry,\x20earliest\x20'+'time);\x20ties\x20resolve\x20by\x20chain\x20timestamp.\x20This\x20rule\x20is\x20disclosed\x20for\x20judge/merchant\x20reference;\x20the\x20'+'chain\x20stores\x20no\x20winner\x20field\x20(F-RQD2-05).');else a==='bounty'&&d['push']('Winner\x20rule\x20(judge-accepted\x20triage):\x20winners\x20are\x20the\x20submitters\x20whose\x20reports\x20the\x20independent\x20judge\x20'+'accepts\x20(severity-ranked);\x20the\x20Progress\x20history\x20proves\x20who\x20delivered,\x20the\x20judge\x20permission\x20decides\x20'+'which\x20delivery\x20wins.');return{'blockers':c,'disclosures':d};}function emitInstallmentGates(a,b){const c=[];if(a==='none')return c;const d=/(due|owed|owing|unpaid|awaiting|pending)/i,f=/(paid|captured|funded|settled)/i,g=/(deposit|down_?pay|balance_due|balance_owed|awaiting|installment|milestone)/i,h=/(refund|cancel|exit|forfeit|kill|void|abandon|release|expire|lapse)/i,i=[];for(const l of b['shape']){const m=l['name'];for(const o of l['from']??[]){typeof o==='string'?i['push']({'prev':o,'target':m}):i['push']({'prev':o['prev'],'target':m,'guardKey':o['guard_key']});}}const j=i['filter'](p=>d['test'](p['prev'])&&f['test'](p['target'])&&(p['guardKey']===undefined||p['guardKey']['trim']()===''));j['length']>0x0&&c['push']({'code':'INSTALLMENT_FUNDING_UNGATED','detail':'installment_mode\x20\x27'+a+'\x27\x20captures\x20a\x20later\x20payment,\x20but\x20the\x20funding\x20forward(s)\x20'+j['map'](p=>'\x27'+p['prev']+'\x27\x20→\x20\x27'+p['target']+'\x27')['join'](',\x20')+'\x20carry\x20NO\x20guard_key.\x20A\x20bare\x20advance\x20records\x20the\x20balance\x20as\x20paid\x20WITHOUT\x20the\x20capture\x20landing\x20in\x20the\x20'+'Allocation\x20—\x20a\x20zero-value\x20advance\x20(INV-B1,\x20H4).\x20Bind\x20a\x20fund-gate\x20Guard\x20on\x20each\x20capture\x20forward\x20'+'(constant\x20=\x20order\x20address,\x20convert_witness\x20OrderAllocation(109),\x20allocation.balance\x20query\x201051\x20>=\x20the\x20'+'capture\x20amount).\x20PRE-STATE\x20CONSTRAINT\x20(esound-mn-261021\x20B-1,\x20mainnet-verified):\x20guards\x20read\x20the\x20'+'COMMITTED\x20pre-transaction\x20balance\x20—\x20funding\x20that\x20lands\x20in\x20the\x20SAME\x20PTB\x20(the\x20one-PTB\x20order_renew\x20'+'payment\x20half)\x20is\x20INVISIBLE\x20to\x20the\x20forward\x27s\x20guard,\x20so\x20a\x20balance-gated\x20capture\x20advanced\x20by\x20'+('order_renew\x20ALWAYS\x20aborts.\x20'+TWO_TX_RENEW_RECIPE+'\x20Pair\x20the\x20balance\x20gate\x20with\x20the\x20once\x20slot\x20')+'(H5\x20—\x20the\x20fund\x20gate\x20is\x20a\x20STATE\x20READ,\x20not\x20a\x20once)\x20so\x20a\x20replay\x20cannot\x20re-capture.'});const k=[];for(const p of b['shape']){if(!g['test'](p['name']))continue;const q=i['filter'](s=>s['prev']===p['name']),r=q['some'](s=>h['test'](s['target']));if(!r)k['push'](p['name']);}return k['length']>0x0&&c['push']({'code':'INSTALLMENT_DEPOSIT_STRANDED','detail':'installment_mode\x20\x27'+a+'\x27\x20holds\x20a\x20buyer\x20payment\x20at\x20state(s)\x20'+k['map'](t=>'\x27'+t+'\x27')['join'](',\x20')+'\x20with\x20NO\x20deposit-exit\x20rail\x20(no\x20outgoing\x20refund\x20/\x20cancel\x20/\x20forfeit\x20/\x20expire\x20edge).\x20There\x20is\x20no\x20on-chain\x20'+'obligation\x20to\x20pay\x20the\x20balance\x20(INV-B2,\x20H1),\x20so\x20a\x20buyer\x20who\x20walks\x20away\x20strands\x20the\x20already-paid\x20portion\x20'+'at\x20that\x20node\x20permanently\x20(Machine\x20+\x20Allocator\x20immutable,\x20IMMUT-001).\x20Add\x20a\x20deposit-exit\x20rail\x20from\x20each\x20'+'held\x20state\x20—\x20a\x20refund/cancel\x20forward\x20into\x20an\x20exit\x20node\x20whose\x20allocator\x20returns\x20the\x20held\x20funds\x20to\x20the\x20'+'order\x20payer\x20(GuardIdentifier(0))\x20or\x20applies\x20the\x20declared\x20deposit_exit_policy\x20(full\x20refund\x20vs\x20a\x20kill\x20fee\x20'+'compensating\x20the\x20merchant\x20for\x20the\x20reserved\x20capacity).'}),c;}function emitAffiliateGates(a,b){const c=[];if(a==='none')return c;const d=/(commission|affiliate|referr|attribut|partner_?payout)/i,e=b['shape']['some'](i=>d['test'](i['name'])),f=b['rows']['some'](i=>d['test'](i['value_from']??'')||d['test'](i['recipient_key']??''));!e&&!f&&c['push']({'code':'AFFILIATE_RAIL_MISSING','detail':'affiliate_mode\x20\x27'+a+'\x27\x20declares\x20a\x20referral/affiliate\x20commission\x20overlay,\x20but\x20machine_shape\x20has\x20no\x20'+'commission-family\x20node\x20and\x20the\x20allocator\x20has\x20no\x20commission\x20row\x20—\x20a\x20declared\x20partner\x20payout\x20with\x20no\x20rail\x20to\x20'+'walk\x20it\x20is\x20a\x20false\x20promise\x20at\x20quote\x20time\x20(INV-D3).\x20Add\x20an\x20INDEPENDENT\x20commission\x20leg:\x20a\x20Rate\x20row\x20off\x20a\x20'+'dedicated\x20commission\x20pool\x20(never\x20a\x20Surplus/Rate\x20drain\x20of\x20the\x20buyer\x27s\x20goods\x20escrow\x20—\x20anti-grab-pool)\x20to\x20an\x20explicit\x20'+'non-empty\x20partner\x20Entity,\x20gated\x20by\x20a\x20window-anchored\x20claim\x20guard\x20(INV-D1\x20rides\x20TIME-ANCHOR-01)\x20so\x20the\x20'+'commission\x20is\x20claimable\x20only\x20after\x20the\x20attribution/refund\x20window\x20closes.'});const g=/(post-?lock|clawback|unrecoverable|irrevocab|no\s*(?:revers|recov|clawback)|cannot be reversed|once released|released commission)/i,h=b['buildNotes']['some'](i=>g['test'](i));return!h&&c['push']({'code':'AFFILIATE_CLAWBACK_UNDISCLOSED','detail':'affiliate_mode\x20\x27'+a+'\x27\x20declares\x20a\x20commission\x20but\x20no\x20build_note\x20discloses\x20the\x20post-lock\x20no-clawback\x20'+'truth\x20(INV-D2).\x20SOLE\x20TRUTH:\x20Allocation\x20distribute\x20is\x20a\x20ONE-WAY\x20outflow\x20(no\x20debit/clawback\x20primitive,\x20§11.0\x20G2),\x20'+'so\x20once\x20a\x20commission\x20is\x20RELEASED\x20it\x20CANNOT\x20be\x20reversed\x20on\x20chain\x20—\x20a\x20refund/chargeback\x20after\x20release\x20leaves\x20the\x20'+'affiliate\x20commission\x20unrecoverable.\x20Add\x20a\x20build_note\x20stating\x20this\x20honestly\x20(e.g.\x20\x22post-lock:\x20a\x20released\x20'+'affiliate\x20commission\x20is\x20unrecoverable\x20—\x20refunds\x20after\x20the\x20attribution\x20window\x20do\x20NOT\x20claw\x20back\x20the\x20'+'partner\x20payout\x22).\x20L-04/D-5:\x20never\x20imply\x20a\x20recovery\x20capability\x20the\x20chain\x20does\x20not\x20have.'}),c;}function emitCrowdfundingGates(a,b){const c=[];if(a==='none')return c;const d=/(releas|settle|funded|disburs|project)/i,e=/(refund|missed|unmet|return|reimburse)/i,f=b['shape']['some'](s=>d['test'](s['name'])),g=b['rows']['some'](s=>s['track']==='settlement'&&(d['test'](s['guard_key']??'')||d['test'](s['recipient_key']??''))),h=b['shape']['some'](s=>e['test'](s['name'])),i=b['rows']['some'](s=>s['track']==='refund'||e['test'](s['guard_key']??''));!f&&!g&&c['push']({'code':'CROWDFUNDING_THRESHOLD_GATE_MISSING','detail':'crowdfunding_mode\x20\x27'+a+'\x27\x20declares\x20a\x20campaign\x20but\x20machine_shape\x20has\x20no\x20release/settlement\x20'+'node\x20and\x20the\x20allocator\x20has\x20no\x20settlement\x20row\x20to\x20the\x20project\x20Entity\x20—\x20the\x20escrowed\x20contributions\x20would\x20'+'strand\x20at\x20the\x20deadline\x20with\x20no\x20exit\x20rail\x20(INV-E1).\x20Add\x20a\x20release\x20leg\x20(Rate\x2010000\x20to\x20a\x20NON-EMPTY\x20project\x20'+'Entity,\x20gated\x20at\x20the\x20campaign-deadline\x20settlement\x20terminal)\x20and,\x20for\x20a\x20threshold\x20campaign,\x20its\x20D-BUG-2\x20'+'refund\x20twin.'});a==='threshold'&&!h&&!i&&c['push']({'code':'CROWDFUNDING_THRESHOLD_GATE_MISSING','detail':'crowdfunding_mode\x20\x27threshold\x27\x20declares\x20an\x20all-or-nothing\x20campaign\x20but\x20there\x20is\x20NO\x20refund-family\x20node/row\x20—\x20'+'a\x20missed\x20goal\x20would\x20strand\x20every\x20contribution\x20instead\x20of\x20returning\x20it\x20(INV-E1\x20/\x20D-BUG-2).\x20Add\x20the\x20refund\x20'+'leg\x20(per-contributor,\x20order-anchored\x20user\x20slot\x200\x20—\x20the\x20submitted\x20Order,\x20never\x20slot\x20254;\x20node-gated\x20at\x20the\x20'+'refund\x20terminal,\x20decision\x2011\x20—\x20never\x20a\x20claimed_by\x20leg)\x20as\x20the\x20mutually-exclusive\x20twin\x20of\x20the\x20'+'release\x20leg:\x20aggregate\x20>=\x20goal\x20→\x20release;\x20aggregate\x20<\x20goal\x20→\x20refund.'});if(a==='threshold'){const s=b['guardSpecs']['filter'](x=>x['host']==='repository'||/repository_write/i['test'](x['template_id'])),t=s['length']>0x0,u=s['some'](x=>{const y=(x['policy']?.['id_from']??'')['toLowerCase']();return y==='signer'||y==='clock';});if(!t)c['push']({'code':'CROWDFUNDING_AGGREGATE_UNBOUND','detail':'crowdfunding_mode\x20\x27threshold\x27\x20gates\x20release\x20on\x20an\x20aggregate\x20funding\x20total,\x20but\x20no\x20host:\x22repository\x22\x20'+'write\x20policy\x20declares\x20the\x20contribution\x20rows\x20—\x20with\x20no\x20write-bound\x20policy\x20the\x20total\x20is\x20forgeable,\x20so\x20'+'anyone\x20could\x20inflate\x20the\x20aggregate\x20and\x20fake\x20a\x20\x27goal\x20met\x27\x20(INV-E2\x20/\x20R-X1-17:\x20existence-is-not-trust).\x20'+'Mount\x20pattern.repository_write_authorization\x20(identity\x20leaf\x20order.owner==Signer\x20/\x20order.agent\x20has\x20Signer)\x20'+'and\x20key\x20the\x20contribution\x20rows\x20by\x20the\x20funder\x27s\x20ORDER\x20(policy\x20id_from\x20unset;\x20row\x20id\x20=\x20the\x20Order\x20address).'});else{if(u){const x=s['filter'](y=>{const z=(y['policy']?.['id_from']??'')['toLowerCase']();return z==='signer'||z==='clock';})['map'](y=>'\x27'+y['key']+'\x27');c['push']({'code':'CROWDFUNDING_SIGNER_KEYED_ROWS','detail':'crowdfunding_mode\x20\x27threshold\x27\x20gates\x20release\x20on\x20an\x20aggregate\x20funding\x20total,\x20but\x20the\x20contribution\x20'+('policy\x20'+x['join'](',\x20')+'\x20keys\x20rows\x20by\x20the\x20WALLET\x20(id_from\x20signer/clock)\x20—\x20the\x20OLD\x20pre-migration\x20')+'shape\x20(ksc-tn-261024\x20F-01/F-05).\x20Wallet-keyed\x20rows\x20feed\x20the\x20escrow-bound\x20sum\x20(query\x201179,\x20per-row\x20'+'min(row,\x20order.amount,\x20LIVE\x20allocation.balance))\x20ZERO\x20—\x20the\x20goal\x20gate\x20silently\x20bricks\x20—\x20and\x20the\x20free-form\x20sum-where\x20(1174)\x20stays\x20'+'self-reported,\x20so\x20a\x20backer\x20can\x20still\x20record\x201.0\x20for\x20a\x200.1\x20pledge.\x20Key\x20the\x20rows\x20by\x20the\x20funder\x27s\x20ORDER\x20'+'instead\x20(policy\x20id_from\x20unset;\x20the\x20backer\x27s\x20tooling\x20submits\x20the\x20row\x20id\x20=\x20their\x20Order\x20address\x20through\x20'+'the\x20passport-bearing\x20data\x20write),\x20pass\x20those\x20ORDER\x20addresses\x20as\x20the\x20aggregate\x27s\x20candidate\x20ids,\x20and\x20pair\x20the\x20gate\x20'+'with\x20the\x20live-escrow\x20leg\x20(allocation.balance\x20query\x201051\x20via\x20convert_witness\x20OrderAllocation\x20109,\x20'+'>=\x20order.amount)\x20so\x20a\x20refunded/never-funded\x20order\x20can\x20neither\x20count\x20toward\x20the\x20goal\x20nor\x20be\x20settled.'});}}const v=b['inputs']['campaign_deadline_ms']??b['feeParams']?.['campaign_deadline_ms'],w=typeof v==='number'?v:Number(v);if(b['buildTimeMs']!==undefined){if(!Number['isFinite'](w)||w<=0x0)c['push']({'code':'CROWDFUNDING_DEADLINE_UNSET','detail':'crowdfunding_mode\x20\x27threshold\x27\x20gates\x20release/refund/withdrawal\x20on\x20the\x20ABSOLUTE\x20shared\x20deadline\x20'+('(campaign_deadline_ms),\x20but\x20it\x20resolved\x20to\x20'+String(v)+'\x20even\x20though\x20this\x20build\x20knows\x20its\x20')+'instant\x20—\x20an\x20unresolved\x20zero\x20opens\x20the\x20deadline\x20gate\x20at\x20genesis:\x20the\x20pre-deadline\x20withdrawal\x20exit\x20is\x20'+'dead\x20on\x20arrival\x20and\x20the\x20threshold/refund\x20polarity\x20is\x20resolvable\x20at\x20block\x20one\x20(ktt5\x20T-20).\x20Pass\x20a\x20real\x20'+'future\x20epoch-ms\x20timestamp\x20via\x20inputs.campaign_deadline_ms,\x20or\x20a\x20length\x20via\x20'+'inputs.campaign_duration_days\x20for\x20the\x20generation-time\x20conversion.'});else{if(w<=b['buildTimeMs'])c['push']({'code':'CROWDFUNDING_DEADLINE_PAST','detail':'campaign_deadline_ms\x20('+w+')\x20is\x20not\x20after\x20this\x20build\x27s\x20instant\x20('+b['buildTimeMs']+')\x20—\x20'+'the\x20shared\x20deadline\x20is\x20ALREADY\x20EXPIRED\x20at\x20publish:\x20the\x20pre-deadline\x20WithdrawPledge\x20exit\x20is\x20dead\x20on\x20'+'arrival\x20and\x20the\x20threshold/refund\x20polarity\x20is\x20resolvable\x20at\x20block\x20one\x20(the\x20live\x20ktt5\x20run\x20set\x20the\x20'+'deadline\x20before\x20the\x20first\x20order\x20and\x20could\x20never\x20test\x20a\x20mid-round\x20withdrawal,\x20T-20).\x20Pass\x20a\x20future\x20'+'epoch-ms\x20timestamp\x20(build\x20instant\x20+\x20campaign_duration_days\x20is\x20the\x20sanctioned\x20conversion).'});else b['buildTimeMs']+0xa*0xea60-w>0x0&&c['push']({'code':'CROWDFUNDING_DEADLINE_IMMINENT','detail':'campaign_deadline_ms\x20('+w+')\x20is\x20less\x20than\x2010\x20minutes\x20after\x20this\x20build\x27s\x20instant\x20'+('('+b['buildTimeMs']+')\x20—\x20the\x20round\x20is\x20effectively\x20expired\x20by\x20the\x20time\x20ANY\x20buyer\x20sees\x20the\x20')+'listing\x20(pdd\x20F-09\x20min-lead).\x20Give\x20the\x20campaign\x20a\x20real\x20lead\x20window:\x20build\x20instant\x20+\x20'+'campaign_duration_days\x20/\x20campaign_duration_hours\x20(hours\x20for\x20short\x20pop-up\x20rounds,\x20minimum\x20'+'sanctioned\x20length\x2010\x20minutes)\x20or\x20a\x20further-out\x20absolute\x20timestamp.'});}}}const j=b['buildNotes'],k=/(attest|keeper|aggregate trust|read-?only sum|not a chain-?verified|independent recomputation)/i,l=/(not investment|non-?investment|no (?:investment )?return|never promise)/i,m=/(kyc|aml|securities|money-?transmission|regulatory|cross-border|compliance)/i,n=/(no-?refund|non-?refundable|keep-?it-?all)/i,o=j['some'](y=>l['test'](y)),p=j['some'](y=>m['test'](y)),q=a==='threshold'?j['some'](y=>k['test'](y)):!![],r=a==='flexible'?j['some'](y=>n['test'](y)):!![];if(!q||!o||!p||!r){const y=[!q?'the\x20aggregate-trust\x20boundary\x20(the\x20funding\x20total\x20is\x20a\x20keeper-attested\x20Repository\x20sum,\x20NOT\x20a\x20chain-verified\x20money\x20oracle)':null,!o?'the\x20L-01\x20non-investment\x20statement\x20(never\x20promise\x20returns\x20/\x20promote\x20coin\x20price;\x20not\x20investment\x20advice\x20or\x20a\x20return\x20promise)':null,!p?'the\x20L-05\x20KYC/AML\x20+\x20cross-border\x20regulatory\x20caution\x20(HIGH\x20intensity)':null,!r?'the\x20flexible\x20keep-it-all\x20NO-REFUND\x20posture\x20(contributions\x20non-refundable\x20once\x20the\x20deadline\x20passes;\x20no\x20refunds)':null]['filter'](Boolean);c['push']({'code':'CROWDFUNDING_DISCLOSURE_MISSING','detail':'crowdfunding_mode\x20\x27'+a+'\x27\x20declares\x20a\x20campaign\x20but\x20no\x20build_note\x20carries:\x20'+y['join'](';\x20')+'\x20'+'(INV-E3\x20/\x20L-04\x20/\x20L-01\x20/\x20L-05).\x20Add\x20these\x20as\x20honest\x20build_notes\x20—\x20never\x20present\x20an\x20attested\x20aggregate\x20as\x20a\x20'+'chain-verified\x20custody\x20proof,\x20never\x20imply\x20investment\x20returns,\x20and\x20flag\x20the\x20compliance\x20surface.'});}return c;}function emitLogisticsGates(a,b){const c=[];if(a==='none')return c;const d=b['shape'],e=d['some'](g=>g['named_operator']!==undefined||(g['from']??[])['some'](h=>h['named_operator']!==undefined));a==='courier'&&!e&&c['push']({'code':'LOGISTICS_COURIER_RAIL_MISSING','detail':'logistics_mode\x20\x27courier\x27\x20declares\x20per-order\x20dispatched\x20riders,\x20but\x20machine_shape\x20carries\x20NO\x20named_operator\x20'+'rail.\x20A\x20dispatched\x20rider\x20is\x20NEITHER\x20a\x20permission\x20entity\x20NOR\x20the\x20buyer\x20—\x20the\x20ONLY\x20forward\x20they\x20can\x20ever\x20'+'pass\x20is\x20a\x20namedOperator\x20roster\x20rail\x20(the\x20rider\x20namespace\x27s\x20per-order\x20roster,\x20written\x20by\x20the\x20dispatch\x20'+'keeper\x20via\x20permission\x20index\x20221;\x20K-1\x20batch\x20B).\x20Bind\x20the\x20handover\x20forwards\x20(merchant→courier\x20pickup,\x20'+'courier→buyer\x20drop-off)\x20with\x20named_operator\x20\x27<namespace>\x27\x20—\x20and\x20disclose\x20the\x20roster\x20duty\x20in\x20a\x20build_note\x20'+'(the\x20NAMED_OPERATOR_ROSTER_UNDISCLOSED\x20gate\x20and\x20the\x20G6\x20dispatch\x20disclosure\x20below\x20enforce\x20the\x20rest).'});const f=/(deliver|courier|shipping|freight|ride|dispatch|logistic)/i;if(a==='courier'){const g=b['rows']['find'](h=>h['mode']==='surplus'&&f['test']((h['value_from']??'')+'\x20'+(h['recipient_key']??'')));g!==undefined&&c['push']({'code':'LOGISTICS_COURIER_FEE_POOLED','detail':'logistics_mode\x20\x27courier\x27\x20has\x20a\x20delivery-fee\x20allocator\x20row\x20in\x20SURPLUS\x20mode\x20'+('(value_from/recipient_key\x20\x27'+(g['value_from']??g['recipient_key']??'')+'\x27)\x20—\x20a\x20surplus\x20leg\x20')+'drains\x20the\x20remainder\x20of\x20the\x20pool\x20it\x20hangs\x20on,\x20which\x20for\x20a\x20courier\x20build\x20IS\x20the\x20buyer\x27s\x20goods\x20escrow\x20'+'(the\x20grab-pool\x20shape\x20the\x20affiliate\x20INV-D3\x20family\x20bans).\x20The\x20delivery\x20fee\x20is\x20KNOWN\x20at\x20order\x20time\x20—\x20the\x20'+'buyer\x20sees\x20and\x20pays\x20it\x20before\x20dispatch\x20—\x20so\x20make\x20it\x20an\x20INDEPENDENT\x20leg:\x20a\x20fixed\x20Amount\x20row\x20(or\x20a\x20Rate\x20'+'row\x20off\x20a\x20dedicated\x20delivery-fee\x20pool\x20funded\x20separately),\x20never\x20a\x20Surplus/Rate\x20drain\x20of\x20the\x20goods\x20pool.'});}if(a==='pickup_point'){const h=b['guardSpecs']['some'](j=>j['template_id']==='pattern.time_lock_absolute'||j['template_id']==='tpl_time_lock_absolute_ms'),i=b['guardSpecs']['some'](j=>j['template_id']==='pattern.time_window_upper_bound'||j['template_id']==='tpl_time_window_upper'||j['template_id']==='tpl_time_window_upper_absolute_ms');(!h||!i)&&c['push']({'code':'LOGISTICS_PICKUP_CUTOFF_MISSING','detail':'logistics_mode\x20\x27pickup_point\x27\x20declares\x20batch\x20consolidation,\x20but\x20the\x20shape\x20is\x20missing\x20'+(''+(!h?'the\x20ABSOLUTE\x20batch-cutoff\x20release\x20gate\x20(pattern.time_lock_absolute\x20—\x20every\x20funder\x27s/leader\x27s\x20release\x20anchors\x20on\x20the\x20SAME\x20shared\x20cutoff\x20clock,\x20not\x20per-order\x20entry+duration)':''))+(''+(!h&&!i?'\x20and\x20':''))+(''+(!i?'the\x20unclaimed-goods\x20exit\x20window\x20(pattern.time_window_upper_bound\x20—\x20goods\x20never\x20picked\x20up\x20must\x20refund/return\x20at\x20a\x20bounded\x20deadline,\x20never\x20hold\x20open-ended)':''))+'.\x20Both\x20are\x20mandatory:\x20without\x20the\x20shared\x20cutoff\x20the\x20batch\x20is\x20not\x20a\x20batch\x20(each\x20order\x20releases\x20on\x20its\x20own\x20clock),\x20and\x20without\x20the\x20exit\x20window\x20an\x20unclaimed\x20parcel\x20strands\x20in\x20the\x20pickup\x20point\x20forever.'});}if(a==='carrier'){const j=/(track|shipping evidence|waybill|airbill|carrier record|parcel evidence)/i,k=b['guardSpecs']['some'](l=>l['host']==='machine'&&j['test'](l['key']+'\x20'+l['purpose']));!k&&c['push']({'code':'LOGISTICS_CARRIER_EVIDENCE_MISSING','detail':'logistics_mode\x20\x27carrier\x27\x20declares\x20third-party\x20carrier\x20shipment,\x20but\x20NO\x20machine\x20guard\x20binds\x20'+'shipping/tracking\x20evidence.\x20Add\x20a\x20repository_data_check\x20guard\x20on\x20the\x20ship\x20forward\x20keyed\x20to\x20a\x20'+'tracking-hash\x20row\x20(the\x20retail\x20idiom:\x20the\x20evidence\x20Repository\x20row\x20is\x20written\x20by\x20an\x20authorized\x20'+'writer\x20—\x20pattern.repository_write_authorization\x20—\x20and\x20the\x20ship\x20guard\x20reads\x20it),\x20so\x20a\x20dispute\x20has\x20a\x20'+'dispute-ready\x20record\x20of\x20what\x20was\x20shipped\x20and\x20when.'});}{const l=/(lost|loss|damag|theft)/i,m=q=>q['replace'](/permanently lost/gi,''),n=/(transit loss|lost (?:parcel|package|goods|in transit)|in[- ]transit loss|carrier lost|loss (?:is |)remed|loss route|lost shipment)/i,o=d['some'](q=>l['test'](q['name'])||l['test'](q['role']??''))||b['guardSpecs']['some'](q=>q['host']==='machine'&&l['test'](m(q['key']+'\x20'+q['purpose']))),p=b['buildNotes']['some'](q=>n['test'](q));!o&&!p&&c['push']({'code':'LOGISTICS_TRANSIT_LOSS_UNCOVERED','detail':'logistics_mode\x20\x27'+a+'\x27\x20moves\x20a\x20physical\x20good,\x20but\x20the\x20shape\x20has\x20NO\x20in-transit\x20loss\x20rail\x20'+'(no\x20loss/damage\x20node\x20or\x20machine-guard\x20family)\x20and\x20NO\x20build_note\x20disclosing\x20the\x20loss\x20remedy.\x20Goods\x20can\x20'+'be\x20lost\x20or\x20damaged\x20between\x20handover\x20and\x20acceptance\x20in\x20EVERY\x20physical\x20mode\x20—\x20silence\x20means\x20the\x20buyer\x27s\x20'+'funds\x20strand\x20behind\x20an\x20undeliverable\x20order\x20with\x20no\x20taught\x20route.\x20Either\x20express\x20the\x20loss\x20waypoint\x20(a\x20'+'node\x20like\x20the\x20retail\x20lost-parcel\x20record,\x20or\x20a\x20loss-evidence\x20machine\x20guard)\x20or\x20add\x20a\x20build_note\x20'+'disclosing\x20the\x20remedy\x20route\x20(e.g.\x20\x22transit\x20loss\x20is\x20remedied\x20by\x20the\x20buyer\x27s\x20arbitration\x20route\x20into\x20the\x20'+'refund\x20rail\x20—\x20the\x20ruling\x20pays\x20the\x20buyer;\x20the\x20carrier\x20claim\x20is\x20an\x20off-chain\x20recovery,\x20disclosed\x20as\x20such\x22).'});}if(a==='courier'||a==='pickup_point'){const q=/(dispatch|schedul|no.{0,24}oracle|no on-chain.{0,24}(dispatch|scheduler)|off-chain keeper|keeper.{0,40}dispatch|roster|named.?operator|permission.{0,12}221)/i,r=b['buildNotes']['some'](s=>q['test'](s));!r&&c['push']({'code':'LOGISTICS_DISPATCH_UNDISCLOSED','detail':'logistics_mode\x20\x27'+a+'\x27\x20is\x20a\x20dynamically\x20dispatched\x20fulfillment\x20topology,\x20but\x20no\x20build_note\x20'+'discloses\x20the\x20two\x20🔴\x20SOLE-TRUTH\x20boundaries.\x20①\x20The\x20chain\x20has\x20NO\x20dispatch/scheduling\x20primitive\x20—\x20'+'assignment\x20of\x20riders/pickup\x20batches\x20is\x20an\x20OFF-CHAIN\x20keeper\x20duty\x20(K-4);\x20its\x20only\x20chain\x20footprint\x20is\x20the\x20'+'namedOperator\x20roster\x20written\x20via\x20permission\x20index\x20221.\x20②\x20There\x20is\x20NO\x20distance/weight/weather\x20oracle\x20—\x20'+'ETA,\x20route,\x20and\x20dynamic\x20pricing\x20are\x20NOT\x20chain-verifiable.\x20Add\x20a\x20build_note\x20stating\x20WHO\x20dispatches\x20(the\x20'+'keeper),\x20WHAT\x20the\x20keeper\x20writes\x20(the\x20roster,\x20per\x20order/shift),\x20and\x20that\x20ETA/pricing\x20live\x20off-chain.'});}return c;}export function emitModeGates(a,b){const c=emitAfterSalesGates(a['afterSalesMode'],b),d=emitAcceptanceGates(a['acceptanceMode'],b);return{'blockers':[...c,...d['blockers'],...emitInstallmentGates(a['installmentMode'],b),...emitAffiliateGates(a['affiliateMode'],b),...emitCrowdfundingGates(a['crowdfundingMode'],b),...emitLogisticsGates(a['logisticsMode'],b)],'disclosures':[...d['disclosures']]};}export function deriveCapabilityModes({template:a,inputs:b}){const c=b['after_sales_mode'],d=c==='return'||c==='exchange'||c==='warranty'||c==='none'?c:undefined,e=d??a['after_sales_mode']??'none',f=b['acceptance_mode'],g=f==='milestone'||f==='contest'||f==='bounty'||f==='agent'||f==='none'?f:undefined,h=g??a['acceptance_mode']??'none',i=b['installment_mode'],j=i==='deposit_balance'||i==='milestone_n'||i==='none'?i:undefined,k=j??a['installment_mode']??'none',l=b['affiliate_mode'],m=l==='commission'||l==='none'?l:undefined,n=m??a['affiliate_mode']??'none',o=b['crowdfunding_mode'],p=o==='threshold'||o==='flexible'||o==='none'?o:undefined,q=p??a['crowdfunding_mode']??'none',r=b['logistics_mode'],s=r==='carrier'||r==='merchant_managed'||r==='courier'||r==='pickup_point'||r==='none'?r:undefined,t=s??a['logistics_mode']??'none';return{'afterSalesMode':e,'acceptanceMode':h,'installmentMode':k,'affiliateMode':n,'crowdfundingMode':q,'logisticsMode':t};}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{landPlatformCommission}from'../knowledge/commission-landing.js';import{collectFeeParamLandings}from'../knowledge/template-scanner.js';import{describeFeeParams}from'../knowledge/param-tiers.js';import{paramSchema}from'../knowledge/param-schema.js';import{PLATFORM_TAKE_KEY}from'../knowledge/template-loader.js';import{compileTemplate}from'./compile.js';const DISCLOSURE_BUILD_MS=Date['UTC'](0x7ea,0x0,0x1);function probeValue(a){const b=typeof a==='number'?a:Number(a);if(!Number['isFinite'](b))return undefined;if(b===0x0)return 0x1;if(b===0x1)return 0x2;return Math['max'](0x1,Math['floor'](b/0x2));}function landedEffect(a,b,c){if(!PLATFORM_TAKE_KEY['test'](b))return{'effect':[]};const d=a['fee_params'],e=landPlatformCommission(a,d),f=landPlatformCommission(a,{...d,[b]:c});if(f['error']!==undefined)return{'effect':[],'blocked':f['error']['split']('.\x20')[0x0]};if(f['rows']===undefined||f['landing']?.['fee_key']!==b)return{'effect':[]};const g=e['rows']??(a['allocator']['rows']??[]);if(JSON['stringify'](g)===JSON['stringify'](f['rows']))return{'effect':[]};return{'effect':['allocator_rows:'+b]};}function changedSteps(c,d){if(d['blockers']['length']>c['blockers']['length'])return[];const e=movedSteps(c,d);if(e['length']===0x0&&d['blockers']['length']<c['blockers']['length']){const f=new Set(d['blockers']['map'](g=>g['code']));for(const g of new Set(c['blockers']['filter'](h=>!f['has'](h['code']))['map'](h=>h['code']))){e['push']('unblocks:'+g);}}return e;}function movedSteps(c,d){const e=[],f=Math['max'](c['plan']['steps']['length'],d['plan']['steps']['length']);for(let g=0x0;g<f;g++){const h=JSON['stringify'](c['plan']['steps'][g]??null),j=JSON['stringify'](d['plan']['steps'][g]??null);if(h!==j)e['push'](c['plan']['steps'][g]?.['id']??d['plan']['steps'][g]?.['id']??'#'+g);}return e;}function pairedKeys(a){const b=new Map();for(const d of a['allocator']['rows']??[]){const e=d['value_from'];if(e===undefined)continue;const f=d['guard_key']??'\x00unkeyed',h=b['get'](f)??new Set();h['add'](e),b['set'](f,h);}const c=new Map();for(const i of b['values']()){if(i['size']<0x2)continue;const j=[...i];for(const k of j)c['set'](k,j['find'](l=>l!==k));}return c;}export function discloseParams(a){const b=collectFeeParamLandings(a),c=compileTemplate(a,{},{'buildTimeMs':DISCLOSURE_BUILD_MS}),d=pairedKeys(a);return describeFeeParams(a)['map'](e=>{const f=(b['get'](e['key'])??[])['map'](
|
|
1
|
+
import{landPlatformCommission}from'../knowledge/commission-landing.js';import{collectFeeParamLandings}from'../knowledge/template-scanner.js';import{describeFeeParams}from'../knowledge/param-tiers.js';import{paramSchema}from'../knowledge/param-schema.js';import{PLATFORM_TAKE_KEY}from'../knowledge/template-loader.js';import{compileTemplate}from'./compile.js';const DISCLOSURE_BUILD_MS=Date['UTC'](0x7ea,0x0,0x1);function probeValue(a){const b=typeof a==='number'?a:Number(a);if(!Number['isFinite'](b))return undefined;if(b===0x0)return 0x1;if(b===0x1)return 0x2;return Math['max'](0x1,Math['floor'](b/0x2));}function landedEffect(a,b,c){if(!PLATFORM_TAKE_KEY['test'](b))return{'effect':[]};const d=a['fee_params'],e=landPlatformCommission(a,d),f=landPlatformCommission(a,{...d,[b]:c});if(f['error']!==undefined)return{'effect':[],'blocked':f['error']['split']('.\x20')[0x0]};if(f['rows']===undefined||f['landing']?.['fee_key']!==b)return{'effect':[]};const g=e['rows']??(a['allocator']['rows']??[]);if(JSON['stringify'](g)===JSON['stringify'](f['rows']))return{'effect':[]};return{'effect':['allocator_rows:'+b]};}function changedSteps(c,d){if(d['blockers']['length']>c['blockers']['length'])return[];const e=movedSteps(c,d);if(e['length']===0x0&&d['blockers']['length']<c['blockers']['length']){const f=new Set(d['blockers']['map'](g=>g['code']));for(const g of new Set(c['blockers']['filter'](h=>!f['has'](h['code']))['map'](h=>h['code']))){e['push']('unblocks:'+g);}}return e;}function movedSteps(c,d){const e=[],f=Math['max'](c['plan']['steps']['length'],d['plan']['steps']['length']);for(let g=0x0;g<f;g++){const h=JSON['stringify'](c['plan']['steps'][g]??null),j=JSON['stringify'](d['plan']['steps'][g]??null);if(h!==j)e['push'](c['plan']['steps'][g]?.['id']??d['plan']['steps'][g]?.['id']??'#'+g);}return e;}function pairedKeys(a){const b=new Map();for(const d of a['allocator']['rows']??[]){const e=d['value_from'];if(e===undefined)continue;const f=d['guard_key']??'\x00unkeyed',h=b['get'](f)??new Set();h['add'](e),b['set'](f,h);}const c=new Map();for(const i of b['values']()){if(i['size']<0x2)continue;const j=[...i];for(const k of j)c['set'](k,j['find'](l=>l!==k));}return c;}export function discloseParams(a){const b=collectFeeParamLandings(a),c=compileTemplate(a,{},{'buildTimeMs':DISCLOSURE_BUILD_MS}),d=pairedKeys(a);return describeFeeParams(a)['map'](e=>{const f=(b['get'](e['key'])??[])['map'](o=>({'surface':o['surface'],'site':o['site']})),g=e['selector']&&typeof e['value']==='string'?(a['conditional_guards']??[])['filter'](o=>o['param']===e['key'])['flatMap'](o=>o['values']??[])['find'](o=>o!==e['value']):undefined;let h=g??probeValue(e['value']);const i=c['plan']['inputs'][e['key']];typeof h==='number'&&typeof i==='number'&&i>=DISCLOSURE_BUILD_MS&&h<=i&&(h=i+0x5265c00);if(h===undefined)return{...e,'status':'not-flippable','effect':[],'landing':f,'editable':![]};const j=compileTemplate(a,{[e['key']]:h},{'buildTimeMs':DISCLOSURE_BUILD_MS}),k=typeof h==='number'?landedEffect(a,e['key'],h):{'effect':[]};k['effect']['length']>0x0&&!f['some'](o=>o['surface']==='allocator_row')&&f['push']({'surface':'allocator_row','site':e['key']});const l=[...changedSteps(c,j),...k['effect']],m=d['get'](e['key']);let n=l['length']>0x0?'live':'inert';return n==='inert'&&m!==undefined&&movedSteps(c,j)['length']>0x0&&(n='live'),{...e,'status':n,'effect':l['length']>0x0?l:n==='live'?['allocator_rows:'+e['key']]:l,'landing':f,'editable':n==='live'&&e['disclosure']!=='hidden',...m!==undefined&&n==='live'?{'paired_with':m}:{},...k['blocked']!==undefined?{'blocked_by':k['blocked']}:{}};});}export function disclosureSummary(a){const b=discloseParams(a);return{'total':b['length'],'knobs':b['filter'](c=>c['disclosure']==='knob')['length'],'editable':b['filter'](c=>c['editable'])['length'],'inertKnobs':b['filter'](c=>c['disclosure']==='knob'&&c['status']==='inert')['map'](c=>c['key']),'benchmark':b['filter'](c=>c['disclosure']==='card')['length'],'hidden':b['filter'](c=>c['disclosure']==='hidden')['length'],'liveKnobs':b['filter'](c=>c['disclosure']==='knob'&&c['status']==='live')['map'](c=>c['key'])};}const EXTERNAL_CARRIER={'arbitration_fee_usd':'the\x20Service\x27s\x20bound\x20Arbitration\x20object\x20(a\x20case-level\x20fee\x20configured\x20there,\x20never\x20a\x20template\x20parameter)','courier_tip_bps':'the\x20rider\x20payroll\x20settled\x20outside\x20the\x20order\x20escrow\x20(tips\x20are\x20not\x20a\x20claim\x20on\x20this\x20pool)','max_discount_bps':'the\x20Service-side\x20Discount\x20(coupon)\x20object;\x20this\x20value\x20only\x20bounds\x20what\x20that\x20object\x20may\x20charge\x20(build-time\x20scale\x20check)','merchant_service_fee_bps':'the\x20INCUMBENT\x20platform\x27s\x20merchant-side\x20fee\x20(benchmark\x20only);\x20this\x20store\x20is\x20WoWok\x20direct\x20sales\x20and\x20takes\x20no\x20platform\x20commission,\x20so\x20no\x20money\x20rail\x20reads\x20this\x20value'};export function inertReason(a){if(a['disclosure']==='hidden')return{'code':'hidden','detail':'Plumbing/directive\x20row:\x20not\x20offered\x20and\x20not\x20meant\x20to\x20be\x20set.'};if(a['status']==='live')return undefined;const b=EXTERNAL_CARRIER[a['key']];if(b!==undefined)return{'code':'external_object','detail':'Carried\x20by\x20'+b+'.\x20Setting\x20it\x20on\x20this\x20template\x20changes\x20nothing\x20on\x20chain\x20—\x20configure\x20it\x20on\x20that\x20object\x20instead.'};if(a['blocked_by']!==undefined)return{'code':'external_object','detail':a['blocked_by']+'.\x20This\x20value\x20is\x20carried\x20by\x20a\x20different\x20object\x20or\x20money\x20shape,\x20not\x20by\x20this\x20template\x27s\x20guards.'};if(a['status']==='not-flippable')return{'code':'not_settable','detail':'The\x20value\x20is\x20not\x20a\x20number\x20a\x20control\x20can\x20offer\x20(no\x20sibling\x20value\x20to\x20probe).'};if(a['landing']['length']===0x0)return{'code':'no_consumer','detail':'No\x20guard,\x20allocator\x20row\x20or\x20time\x20anchor\x20names\x20this\x20key\x20—\x20setting\x20it\x20changes\x20nothing\x20on\x20chain.'};if(a['landing']['every'](e=>e['surface']==='directive'))return{'code':'prose_only','detail':'Named\x20only\x20in\x20the\x20template\x27s\x20prose\x20(build\x20notes\x20/\x20user\x20inputs);\x20no\x20machine\x20object\x20reads\x20it.'};const c=[...new Set(a['landing']['map'](e=>e['surface']+'\x20\x27'+e['site']+'\x27'))]['join'](',\x20'),d=a['landing']['some'](e=>e['surface']==='allocator_row')?'\x20—\x20the\x20allocator\x20rows\x20compile\x20with\x20a\x20literal\x20value,\x20not\x20this\x20key':a['landing']['some'](e=>e['surface']==='guard')?'\x20—\x20the\x20guard\x27s\x20constant\x20is\x20frozen\x20into\x20the\x20Guard\x20at\x20publish':a['landing']['some'](e=>e['surface']==='time_anchor')?'\x20—\x20the\x20time\x20anchor\x20compiles\x20its\x20duration\x20as\x20a\x20constant':'';return{'code':'seat_not_built','detail':'A\x20seat\x20is\x20declared\x20('+c+')\x20but\x20overriding\x20the\x20value\x20does\x20not\x20change\x20the\x20compiled\x20plan'+d+'.\x20It\x20is\x20a\x20published\x20price/capacity\x20figure,\x20not\x20an\x20enforced\x20constant:\x20a\x20Machine\x20rebuild\x20is\x20what\x20changes\x20it.'};}const SURFACE_WORDING={'guard':'enforced\x20by\x20guard','allocator_row':'allocator\x20row','time_anchor':'time\x20anchor','kernel':'compile\x20kernel','directive':'prose\x20only\x20(no\x20chain\x20effect)'};export function landingLine(a){if(a['length']===0x0)return'no\x20declared\x20landing';const b=new Set(),c=[];for(const d of a){const e=SURFACE_WORDING[d['surface']]??d['surface'],f=d['surface']==='directive'?e:e+'\x20\x27'+d['site']+'\x27';if(b['has'](f))continue;b['add'](f),c['push'](f);}return c['join'](';\x20');}export function paramPlane(a){const b=new Map(paramSchema(a)['map'](c=>[c['key'],c]));return discloseParams(a)['map'](c=>{const d=b['get'](c['key']);if(d===undefined)throw new Error('paramPlane:\x20\x27'+c['key']+'\x27\x20has\x20no\x20schema\x20row\x20(classification\x20is\x20not\x20total)');const e=inertReason(c);return{...d,'status':c['status'],'effect':c['effect'],'landing':c['landing'],'landing_line':c['status']!=='live'&&EXTERNAL_CARRIER[c['key']]!==undefined?'carried\x20by\x20'+EXTERNAL_CARRIER[c['key']]:landingLine(c['landing']),'editable':c['editable'],...e!==undefined?{'inert_reason':e}:{},...c['blocked_by']!==undefined?{'blocked_by':c['blocked_by']}:{},...c['paired_with']!==undefined?{'pair_note':'Shares\x20ONE\x2010000\x20basis-point\x20split\x20with\x20\x27'+c['paired_with']+'\x27\x20—\x20set\x20both\x20together;\x20moving\x20either\x20alone\x20exceeds\x2010000\x20and\x20the\x20build\x20refuses.'}:{}};});}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export interface PlanStepOutcomeLike {
|
|
2
|
+
stepId: string;
|
|
3
|
+
status: string;
|
|
4
|
+
digest?: string;
|
|
5
|
+
error?: string;
|
|
6
|
+
}
|
|
7
|
+
export interface RepeatedFailure {
|
|
8
|
+
step_id: string;
|
|
9
|
+
consecutive_rounds: number;
|
|
10
|
+
error: string;
|
|
11
|
+
}
|
|
12
|
+
export interface LockedStep {
|
|
13
|
+
stepId: string;
|
|
14
|
+
count: number;
|
|
15
|
+
lastError: string;
|
|
16
|
+
}
|
|
17
|
+
export declare function planLedgerKey(plan: unknown): string;
|
|
18
|
+
export declare function recordPlanRound(planKey: string, steps: readonly PlanStepOutcomeLike[]): void;
|
|
19
|
+
export declare function repeatedPlanFailures(planKey: string): RepeatedFailure[];
|
|
20
|
+
export declare function lockedFreshStep(planKey: string, planStepIds: readonly string[], adopted: ReadonlySet<string>): LockedStep | undefined;
|
|
21
|
+
export declare function clearPlanStep(planKey: string, stepId: string): void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const LEDGER_PLAN_CAP=0x14,ledger=new Map();export function planLedgerKey(a){let b;try{b=JSON['stringify'](a)??'';}catch{b=String(typeof a);}let c=0x811c9dc5;for(let d=0x0;d<b['length'];d++){c^=b['charCodeAt'](d),c=Math['imul'](c,0x1000193);}return(c>>>0x0)['toString'](0x10);}function entriesFor(a){let b=ledger['get'](a);if(b===undefined){b=new Map(),ledger['set'](a,b);while(ledger['size']>LEDGER_PLAN_CAP){const c=ledger['keys']()['next']()['value'];if(c===undefined)break;ledger['delete'](c);}}return b;}export function recordPlanRound(a,b){const c=entriesFor(a);for(const d of b){if(d['status']==='executed'){if(d['error']===undefined||d['error']['startsWith']('resumed\x20from\x20a\x20prior\x20run'))c['delete'](d['stepId']);continue;}if(d['status']==='failed'&&typeof d['error']==='string'&&d['error']['length']>0x0){const e=c['get'](d['stepId']);if(e!==undefined&&e['lastError']===d['error'])e['count']+=0x1;else c['set'](d['stepId'],{'lastError':d['error'],'count':0x1});}}}export function repeatedPlanFailures(a){const b=ledger['get'](a);if(b===undefined)return[];return[...b['entries']()]['filter'](([,c])=>c['count']>=0x2)['map'](([c,d])=>({'step_id':c,'consecutive_rounds':d['count'],'error':d['lastError']}));}export function lockedFreshStep(a,b,c){const d=new Map(repeatedPlanFailures(a)['map'](e=>[e['step_id'],e]));for(const e of b){if(c['has'](e))continue;const f=d['get'](e);if(f!==undefined)return{'stepId':e,'count':f['consecutive_rounds'],'lastError':f['error']};}return undefined;}export function clearPlanStep(a,b){ledger['get'](a)?.['delete'](b);}
|
|
@@ -20,6 +20,10 @@ export type ResolvedValue = JsonValue | RefExpr | LateExpr;
|
|
|
20
20
|
export type ResolvedParams = Record<string, ResolvedValue>;
|
|
21
21
|
export declare function isRef(v: ResolvedValue): v is RefExpr;
|
|
22
22
|
export declare function isLate(v: ResolvedValue): v is LateExpr;
|
|
23
|
+
export declare const P: (o: Record<string, unknown>) => ResolvedParams;
|
|
24
|
+
export declare function ref(stepId: string): RefExpr;
|
|
25
|
+
export declare function collectLateMarks(node: unknown, out?: Set<string>): Set<string>;
|
|
26
|
+
export declare function collectAddressSlotBareNames(plan: Plan, out?: Set<string>): Set<string>;
|
|
23
27
|
export declare const CREATABLE_OBJECTS: {
|
|
24
28
|
readonly permission: "Permission";
|
|
25
29
|
readonly guard: "Guard";
|
|
@@ -36,7 +40,6 @@ export declare const CREATABLE_OBJECTS: {
|
|
|
36
40
|
};
|
|
37
41
|
export type CreatableKind = keyof typeof CREATABLE_OBJECTS;
|
|
38
42
|
export declare const PUBLISHABLE_KINDS: readonly ["service", "machine"];
|
|
39
|
-
export type PublishableKind = (typeof PUBLISHABLE_KINDS)[number];
|
|
40
43
|
interface StepBase {
|
|
41
44
|
id: StepId;
|
|
42
45
|
notes?: string;
|
|
@@ -76,8 +79,10 @@ export interface Plan {
|
|
|
76
79
|
version: 1;
|
|
77
80
|
intent: string;
|
|
78
81
|
templateId?: string;
|
|
82
|
+
template_digest?: string;
|
|
79
83
|
inputs: Record<string, JsonValue>;
|
|
80
84
|
steps: PlanStep[];
|
|
85
|
+
external_refs?: string[];
|
|
81
86
|
pending_guards?: PendingGuard[];
|
|
82
87
|
derived_params?: DerivedParam[];
|
|
83
88
|
}
|
|
@@ -94,7 +99,7 @@ export declare function stepById(plan: Plan, id: StepId): PlanStep | undefined;
|
|
|
94
99
|
export declare function createsOf(plan: Plan, kind: CreatableKind): CreateStep[];
|
|
95
100
|
export declare function resolveValue(value: ResolvedValue, outputs: ReadonlyMap<StepId, string>, resolveLate: (q: LateQuery) => string): JsonValue | string;
|
|
96
101
|
export interface PlanIssue {
|
|
97
|
-
code: "PLAN_DUP_STEP" | "PLAN_UNKNOWN_KIND" | "PLAN_REF_UNKNOWN" | "PLAN_REF_FORWARD" | "PLAN_PUBLISH_TARGET" | "PLAN_PROSE_GUARD" | "PLAN_MACHINE_NODES" | "PLAN_REQUIRES_UNKNOWN" | "PLAN_GUARD_PLACEHOLDER" | "PLAN_GUARD_EMPTY_VEC" | "PLAN_LOGIC_ARITY";
|
|
102
|
+
code: "PLAN_DUP_STEP" | "PLAN_UNKNOWN_KIND" | "PLAN_REF_UNKNOWN" | "PLAN_REF_FORWARD" | "PLAN_PUBLISH_TARGET" | "PLAN_PROSE_GUARD" | "PLAN_MACHINE_NODES" | "PLAN_REQUIRES_UNKNOWN" | "PLAN_GUARD_PLACEHOLDER" | "PLAN_GUARD_EMPTY_VEC" | "PLAN_GUARD_ZERO_ADDR" | "PLAN_LOGIC_ARITY" | "PLAN_NAME_COLLISION";
|
|
98
103
|
step?: StepId;
|
|
99
104
|
detail: string;
|
|
100
105
|
}
|
package/dist/composition/plan.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{OBJECT_GRAPH}from'../chain-semantics/index.js';export function isRef(a){return typeof a==='object'&&a!==null&&!Array['isArray'](a)&&typeof a['$ref']==='string'&&Object['keys'](a)['every'](b=>b==='$ref'||b==='path');}export function isLate(a){return typeof a==='object'&&a!==null&&!Array['isArray'](a)&&typeof a['$late']==='object'&&a['$late']!==null&&Object['keys'](a)['every'](b=>b==='$late');}export const CREATABLE_OBJECTS={'permission':'Permission','guard':'Guard','repository':'Repository','machine':'Machine','service':'Service<T>','arbitration':'Arbitration<T>','treasury':'Treasury<T>','reward':'Reward<T>','demand':'Demand','contact':'Contact','proof':'Proof','resource':'Resource'};export const PUBLISHABLE_KINDS=['service','machine'];export function refsOf(a,b=new Set()){if(isRef(a))b['add'](a['$ref']);else{if(Array['isArray'](a)){for(const c of a)refsOf(c,b);}else{if(typeof a==='object'&&a!==null&&!isLate(a)){for(const d of Object['values'](a))refsOf(d,b);}}}return b;}export function stepById(a,b){return a['steps']['find'](c=>c['id']===b);}export function createsOf(a,b){return a['steps']['filter'](c=>c['op']==='create'&&c['object']===b);}export function resolveValue(a,b,c){if(isRef(a)){const d=b['get'](a['$ref']);if(d===undefined)throw new Error('unresolved\x20ref:\x20'+a['$ref']);return a['path']?''+d+a['path']:d;}if(isLate(a))return c(a['$late']);if(Array['isArray'](a))return a['map'](e=>resolveValue(e,b,c));if(typeof a==='object'&&a!==null)return Object['fromEntries'](Object['entries'](a)['map'](([e,f])=>[e,resolveValue(f,b,c)]));return a;}function guardStructuralIssues(a,b){const c=[],d=g=>{typeof g==='string'&&g['includes']('${')&&c['push']({'code':'PLAN_GUARD_PLACEHOLDER','step':a,'detail':'unfilled\x20template\x20placeholder\x20\x27'+g['slice'](0x0,0x30)+'\x27\x20—\x20resolve\x20every\x20guard\x20param\x20before\x20execution'});},e=b['table'];if(Array['isArray'](e))for(const g of e){if(g===null||typeof g!=='object')continue;const h=g,i=h['value'];i===''&&c['push']({'code':'PLAN_GUARD_EMPTY_VEC','step':a,'detail':'table\x20row\x20'+String(h['identifier'])+'\x20carries\x20an\x20EMPTY\x20value\x20—\x20the\x20serialized\x20bytes\x20are\x20empty\x20and\x20the\x20chain\x20aborts\x20the\x20create\x20(E_TABLE_ITEM_VALUE_EMPTY=14)'}),d(i);}const f=j=>{if(Array['isArray'](j)){for(const m of j)f(m);return;}if(j===null||typeof j!=='object')return;const l=j;(l['type']==='logic_and'||l['type']==='logic_or')&&Array['isArray'](l['nodes'])&&l['nodes']['length']===0x1&&c['push']({'code':'PLAN_LOGIC_ARITY','step':a,'detail':String(l['type'])+'\x20with\x20a\x20single\x20child\x20—\x20the\x20kernel\x20rejects\x20the\x20shape;\x20unwrap\x20the\x20operand\x20(the\x20compile\x20kernel\x20normalizes\x20this\x20automatically)'});for(const [o,p]of Object['entries'](l)){if(o==='type')continue;d(p),f(p);}};return f(b['root']),c;}export function validatePlan(a){const b=[],c=new Set(a['steps']['map'](e=>e['id'])),d=new Map();return a['steps']['forEach']((e,f)=>{d['has'](e['id'])&&b['push']({'code':'PLAN_DUP_STEP','step':e['id'],'detail':'duplicate\x20step\x20id\x20at\x20index\x20'+f});d['set'](e['id'],f);if(e['op']==='create'){if(!(e['object']in CREATABLE_OBJECTS))b['push']({'code':'PLAN_UNKNOWN_KIND','step':e['id'],'detail':'unknown\x20object\x20kind:\x20'+e['object']});else!(CREATABLE_OBJECTS[e['object']]in OBJECT_GRAPH)&&b['push']({'code':'PLAN_UNKNOWN_KIND','step':e['id'],'detail':'kind\x20'+e['object']+'\x20not\x20in\x20chain\x20OBJECT_GRAPH'});if(e['object']==='guard'){const h=e['params']['table'];(!Array['isArray'](h)||h['length']===0x0)&&b['push']({'code':'PLAN_PROSE_GUARD','step':e['id'],'detail':'guard\x20requires\x20a\x20non-empty\x20structured\x20`table`\x20param\x20(no\x20prose\x20logic\x20slots)'}),b['push'](...guardStructuralIssues(e['id'],e['params']));}if(e['object']==='machine'){const j=e['params']['nodes'];(!Array['isArray'](j)||j['length']===0x0)&&b['push']({'code':'PLAN_MACHINE_NODES','step':e['id'],'detail':'machine\x20requires\x20a\x20non-empty\x20`nodes`\x20param'});}}if(e['op']==='configure')for(const k of e['requires']??[]){(!d['has'](k)||d['get'](k)===f)&&b['push']({'code':'PLAN_REQUIRES_UNKNOWN','step':e['id'],'detail':'requires\x20unknown/prior-less\x20step:\x20'+k});}if(e['op']==='publish'){const l=d['get'](e['target']['$ref']),m=l===undefined?undefined:a['steps'][l];if(!c['has'](e['target']['$ref']))b['push']({'code':'PLAN_REF_UNKNOWN','step':e['id'],'detail':'publish\x20target\x20unknown:\x20'+e['target']['$ref']});else(m===undefined||m['op']!=='create'||!PUBLISHABLE_KINDS['includes'](m['object']))&&b['push']({'code':'PLAN_PUBLISH_TARGET','step':e['id'],'detail':'publish\x20target\x20must\x20be\x20a\x20created\x20service|machine,\x20got:\x20'+(m?.['op']==='create'?m['object']:m?.['op'])});}const g=e['op']==='create'||e['op']==='configure'?refsOf(e['params']):new Set();if(e['op']==='configure'&&isRef(e['target']))g['add'](e['target']['$ref']);if(e['op']==='publish')g['add'](e['target']['$ref']);for(const n of g){const o=d['get'](n);if(!c['has'](n))b['push']({'code':'PLAN_REF_UNKNOWN','step':e['id'],'detail':'ref\x20to\x20unknown\x20step:\x20'+n});else(o===undefined||o>=f)&&b['push']({'code':'PLAN_REF_FORWARD','step':e['id'],'detail':'ref\x20to\x20non-prior\x20step:\x20'+n});}}),b;}
|
|
1
|
+
import{OBJECT_GRAPH}from'../chain-semantics/index.js';export function isRef(a){return typeof a==='object'&&a!==null&&!Array['isArray'](a)&&typeof a['$ref']==='string'&&Object['keys'](a)['every'](b=>b==='$ref'||b==='path');}export function isLate(a){return typeof a==='object'&&a!==null&&!Array['isArray'](a)&&typeof a['$late']==='object'&&a['$late']!==null&&Object['keys'](a)['every'](b=>b==='$late');}export const P=a=>a;export function ref(a){return{'$ref':a};}export function collectLateMarks(a,b=new Set()){if(Array['isArray'](a)){for(const c of a)collectLateMarks(c,b);return b;}if(a&&typeof a==='object'){const d=a,e=d['$late'];if(e&&typeof e==='object'){const f=e;if(f['by']==='local_name'&&typeof f['mark']==='string')b['add'](f['mark']);}for(const g of Object['values'](d))collectLateMarks(g,b);}return b;}export function collectAddressSlotBareNames(a,b=new Set()){const c=d=>/^0x[0-9a-fA-F]{1,64}$/['test'](d['trim']());for(const d of a['steps']){if(d['op']!=='create'||d['object']!=='guard')continue;const e=d['params']['table'];if(!Array['isArray'](e))continue;for(const f of e){if(f===null||typeof f!=='object')continue;const g=f,h=g['value_type'],i=h==='Address',j=h==='VecAddress';if(!i&&!j)continue;const k=g['value'];i&&typeof k==='string'&&k['length']>0x0&&!c(k)&&b['add'](k);if(j&&Array['isArray'](k))for(const l of k){if(typeof l==='string'&&l['length']>0x0&&!c(l))b['add'](l);}}}return b;}export const CREATABLE_OBJECTS={'permission':'Permission','guard':'Guard','repository':'Repository','machine':'Machine','service':'Service<T>','arbitration':'Arbitration<T>','treasury':'Treasury<T>','reward':'Reward<T>','demand':'Demand','contact':'Contact','proof':'Proof','resource':'Resource'};export const PUBLISHABLE_KINDS=['service','machine'];export function refsOf(a,b=new Set()){if(isRef(a))b['add'](a['$ref']);else{if(Array['isArray'](a)){for(const c of a)refsOf(c,b);}else{if(typeof a==='object'&&a!==null&&!isLate(a)){for(const d of Object['values'](a))refsOf(d,b);}}}return b;}export function stepById(a,b){return a['steps']['find'](c=>c['id']===b);}export function createsOf(a,b){return a['steps']['filter'](c=>c['op']==='create'&&c['object']===b);}export function resolveValue(a,b,c){if(isRef(a)){const d=b['get'](a['$ref']);if(d===undefined)throw new Error('unresolved\x20ref:\x20'+a['$ref']);return a['path']?''+d+a['path']:d;}if(isLate(a))return c(a['$late']);if(Array['isArray'](a))return a['map'](e=>resolveValue(e,b,c));if(typeof a==='object'&&a!==null)return Object['fromEntries'](Object['entries'](a)['map'](([e,f])=>[e,resolveValue(f,b,c)]));return a;}function guardStructuralIssues(a,b){const c=[],d=g=>{typeof g==='string'&&g['includes']('${')&&c['push']({'code':'PLAN_GUARD_PLACEHOLDER','step':a,'detail':'unfilled\x20template\x20placeholder\x20\x27'+g['slice'](0x0,0x30)+'\x27\x20—\x20resolve\x20every\x20guard\x20param\x20before\x20execution'});},e=b['table'];if(Array['isArray'](e))for(const g of e){if(g===null||typeof g!=='object')continue;const h=g,i=h['value'];i===''&&c['push']({'code':'PLAN_GUARD_EMPTY_VEC','step':a,'detail':'table\x20row\x20'+String(h['identifier'])+'\x20carries\x20an\x20EMPTY\x20value\x20—\x20the\x20serialized\x20bytes\x20are\x20empty\x20and\x20the\x20chain\x20aborts\x20the\x20create\x20(E_TABLE_ITEM_VALUE_EMPTY=14)'}),(h['value_type']==='VecAddress'||h['value_type']===0xa)&&Array['isArray'](i)&&i['some'](j=>typeof j==='string'&&/^0x0+$/i['test'](j))&&c['push']({'code':'PLAN_GUARD_ZERO_ADDR','step':a,'detail':'table\x20row\x20'+String(h['identifier'])+'\x20(VecAddress)\x20carries\x20a\x20ZERO-ADDRESS\x20placeholder\x20—\x20'+'the\x20retired\x20ddmc4\x20B-04\x20workaround;\x20a\x20zero\x20address\x20is\x20NOT\x20\x22no\x20list\x22\x20(the\x20guard\x20table\x20would\x20claim\x20'+'address\x200\x20is\x20allowed).\x20Legal\x20exits:\x20arm\x20the\x20list\x20with\x20real\x20addresses,\x20or\x20omit\x20the\x20guard\x20via\x20'+'guard_resolutions\x20{kind:\x22omit\x22}\x20when\x20\x27no\x20list\x27\x20is\x20the\x20intended\x20polarity.'}),d(i);}const f=j=>{if(Array['isArray'](j)){for(const m of j)f(m);return;}if(j===null||typeof j!=='object')return;const l=j;(l['type']==='logic_and'||l['type']==='logic_or')&&Array['isArray'](l['nodes'])&&l['nodes']['length']===0x1&&c['push']({'code':'PLAN_LOGIC_ARITY','step':a,'detail':String(l['type'])+'\x20with\x20a\x20single\x20child\x20—\x20the\x20kernel\x20rejects\x20the\x20shape;\x20unwrap\x20the\x20operand\x20(the\x20compile\x20kernel\x20normalizes\x20this\x20automatically)'});for(const [o,p]of Object['entries'](l)){if(o==='type')continue;d(p),f(p);}};return f(b['root']),c;}export function validatePlan(a){const b=[],c=new Set(a['steps']['map'](e=>e['id'])),d=new Map();return a['steps']['forEach']((e,f)=>{d['has'](e['id'])&&b['push']({'code':'PLAN_DUP_STEP','step':e['id'],'detail':'duplicate\x20step\x20id\x20at\x20index\x20'+f});d['set'](e['id'],f);if(e['op']==='create'){if(!(e['object']in CREATABLE_OBJECTS))b['push']({'code':'PLAN_UNKNOWN_KIND','step':e['id'],'detail':'unknown\x20object\x20kind:\x20'+e['object']});else!(CREATABLE_OBJECTS[e['object']]in OBJECT_GRAPH)&&b['push']({'code':'PLAN_UNKNOWN_KIND','step':e['id'],'detail':'kind\x20'+e['object']+'\x20not\x20in\x20chain\x20OBJECT_GRAPH'});if(e['object']==='guard'){const h=e['params']['table'];(!Array['isArray'](h)||h['length']===0x0)&&b['push']({'code':'PLAN_PROSE_GUARD','step':e['id'],'detail':'guard\x20requires\x20a\x20non-empty\x20structured\x20`table`\x20param\x20(no\x20prose\x20logic\x20slots)'}),b['push'](...guardStructuralIssues(e['id'],e['params']));}if(e['object']==='machine'){const j=e['params']['nodes'];(!Array['isArray'](j)||j['length']===0x0)&&b['push']({'code':'PLAN_MACHINE_NODES','step':e['id'],'detail':'machine\x20requires\x20a\x20non-empty\x20`nodes`\x20param'});}}if(e['op']==='configure'){for(const k of e['requires']??[]){(!d['has'](k)||d['get'](k)===f)&&b['push']({'code':'PLAN_REQUIRES_UNKNOWN','step':e['id'],'detail':'requires\x20unknown/prior-less\x20step:\x20'+k});}typeof e['target']==='string'&&c['has'](e['target'])&&b['push']({'code':'PLAN_NAME_COLLISION','step':e['id'],'detail':'target\x20\x27'+e['target']+'\x27\x20names\x20a\x20create\x20step\x20in\x20THIS\x20plan\x20—\x20pass\x20{\x22$ref\x22:\x20\x22'+e['target']+'\x22}\x20so\x20it\x20binds\x20to\x20this\x20run\x27s\x20output.\x20'+'A\x20bare\x20name\x20resolves\x20through\x20the\x20global\x20mark\x20namespace\x20and\x20silently\x20binds\x20a\x20previous\x20run\x27s\x20object\x20(frozen,\x20unrepairable)'});}if(e['op']==='publish'){const l=d['get'](e['target']['$ref']),m=l===undefined?undefined:a['steps'][l];if(!c['has'](e['target']['$ref']))b['push']({'code':'PLAN_REF_UNKNOWN','step':e['id'],'detail':'publish\x20target\x20unknown:\x20'+e['target']['$ref']});else(m===undefined||m['op']!=='create'||!PUBLISHABLE_KINDS['includes'](m['object']))&&b['push']({'code':'PLAN_PUBLISH_TARGET','step':e['id'],'detail':'publish\x20target\x20must\x20be\x20a\x20created\x20service|machine,\x20got:\x20'+(m?.['op']==='create'?m['object']:m?.['op'])});}const g=e['op']==='create'||e['op']==='configure'?refsOf(e['params']):new Set();if(e['op']==='configure'&&isRef(e['target']))g['add'](e['target']['$ref']);if(e['op']==='publish')g['add'](e['target']['$ref']);for(const n of g){const o=d['get'](n);if(!c['has'](n))b['push']({'code':'PLAN_REF_UNKNOWN','step':e['id'],'detail':'ref\x20to\x20unknown\x20step:\x20'+n});else(o===undefined||o>=f)&&b['push']({'code':'PLAN_REF_FORWARD','step':e['id'],'detail':'ref\x20to\x20non-prior\x20step:\x20'+n});}}),b;}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
export interface CardEvidence {
|
|
2
|
+
source: string;
|
|
3
|
+
detail: string;
|
|
4
|
+
}
|
|
5
|
+
export interface CardAlignment {
|
|
6
|
+
template_id: string;
|
|
7
|
+
industry: string;
|
|
8
|
+
variant: string;
|
|
9
|
+
product_ref: string;
|
|
10
|
+
archetype: "leader" | "challenger";
|
|
11
|
+
phase: 1 | 2 | 3;
|
|
12
|
+
one_liner: string;
|
|
13
|
+
evidence: CardEvidence[];
|
|
14
|
+
}
|
|
15
|
+
export interface CardFundSpeed {
|
|
16
|
+
key: string;
|
|
17
|
+
value: number | string;
|
|
18
|
+
landing_line: string;
|
|
19
|
+
evidence: CardEvidence[];
|
|
20
|
+
}
|
|
21
|
+
export interface CardVsTraditional {
|
|
22
|
+
dimension: string;
|
|
23
|
+
wowok: string;
|
|
24
|
+
traditional: null;
|
|
25
|
+
wowok_evidence: string[];
|
|
26
|
+
}
|
|
27
|
+
export interface CardFeatures {
|
|
28
|
+
flow: string[];
|
|
29
|
+
fund_speed: CardFundSpeed | null;
|
|
30
|
+
model: string[];
|
|
31
|
+
vs_traditional: CardVsTraditional[];
|
|
32
|
+
}
|
|
33
|
+
export interface CardCost {
|
|
34
|
+
platform_fee: {
|
|
35
|
+
bps: number;
|
|
36
|
+
cap_bps: number | null;
|
|
37
|
+
self_platform: string;
|
|
38
|
+
evidence: CardEvidence[];
|
|
39
|
+
};
|
|
40
|
+
gas_objects_estimate: {
|
|
41
|
+
value: number;
|
|
42
|
+
basis: string;
|
|
43
|
+
};
|
|
44
|
+
compensation_fund: {
|
|
45
|
+
policy: "allowed" | "forbidden";
|
|
46
|
+
note: string;
|
|
47
|
+
};
|
|
48
|
+
keeper_dependencies: string[];
|
|
49
|
+
}
|
|
50
|
+
export interface CardParams {
|
|
51
|
+
total: number;
|
|
52
|
+
editable: number;
|
|
53
|
+
live: number;
|
|
54
|
+
groups: Array<{
|
|
55
|
+
group: string;
|
|
56
|
+
tier: number;
|
|
57
|
+
count: number;
|
|
58
|
+
}>;
|
|
59
|
+
full_rows_via: string;
|
|
60
|
+
}
|
|
61
|
+
export interface CardRisks {
|
|
62
|
+
key_risk: string;
|
|
63
|
+
differences: string[];
|
|
64
|
+
user_inputs: string[];
|
|
65
|
+
capability_risks: string[];
|
|
66
|
+
capability_risks_note: string;
|
|
67
|
+
}
|
|
68
|
+
export interface ProductCard {
|
|
69
|
+
alignment: CardAlignment;
|
|
70
|
+
features: CardFeatures;
|
|
71
|
+
cost: CardCost;
|
|
72
|
+
params: CardParams;
|
|
73
|
+
risks: CardRisks;
|
|
74
|
+
templates_version: number;
|
|
75
|
+
}
|
|
76
|
+
export interface ProductCardSummary {
|
|
77
|
+
template_id: string;
|
|
78
|
+
industry: string;
|
|
79
|
+
product_ref: string;
|
|
80
|
+
archetype: string;
|
|
81
|
+
one_liner: string;
|
|
82
|
+
cost_headline: {
|
|
83
|
+
platform_fee_bps: number;
|
|
84
|
+
gas_objects_estimate: number;
|
|
85
|
+
compensation_fund: "allowed" | "forbidden";
|
|
86
|
+
};
|
|
87
|
+
params: {
|
|
88
|
+
total: number;
|
|
89
|
+
editable: number;
|
|
90
|
+
};
|
|
91
|
+
templates_version: number;
|
|
92
|
+
}
|
|
93
|
+
export declare function productCard(templateId: string): ProductCard;
|
|
94
|
+
export declare function productCards(industry?: string): ProductCardSummary[];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{listBuiltinTemplates,getBuiltinTemplate,BUILTIN_TEMPLATES_VERSION}from'../knowledge/builtin-templates.js';import{paramPlane}from'./param-disclosure.js';const COMPARE_KEYS=[{'key':'platform_commission_bps','dimension':'platform_take_rate','label':'platform\x20commission'},{'key':'merchant_service_fee_bps','dimension':'merchant_service_fee','label':'merchant\x20service\x20fee'},{'key':'incumbent_take_bps','dimension':'incumbent_take_rate_reference','label':'declared\x20incumbent\x20take-rate\x20reference'}],FUND_SPEED_KEYS=['settle_hours','auto_confirm_hours'],SELF_PLATFORM_NOTE='supported\x20—\x20set\x20platform_commission_bps\x20and\x20attach\x20a\x20dedicated\x20platform\x20Entity;\x20the\x20cap\x20(when\x20declared)\x20bounds\x20the\x20take';function bpsToPercent(a){const b=a/0x64;return(Number['isInteger'](b)?b:b['toFixed'](0x2))+'%';}function projectFundSpeed(a,b){const c=FUND_SPEED_KEYS['find'](e=>a['fee_params'][e]!==undefined);if(c===undefined)return null;const d=b['find'](e=>e['key']===c);return{'key':c,'value':a['fee_params'][c],'landing_line':d?.['landing_line']??'declared\x20in\x20fee_params\x20(no\x20landing\x20probe\x20row)','evidence':[{'source':'fee_params','detail':c+'\x20=\x20'+String(a['fee_params'][c])},...d?[{'source':'param_plane','detail':'status='+d['status']+',\x20landing='+d['landing_line']}]:[]]};}function projectVsTraditional(a){const b=[];for(const {key:c,dimension:d,label:e}of COMPARE_KEYS){const f=a['fee_params'][c];if(f===undefined||typeof f!=='number')continue;const g=a['fee_params']['platform_rate_cap_bps'],h=typeof g==='number'&&c==='platform_commission_bps'?'\x20(declared\x20cap\x20'+bpsToPercent(g)+')':'';b['push']({'dimension':d,'wowok':bpsToPercent(f)+'\x20'+e+h,'traditional':null,'wowok_evidence':[c,...typeof g==='number'&&c==='platform_commission_bps'?['platform_rate_cap_bps']:[]]});}return b;}export function productCard(a){const b=getBuiltinTemplate(a);if(!b)throw new Error('template\x20\x27'+a+'\x27\x20is\x20not\x20in\x20the\x20builtin\x20catalog\x20'+('(available:\x20'+listBuiltinTemplates()['map'](e=>e['id'])['join'](',\x20')+')'));const c=paramPlane(b),d=b['machine_shape']['map'](e=>{const f=e['semantic_role']??e['role'];return e['name']+'\x20—\x20'+f;});return{'alignment':{'template_id':b['id'],'industry':b['industry'],'variant':b['variant'],'product_ref':b['product_ref'],'archetype':b['archetype'],'phase':b['phase'],'one_liner':b['product_ref']+'-modeled\x20'+b['variant']+'\x20archetype\x20for\x20'+b['industry']+':\x20'+(b['trust_mechanisms']['length']+'\x20declared\x20trust\x20mechanisms,\x20'+b['guards']['length']+'\x20guard\x20refs,\x20')+(b['machine_shape']['length']+'\x20machine\x20nodes,\x20'+c['filter'](e=>e['editable'])['length']+'/'+c['length']+'\x20params\x20editable.'),'evidence':[{'source':'product_ref','detail':b['product_ref']},{'source':'trust_mechanisms','detail':b['trust_mechanisms']['length']+'\x20entries'},{'source':'guards','detail':b['guards']['length']+'\x20refs'},{'source':'machine_shape','detail':b['machine_shape']['length']+'\x20nodes'}]},'features':{'flow':d,'fund_speed':projectFundSpeed(b,c),'model':[...b['trust_mechanisms']],'vs_traditional':projectVsTraditional(b)},'cost':{'platform_fee':{'bps':typeof b['fee_params']['platform_commission_bps']==='number'?b['fee_params']['platform_commission_bps']:0x0,'cap_bps':typeof b['fee_params']['platform_rate_cap_bps']==='number'?b['fee_params']['platform_rate_cap_bps']:null,'self_platform':SELF_PLATFORM_NOTE,'evidence':[{'source':'fee_params','detail':'platform_commission_bps\x20=\x20'+String(b['fee_params']['platform_commission_bps']??0x0)},...typeof b['fee_params']['platform_rate_cap_bps']==='number'?[{'source':'fee_params','detail':'platform_rate_cap_bps\x20=\x20'+String(b['fee_params']['platform_rate_cap_bps'])}]:[]]},'gas_objects_estimate':{'value':b['machine_shape']['length']+b['guards']['length'],'basis':'template\x20shape\x20(machine\x20nodes\x20+\x20guard\x20refs),\x20pre-compile\x20—\x20the\x20compiled\x20object\x20count\x20is\x20the\x20MID\x20stage\x27s\x20compose_probe\x20verdict'},'compensation_fund':{'policy':b['compensation_fund_policy']==='forbidden'?'forbidden':'allowed','note':b['compensation_fund_policy']==='forbidden'?'DO-NOT-FUND\x20ruling\x20on\x20this\x20template\x27s\x20key_risk\x20—\x20the\x20build\x20guide\x20emits\x20neither\x20the\x20topup\x20step\x20nor\x20the\x20fund-sizing\x20check':'sized\x20at\x20deploy\x20time\x20against\x20the\x20key_risk\x20—\x20never\x20a\x20fixed\x20formula'},'keeper_dependencies':[...b['keeper_dependencies']]},'params':{'total':c['length'],'editable':c['filter'](e=>e['editable'])['length'],'live':c['filter'](e=>e['status']==='live')['length'],'groups':((()=>{const e=new Map();for(const f of c){const g=e['get'](f['group'])??{'tier':f['tier'],'count':0x0};e['set'](f['group'],{'tier':Math['min'](g['tier'],f['tier']),'count':g['count']+0x1});}return[...e['entries']()]['map'](([h,{tier:i,count:j}])=>({'group':h,'tier':i,'count':j}))['sort']((h,i)=>h['tier']-i['tier']||h['group']['localeCompare'](i['group']));})()),'full_rows_via':'industry_pack_operation\x20action=\x27get\x27\x20layer=\x27params\x27\x20template=\x27<id>\x27'},'risks':{'key_risk':b['key_risk'],'differences':[...b['differences']],'user_inputs':[...b['user_inputs']],'capability_risks':[],'capability_risks_note':'union\x20with\x20Lattice\x20Capability.risks\x20lands\x20with\x20the\x20Binding\x20Table\x20(M2+)\x20—\x20this\x20card\x20projects\x20the\x20template\x27s\x20own\x20declared\x20risks\x20only'},'templates_version':BUILTIN_TEMPLATES_VERSION};}export function productCards(a){const b=listBuiltinTemplates(),c=a?b['filter'](d=>d['industry']===a):b;return c['map'](d=>{const e=paramPlane(d);return{'template_id':d['id'],'industry':d['industry'],'product_ref':d['product_ref'],'archetype':d['archetype'],'one_liner':d['product_ref']+'-modeled\x20'+d['variant']+'\x20archetype\x20for\x20'+d['industry']+':\x20'+(d['trust_mechanisms']['length']+'\x20trust\x20mechanisms,\x20'+e['filter'](f=>f['editable'])['length']+'/'+e['length']+'\x20params\x20editable.'),'cost_headline':{'platform_fee_bps':typeof d['fee_params']['platform_commission_bps']==='number'?d['fee_params']['platform_commission_bps']:0x0,'gas_objects_estimate':d['machine_shape']['length']+d['guards']['length'],'compensation_fund':d['compensation_fund_policy']==='forbidden'?'forbidden':'allowed'},'params':{'total':e['length'],'editable':e['filter'](f=>f['editable'])['length']},'templates_version':BUILTIN_TEMPLATES_VERSION};});}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type { DerivedParam, PlanStep } from "./plan.js";
|
|
2
|
+
import type { PrimitiveId } from "../chain-semantics/index.js";
|
|
3
|
+
export type ProcurementAxis = "merchant_procured" | "user_procured";
|
|
4
|
+
export type CompositionForm = "rendezvous" | "submission";
|
|
5
|
+
export interface SupplyChainPromise {
|
|
6
|
+
sub_service: string;
|
|
7
|
+
axis: ProcurementAxis;
|
|
8
|
+
service_name?: string;
|
|
9
|
+
done_node: string;
|
|
10
|
+
done_node_alt?: string;
|
|
11
|
+
done_node_alt2?: string;
|
|
12
|
+
form?: CompositionForm;
|
|
13
|
+
fact_key?: string;
|
|
14
|
+
ack_key?: string;
|
|
15
|
+
ack_window_days?: number;
|
|
16
|
+
payout_to?: string;
|
|
17
|
+
payout_rate?: number;
|
|
18
|
+
repository?: string;
|
|
19
|
+
repository_name?: string;
|
|
20
|
+
service_step_id?: string;
|
|
21
|
+
id_prefix?: string;
|
|
22
|
+
}
|
|
23
|
+
export interface EmissionBlocker {
|
|
24
|
+
code: "SUPPLY_CHAIN_PROMISE_INCOMPLETE" | "SUPPLY_CHAIN_GATE_TEMPLATE" | "SUPPLY_CHAIN_ACK_WITHOUT_DEADLINE" | "SUPPLY_CHAIN_PAYOUT_RATE";
|
|
25
|
+
detail: string;
|
|
26
|
+
}
|
|
27
|
+
export interface SupplyChainHandoff {
|
|
28
|
+
repository: string;
|
|
29
|
+
writes: {
|
|
30
|
+
policy: string;
|
|
31
|
+
row_id: string;
|
|
32
|
+
value: string;
|
|
33
|
+
write_guard: string;
|
|
34
|
+
submissions: string;
|
|
35
|
+
}[];
|
|
36
|
+
}
|
|
37
|
+
export interface SupplyChainEmission {
|
|
38
|
+
steps: PlanStep[];
|
|
39
|
+
inputs: Record<string, string>;
|
|
40
|
+
primitives: PrimitiveId[];
|
|
41
|
+
notes: string[];
|
|
42
|
+
blockers: EmissionBlocker[];
|
|
43
|
+
handoff?: SupplyChainHandoff;
|
|
44
|
+
derived_params?: DerivedParam[];
|
|
45
|
+
}
|
|
46
|
+
export declare function emitSupplyChainPromise(promise: SupplyChainPromise): SupplyChainEmission;
|