@wowok/agent-mcp 3.3.9 → 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/field-capability.js +1 -1
- package/dist/chain-semantics/freeze-map.js +1 -1
- package/dist/chain-semantics/fund-flow.js +1 -1
- package/dist/chain-semantics/guard-verbs.js +1 -1
- package/dist/chain-semantics/index.d.ts +1 -0
- package/dist/chain-semantics/index.js +1 -1
- package/dist/chain-semantics/object-graph.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 +26 -4
- 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 +26 -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 +22 -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.d.ts +61 -0
- package/dist/composition/param-disclosure.js +1 -0
- 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 +17 -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/customer/account-events.js +1 -1
- package/dist/data/api/api.spec.js +1 -1
- package/dist/data/api/cli.js +1 -1
- package/dist/data/api/server.d.ts +1 -0
- package/dist/data/api/server.js +1 -1
- package/dist/data/projection/store.d.ts +3 -1
- package/dist/data/projection/store.js +1 -1
- package/dist/data/projection/types.d.ts +32 -0
- package/dist/data/sync/cdc.d.ts +1 -2
- package/dist/data/sync/cdc.js +1 -1
- package/dist/data/sync/cdc.spec.js +1 -1
- package/dist/data/sync/store.d.ts +5 -0
- package/dist/data/sync/store.js +1 -1
- package/dist/data/sync/types.d.ts +2 -0
- 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/guard-scan.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/index.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/allocation-templates.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/arb-fund-facts.d.ts +1 -0
- package/dist/knowledge/arb-fund-facts.js +1 -1
- package/dist/knowledge/arbitration-ledger.js +1 -1
- package/dist/knowledge/arbitration-puzzle.js +1 -1
- package/dist/knowledge/arbitration-risk.d.ts +1 -0
- package/dist/knowledge/arbitration-risk.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/allocation.json +6 -6
- package/dist/knowledge/baselines/rules/arb.json +2 -2
- package/dist/knowledge/baselines/rules/guard.json +11 -11
- package/dist/knowledge/baselines/rules/oracle.json +120 -0
- package/dist/knowledge/baselines/rules/order.json +1 -1
- package/dist/knowledge/baselines/rules/plan.json +385 -18
- package/dist/knowledge/baselines/rules/progress.json +20 -2
- package/dist/knowledge/baselines/semantic-facts.js +1 -1
- package/dist/knowledge/builtin-templates.d.ts +25 -1
- package/dist/knowledge/builtin-templates.js +1 -1
- package/dist/knowledge/catalog-facts.d.ts +4 -0
- package/dist/knowledge/catalog-facts.js +1 -0
- package/dist/knowledge/commission-landing.js +1 -1
- package/dist/knowledge/component-schema.d.ts +64 -0
- package/dist/knowledge/component-schema.js +1 -0
- 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/entity-recipient-guard.js +1 -1
- package/dist/knowledge/event-semantics.js +1 -1
- package/dist/knowledge/fee-param-bindings.d.ts +26 -0
- package/dist/knowledge/fee-param-bindings.js +1 -0
- 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.d.ts +2 -2
- package/dist/knowledge/getting-started.js +1 -1
- package/dist/knowledge/guard-anchor-reach.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-ledger.js +1 -1
- package/dist/knowledge/guard-lint.d.ts +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/industry-strategy.js +1 -1
- package/dist/knowledge/jsonrpc-enum.d.ts +52 -3
- package/dist/knowledge/jsonrpc-enum.js +1 -1
- package/dist/knowledge/knob-docs.d.ts +5 -0
- package/dist/knowledge/knob-docs.js +1 -0
- package/dist/knowledge/machine-templates.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 +4 -0
- package/dist/knowledge/onchain-constants.js +1 -1
- package/dist/knowledge/order-ledger.js +1 -1
- package/dist/knowledge/param-schema.d.ts +93 -0
- package/dist/knowledge/param-schema.js +1 -0
- package/dist/knowledge/param-tiers.d.ts +25 -0
- package/dist/knowledge/param-tiers.js +1 -0
- package/dist/knowledge/passport-ledger.d.ts +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 +108 -0
- package/dist/knowledge/pattern-resolutions.js +1 -0
- 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/safety-rules.js +1 -1
- package/dist/knowledge/scenario-modes.d.ts +2 -0
- package/dist/knowledge/scenario-modes.js +1 -1
- package/dist/knowledge/scenario-topology.js +1 -1
- package/dist/knowledge/semantic-ir.d.ts +4 -0
- package/dist/knowledge/semantic-ir.js +1 -1
- package/dist/knowledge/service-allocation-semantics.js +1 -1
- package/dist/knowledge/service-ledger.d.ts +1 -1
- package/dist/knowledge/service-ledger.js +1 -1
- package/dist/knowledge/service-templates.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/strategy-manuals.d.ts +1 -1
- package/dist/knowledge/strategy-manuals.js +1 -1
- package/dist/knowledge/supply-chain.d.ts +9 -0
- package/dist/knowledge/supply-chain.js +1 -1
- package/dist/knowledge/template-loader.d.ts +114 -6
- package/dist/knowledge/template-loader.js +1 -1
- package/dist/knowledge/template-nav.d.ts +9 -0
- package/dist/knowledge/template-nav.js +1 -0
- package/dist/knowledge/template-prose.d.ts +1 -1
- package/dist/knowledge/template-registry.js +1 -1
- package/dist/knowledge/template-scanner.d.ts +95 -0
- package/dist/knowledge/template-scanner.js +1 -1
- package/dist/knowledge/template-test-profiles.d.ts +17 -0
- package/dist/knowledge/template-test-profiles.js +1 -0
- package/dist/knowledge/template-validation.d.ts +1 -0
- package/dist/knowledge/template-validation.js +1 -1
- package/dist/knowledge/tools-reference.js +1 -1
- package/dist/knowledge/treasury-templates.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.d.ts +37 -0
- package/dist/participation/time-window.js +1 -0
- 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.d.ts +1 -0
- package/dist/playbooks/service-build/machine-panorama.js +1 -1
- package/dist/playbooks/service-build/merchant-guide.d.ts +52 -22
- 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.d.ts +1 -0
- 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 +2 -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/relationship/registry.js +1 -1
- package/dist/review/index.js +1 -1
- package/dist/review/repository.js +1 -1
- package/dist/runtime/instance-registry.d.ts +7 -1
- package/dist/runtime/instance-registry.js +1 -1
- package/dist/safety/confirm-gate.js +1 -1
- package/dist/schema/benchmark-migration/index.d.ts +106 -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/arbitration.js +1 -1
- package/dist/schema/call/base.d.ts +264 -0
- package/dist/schema/call/base.js +1 -1
- package/dist/schema/call/bridge.d.ts +34 -6
- package/dist/schema/call/demand.d.ts +15 -6
- package/dist/schema/call/demand.js +1 -1
- package/dist/schema/call/error-codes.d.ts +1 -1
- package/dist/schema/call/error-codes.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 +131 -43
- 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 +224 -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 +116 -1
- package/dist/schema/goal/planning.js +1 -1
- package/dist/schema/industry-pack/index.d.ts +166 -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 +157 -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 +28 -0
- package/dist/schema/messenger/index.js +1 -1
- package/dist/schema/operations.d.ts +343 -84
- 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 +251 -4
- package/dist/schema/query/bi.js +1 -1
- package/dist/schema/query/index.d.ts +271 -78
- 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 +98 -2
- package/dist/schemas/benchmark_migration_operation.output.json +341 -12
- package/dist/schemas/benchmark_migration_operation.schema.json +42 -3
- package/dist/schemas/bridge_operation.output.json +98 -2
- package/dist/schemas/bridge_operation.schema.json +5 -5
- 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 +586 -4
- package/dist/schemas/evaluation_operation.schema.json +194 -3
- package/dist/schemas/goal_operation.schema.json +183 -0
- package/dist/schemas/guard2file.schema.json +1 -1
- package/dist/schemas/index.json +1 -1
- package/dist/schemas/industry_pack_operation.output.json +771 -1
- package/dist/schemas/industry_pack_operation.schema.json +28 -4
- package/dist/schemas/keeper_operation.output.json +96 -2
- package/dist/schemas/local_cache_operation.output.json +98 -2
- package/dist/schemas/local_history_operation.output.json +98 -2
- package/dist/schemas/local_info_operation.output.json +98 -2
- package/dist/schemas/local_mark_operation.output.json +98 -2
- package/dist/schemas/machineNode2file.schema.json +1 -1
- package/dist/schemas/messenger_operation.output.json +107 -2
- package/dist/schemas/messenger_operation.schema.json +41 -34
- package/dist/schemas/monitor_events.output.json +96 -2
- package/dist/schemas/monitor_subscription.output.json +96 -2
- package/dist/schemas/onchain_events.output.json +108 -14
- package/dist/schemas/onchain_operations.output.json +326 -11
- package/dist/schemas/onchain_operations.schema.json +1343 -734
- package/dist/schemas/onchain_operations_allocation.schema.json +35 -19
- package/dist/schemas/onchain_operations_arbitration.schema.json +16 -8
- package/dist/schemas/onchain_operations_contact.schema.json +12 -4
- package/dist/schemas/onchain_operations_demand.schema.json +33 -17
- package/dist/schemas/onchain_operations_gen_passport.schema.json +12 -4
- package/dist/schemas/onchain_operations_gen_proof.schema.json +1 -1
- package/dist/schemas/onchain_operations_guard.schema.json +297 -111
- package/dist/schemas/onchain_operations_machine.schema.json +56 -39
- package/dist/schemas/onchain_operations_order.schema.json +67 -42
- package/dist/schemas/onchain_operations_payment.schema.json +27 -12
- package/dist/schemas/onchain_operations_permission.schema.json +363 -232
- package/dist/schemas/onchain_operations_personal.schema.json +43 -28
- package/dist/schemas/onchain_operations_progress.schema.json +49 -32
- package/dist/schemas/onchain_operations_proof.schema.json +12 -4
- package/dist/schemas/onchain_operations_repository.schema.json +17 -8
- package/dist/schemas/onchain_operations_reward.schema.json +36 -20
- package/dist/schemas/onchain_operations_service.schema.json +230 -130
- package/dist/schemas/onchain_operations_treasury.schema.json +36 -20
- package/dist/schemas/onchain_table_data.output.json +276 -19
- package/dist/schemas/onchain_table_data.schema.json +104 -64
- 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 +1054 -146
- package/dist/schemas/query_toolkit.schema.json +144 -13
- package/dist/schemas/schema_query.schema.json +1 -1
- package/dist/schemas/watch_operation.output.json +86 -3
- package/dist/schemas/wip_file.output.json +8 -0
- package/dist/schemas/workflow_operation.schema.json +5 -4
- package/dist/schemas/wowok_buildin_info.schema.json +1 -1
- package/dist/task/playbook.js +1 -1
- package/dist/tools/handlers/benchmark-migration.d.ts +12 -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/messenger.js +1 -1
- package/dist/tools/handlers/onchain.d.ts +24 -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/onchain.js +1 -1
- package/dist/tools/registry/query.js +1 -1
- package/dist/tools/sanitize-output.js +1 -1
- package/dist/tools/sanitize-output.spec.js +1 -1
- package/dist/tools/transport-integrity.d.ts +7 -0
- package/dist/tools/transport-integrity.js +1 -0
- package/dist/tools/types.d.ts +1 -0
- package/dist/tools/upgrade-check.d.ts +22 -0
- package/dist/tools/upgrade-check.js +1 -1
- package/dist/tools/wrap.d.ts +6 -1
- package/dist/tools/wrap.js +1 -1
- package/package.json +7 -6
- 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 +1 @@
|
|
|
1
|
-
import{describe,expect,it}from'vitest';import{ENTRYPOINT}from'@wowok/wowok';import{FakeDataPlane}from'../../graph/onchain/dataplane.js';import{expandTopology}from'../../graph/onchain/expand.js';import{FULL,GAP,fullServiceState,gapServiceState,truncatedServiceState}from'../../graph/onchain/fixtures.js';import{buildViewport}from'../../graph/onchain/viewport.js';import{runAnalyzers}from'../../graph/onchain/analyze.js';import{EVALUATION_SERVICE_INTENTS,resolveExpansionStrategy,withEvaluationBundle}from'../../graph/onchain/strategy.js';import{projectEvaluationFacts as
|
|
1
|
+
import{describe,expect,it}from'vitest';import{ENTRYPOINT}from'@wowok/wowok';import{FakeDataPlane}from'../../graph/onchain/dataplane.js';import{expandTopology}from'../../graph/onchain/expand.js';import{FULL,GAP,fullServiceState,gapServiceState,truncatedServiceState}from'../../graph/onchain/fixtures.js';import{buildViewport}from'../../graph/onchain/viewport.js';import{runAnalyzers}from'../../graph/onchain/analyze.js';import{EVALUATION_SERVICE_INTENTS,resolveExpansionStrategy,withEvaluationBundle}from'../../graph/onchain/strategy.js';import{projectEvaluationFacts as a87a}from'../../graph/onchain/facts.js';import{evaluateGraphServiceFacts,GRAPH_RULE_INPUT_FACTS,registerGraphServiceEvaluations}from'./graph-service.js';async function evalState(a,b){registerGraphServiceEvaluations();const c=withEvaluationBundle(resolveExpansionStrategy({'intents':[...EVALUATION_SERVICE_INTENTS]})),d=await expandTopology(new FakeDataPlane(a),{'network':ENTRYPOINT['Mainnet'],'seed':b,'edges':c['edges'],'budget':c['budget']}),e=buildViewport(d,b,'neutral'),f=a87a(e,b,runAnalyzers(e));return{'projected':f,'r':await evaluateGraphServiceFacts(f)};}const scoreOf=(a,b,c)=>a[b]['breakdown']['find'](d=>d['rule_id']===c);describe('graph\x20service\x20evaluation\x20—\x20fully\x20hooked\x20shop\x20(TR-14.1)',()=>{it('scores\x20all\x20nine\x20dimensions\x20from\x20material\x20facts\x20with\x20no\x20default-low\x20deductions',async()=>{const {r:a}=await evalState(fullServiceState(),FULL['svc']);expect(a['unverified'])['toEqual']([]),expect(a['completeness'])['toBe'](0x64);const c=scoreOf(a,'trust','trust_arbitration');expect(c['score'])['toBe'](0x64),expect(c['matched'])['toEqual'](expect['arrayContaining'](['arbitrator\x20roster\x20configured','arbitration\x20fee\x20funded','arbitration\x20active'])),expect(c['reason'])['toContain']('Arbitration\x2020/20'),expect(scoreOf(a,'trust','trust_reviews')['score'])['toBe'](0x28),expect(scoreOf(a,'trust','trust_fulfillment')['score'])['toBe'](0x19);const d=scoreOf(a,'trust','trust_fund_safety');expect(d['score'])['toBe'](0x0),expect(d['mismatched'])['toContain']('compensation\x20fund\x20below\x20the\x20statutory\x203x\x20largest-order\x20exposure\x20ceiling'),expect(scoreOf(a,'trust','trust_transparency')['score'])['toBe'](0x64),expect(a['trust']['total'])['toBe'](0x31);const e=scoreOf(a,'risk','risk_fund');expect(e['score'])['toBeLessThan'](0x64),expect(e['mismatched'])['toContain']('Payout\x20exposure:\x20compensation\x20fund\x20cannot\x20cover\x20a\x20maximum-multiple\x20award\x20on\x20the\x20largest\x20windowed\x20order'),expect(e['mismatched']?.['some'](h=>h['startsWith']('R2:')))['toBe'](![]),expect(e['finding_refs']?.['map'](h=>h['id']))['toContain']('R2:'+FULL['svc']['toLowerCase']());const f=scoreOf(a,'risk','risk_trust');expect(f['score'])['toBeLessThan'](0x64),expect(f['mismatched']?.['some'](h=>h['startsWith']('R1:')))['toBe'](![]),expect(f['mismatched']?.['length'])['toBeGreaterThan'](0x0),expect(f['finding_refs']?.['some'](h=>h['id']['startsWith']('R1:')))['toBe'](!![]);for(const h of[...a['trust']['breakdown'],...a['risk']['breakdown']]){for(const i of h['mismatched']??[])expect(i)['not']['toContain']('::node::');}expect(scoreOf(a,'risk','risk_workflow')['score'])['toBe'](0x64),expect(scoreOf(a,'risk','risk_behavior')['score'])['toBe'](0x64);for(const j of[...a['trust']['breakdown'],...a['risk']['breakdown']]){const k=(j['reason']??'')['toLowerCase']();expect(k)['not']['toContain']('no\x20data'),expect(k)['not']['toContain']('default\x20low');}const g=a['trust']['trace']['filter'](l=>l['kind']==='rule'&&l['detail']['startsWith']('score='));expect(g['map'](l=>l['id']))['toEqual'](expect['arrayContaining'](Object['keys'](GRAPH_RULE_INPUT_FACTS)['filter'](l=>l['startsWith']('trust_'))));}),it('keeps\x20the\x20injection\x20+\x20requirement\x20mechanisms\x20working',async()=>{const {projected:a}=await evalState(fullServiceState(),FULL['svc']),b=await evaluateGraphServiceFacts(a,{'overrides':{'rules':{'trust_arbitration':{'weight':0x28}}}});expect(b['trust']['total'])['toBe'](0x3a);const c=await evaluateGraphServiceFacts(a,{'requirements':[{'rule_id':'trust_fund_safety','condition':'require'}]});expect(c['trust']['blocked'])['toBe'](!![]),expect(c['trust']['red_flags']['length'])['toBeGreaterThan'](0x0);});}),describe('graph\x20service\x20evaluation\x20—\x20configured-empty\x20shell\x20(TR-14.1)',()=>{it('scores\x20verified\x20absence\x20as\x20a\x20configured\x20fact\x20and\x20excludes\x20only\x20the\x20gap\x20dimension',async()=>{const {r:a}=await evalState(gapServiceState(),GAP['svc']),b=scoreOf(a,'trust','trust_arbitration');expect(b['score'])['toBe'](0x0),expect(b['reason'])['toContain']('verified\x20absence'),expect(scoreOf(a,'trust','trust_reviews')['score'])['toBe'](0x32),expect(a['unverified'])['toEqual'](['risk_workflow']),expect(scoreOf(a,'risk','risk_workflow'))['toBeUndefined'](),expect(a['risk']['unverified'])['toEqual'](['risk_workflow']),expect(a['trust']['unverified'])['toEqual'](['risk_workflow']);const c=a['risk']['trace']['find'](d=>d['kind']==='rule'&&d['id']==='risk_workflow');expect(c?.['detail'])['toContain']('not\x20applicable'),expect(scoreOf(a,'trust','trust_transparency')['score'])['toBe'](0x28),expect(scoreOf(a,'trust','trust_fund_safety')['score'])['toBe'](0x0);});}),describe('graph\x20service\x20evaluation\x20—\x20truncated\x20order\x20window\x20(TR-14.1)',()=>{it('excludes\x20the\x20unverifiable\x20dimensions\x20and\x20renormalizes\x20the\x20weighted\x20total',async()=>{const {r:a}=await evalState(truncatedServiceState(),FULL['svc']);expect(a['unverified'])['toEqual'](expect['arrayContaining'](['trust_fulfillment','trust_fund_safety','risk_fund','risk_behavior'])),expect(scoreOf(a,'trust','trust_fulfillment'))['toBeUndefined'](),expect(scoreOf(a,'trust','trust_fund_safety'))['toBeUndefined'](),expect(scoreOf(a,'risk','risk_fund'))['toBeUndefined'](),expect(scoreOf(a,'risk','risk_behavior'))['toBeUndefined'](),expect(a['trust']['total'])['toBe'](0x44);for(const b of['trust_fulfillment','trust_fund_safety']){expect(a['trust']['trace']['find'](c=>c['kind']==='rule'&&c['id']===b)?.['detail'])['toContain']('not\x20applicable');}for(const c of['risk_fund','risk_behavior']){expect(a['risk']['trace']['find'](d=>d['kind']==='rule'&&d['id']===c)?.['detail'])['toContain']('not\x20applicable');}});}),describe('graph\x20service\x20evaluation\x20—\x20scoring\x20report\x20(TR-14.2)',()=>{it('renders\x20a\x20per-dimension\x20report\x20with\x20score,\x20weight,\x20state,\x20confidence\x20and\x20evidence',async()=>{const {projected:a,r:c}=await evalState(fullServiceState(),FULL['svc']),d=new Map(a['facts']['map'](g=>[g['key'],g])),e=[];for(const g of['trust','risk']){const h=c[g];e['push'](g['toUpperCase']()+'\x20'+h['total']+'/100\x20('+h['level']+')\x20—\x20'+h['summary']);for(const i of h['breakdown']){const j=GRAPH_RULE_INPUT_FACTS[i['rule_id']]??[],k=j['map'](o=>o+':state='+(d['get'](o)?.['state']??'missing')),l=j['map'](o=>d['get'](o)?.['provenance']['confidence']??'missing'),n=j['map'](o=>d['get'](o)?.['evidence']??'missing')['join']('\x20');e['push'](i['rule_id']+':\x20score='+i['score']+'\x20weight='+i['weight']+'\x20'+k['join'](',')+'\x20confidence='+[...new Set(l)]['join']('+')+'\x20evidence=\x22'+n+'\x22');}}expect(e)['toHaveLength'](0xb);const f=e['filter'](o=>o['includes']('score='));expect(f)['toHaveLength'](0x9);for(const o of f){expect(o)['toMatch'](/weight=\d+/),expect(o)['toContain']('state=present'),expect(o)['toMatch'](/confidence=(exact|bounded|windowed|derived)/);const p=o['match'](/evidence="(.*)"/);expect(p,o)['not']['toBeNull'](),expect(p[0x1]['length'],o)['toBeGreaterThan'](0x0);}expect(c['trust']['summary'])['toContain']('weakest\x20Fund\x20safety'),expect(c['trust']['summary'])['not']['toContain']('trust_fund_safety'),expect(c['trust']['summary'])['toMatch'](/grade: (strong|fair|weak)/),expect(c['trust']['summary'])['toContain']('Compensation\x20fund');});});
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { Region } from "./region.js";
|
|
2
|
+
import type { CatalogBuyability } from "../knowledge/sku-name-gate.js";
|
|
2
3
|
export type IndustryScenario = string;
|
|
3
4
|
export interface WorkflowCapabilities {
|
|
4
5
|
has_arbitration: boolean;
|
|
@@ -31,6 +32,7 @@ export interface CapabilityVector {
|
|
|
31
32
|
capabilities: WorkflowCapabilities;
|
|
32
33
|
tags: string[];
|
|
33
34
|
keywords: string[];
|
|
35
|
+
buyable?: CatalogBuyability;
|
|
34
36
|
}
|
|
35
37
|
export interface CapabilityGap {
|
|
36
38
|
dimension: keyof WorkflowCapabilities | "industry" | "region" | "price" | "trust";
|
|
@@ -17,7 +17,6 @@ export interface CategoryMatchRules {
|
|
|
17
17
|
}
|
|
18
18
|
export declare const CATEGORY_MATCH_RULES: Record<string, CategoryMatchRules>;
|
|
19
19
|
export declare function resolveCategoryMatchRules(category?: string): CategoryMatchRules | undefined;
|
|
20
|
-
export declare function listCategoryMatchRules(): string[];
|
|
21
20
|
export declare function registerCategoryMatchRules(rules: CategoryMatchRules, replace?: boolean): boolean;
|
|
22
21
|
export declare function toSoftWeightInjection(rules: CategoryMatchRules): UserInjection;
|
|
23
22
|
export interface HardConstraintResult<T> {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export const CATEGORY_MATCH_RULES={'life_service':{'category':'life_service','hard_constraints':[{'field':'bPublished','kind':'truthy','description':'service\x20must\x20be\x20published'},{'field':'bPaused','kind':'falsy','description':'service\x20must\x20not\x20be\x20paused'}],'soft_weights':{'region':0x14,'industry':0xf,'price':0xa,'trust':0x19,'capabilities':0x19,'tags':0x5},'highlight_fields':['service_radius','slot_availability','credential'],'calendar_mode':'slot','geo_mode':'strict','pricing_rules':['time_slot','last_minute']},'retail':{'category':'retail','hard_constraints':[{'field':'bPublished','kind':'truthy','description':'service\x20must\x20be\x20published'},{'field':'bPaused','kind':'falsy','description':'service\x20must\x20not\x20be\x20paused'}],'soft_weights':{'region':0xa,'industry':0xf,'price':0x19,'trust':0xf,'capabilities':0x1e,'tags':0x5},'highlight_fields':['return_policy','logistics_sla','stock'],'calendar_mode':'none','geo_mode':'logistics','pricing_rules':['tiered_quantity','seasonal_float']}};export function resolveCategoryMatchRules(a){if(!a)return undefined;return CATEGORY_MATCH_RULES[a]??CATEGORY_MATCH_RULES[a['toLowerCase']()];}export function
|
|
1
|
+
export const CATEGORY_MATCH_RULES={'life_service':{'category':'life_service','hard_constraints':[{'field':'bPublished','kind':'truthy','description':'service\x20must\x20be\x20published'},{'field':'bPaused','kind':'falsy','description':'service\x20must\x20not\x20be\x20paused'}],'soft_weights':{'region':0x14,'industry':0xf,'price':0xa,'trust':0x19,'capabilities':0x19,'tags':0x5},'highlight_fields':['service_radius','slot_availability','credential'],'calendar_mode':'slot','geo_mode':'strict','pricing_rules':['time_slot','last_minute']},'retail':{'category':'retail','hard_constraints':[{'field':'bPublished','kind':'truthy','description':'service\x20must\x20be\x20published'},{'field':'bPaused','kind':'falsy','description':'service\x20must\x20not\x20be\x20paused'}],'soft_weights':{'region':0xa,'industry':0xf,'price':0x19,'trust':0xf,'capabilities':0x1e,'tags':0x5},'highlight_fields':['return_policy','logistics_sla','stock'],'calendar_mode':'none','geo_mode':'logistics','pricing_rules':['tiered_quantity','seasonal_float']}};export function resolveCategoryMatchRules(a){if(!a)return undefined;return CATEGORY_MATCH_RULES[a]??CATEGORY_MATCH_RULES[a['toLowerCase']()];}export function registerCategoryMatchRules(a,b=![]){const c=a['category'];if(!c)return![];if(CATEGORY_MATCH_RULES[c]&&!b)return![];return CATEGORY_MATCH_RULES[c]=a,!![];}export function toSoftWeightInjection(a){const b={};for(const [c,d]of Object['entries'](a['soft_weights'])){b[c]={'weight':d};}return{'overrides':{'rules':b}};}export function applyHardConstraints(a,b){const c=[],d=[];for(const e of b){const f=e;let g=!![];for(const h of a['hard_constraints']){const i=f[h['field']];if(i===undefined||i===null)continue;const j=h['kind']==='truthy'?!!i:!i;if(!j){d['push']({'candidate':e,'constraint':h}),g=![];break;}}if(g)c['push'](e);}return{'passed':c,'dropped':d};}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { CapabilityVector, WorkflowCapabilities } from "./capability.js";
|
|
2
|
+
import type { CapabilityId } from "../extensions/capability.js";
|
|
2
3
|
export interface CompositePlan {
|
|
3
4
|
demand: string;
|
|
4
5
|
services: Array<{
|
|
@@ -11,3 +12,27 @@ export interface CompositePlan {
|
|
|
11
12
|
summary: string;
|
|
12
13
|
}
|
|
13
14
|
export declare function composeServicesForDemand(demand: CapabilityVector, services: CapabilityVector[]): CompositePlan;
|
|
15
|
+
export interface ComposeProbeBlocker {
|
|
16
|
+
code: string;
|
|
17
|
+
detail: string;
|
|
18
|
+
}
|
|
19
|
+
export interface ComposeProbeResult {
|
|
20
|
+
capabilities: CapabilityId[];
|
|
21
|
+
feasible: boolean;
|
|
22
|
+
blockers: ComposeProbeBlocker[];
|
|
23
|
+
risks: string[];
|
|
24
|
+
disclosures: string[];
|
|
25
|
+
cost_delta: {
|
|
26
|
+
gas_objects: number;
|
|
27
|
+
funds: string[];
|
|
28
|
+
};
|
|
29
|
+
provides: Array<keyof WorkflowCapabilities>;
|
|
30
|
+
plan_steps?: number;
|
|
31
|
+
audit_score?: number;
|
|
32
|
+
templates_version: number;
|
|
33
|
+
}
|
|
34
|
+
interface ComposeProbeOptions {
|
|
35
|
+
baseTemplate?: string;
|
|
36
|
+
}
|
|
37
|
+
export declare function composeProbe(capabilityIds: CapabilityId[], opts?: ComposeProbeOptions): ComposeProbeResult;
|
|
38
|
+
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{requiredCapabilities}from'./capability.js';import{relateRegion}from'./region.js';export function composeServicesForDemand(a,b){const c=requiredCapabilities(a['capabilities']),d=new Set(c),e=[],f=b['filter'](
|
|
1
|
+
import{requiredCapabilities}from'./capability.js';import{relateRegion}from'./region.js';import{getCapability}from'../extensions/capability.js';import{compileTemplate}from'../composition/compile.js';import{reflux}from'../composition/reflux.js';import{getBuiltinTemplate,BUILTIN_TEMPLATES_VERSION}from'../knowledge/builtin-templates.js';export function composeServicesForDemand(a,b){const c=requiredCapabilities(a['capabilities']),d=new Set(c),e=[],f=b['filter'](j=>relateRegion(a['region'],j['region'])!=='mismatch'),g=b['filter'](j=>!f['includes'](j));for(const j of[f,g]){while(d['size']>0x0){let l=null;for(const m of j){if(e['some'](o=>o['id']===m['id']))continue;const n=c['filter'](o=>d['has'](o)&&m['capabilities'][o]);(!l||n['length']>l['covered']['length'])&&(l={'id':m['id'],'covered':n});}if(!l||l['covered']['length']===0x0)break;e['push'](l);for(const o of l['covered'])d['delete'](o);}}const h=c['length']===0x0?0x64:Math['round']((c['length']-d['size'])/c['length']*0x64),i=d['size']===0x0?'ready':e['length']>0x0?'needs_supply_chain':'infeasible';return{'demand':a['id'],'services':e,'coverage_score':h,'remaining_missing':[...d],'feasibility':i,'summary':d['size']===0x0?'Composite\x20of\x20'+e['length']+'\x20service(s)\x20covers\x20all\x20'+c['length']+'\x20requirements':'Composite\x20of\x20'+e['length']+'\x20service(s)\x20covers\x20'+h+'/100;\x20missing:\x20'+([...d]['join'](',\x20')||'none')};}const composeProbeCache=new Map();export function composeProbe(a,c){const d=[...new Set(a)],e=c?.['baseTemplate'],f=BUILTIN_TEMPLATES_VERSION+'|'+d['slice']()['sort']()['join'](',')+'|'+(e??''),g=composeProbeCache['get'](f);if(g)return g;const h=[],i=d['map'](r=>getCapability(r))['filter'](r=>!!r);for(const r of d){!i['some'](s=>s['id']===r)&&h['push']({'code':'COMPOSE-UNKNOWN-CAPABILITY','detail':'\x27'+r+'\x27\x20is\x20not\x20a\x20registered\x20capability\x20—\x20list\x20them\x20via\x20industry_pack_operation\x20action=\x27capability_list\x27'});}for(const s of i){for(const u of s['requires']){!d['includes'](u)&&h['push']({'code':'COMPOSE-REQUIRES-MISSING','detail':'\x27'+s['id']+'\x27\x20requires\x20\x27'+u+'\x27\x20in\x20the\x20same\x20selection'});}for(const v of s['excludes']){d['includes'](v)&&h['push']({'code':'COMPOSE-EXCLUDES-CONFLICT','detail':'\x27'+s['id']+'\x27\x20and\x20\x27'+v+'\x27\x20cannot\x20coexist\x20in\x20one\x20build\x20(mutual\x20exclusion)'});}}const j=[...new Set(i['flatMap'](w=>w['risks']))],k=[...new Set(i['flatMap'](w=>w['disclosures']))],l=[...new Set(i['map'](w=>w['cost']['fund'])['filter'](w=>!!w))],m={'gas_objects':i['reduce']((w,y)=>w+y['cost']['gas_objects'],0x0),'funds':l},n=[...new Set(i['flatMap'](w=>w['provides']))];let o,p;if(e!==undefined){const w=getBuiltinTemplate(e);if(!w)h['push']({'code':'COMPOSE-BASE-TEMPLATE-UNKNOWN','detail':'base\x20template\x20\x27'+e+'\x27\x20is\x20not\x20in\x20the\x20builtin\x20catalog'});else{const y=compileTemplate(w,{},{'nameBase':'compose-probe','buildTimeMs':0x0});for(const A of y['blockers']){h['push']({'code':A['code'],'detail':'base\x20template\x20\x27'+e+'\x27:\x20'+A['detail']});}const z=reflux(y['plan']);for(const B of z['audit']['issues']){h['push']({'code':B['code'],'detail':'base\x20template\x20\x27'+e+'\x27:\x20'+B['detail']});}o=z['plan']['steps']['length'],p=z['audit']['issues']['length']===0x0?0x64:0x0;}}const q={'capabilities':d,'feasible':h['length']===0x0,'blockers':h,'risks':j,'disclosures':k,'cost_delta':m,'provides':n,...o!==undefined?{'plan_steps':o}:{},...p!==undefined?{'audit_score':p}:{},'templates_version':BUILTIN_TEMPLATES_VERSION};return composeProbeCache['set'](f,q),q;}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{REQUIREMENT_PASS_THRESHOLD,effectiveWeight,isDataSourceEnabled,isRuleEnabled,normalizeInjection}from'./user-injection.js';import{levelFromScore as
|
|
1
|
+
import{REQUIREMENT_PASS_THRESHOLD,effectiveWeight,isDataSourceEnabled,isRuleEnabled,normalizeInjection}from'./user-injection.js';import{levelFromScore as a93a}from'./standards.js';export function levelFromScore(a){return a93a(a);}function appliesTo(a,b){if(!a||a['length']===0x0)return!![];return a['includes'](b);}export class EvaluationEngine{static ['instance']=null;['dataSources']=new Map();['rules']=new Map();static['Instance'](){return!EvaluationEngine['instance']&&(EvaluationEngine['instance']=new EvaluationEngine()),EvaluationEngine['instance'];}['registerDataSource'](a){if(!a['id']||this['dataSources']['has'](a['id']))return![];return this['dataSources']['set'](a['id'],a),!![];}['unregisterDataSource'](a){return this['dataSources']['delete'](a);}['registerRule'](a){if(!a['id']||this['rules']['has'](a['id']))return![];return this['rules']['set'](a['id'],a),!![];}['unregisterRule'](a){return this['rules']['delete'](a);}['getRule'](a){return this['rules']['get'](a);}['listRules'](){return Array['from'](this['rules']['values']());}['getDataSource'](a){return this['dataSources']['get'](a);}['listDataSources'](){return Array['from'](this['dataSources']['values']());}async['evaluate'](a,b,c){const d=normalizeInjection(c),e={'evaluation_id':a,'entities':b,'facts':{},'injection':d,'now':Date['now']()},f=[],g=[],h=Array['from'](this['dataSources']['values']())['filter'](n=>appliesTo(n['evaluation_ids'],a))['sort']((n,o)=>(n['priority']??0x0)-(o['priority']??0x0));for(const n of h){if(!isDataSourceEnabled(n['id'],d)){f['push']({'kind':'override','id':n['id'],'detail':'data\x20source\x20disabled\x20by\x20user\x20override'});continue;}if(n['isEnabled']&&!n['isEnabled'](e))continue;const o=await n['extract'](e);Object['assign'](e['facts'],o),f['push']({'kind':'data_source','id':n['id'],'detail':'extracted\x20'+Object['keys'](o)['length']+'\x20fact(s)'});}const i=[],j=[];for(const p of this['rules']['values']()){if(!appliesTo(p['evaluation_ids'],a))continue;if(!isRuleEnabled(p['id'],d)){f['push']({'kind':'override','id':p['id'],'detail':'rule\x20disabled\x20by\x20user\x20override'});continue;}if(p['isEnabled']&&!p['isEnabled'](e))continue;const q=p['evaluate'](e);if(!q){f['push']({'kind':'rule','id':p['id'],'detail':'not\x20applicable\x20—\x20excluded\x20from\x20weighted\x20aggregation'});continue;}const r=effectiveWeight(p,d);i['push']({'rule_id':p['id'],'dimension':p['dimension'],'score':q['score'],'weight':r,'weight_source':r!==p['weight']?'override':'default','reason':q['reason'],'matched':q['matched'],'mismatched':q['mismatched'],'finding_refs':q['finding_refs'],'red_flag':q['red_flag']});if(q['red_flag']){const s=q['reason']??p['id']+'\x20triggered\x20a\x20hard\x20block';j['push'](s),g['push']({'flag':s,'basis':'object_defect','rule_id':p['id']});}f['push']({'kind':'rule','id':p['id'],'detail':'score='+q['score']+'\x20weight='+r});}const k=aggregateScore(i);let l=j['length']>0x0;for(const t of d['requirements']??[]){const u=i['find'](v=>v['rule_id']===t['rule_id']);if(t['condition']==='require'){if(!u||u['score']<REQUIREMENT_PASS_THRESHOLD||u['red_flag']){l=!![];const v=t['note']??'Requirement\x20requires\x20rule\x20\x27'+t['rule_id']+'\x27\x20to\x20pass';j['push'](v),g['push']({'flag':v,'basis':'requirement_unmet','rule_id':t['rule_id']});}}else{if(t['condition']==='forbid'){if(u&&u['red_flag']){l=!![];const w=t['note']??'Requirement\x20forbids\x20rule\x20\x27'+t['rule_id']+'\x27\x20from\x20triggering';j['push'](w),g['push']({'flag':w,'basis':'requirement_unmet','rule_id':t['rule_id']});}}}}const m=e['facts']['summary']??buildSummary(a,k,i,j,l);return{'evaluation_id':a,'total':k,'level':levelFromScore(k),'breakdown':i,'red_flags':j,'red_flag_basis':g,'blocked':l,'trace':f,'summary':m,'criterionScores':e['facts']['criterionScores'],'findings':e['facts']['findings'],'strengths':e['facts']['strengths'],'needsLlm':e['facts']['needsLlm'],'llmPrompt':e['facts']['llmPrompt']};}}function aggregateScore(a){if(a['length']===0x0)return 0x0;let c=0x0,d=0x0;for(const e of a){c+=e['score']*e['weight'],d+=e['weight'];}if(d<=0x0)return 0x0;return clamp(Math['round'](c/d),0x0,0x64);}function clamp(a,b,c){return Math['max'](b,Math['min'](c,a));}function buildSummary(a,b,c,d,e){const f=['Evaluation\x20\x27'+a+'\x27:\x20score\x20'+b+'/100'];return e?f['push']('BLOCKED\x20('+d['length']+'\x20red\x20flag(s))'):f['push'](c['length']+'\x20rule(s)\x20evaluated'),f['join']('\x20—\x20');}export function getEvaluationEngine(){return EvaluationEngine['Instance']();}
|
|
@@ -23,6 +23,12 @@ export interface ServiceExtractInput {
|
|
|
23
23
|
bPaused?: boolean;
|
|
24
24
|
order_allocators?: unknown;
|
|
25
25
|
owner?: string;
|
|
26
|
+
buyer_feedback?: CounterpartyFeedback;
|
|
27
|
+
}
|
|
28
|
+
export interface CounterpartyFeedback {
|
|
29
|
+
total: number;
|
|
30
|
+
likes: number;
|
|
31
|
+
completed_orders?: number;
|
|
26
32
|
}
|
|
27
33
|
export interface DemandExtractInput {
|
|
28
34
|
object: string;
|
|
@@ -33,4 +39,5 @@ export interface DemandExtractInput {
|
|
|
33
39
|
owner?: string;
|
|
34
40
|
}
|
|
35
41
|
export declare function extractServiceCapability(input: ServiceExtractInput, overrides?: Partial<CapabilityVector>): CapabilityVector;
|
|
42
|
+
export declare function hasOrderBoundPayoutRail(order_allocators: unknown): boolean;
|
|
36
43
|
export declare function extractDemandCapability(input: DemandExtractInput, overrides?: Partial<CapabilityVector>): CapabilityVector;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{parseRegion}from'./region.js';import{findSimilarIndustries,inferTraitsFromDescription}from'../knowledge/industry-generalizer.js';import{isRegisteredIndustry}from'../knowledge/industry-registry.js';export function enrichFromDescription(a){const b=a?.['trim']();if(!b)return{'industry':'general','industry_confidence':0x0,'tags':[],'keywords':[]};const {traits:c,confidence:d,matched_keywords:e}=inferTraitsFromDescription(b),
|
|
1
|
+
import{parseRegion}from'./region.js';import{findSimilarIndustries,inferTraitsFromDescription,detectDomainPriors}from'../knowledge/industry-generalizer.js';import{isRegisteredIndustry}from'../knowledge/industry-registry.js';import{catalogBuyability}from'../knowledge/sku-name-gate.js';export function enrichFromDescription(a){const b=a?.['trim']();if(!b)return{'industry':'general','industry_confidence':0x0,'tags':[],'keywords':[]};const {traits:c,confidence:d,matched_keywords:e,trait_confidence:f}=inferTraitsFromDescription(b),g=findSimilarIndustries(c,0x3,{'trait_confidence':f}),h=detectDomainPriors(b),i=g['map'](n=>{const o=h['filter'](q=>q['industries']['includes'](n['industry']))['reduce']((q,r)=>q+r['boost'],0x0);return o>0x0?{...n,'similarity':Math['min'](0x1,n['similarity']+o),'domain_prior':!![]}:n;})['sort']((n,o)=>o['similarity']-n['similarity']),j=i[0x0],k=j?.['similarity']??0x0,l=e['length']>0x0&&k>=0.5,m=j&&isRegisteredIndustry(j['industry'])?j['industry']:'general';return{'industry':l?m:'general','industry_confidence':l?Math['max'](d,k):0x0,'tags':l?i['slice'](0x0,0x3)['map'](n=>n['industry']):[],'keywords':e};}export function extractServiceCapability(a,b){const c=a['sales']??[],d=c['map'](p=>toBigInt(p['price']))['filter'](q=>q!==undefined),e=a['arbitrations']??[],f=toBigInt(a['compensation_fund'])??0x0n,g=enrichFromDescription(a['description']),h={'has_arbitration':e['length']>0x0,'has_refund_path':e['length']>0x0&&f>0x0n||hasOrderBoundPayoutRail(a['order_allocators']),'has_milestone_nodes':a['machine']!=null,'has_compensation_fund':f>0x0n,'has_wip_verification':c['some'](p=>!!p['wip_hash']),'has_messenger':a['um']!=null,'has_buy_guard':a['buy_guard']!=null,'has_dynamic_pricing':![],'is_published':a['bPublished']===!![],'is_paused':a['bPaused']===!![]},i=a['buyer_feedback'],j=!!i&&Number['isFinite'](i['total'])&&Number['isFinite'](i['likes'])&&i['total']>0x0,k=j?Math['max'](0x0,Math['min'](i['total'],Math['round'](i['likes']))):0x0,l=j?Math['round'](i['total']):0x0,m=0x5,n=j?Math['max'](0x0,Math['min'](0x64,Math['round'](0x32+(k/l*0x64-0x32)*Math['min'](0x1,l/m)))):0x32,o={'id':a['object'],'kind':'service','owner':a['owner']??'','industry':g['industry'],'industry_confidence':g['industry_confidence'],'region':parseRegion(a['location']),'price_min':d['length']>0x0?minBigInt(d):undefined,'price_max':d['length']>0x0?maxBigInt(d):undefined,'token_type':'','ticket_size':'medium','trust_score':n,'trust_provenance':j?'verified':'cold_start_prior','reputation_like_ratio':0x1,'arbitration_independent':![],'merchant_history_count':j?i['completed_orders']??Math['round'](i['total']):0x0,'capabilities':h,'tags':g['tags'],'keywords':g['keywords'],'buyable':catalogBuyability(c)};return{...o,...b};}export function hasOrderBoundPayoutRail(b){const c=b,d=Array['isArray'](c?.['allocators'])?c['allocators']:[];for(const e of d){const f=Array['isArray'](e?.['sharing'])?e['sharing']:[];for(const g of f){const h=g?.['who'];if(h&&typeof h==='object'&&'GuardIdentifier'in h)return!![];}}return![];}export function extractDemandCapability(a,b){const c=enrichFromDescription(a['description']),d={'id':a['object'],'kind':'demand','owner':a['owner']??'','industry':c['industry'],'industry_confidence':c['industry_confidence'],'region':parseRegion(a['location']),'price_min':undefined,'price_max':undefined,'token_type':'','ticket_size':'medium','trust_score':0x32,'trust_provenance':'cold_start_prior','reputation_like_ratio':0x1,'arbitration_independent':![],'merchant_history_count':0x0,'capabilities':{'has_arbitration':![],'has_refund_path':![],'has_milestone_nodes':![],'has_compensation_fund':![],'has_wip_verification':![],'has_messenger':a['um']!=null,'has_buy_guard':![],'has_dynamic_pricing':![],'is_published':!![],'is_paused':![]},'tags':c['tags'],'keywords':c['keywords']};return{...d,...b};}function toBigInt(a){if(a===undefined||a===null)return undefined;try{return BigInt(a);}catch{return undefined;}}function minBigInt(a){return a['reduce']((c,d)=>c<d?c:d);}function maxBigInt(a){return a['reduce']((c,d)=>c>d?c:d);}
|
|
@@ -7,8 +7,6 @@ export interface RoleInterests {
|
|
|
7
7
|
avoid: string[];
|
|
8
8
|
sensitivity: number;
|
|
9
9
|
}
|
|
10
|
-
export declare function outcomeSemantics(): Record<OperationOutcome, string[]>;
|
|
11
|
-
export declare function roleInterests(): Record<string, RoleInterests>;
|
|
12
10
|
export declare function classifyOutcome(consequence?: string): OperationOutcome;
|
|
13
11
|
export declare function appetiteMultiplier(appetite?: RiskAppetite): number;
|
|
14
12
|
export declare function interestsOf(role: CommercialRole): RoleInterests;
|
|
@@ -25,7 +23,6 @@ export interface OutcomeEvaluation {
|
|
|
25
23
|
risks: string[];
|
|
26
24
|
}
|
|
27
25
|
export declare function evaluateOutcome(outcome: OperationOutcome, role: CommercialRole, drive?: PersonaDrive): OutcomeEvaluation;
|
|
28
|
-
export declare function consistencyScore(outcome: OperationOutcome, role: CommercialRole): number;
|
|
29
26
|
export interface OutcomeAssessmentOptions {
|
|
30
27
|
costOfDelay?: string;
|
|
31
28
|
stake?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{getJudgmentDoc}from'../config/judgment.js';function gameParams(){return getJudgmentDoc()['game'];}export function
|
|
1
|
+
import{getJudgmentDoc}from'../config/judgment.js';function gameParams(){return getJudgmentDoc()['game'];}export function classifyOutcome(a){if(a?.['startsWith']('Completion'))return'completion';if(a?.['startsWith']('Refund'))return'refund';return'advance';}export function appetiteMultiplier(a){const b=gameParams()['appetite_multipliers'];if(a==='conservative')return b['conservative'];if(a==='aggressive')return b['aggressive'];return b['balanced'];}export function interestsOf(a){return gameParams()['role_interests'][a]??{'prefer':[],'avoid':[],'sensitivity':0x1};}function dedupe(a){return Array['from'](new Set(a));}export function resolveInterests(a,b){const c=gameParams(),d=interestsOf(a),e=d['sensitivity']*appetiteMultiplier(b?.['risk_appetite']),f=[...d['prefer']],g=[...d['avoid']];for(const h of b?.['requirements']??[]){const i=h['toLowerCase'](),j=new RegExp(c['forbid_pattern'],'i')['test'](i);for(const k of c['keyword_rules']){if(k['when_forbidden']!==j)continue;k['keywords']['some'](l=>i['includes'](l['toLowerCase']()))&&(k['anchor']==='prefer'?f:g)['push'](k['effect']);}}return{'prefer':dedupe(f),'avoid':dedupe(g),'sensitivity':e};}export function evaluateOutcome(a,b,c){const d=gameParams(),e=d['outcome_semantics'][a]??[],f=resolveInterests(b,c),g=f['sensitivity'],h=[],i=[];for(const m of e){if(f['prefer']['includes'](m))h['push'](m);if(f['avoid']['includes'](m))i['push'](m);}const j=h['length']*d['scoring']['per_gain'],k=Math['round'](i['length']*d['scoring']['per_risk']*g),l=Math['max'](0x0,Math['min'](0x64,d['scoring']['base']+j-k));return{'gain_score':j,'risk_score':k,'net_score':l,'gains':h,'risks':i};}export function outcomeAssessment(a,b){return{'consistency':a['net_score'],'net':a['net_score'],'gains':[...a['gains']],'risks':[...a['risks']],...b?.['costOfDelay']!==undefined?{'cost_of_delay':b['costOfDelay']}:{},...b?.['stake']!==undefined?{'commercial_stake':b['stake']}:{}};}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{readdirSync,readFileSync}from'node:fs';import{join}from'node:path';export function stripComments(a){return a['replace'](/\/\*[\s\S]*?\*\//g,'\x20')['replace'](/(^|[^:])\/\/[^\n]*/g,'$1\x20');}export function importSourcesOf(a){const b=[];for(const c of a['matchAll'](/\bimport\s+(?:type\s+)?\{[^}]*\}\s*from\s*["']([^"']+)["']/g))b['push'](c[0x1]);for(const d of a['matchAll'](/\bimport\s+(?:type\s+)?(?:\*\s+as\s+\w+|\w+)(?:\s*,\s*\{[^}]*\})?\s*from\s*["']([^"']+)["']/g))b['push'](d[0x1]);for(const e of a['matchAll'](/\bexport\s+(?:\*\s*|\{[^}]*\}\s*)from\s*["']([^"']+)["']/g))b['push'](e[0x1]);for(const f of a['matchAll'](/^\s*import\s+["']([^"']+)["']/gm))b['push'](f[0x1]);return b;}export function namedSdkImportsOf(a){const b=[];for(const c of a['matchAll'](/import\s+(?:type\s+)?\{([^}]*)\}\s+from\s+["']@wowok\/wowok["']/g)){for(const d of c[0x1]['split'](',')){const e=d['replace'](/\btype\s+/g,'')['trim']()['split'](/\s+as\s+/)[0x0]['trim']();if(e)b['push'](e);}}return b;}export const SDK_CONSTANT_ALLOWLIST=new Set(['MAX_VOTING_GUARD_COUNT']);export const ONCHAIN_IO_CALLS=[[/\bnew\s+SdkDataPlane\b/,'SdkDataPlane\x20construction'],[/\b(?:query_objects|query_table|query_services|query_arbs|query_events)\s*\(/,'SDK\x20query\x20call'],[/\bLocalMark\.Instance\s*\(\)/,'LocalMark\x20store\x20access'],[/\bget_many_address\s*\(/,'LocalMark\x20name\x20resolution'],[/\bfetchObjectLinker\s*\(/,'linker\x20chain\x20IO'],[/\bnetwork_get\s*\(/,'authority\x20network\x20read']];export function onchainIoCalls(a){return ONCHAIN_IO_CALLS['filter'](([b])=>b['test'](a))['map'](([,b])=>b);}export function listRuntimeSources(a){const b=[];for(const c of readdirSync(a,{'withFileTypes':!![]})){const d=join(a,c['name']);if(c['isDirectory']())b['push'](...listRuntimeSources(d));else c['name']['endsWith']('.ts')&&!c['name']['endsWith']('.spec.ts')&&b['push']({'file':c['name'],'text':stripComments(readFileSync(d,'utf8'))});}return b['sort']((e,f)=>e['file']['localeCompare'](f['file']));}
|
|
1
|
+
import{readdirSync,readFileSync}from'node:fs';import{join}from'node:path';export function stripComments(a){return a['replace'](/\/\*[\s\S]*?\*\//g,'\x20')['replace'](/(^|[^:])\/\/[^\n]*/g,'$1\x20');}export function importSourcesOf(a){const b=[];for(const c of a['matchAll'](/\bimport\s+(?:type\s+)?\{[^}]*\}\s*from\s*["']([^"']+)["']/g))b['push'](c[0x1]);for(const d of a['matchAll'](/\bimport\s+(?:type\s+)?(?:\*\s+as\s+\w+|\w+)(?:\s*,\s*\{[^}]*\})?\s*from\s*["']([^"']+)["']/g))b['push'](d[0x1]);for(const e of a['matchAll'](/\bexport\s+(?:\*\s*|\{[^}]*\}\s*)from\s*["']([^"']+)["']/g))b['push'](e[0x1]);for(const f of a['matchAll'](/^\s*import\s+["']([^"']+)["']/gm))b['push'](f[0x1]);return b;}export function namedSdkImportsOf(a){const b=[];for(const c of a['matchAll'](/import\s+(?:type\s+)?\{([^}]*)\}\s+from\s+["']@wowok\/wowok["']/g)){for(const d of c[0x1]['split'](',')){const e=d['replace'](/\btype\s+/g,'')['trim']()['split'](/\s+as\s+/)[0x0]['trim']();if(e)b['push'](e);}}return b;}export const SDK_CONSTANT_ALLOWLIST=new Set(['MAX_VOTING_GUARD_COUNT']);export const ONCHAIN_IO_CALLS=[[/\bnew\s+SdkDataPlane\b/,'SdkDataPlane\x20construction'],[/\b(?:query_objects|query_table|query_services|query_arbs|query_events)\s*\(/,'SDK\x20query\x20call'],[/\bLocalMark\.Instance\s*\(\)/,'LocalMark\x20store\x20access'],[/\bget_many_address\s*\(/,'LocalMark\x20name\x20resolution'],[/\bfetchObjectLinker\s*\(/,'linker\x20chain\x20IO'],[/\bnetwork_get\s*\(/,'authority\x20network\x20read']];export function onchainIoCalls(a){return ONCHAIN_IO_CALLS['filter'](([b])=>b['test'](a))['map'](([,b])=>b);}export function listRuntimeSources(a){const b=[];for(const c of readdirSync(a,{'withFileTypes':!![]})){const d=join(a,c['name']);if(c['isDirectory']())b['push'](...listRuntimeSources(d));else c['name']['endsWith']('.ts')&&!c['name']['endsWith']('.spec'+'.ts')&&b['push']({'file':c['name'],'text':stripComments(readFileSync(d,'utf8'))});}return b['sort']((e,f)=>e['file']['localeCompare'](f['file']));}
|
|
@@ -8,7 +8,16 @@ export interface OperationBridge {
|
|
|
8
8
|
operation_type: "demand" | "service";
|
|
9
9
|
preconditions: string[];
|
|
10
10
|
rationale: string;
|
|
11
|
+
state?: {
|
|
12
|
+
demand_object: string;
|
|
13
|
+
presenters_count: number | null;
|
|
14
|
+
};
|
|
11
15
|
}
|
|
12
16
|
export declare function nextOperationForServiceMatch(demand: DemandExtractInput, guarded: boolean | null): OperationBridge;
|
|
13
17
|
export declare function nextOperationForDemandMatch(service: ServiceExtractInput): OperationBridge;
|
|
18
|
+
export interface DemandLiveState {
|
|
19
|
+
object: string;
|
|
20
|
+
presenters_count: number | null;
|
|
21
|
+
}
|
|
22
|
+
export declare function nextOperationForDemandMatchLive(service: ServiceExtractInput, live: DemandLiveState | null): OperationBridge;
|
|
14
23
|
export declare function nextOperationForServiceOrder(service: ServiceExtractInput): OperationBridge;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export const OP_DEMAND_PRESENT_SERVICE='demand.present';export const OP_DEMAND_PRESENT_SERVICE_WITH_PASSPORT='demand.present_guarded';export const OP_DEMAND_PUBLISH='demand.publish';export const OP_SERVICE_ORDER_NEW='service.order_new';export function nextOperationForServiceMatch(a,b){return{'operation':b===!![]?OP_DEMAND_PRESENT_SERVICE_WITH_PASSPORT:OP_DEMAND_PRESENT_SERVICE,'operation_type':'demand','preconditions':['Demand\x20is\x20still\x20open\x20(not\x20expired)\x20and\x20this\x20supplier\x20has\x20not\x20already\x20presented.','Service\x20is\x20published\x20and\x20not\x20paused.',b===null?'Verify\x20Demand.guards:\x20if\x20non-empty\x20present\x20through\x20one\x20of\x20them\x20(by_guard\x20from\x20Demand.guards);\x20if\x20empty\x20use\x20plain\x20present.':b?'Select\x20a\x20by_guard\x20present\x20in\x20Demand.guards\x20for\x20the\x20guarded\x20present\x20(guard\x20verification\x20runs\x20at\x20present\x20time).':'Demand.guards\x20is\x20empty\x20→\x20plain\x20present\x20is\x20valid.'],'rationale':'Present\x20this\x20service\x20to\x20demand\x20'+a['object']+';\x20the\x20demander\x20then\x20gives\x20feedback\x20(acceptance_score)\x20and\x20selects\x20→\x20Order\x20via\x20'+OP_SERVICE_ORDER_NEW+'\x20(see\x20nextOperationForServiceOrder).'};}export function nextOperationForDemandMatch(a){return{'operation':OP_DEMAND_PUBLISH,'operation_type':'demand','preconditions':['Service\x20is\x20published\x20and\x20not\x20paused\x20(eligible\x20to\x20be\x20presented\x20into\x20the\x20Demand).','This\x20account\x20holds\x20the\x20Demand\x27s\x20Permission\x20(owner)\x20to\x20publish\x20and\x20later\x20score/select\x20presenters.'],'rationale':'Publish\x20a\x20Demand\x20encoding\x20the\x20requirement\x20so\x20'+a['object']+'\x20(and\x20peers)\x20can\x20present\x20(demand.present*);\x20then\x20feedback\x20(acceptance_score)\x20+\x20select\x20forms\x20the\x20Order\x20via\x20'+OP_SERVICE_ORDER_NEW+'\x20(see\x20nextOperationForServiceOrder).'};}export function nextOperationForServiceOrder(a){return{'operation':OP_SERVICE_ORDER_NEW,'operation_type':'service','preconditions':['Service\x20is\x20published\x20and\x20not\x20paused\x20(E1\x20gate\x20of\x20pre-purchase\x20due\x20diligence).','Pin\x20each\x20sale\x20item\x27s\x20wip_hash\x20in\x20the\x20buy\x20items\x20—\x20prevents\x20WIP\x20swap\x20between\x20viewing\x20and\x20ordering.','If\x20Service.buy_guard\x20is\x20non-empty,\x20obtain\x20a\x20valid\x20passport\x20first\x20(buy\x20requires\x20guard\x20validation).','If\x20Service.customer_required\x20is\x20non-empty,\x20deliver\x20the\x20required\x20info\x20to\x20the\x20merchant\x27s\x20IM\x20user\x20address\x20(resolved\x20from\x20the\x20Service\x27s\x20Contact)\x20via\x20Messenger,\x20then\x20record\x20as\x20order_required_info\x20either\x20that\x20IM\x20address\x20or\x20an\x20on-chain\x20WTS\x20Proof\x20address\x20(embeds\x20the\x20IM\x20address\x20+\x20last-message\x20timestamp;\x20costs\x20gas).','If\x20this\x20selection\x20follows\x20a\x20Demand\x20you\x20published\x20with\x20presenters:\x20score\x20the\x20presenters\x20first\x20(demand\x20feedback\x20→\x20acceptance_score)\x20—\x20skipping\x20feedback\x20damages\x20your\x20acceptance_score\x20reputation.','Sufficient\x20balance\x20for\x20the\x20total\x20price\x20plus\x20gas;\x20payment\x20is\x20escrowed\x20in\x20the\x20Order\x20until\x20Allocation\x20settlement.'],'rationale':'Create\x20the\x20Order\x20on\x20the\x20chosen\x20service\x20'+a['object']+'\x20('+OP_SERVICE_ORDER_NEW+')\x20—\x20the\x20transaction-formation\x20step:\x20Order\x20+\x20Progress\x20+\x20Allocation\x20are\x20created\x20atomically,\x20then\x20Progress\x20advances\x20through\x20the\x20Machine\x20and\x20Allocation\x20settles\x20the\x20payment.'};}
|
|
1
|
+
export const OP_DEMAND_PRESENT_SERVICE='demand.present';export const OP_DEMAND_PRESENT_SERVICE_WITH_PASSPORT='demand.present_guarded';export const OP_DEMAND_PUBLISH='demand.publish';export const OP_SERVICE_ORDER_NEW='service.order_new';export function nextOperationForServiceMatch(a,b){return{'operation':b===!![]?OP_DEMAND_PRESENT_SERVICE_WITH_PASSPORT:OP_DEMAND_PRESENT_SERVICE,'operation_type':'demand','preconditions':['Demand\x20is\x20still\x20open\x20(not\x20expired)\x20and\x20this\x20supplier\x20has\x20not\x20already\x20presented.','Service\x20is\x20published\x20and\x20not\x20paused.',b===null?'Verify\x20Demand.guards:\x20if\x20non-empty\x20present\x20through\x20one\x20of\x20them\x20(by_guard\x20from\x20Demand.guards);\x20if\x20empty\x20use\x20plain\x20present.':b?'Select\x20a\x20by_guard\x20present\x20in\x20Demand.guards\x20for\x20the\x20guarded\x20present\x20(guard\x20verification\x20runs\x20at\x20present\x20time).':'Demand.guards\x20is\x20empty\x20→\x20plain\x20present\x20is\x20valid.'],'rationale':'Present\x20this\x20service\x20to\x20demand\x20'+a['object']+';\x20the\x20demander\x20then\x20gives\x20feedback\x20(acceptance_score)\x20and\x20selects\x20→\x20Order\x20via\x20'+OP_SERVICE_ORDER_NEW+'\x20(see\x20nextOperationForServiceOrder).'};}export function nextOperationForDemandMatch(a){return{'operation':OP_DEMAND_PUBLISH,'operation_type':'demand','preconditions':['Service\x20is\x20published\x20and\x20not\x20paused\x20(eligible\x20to\x20be\x20presented\x20into\x20the\x20Demand).','This\x20account\x20holds\x20the\x20Demand\x27s\x20Permission\x20(owner)\x20to\x20publish\x20and\x20later\x20score/select\x20presenters.'],'rationale':'Publish\x20a\x20Demand\x20encoding\x20the\x20requirement\x20so\x20'+a['object']+'\x20(and\x20peers)\x20can\x20present\x20(demand.present*);\x20then\x20feedback\x20(acceptance_score)\x20+\x20select\x20forms\x20the\x20Order\x20via\x20'+OP_SERVICE_ORDER_NEW+'\x20(see\x20nextOperationForServiceOrder).'};}export function nextOperationForDemandMatchLive(a,b){if(!b){const c=nextOperationForDemandMatch(a);return{...c,'preconditions':[...c['preconditions'],'No\x20on-chain\x20Demand\x20reference\x20supplied\x20(demand_object\x20absent)\x20—\x20this\x20bridge\x20ASSUMES\x20the\x20Demand\x20does\x20not\x20exist\x20yet.\x20If\x20one\x20already\x20exists,\x20re-invoke\x20with\x20demand_object\x20so\x20`next`\x20is\x20derived\x20from\x20live\x20state\x20instead\x20of\x20this\x20static\x20template\x20(F-RQ-06\x20ghost-publish\x20guard).']};}if(b['presenters_count']===null)return{'operation':OP_DEMAND_PUBLISH,'operation_type':'demand','preconditions':['Demand\x20'+b['object']+'\x20could\x20NOT\x20be\x20read\x20live\x20—\x20state\x20UNVERIFIED.','VERIFY\x20FIRST\x20(query_toolkit\x20onchain_object\x20/\x20onchain_table_item\x20demand_presenter):\x20is\x20it\x20published?\x20presenters_count?','If\x20already\x20published,\x20do\x20NOT\x20publish\x20again\x20—\x20a\x20second\x20publish\x20creates\x20a\x20duplicate\x20Demand.\x20Published\x20with\x20presenters\x20→\x20demand.feedback\x20then\x20service.order_new;\x20published\x20with\x20zero\x20presenters\x20→\x20await\x20presenters\x20(suppliers\x20present).'],'rationale':'Live\x20read\x20of\x20demand\x20'+b['object']+'\x20failed\x20—\x20falling\x20back\x20to\x20the\x20publish\x20template\x20behind\x20a\x20mandatory\x20verify-first\x20gate\x20(F-RQ-06:\x20never\x20act\x20on\x20a\x20static\x20next\x20while\x20live\x20state\x20is\x20unknown).','state':{'demand_object':b['object'],'presenters_count':null}};if(b['presenters_count']===0x0)return{'operation':'demand.await_presenters','operation_type':'demand','preconditions':['Demand\x20'+b['object']+'\x20is\x20LIVE\x20on-chain\x20(read\x20at\x20match\x20time):\x20presenters_count\x20=\x200.','DO\x20NOT\x20publish\x20again\x20—\x20the\x20Demand\x20already\x20exists;\x20a\x20second\x20publish\x20creates\x20a\x20duplicate\x20(F-RQ-06\x20ghost-publish).','demand.present\x20is\x20the\x20SUPPLIERS\x27\x20move:\x20they\x20present\x20services\x20into\x20this\x20Demand.\x20As\x20the\x20demander:\x20monitor\x20presenters\x20(query_toolkit\x20onchain_table_item\x20demand_presenter)\x20or\x20share\x20the\x20Demand\x20with\x20candidate\x20suppliers.'],'rationale':'Live-state\x20derivation:\x20demand\x20'+b['object']+'\x20is\x20published\x20and\x20awaiting\x20presenters\x20—\x20demand.publish\x20advice\x20is\x20OBSOLETE.\x20The\x20next\x20WRITE\x20unlocks\x20once\x20a\x20supplier\x20presents\x20(then\x20demand.feedback\x20→\x20service.order_new,\x20see\x20the\x20order\x20bridge).','state':{'demand_object':b['object'],'presenters_count':0x0}};return{'operation':'demand.feedback','operation_type':'demand','preconditions':['Demand\x20'+b['object']+'\x20is\x20LIVE\x20on-chain\x20(read\x20at\x20match\x20time):\x20presenters_count\x20=\x20'+b['presenters_count']+'.','Score\x20the\x20presenters\x20via\x20demand.feedback\x20(acceptance_score\x200-255,\x20one\x20presenter\x20per\x20call)\x20—\x20skipping\x20feedback\x20damages\x20YOUR\x20acceptance_score\x20reputation.','Then\x20form\x20the\x20transaction:\x20'+OP_SERVICE_ORDER_NEW+'\x20on\x20the\x20selected\x20service\x20(see\x20the\x20order\x20bridge).'],'rationale':'Live-state\x20derivation:\x20demand\x20'+b['object']+'\x20has\x20'+b['presenters_count']+'\x20presenter(s)\x20—\x20the\x20static\x20demand.publish\x20advice\x20is\x20OBSOLETE\x20(F-RQ-06);\x20the\x20demander\x27s\x20next\x20move\x20is\x20feedback\x20→\x20select\x20→\x20order.','state':{'demand_object':b['object'],'presenters_count':b['presenters_count']}};}export function nextOperationForServiceOrder(a){return{'operation':OP_SERVICE_ORDER_NEW,'operation_type':'service','preconditions':['Service\x20is\x20published\x20and\x20not\x20paused\x20(E1\x20gate\x20of\x20pre-purchase\x20due\x20diligence).','Pin\x20each\x20sale\x20item\x27s\x20wip_hash\x20in\x20the\x20buy\x20items\x20—\x20prevents\x20WIP\x20swap\x20between\x20viewing\x20and\x20ordering.','If\x20Service.buy_guard\x20is\x20non-empty,\x20obtain\x20a\x20valid\x20passport\x20first\x20(buy\x20requires\x20guard\x20validation).','If\x20Service.customer_required\x20is\x20non-empty,\x20deliver\x20the\x20required\x20info\x20to\x20the\x20merchant\x27s\x20IM\x20user\x20address\x20(resolved\x20from\x20the\x20Service\x27s\x20Contact)\x20via\x20Messenger,\x20then\x20record\x20as\x20order_required_info\x20either\x20that\x20IM\x20address\x20or\x20an\x20on-chain\x20WTS\x20Proof\x20address\x20(embeds\x20the\x20IM\x20address\x20+\x20last-message\x20timestamp;\x20costs\x20gas).','If\x20this\x20selection\x20follows\x20a\x20Demand\x20you\x20published\x20with\x20presenters:\x20score\x20the\x20presenters\x20first\x20(demand\x20feedback\x20→\x20acceptance_score)\x20—\x20skipping\x20feedback\x20damages\x20your\x20acceptance_score\x20reputation.','Sufficient\x20balance\x20for\x20the\x20total\x20price\x20plus\x20gas;\x20payment\x20is\x20escrowed\x20in\x20the\x20Order\x20until\x20Allocation\x20settlement.'],'rationale':'Create\x20the\x20Order\x20on\x20the\x20chosen\x20service\x20'+a['object']+'\x20('+OP_SERVICE_ORDER_NEW+')\x20—\x20the\x20transaction-formation\x20step:\x20Order\x20+\x20Progress\x20+\x20Allocation\x20are\x20created\x20atomically,\x20then\x20Progress\x20advances\x20through\x20the\x20Machine\x20and\x20Allocation\x20settles\x20the\x20payment.'};}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type MatchPolicyDirection } from "../config/match-policy-file.js";
|
|
2
|
+
import { type MatchPolicy, type MatchPolicyInput, type MatchPolicySource } from "./match-policy.js";
|
|
3
|
+
export type { MatchPolicySource, MatchPolicyDirection };
|
|
4
|
+
export interface EffectiveMatchPolicy {
|
|
5
|
+
policy?: MatchPolicy;
|
|
6
|
+
source: MatchPolicySource;
|
|
7
|
+
note?: string;
|
|
8
|
+
}
|
|
9
|
+
export declare function resolveEffectiveMatchPolicy(input: MatchPolicyInput | undefined, direction: MatchPolicyDirection, account?: string): Promise<EffectiveMatchPolicy>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{getPersonaStore}from'../persona/store.js';import{getMatchPolicyFile}from'../config/match-policy-file.js';import{resolveMatchPolicy}from'./match-policy.js';function carriedForDirection(a,b){if(a['direction']!==undefined&&a['direction']!==b)return undefined;return a['direction']===undefined?{...a,'direction':b}:a;}async function personaCarriedPolicy(a,b,c){if(b['length']===0x0)return undefined;let d;try{d=getPersonaStore();}catch(f){return c['push']('persona\x20store\x20unavailable\x20('+(f instanceof Error?f['message']:String(f))+')\x20—\x20persona\x20match\x20layers\x20skipped'),undefined;}for(const {scope:g,addr:h,source:i}of b){let j;try{j=await d['get'](g,h);}catch(m){c['push'](g+'\x20persona\x20unreadable\x20('+(m instanceof Error?m['message']:String(m))+')\x20—\x20skipped');continue;}if(!j)continue;const k=j['current']['match']?.[a]??j['long_term']['match']?.[a];if(!k)continue;const l=carriedForDirection(k,a);if(!l){c['push'](g+'\x20persona\x20carries\x20a\x20'+k['direction']+'\x20policy,\x20not\x20'+a+'\x20—\x20skipped');continue;}return{'policy':l,'source':i};}return undefined;}export async function resolveEffectiveMatchPolicy(a,b,c){if(a!==undefined)return{'policy':resolveMatchPolicy(a,b),'source':'request'};const d=[],e=c?[{'scope':'account','addr':c,'source':'account_persona'}]:[],f=await personaCarriedPolicy(b,e,d);if(f)return{'policy':f['policy'],'source':f['source'],...d['length']?{'note':d['join'](';\x20')}:{}};const g=getMatchPolicyFile(),h=g[b];if(h){if(g['error'])d['push']('match-policy.json\x20also\x20reports:\x20'+g['error']);return{'policy':h,'source':'general_file',...d['length']?{'note':d['join'](';\x20')}:{}};}if(g['error'])d['push']('match-policy.json\x20unreadable\x20('+g['error']+')\x20—\x20falling\x20through');const i=await personaCarriedPolicy(b,[{'scope':'system','source':'system_persona'}],d);if(i)return{'policy':i['policy'],'source':i['source'],...d['length']?{'note':d['join'](';\x20')}:{}};return{'source':'factory_defaults',...d['length']?{'note':d['join'](';\x20')}:{}};}
|
|
@@ -43,6 +43,7 @@ export interface MatchPolicy {
|
|
|
43
43
|
output?: PolicyOutput;
|
|
44
44
|
}
|
|
45
45
|
export type MatchPolicyInput = string | MatchPolicy;
|
|
46
|
+
export type MatchPolicySource = "factory_defaults" | "system_persona" | "general_file" | "account_persona" | "request";
|
|
46
47
|
export declare const POLICY_WEIGHT_RULE_IDS: readonly ["region", "industry", "price", "trust", "capabilities", "tags", "acceptance"];
|
|
47
48
|
export declare const PRESET_MATCH_POLICIES: Record<string, MatchPolicy>;
|
|
48
49
|
export declare function resolveMatchPolicy(input: MatchPolicyInput | undefined, direction: "demand_to_supply" | "supply_to_demand"): MatchPolicy | undefined;
|
|
@@ -120,6 +121,7 @@ export interface PolicyEffect {
|
|
|
120
121
|
version?: number;
|
|
121
122
|
direction: string;
|
|
122
123
|
policy_hash: string;
|
|
124
|
+
policy_source: MatchPolicySource;
|
|
123
125
|
unknown_policy: string;
|
|
124
126
|
dropped: Array<{
|
|
125
127
|
object: string;
|
|
@@ -139,4 +141,4 @@ export interface PolicyEffect {
|
|
|
139
141
|
export declare function buildPolicyEffect(policy: MatchPolicy, gateOutcome: PolicyGateOutcome, weights: {
|
|
140
142
|
applied: Record<string, number>;
|
|
141
143
|
ignored: string[];
|
|
142
|
-
}, rerank: PolicyRerankSummary, extraIgnored?: string[]): PolicyEffect;
|
|
144
|
+
}, rerank: PolicyRerankSummary, extraIgnored?: string[], policySource?: MatchPolicySource): PolicyEffect;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createHash}from'node:crypto';export const POLICY_WEIGHT_RULE_IDS=['region','industry','price','trust','capabilities','tags','acceptance'];export const PRESET_MATCH_POLICIES={'default':{'policy_id':'default','version':0x1,'unknown_policy':'neutral_score'},'retail':{'policy_id':'retail','version':0x1,'unknown_policy':'neutral_score','gates':[{'dim':'live','op':'eq','value':!![]}],'weights':{'region':0xa,'industry':0xf,'price':0x19,'trust':0xf,'capabilities':0x1e,'tags':0x5}},'life_service':{'policy_id':'life_service','version':0x1,'unknown_policy':'neutral_score','gates':[{'dim':'live','op':'eq','value':!![]}],'weights':{'region':0x14,'industry':0xf,'price':0xa,'trust':0x19,'capabilities':0x19,'tags':0x5}},'trust_first':{'policy_id':'trust_first','version':0x1,'unknown_policy':'drop','gates':[{'dim':'live','op':'eq','value':!![]},{'dim':'arb','op':'gte','value':0x1}],'weights':{'trust':0x1e,'capabilities':0x19,'region':0xa,'industry':0xa,'price':0xa,'tags':0x5}},'cross_border':{'policy_id':'cross_border','version':0x1,'unknown_policy':'neutral_score','gates':[{'dim':'live','op':'eq','value':!![]},{'dim':'wip_verify','op':'eq','value':!![]}],'weights':{'capabilities':0x19,'trust':0x14,'industry':0x14,'tags':0xf,'price':0xf,'region':0x5}},'cheap_and_fast':{'policy_id':'cheap_and_fast','version':0x1,'unknown_policy':'drop','gates':[{'dim':'price','op':'lte','params':{'from_budget':!![],'hard':!![]}}],'weights':{'price':0x23,'trust':0xf,'capabilities':0xf,'region':0xa,'industry':0xa,'tags':0x5}},'enterprise':{'policy_id':'enterprise','version':0x1,'unknown_policy':'drop','gates':[{'dim':'live','op':'eq','value':!![]},{'dim':'machine','op':'eq','value':!![]},{'dim':'buy_guard','op':'eq','value':!![]}],'weights':{'capabilities':0x1e,'trust':0x19,'industry':0xf,'acceptance':0xa,'price':0xa,'region':0x5,'tags':0x5}},'supplier_hunting':{'policy_id':'supplier_hunting','version':0x1,'direction':'supply_to_demand','unknown_policy':'neutral_score'}};function normalizePresetId(a){return a['trim']()['toLowerCase']()['replace'](/-/g,'_');}export function resolveMatchPolicy(a,b){if(a===undefined)return undefined;let c;if(typeof a==='string'){const e=PRESET_MATCH_POLICIES[normalizePresetId(a)];if(!e)throw new Error('unknown\x20match_policy\x20preset\x20\x27'+a+'\x27\x20—\x20available:\x20'+Object['keys'](PRESET_MATCH_POLICIES)['join'](',\x20')+'\x20(or\x20pass\x20an\x20inline\x20policy\x20object)');c=e;}else{if(typeof a!=='object'||a===null||typeof a['policy_id']!=='string'||a['policy_id']['length']===0x0)throw new Error('inline\x20match_policy\x20must\x20be\x20an\x20object\x20with\x20a\x20non-empty\x20string\x20policy_id');c=a;}const d=c['direction']??'demand_to_supply';if(d!==b)throw new Error('match_policy\x20\x27'+c['policy_id']+'\x27\x20has\x20direction\x20\x27'+d+'\x27\x20and\x20cannot\x20drive\x20a\x20\x27'+b+'\x27\x20query');return c;}function bigIntValue(a){if(typeof a==='bigint')return a;if(typeof a==='number'&&Number['isInteger'](a))return BigInt(a);if(typeof a==='string'&&/^-?\d+$/['test'](a['trim']()))return BigInt(a['trim']());return undefined;}function asStringArray(a){if(Array['isArray'](a))return a['map'](String);if(typeof a==='string')return[a];return undefined;}function minSalePrice(a){if(!a['sales']||a['sales']['length']===0x0)return undefined;let b;for(const c of a['sales']){const d=bigIntValue(c['price']);if(d===undefined)continue;if(b===undefined||d<b)b=d;}return b;}function evalGate(a,b,c){const d=a['op']??'eq';switch(a['dim']){case'live':{const e=a['value']===undefined?!![]:Boolean(a['value']);if(b['bPublished']===undefined&&b['bPaused']===undefined)return{'dim':a['dim'],'status':'unknown','reason':'published/paused\x20flags\x20absent\x20from\x20candidate\x20payload'};const f=(b['bPublished']??![])&&!(b['bPaused']??![]);return f===e?{'dim':a['dim'],'status':'satisfied','reason':'live='+f}:{'dim':a['dim'],'status':'violated','reason':'live='+f+',\x20gate\x20requires\x20'+e};}case'price':{if(d!=='lte'&&d!=='gte')return null;let g=bigIntValue(a['value']);if(g===undefined&&a['params']?.['from_budget']===!![])g=c['budgetWei'];if(g===undefined)return{'dim':a['dim'],'status':'unknown','reason':'no\x20gate\x20value\x20and\x20no\x20request\x20budget\x20to\x20bind\x20from_budget'};const h=minSalePrice(b);if(h===undefined)return{'dim':a['dim'],'status':'unknown','reason':'candidate\x20exposes\x20no\x20sale\x20price'};const i=d==='lte'?h<=g:h>=g;return i?{'dim':a['dim'],'status':'satisfied','reason':'price_min\x20'+h+'\x20'+d+'\x20'+g}:{'dim':a['dim'],'status':'violated','reason':'price_min\x20'+h+'\x20fails\x20'+d+'\x20'+g};}case'arb':{if(d!=='gte')return null;const j=bigIntValue(a['value']);if(j===undefined)return null;if(!b['arbitrations'])return{'dim':a['dim'],'status':'unknown','reason':'arbitration\x20list\x20absent\x20from\x20candidate\x20payload'};const k=BigInt(b['arbitrations']['length'])>=j;return k?{'dim':a['dim'],'status':'satisfied','reason':'arb_count\x20'+b['arbitrations']['length']+'\x20>=\x20'+j}:{'dim':a['dim'],'status':'violated','reason':'arb_count\x20'+b['arbitrations']['length']+'\x20<\x20'+j};}case'compensation':{if(d!=='gte')return null;const l=bigIntValue(a['value']);if(l===undefined)return null;const m=bigIntValue(b['compensation_fund']);if(m===undefined)return{'dim':a['dim'],'status':'unknown','reason':'compensation_fund\x20absent\x20from\x20candidate\x20payload'};return m>=l?{'dim':a['dim'],'status':'satisfied','reason':'compensation_fund\x20'+m+'\x20>=\x20'+l}:{'dim':a['dim'],'status':'violated','reason':'compensation_fund\x20'+m+'\x20<\x20'+l};}case'machine':case'messenger':case'buy_guard':{const n=a['value']===undefined?!![]:Boolean(a['value']),o=a['dim']==='machine'?b['machine']:a['dim']==='messenger'?b['um']:b['buy_guard'];if(o===undefined)return{'dim':a['dim'],'status':'unknown','reason':a['dim']+'\x20binding\x20absent\x20from\x20candidate\x20payload'};const p=o!==null;return p===n?{'dim':a['dim'],'status':'satisfied','reason':a['dim']+'\x20bound='+p}:{'dim':a['dim'],'status':'violated','reason':a['dim']+'\x20bound='+p+',\x20gate\x20requires\x20'+n};}case'wip_verify':{const q=a['value']===undefined?!![]:Boolean(a['value']);if(!b['sales'])return{'dim':a['dim'],'status':'unknown','reason':'sales\x20absent\x20from\x20candidate\x20payload'};const r=b['sales']['some'](t=>typeof t['wip_hash']==='string'&&t['wip_hash']['length']>0x0);return r===q?{'dim':a['dim'],'status':'satisfied','reason':'has_wip_verification='+r}:{'dim':a['dim'],'status':'violated','reason':'has_wip_verification='+r+',\x20gate\x20requires\x20'+q};}case'text':{if(d!=='must_contain'&&d!=='must_not_contain')return null;const t=asStringArray(a['value']);if(!t||t['length']===0x0)return null;const u=[b['description']??'',...(b['sales']??[])['map'](w=>w['name']??'')]['join']('\x20')['toLowerCase']();if(u['trim']()['length']===0x0)return{'dim':a['dim'],'status':'unknown','reason':'candidate\x20carries\x20no\x20text\x20to\x20match'};if(d==='must_contain'){const w=t['filter'](x=>!u['includes'](x['toLowerCase']()));return w['length']===0x0?{'dim':a['dim'],'status':'satisfied','reason':'all\x20'+t['length']+'\x20term(s)\x20present'}:{'dim':a['dim'],'status':'violated','reason':'missing\x20term(s):\x20'+w['join'](',\x20')};}const v=t['filter'](x=>u['includes'](x['toLowerCase']()));return v['length']===0x0?{'dim':a['dim'],'status':'satisfied','reason':'no\x20forbidden\x20term\x20present'}:{'dim':a['dim'],'status':'violated','reason':'forbidden\x20term(s)\x20present:\x20'+v['join'](',\x20')};}case'owner':{if(d!=='in'&&d!=='not_in')return null;const x=asStringArray(a['value']);if(!x)return null;if(b['owner']===undefined)return{'dim':a['dim'],'status':'unknown','reason':'owner\x20absent\x20from\x20candidate\x20payload'};const y=x['includes'](b['owner']),z=d==='in'?y:!y;return z?{'dim':a['dim'],'status':'satisfied','reason':'owner\x20'+d+'\x20list'}:{'dim':a['dim'],'status':'violated','reason':'owner\x20fails\x20'+d+'\x20list'};}default:return null;}}function applyGates(a,b,d,e){const f=a['unknown_policy']??'neutral_score',g=new Set(),h=[],i=[],j=[];for(const m of a['gates']??[]){d(m,e)===null&&g['add']('gate\x20dim\x20\x27'+m['dim']+'\x27\x20(op\x20\x27'+(m['op']??'eq')+'\x27)\x20not\x20enforceable\x20client-side');}const k=new Set(),l=new Set();for(const n of a['excludes']??[]){if(n['dim']==='blacklist'){for(const p of n['objects']??[])k['add'](p);for(const q of n['owners']??[])l['add'](q);}else g['add']('exclude\x20dim\x20\x27'+n['dim']+'\x27\x20not\x20enforceable\x20client-side\x20(no\x20local\x20facet)');}for(const r of b){if(k['has'](r['object'])){i['push']({'object':r['object'],'reason':'excluded:\x20blacklisted\x20object'});continue;}const s=r['owner'];if(s!==undefined&&l['has'](s)){i['push']({'object':r['object'],'reason':'excluded:\x20blacklisted\x20owner'});continue;}let t=!![];for(const u of a['gates']??[]){const v=d(u,r);if(v===null){g['add']('gate\x20dim\x20\x27'+u['dim']+'\x27\x20(op\x20\x27'+(u['op']??'eq')+'\x27)\x20not\x20enforceable\x20client-side');continue;}if(v['status']==='violated'){i['push']({'object':r['object'],'reason':'gate\x20'+v['dim']+':\x20'+v['reason']}),t=![];break;}if(v['status']==='unknown'){if(f==='drop'){i['push']({'object':r['object'],'reason':'gate\x20'+v['dim']+'\x20unknown\x20('+v['reason']+')\x20and\x20unknown_policy=drop'}),t=![];break;}j['push']({'object':r['object'],'dim':v['dim'],'reason':v['reason']});}}if(t)h['push'](r);}return{'passed':h,'dropped':i,'unknown_notes':j,'ignored':[...g]['sort']()};}export function applyPolicyGates(a,b,c={}){return applyGates(a,b,(d,e)=>evalGate(d,e,c),{'object':'','description':'','location':''});}function evalDemandGate(a,b){const c=a['op']??'eq';switch(a['dim']){case'text':{if(c!=='must_contain'&&c!=='must_not_contain')return null;const e=asStringArray(a['value']);if(!e||e['length']===0x0)return null;const f=(b['description']??'')['toLowerCase']();if(f['trim']()['length']===0x0)return{'dim':a['dim'],'status':'unknown','reason':'demand\x20carries\x20no\x20description\x20text'};if(c==='must_contain'){const h=e['filter'](i=>!f['includes'](i['toLowerCase']()));return h['length']===0x0?{'dim':a['dim'],'status':'satisfied','reason':'all\x20'+e['length']+'\x20term(s)\x20present'}:{'dim':a['dim'],'status':'violated','reason':'missing\x20term(s):\x20'+h['join'](',\x20')};}const g=e['filter'](i=>f['includes'](i['toLowerCase']()));return g['length']===0x0?{'dim':a['dim'],'status':'satisfied','reason':'no\x20forbidden\x20term\x20present'}:{'dim':a['dim'],'status':'violated','reason':'forbidden\x20term(s)\x20present:\x20'+g['join'](',\x20')};}case'location':{if(c!=='must_contain'&&c!=='must_not_contain')return null;const i=asStringArray(a['value']);if(!i||i['length']===0x0)return null;const j=(b['location']??'')['toLowerCase']();if(j['trim']()['length']===0x0)return{'dim':a['dim'],'status':'unknown','reason':'demand\x20carries\x20no\x20location'};if(c==='must_contain'){const l=i['filter'](m=>!j['includes'](m['toLowerCase']()));return l['length']===0x0?{'dim':a['dim'],'status':'satisfied','reason':'all\x20'+i['length']+'\x20term(s)\x20present\x20in\x20location'}:{'dim':a['dim'],'status':'violated','reason':'location\x20missing\x20term(s):\x20'+l['join'](',\x20')};}const k=i['filter'](m=>j['includes'](m['toLowerCase']()));return k['length']===0x0?{'dim':a['dim'],'status':'satisfied','reason':'no\x20forbidden\x20term\x20in\x20location'}:{'dim':a['dim'],'status':'violated','reason':'forbidden\x20term(s)\x20in\x20location:\x20'+k['join'](',\x20')};}case'reward':{if(c!=='gte'&&c!=='lte')return null;const m=bigIntValue(a['value']);if(m===undefined)return null;if(b['rewards']===undefined)return{'dim':a['dim'],'status':'unknown','reason':'reward\x20list\x20absent\x20from\x20demand\x20payload'};const n=BigInt(b['rewards']['length']),o=c==='gte'?n>=m:n<=m;return o?{'dim':a['dim'],'status':'satisfied','reason':'reward_count\x20'+n+'\x20'+c+'\x20'+m}:{'dim':a['dim'],'status':'violated','reason':'reward_count\x20'+n+'\x20fails\x20'+c+'\x20'+m};}case'messenger':{const p=a['value']===undefined?!![]:Boolean(a['value']);if(b['um']===undefined)return{'dim':a['dim'],'status':'unknown','reason':'messenger\x20binding\x20absent\x20from\x20demand\x20payload'};const q=b['um']!==null;return q===p?{'dim':a['dim'],'status':'satisfied','reason':'messenger\x20bound='+q}:{'dim':a['dim'],'status':'violated','reason':'messenger\x20bound='+q+',\x20gate\x20requires\x20'+p};}case'guard':{const r=a['value']===undefined?!![]:Boolean(a['value']);if(b['guards']===undefined)return{'dim':a['dim'],'status':'unknown','reason':'guard\x20list\x20absent\x20from\x20demand\x20payload'};const s=b['guards']['length']>0x0;return s===r?{'dim':a['dim'],'status':'satisfied','reason':'guarded='+s}:{'dim':a['dim'],'status':'violated','reason':'guarded='+s+',\x20gate\x20requires\x20'+r};}case'presenters':{if(c!=='gte'&&c!=='lte')return null;const t=bigIntValue(a['value']);if(t===undefined)return null;if(b['presenters_count']===undefined)return{'dim':a['dim'],'status':'unknown','reason':'presenters_count\x20absent\x20from\x20demand\x20payload'};const u=BigInt(b['presenters_count']),v=c==='gte'?u>=t:u<=t;return v?{'dim':a['dim'],'status':'satisfied','reason':'presenters_count\x20'+u+'\x20'+c+'\x20'+t}:{'dim':a['dim'],'status':'violated','reason':'presenters_count\x20'+u+'\x20fails\x20'+c+'\x20'+t};}case'owner':{if(c!=='in'&&c!=='not_in')return null;const w=asStringArray(a['value']);if(!w)return null;if(b['owner']===undefined)return{'dim':a['dim'],'status':'unknown','reason':'owner\x20absent\x20from\x20demand\x20payload'};const x=w['includes'](b['owner']),y=c==='in'?x:!x;return y?{'dim':a['dim'],'status':'satisfied','reason':'owner\x20'+c+'\x20list'}:{'dim':a['dim'],'status':'violated','reason':'owner\x20fails\x20'+c+'\x20list'};}default:return null;}}export function applyDemandPolicyGates(a,b){return applyGates(a,b,evalDemandGate,{'object':'','description':'','location':''});}export function policyToInjection(a){const b={},c=[],d=new Set(POLICY_WEIGHT_RULE_IDS);for(const [e,f]of Object['entries'](a['weights']??{})){if(d['has'](e))b[e]=f;else c['push']('weight\x20on\x20unregistered\x20rule\x20\x27'+e+'\x27\x20ignored\x20(client\x20engine\x20has:\x20'+POLICY_WEIGHT_RULE_IDS['join'](',\x20')+')');}return{'injection':{'overrides':{'rules':Object['fromEntries'](Object['entries'](b)['map'](([g,h])=>[g,{'weight':h}]))}},'applied':b,'ignored':c['sort']()};}export function applyPolicyRerank(a,b){const c=[],d=[...a]['sort']((k,l)=>l['result']['total']-k['result']['total']||k['service']['object']['localeCompare'](l['service']['object']));let e=d,f=![],g=0x0;const h=b['rerank']?.['diversity'];if(h){if(h['by']==='permission')c['push']('rerank.diversity\x20by\x20\x27permission\x27\x20not\x20enforceable\x20client-side\x20(no\x20permission\x20facet\x20on\x20candidates);\x20use\x20\x27owner\x27');else{const k=new Map(),l=[],n=[];for(const o of e){const p=o['service']['owner'];if(p===undefined){l['push'](o);continue;}const q=k['get'](p)??0x0;q<h['max_per_group']?(k['set'](p,q+0x1),l['push'](o)):n['push'](o);}e=[...l,...n],f=!![],g=n['length'];}}if(b['rerank']?.['explore']!==undefined)c['push']('rerank.explore\x20not\x20enforceable\x20in\x20this\x20build\x20(no\x20local\x20bandit\x20state)');if(b['rerank']?.['llm']!==undefined)c['push']('rerank.llm\x20not\x20enforceable\x20in\x20this\x20build\x20(deterministic\x20kernel\x20only)');if(b['rerank']?.['fairness']!==undefined)c['push']('rerank.fairness\x20not\x20enforceable\x20in\x20this\x20build\x20(no\x20exposure\x20accounting)');const i=b['output']?.['top_n'],j=i!==undefined?e['slice'](0x0,i):e;return{'matches':j,'order':'total\x20DESC,\x20object_id\x20ASC'+(f?',\x20diversity(owner)<='+h['max_per_group']:''),'diversity_applied':f,'deferred':g,'ignored':c['sort']()};}export function rerankDemandMatches(a,b){const c=applyPolicyRerank(a['map'](e=>({'service':{'object':e['demand']['object'],...e['demand']['owner']!==undefined?{'owner':e['demand']['owner']}:{}},'result':e['result']})),b),d=new Map(a['map'](e=>[e['demand']['object'],e]));return{...c,'matches':c['matches']['map'](e=>d['get'](e['service']['object']))};}function canonicalize(a){if(Array['isArray'](a))return a['map'](canonicalize);if(a&&typeof a==='object'){const b={};for(const c of Object['keys'](a)['sort']()){b[c]=canonicalize(a[c]);}return b;}return a;}export function policyHash(a){return createHash('sha256')['update'](JSON['stringify'](canonicalize(a)))['digest']('hex');}export function buildPolicyEffect(a,b,c,d,e=[]){const f=[...new Set([...b['ignored'],...c['ignored'],...d['ignored'],...e])]['sort']();if(a['recall']!==undefined)f['push']('section\x20\x27recall\x27\x20is\x20a\x20server-side\x20directive\x20—\x20not\x20sent\x20upstream\x20from\x20a\x20private\x20policy;\x20recall\x20stays\x20on\x20the\x20route\x20in\x20effect');if(a['verify']!==undefined)f['push']('section\x20\x27verify\x27\x20not\x20enforceable\x20client-side\x20in\x20this\x20build');return{'policy_id':a['policy_id'],'version':a['version'],'direction':a['direction']??'demand_to_supply','policy_hash':policyHash(a),'unknown_policy':a['unknown_policy']??'neutral_score','dropped':b['dropped'],'unknown_kept':b['unknown_notes'],'weights_applied':c['applied'],'rerank':d['order'],'deferred_by_diversity':d['deferred'],'ignored':f['sort'](),'privacy':'client_side_only\x20—\x20the\x20policy\x20and\x20its\x20hash\x20never\x20leave\x20this\x20device'};}
|
|
1
|
+
import{createHash}from'node:crypto';export const POLICY_WEIGHT_RULE_IDS=['region','industry','price','trust','capabilities','tags','acceptance'];export const PRESET_MATCH_POLICIES={'default':{'policy_id':'default','version':0x1,'unknown_policy':'neutral_score'},'retail':{'policy_id':'retail','version':0x1,'unknown_policy':'neutral_score','gates':[{'dim':'live','op':'eq','value':!![]}],'weights':{'region':0xa,'industry':0xf,'price':0x19,'trust':0xf,'capabilities':0x1e,'tags':0x5}},'life_service':{'policy_id':'life_service','version':0x1,'unknown_policy':'neutral_score','gates':[{'dim':'live','op':'eq','value':!![]}],'weights':{'region':0x14,'industry':0xf,'price':0xa,'trust':0x19,'capabilities':0x19,'tags':0x5}},'trust_first':{'policy_id':'trust_first','version':0x1,'unknown_policy':'drop','gates':[{'dim':'live','op':'eq','value':!![]},{'dim':'arb','op':'gte','value':0x1}],'weights':{'trust':0x1e,'capabilities':0x19,'region':0xa,'industry':0xa,'price':0xa,'tags':0x5}},'cross_border':{'policy_id':'cross_border','version':0x1,'unknown_policy':'neutral_score','gates':[{'dim':'live','op':'eq','value':!![]},{'dim':'wip_verify','op':'eq','value':!![]}],'weights':{'capabilities':0x19,'trust':0x14,'industry':0x14,'tags':0xf,'price':0xf,'region':0x5}},'cheap_and_fast':{'policy_id':'cheap_and_fast','version':0x1,'unknown_policy':'drop','gates':[{'dim':'price','op':'lte','params':{'from_budget':!![],'hard':!![]}}],'weights':{'price':0x23,'trust':0xf,'capabilities':0xf,'region':0xa,'industry':0xa,'tags':0x5}},'enterprise':{'policy_id':'enterprise','version':0x1,'unknown_policy':'drop','gates':[{'dim':'live','op':'eq','value':!![]},{'dim':'machine','op':'eq','value':!![]},{'dim':'buy_guard','op':'eq','value':!![]}],'weights':{'capabilities':0x1e,'trust':0x19,'industry':0xf,'acceptance':0xa,'price':0xa,'region':0x5,'tags':0x5}},'supplier_hunting':{'policy_id':'supplier_hunting','version':0x1,'direction':'supply_to_demand','unknown_policy':'neutral_score'}};function normalizePresetId(a){return a['trim']()['toLowerCase']()['replace'](/-/g,'_');}export function resolveMatchPolicy(a,b){if(a===undefined)return undefined;let c;if(typeof a==='string'){const e=PRESET_MATCH_POLICIES[normalizePresetId(a)];if(!e)throw new Error('unknown\x20match_policy\x20preset\x20\x27'+a+'\x27\x20—\x20available:\x20'+Object['keys'](PRESET_MATCH_POLICIES)['join'](',\x20')+'\x20(or\x20pass\x20an\x20inline\x20policy\x20object)');c=e;}else{if(typeof a!=='object'||a===null||typeof a['policy_id']!=='string'||a['policy_id']['length']===0x0)throw new Error('inline\x20match_policy\x20must\x20be\x20an\x20object\x20with\x20a\x20non-empty\x20string\x20policy_id');c=a;}const d=c['direction']??'demand_to_supply';if(d!==b)throw new Error('match_policy\x20\x27'+c['policy_id']+'\x27\x20has\x20direction\x20\x27'+d+'\x27\x20and\x20cannot\x20drive\x20a\x20\x27'+b+'\x27\x20query');return c;}function bigIntValue(a){if(typeof a==='bigint')return a;if(typeof a==='number'&&Number['isInteger'](a))return BigInt(a);if(typeof a==='string'&&/^-?\d+$/['test'](a['trim']()))return BigInt(a['trim']());return undefined;}function asStringArray(a){if(Array['isArray'](a))return a['map'](String);if(typeof a==='string')return[a];return undefined;}function minSalePrice(a){if(!a['sales']||a['sales']['length']===0x0)return undefined;let b;for(const c of a['sales']){const d=bigIntValue(c['price']);if(d===undefined)continue;if(b===undefined||d<b)b=d;}return b;}function evalGate(a,b,c){const d=a['op']??'eq';switch(a['dim']){case'live':{const e=a['value']===undefined?!![]:Boolean(a['value']);if(b['bPublished']===undefined&&b['bPaused']===undefined)return{'dim':a['dim'],'status':'unknown','reason':'published/paused\x20flags\x20absent\x20from\x20candidate\x20payload'};const f=(b['bPublished']??![])&&!(b['bPaused']??![]);return f===e?{'dim':a['dim'],'status':'satisfied','reason':'live='+f}:{'dim':a['dim'],'status':'violated','reason':'live='+f+',\x20gate\x20requires\x20'+e};}case'price':{if(d!=='lte'&&d!=='gte')return null;let g=bigIntValue(a['value']);if(g===undefined&&a['params']?.['from_budget']===!![])g=c['budgetWei'];if(g===undefined)return{'dim':a['dim'],'status':'unknown','reason':'no\x20gate\x20value\x20and\x20no\x20request\x20budget\x20to\x20bind\x20from_budget'};const h=minSalePrice(b);if(h===undefined)return{'dim':a['dim'],'status':'unknown','reason':'candidate\x20exposes\x20no\x20sale\x20price'};const i=d==='lte'?h<=g:h>=g;return i?{'dim':a['dim'],'status':'satisfied','reason':'price_min\x20'+h+'\x20'+d+'\x20'+g}:{'dim':a['dim'],'status':'violated','reason':'price_min\x20'+h+'\x20fails\x20'+d+'\x20'+g};}case'arb':{if(d!=='gte')return null;const j=bigIntValue(a['value']);if(j===undefined)return null;if(!b['arbitrations'])return{'dim':a['dim'],'status':'unknown','reason':'arbitration\x20list\x20absent\x20from\x20candidate\x20payload'};const k=BigInt(b['arbitrations']['length'])>=j;return k?{'dim':a['dim'],'status':'satisfied','reason':'arb_count\x20'+b['arbitrations']['length']+'\x20>=\x20'+j}:{'dim':a['dim'],'status':'violated','reason':'arb_count\x20'+b['arbitrations']['length']+'\x20<\x20'+j};}case'compensation':{if(d!=='gte')return null;const l=bigIntValue(a['value']);if(l===undefined)return null;const m=bigIntValue(b['compensation_fund']);if(m===undefined)return{'dim':a['dim'],'status':'unknown','reason':'compensation_fund\x20absent\x20from\x20candidate\x20payload'};return m>=l?{'dim':a['dim'],'status':'satisfied','reason':'compensation_fund\x20'+m+'\x20>=\x20'+l}:{'dim':a['dim'],'status':'violated','reason':'compensation_fund\x20'+m+'\x20<\x20'+l};}case'machine':case'messenger':case'buy_guard':{const n=a['value']===undefined?!![]:Boolean(a['value']),o=a['dim']==='machine'?b['machine']:a['dim']==='messenger'?b['um']:b['buy_guard'];if(o===undefined)return{'dim':a['dim'],'status':'unknown','reason':a['dim']+'\x20binding\x20absent\x20from\x20candidate\x20payload'};const p=o!==null;return p===n?{'dim':a['dim'],'status':'satisfied','reason':a['dim']+'\x20bound='+p}:{'dim':a['dim'],'status':'violated','reason':a['dim']+'\x20bound='+p+',\x20gate\x20requires\x20'+n};}case'wip_verify':{const q=a['value']===undefined?!![]:Boolean(a['value']);if(!b['sales'])return{'dim':a['dim'],'status':'unknown','reason':'sales\x20absent\x20from\x20candidate\x20payload'};const r=b['sales']['some'](t=>typeof t['wip_hash']==='string'&&t['wip_hash']['length']>0x0);return r===q?{'dim':a['dim'],'status':'satisfied','reason':'has_wip_verification='+r}:{'dim':a['dim'],'status':'violated','reason':'has_wip_verification='+r+',\x20gate\x20requires\x20'+q};}case'text':{if(d!=='must_contain'&&d!=='must_not_contain')return null;const t=asStringArray(a['value']);if(!t||t['length']===0x0)return null;const u=[b['description']??'',...(b['sales']??[])['map'](w=>w['name']??'')]['join']('\x20')['toLowerCase']();if(u['trim']()['length']===0x0)return{'dim':a['dim'],'status':'unknown','reason':'candidate\x20carries\x20no\x20text\x20to\x20match'};if(d==='must_contain'){const w=t['filter'](x=>!u['includes'](x['toLowerCase']()));return w['length']===0x0?{'dim':a['dim'],'status':'satisfied','reason':'all\x20'+t['length']+'\x20term(s)\x20present'}:{'dim':a['dim'],'status':'violated','reason':'missing\x20term(s):\x20'+w['join'](',\x20')};}const v=t['filter'](x=>u['includes'](x['toLowerCase']()));return v['length']===0x0?{'dim':a['dim'],'status':'satisfied','reason':'no\x20forbidden\x20term\x20present'}:{'dim':a['dim'],'status':'violated','reason':'forbidden\x20term(s)\x20present:\x20'+v['join'](',\x20')};}case'owner':{if(d!=='in'&&d!=='not_in')return null;const x=asStringArray(a['value']);if(!x)return null;if(b['owner']===undefined)return{'dim':a['dim'],'status':'unknown','reason':'owner\x20absent\x20from\x20candidate\x20payload'};const y=x['includes'](b['owner']),z=d==='in'?y:!y;return z?{'dim':a['dim'],'status':'satisfied','reason':'owner\x20'+d+'\x20list'}:{'dim':a['dim'],'status':'violated','reason':'owner\x20fails\x20'+d+'\x20list'};}default:return null;}}function applyGates(a,b,d,e){const f=a['unknown_policy']??'neutral_score',g=new Set(),h=[],i=[],j=[];for(const m of a['gates']??[]){d(m,e)===null&&g['add']('gate\x20dim\x20\x27'+m['dim']+'\x27\x20(op\x20\x27'+(m['op']??'eq')+'\x27)\x20not\x20enforceable\x20client-side');}const k=new Set(),l=new Set();for(const n of a['excludes']??[]){if(n['dim']==='blacklist'){for(const p of n['objects']??[])k['add'](p);for(const q of n['owners']??[])l['add'](q);}else g['add']('exclude\x20dim\x20\x27'+n['dim']+'\x27\x20not\x20enforceable\x20client-side\x20(no\x20local\x20facet)');}for(const r of b){if(k['has'](r['object'])){i['push']({'object':r['object'],'reason':'excluded:\x20blacklisted\x20object'});continue;}const s=r['owner'];if(s!==undefined&&l['has'](s)){i['push']({'object':r['object'],'reason':'excluded:\x20blacklisted\x20owner'});continue;}let t=!![];for(const u of a['gates']??[]){const v=d(u,r);if(v===null){g['add']('gate\x20dim\x20\x27'+u['dim']+'\x27\x20(op\x20\x27'+(u['op']??'eq')+'\x27)\x20not\x20enforceable\x20client-side');continue;}if(v['status']==='violated'){i['push']({'object':r['object'],'reason':'gate\x20'+v['dim']+':\x20'+v['reason']}),t=![];break;}if(v['status']==='unknown'){if(f==='drop'){i['push']({'object':r['object'],'reason':'gate\x20'+v['dim']+'\x20unknown\x20('+v['reason']+')\x20and\x20unknown_policy=drop'}),t=![];break;}j['push']({'object':r['object'],'dim':v['dim'],'reason':v['reason']});}}if(t)h['push'](r);}return{'passed':h,'dropped':i,'unknown_notes':j,'ignored':[...g]['sort']()};}export function applyPolicyGates(a,b,c={}){return applyGates(a,b,(d,e)=>evalGate(d,e,c),{'object':'','description':'','location':''});}function evalDemandGate(a,b){const c=a['op']??'eq';switch(a['dim']){case'text':{if(c!=='must_contain'&&c!=='must_not_contain')return null;const e=asStringArray(a['value']);if(!e||e['length']===0x0)return null;const f=(b['description']??'')['toLowerCase']();if(f['trim']()['length']===0x0)return{'dim':a['dim'],'status':'unknown','reason':'demand\x20carries\x20no\x20description\x20text'};if(c==='must_contain'){const h=e['filter'](i=>!f['includes'](i['toLowerCase']()));return h['length']===0x0?{'dim':a['dim'],'status':'satisfied','reason':'all\x20'+e['length']+'\x20term(s)\x20present'}:{'dim':a['dim'],'status':'violated','reason':'missing\x20term(s):\x20'+h['join'](',\x20')};}const g=e['filter'](i=>f['includes'](i['toLowerCase']()));return g['length']===0x0?{'dim':a['dim'],'status':'satisfied','reason':'no\x20forbidden\x20term\x20present'}:{'dim':a['dim'],'status':'violated','reason':'forbidden\x20term(s)\x20present:\x20'+g['join'](',\x20')};}case'location':{if(c!=='must_contain'&&c!=='must_not_contain')return null;const i=asStringArray(a['value']);if(!i||i['length']===0x0)return null;const j=(b['location']??'')['toLowerCase']();if(j['trim']()['length']===0x0)return{'dim':a['dim'],'status':'unknown','reason':'demand\x20carries\x20no\x20location'};if(c==='must_contain'){const l=i['filter'](m=>!j['includes'](m['toLowerCase']()));return l['length']===0x0?{'dim':a['dim'],'status':'satisfied','reason':'all\x20'+i['length']+'\x20term(s)\x20present\x20in\x20location'}:{'dim':a['dim'],'status':'violated','reason':'location\x20missing\x20term(s):\x20'+l['join'](',\x20')};}const k=i['filter'](m=>j['includes'](m['toLowerCase']()));return k['length']===0x0?{'dim':a['dim'],'status':'satisfied','reason':'no\x20forbidden\x20term\x20in\x20location'}:{'dim':a['dim'],'status':'violated','reason':'forbidden\x20term(s)\x20in\x20location:\x20'+k['join'](',\x20')};}case'reward':{if(c!=='gte'&&c!=='lte')return null;const m=bigIntValue(a['value']);if(m===undefined)return null;if(b['rewards']===undefined)return{'dim':a['dim'],'status':'unknown','reason':'reward\x20list\x20absent\x20from\x20demand\x20payload'};const n=BigInt(b['rewards']['length']),o=c==='gte'?n>=m:n<=m;return o?{'dim':a['dim'],'status':'satisfied','reason':'reward_count\x20'+n+'\x20'+c+'\x20'+m}:{'dim':a['dim'],'status':'violated','reason':'reward_count\x20'+n+'\x20fails\x20'+c+'\x20'+m};}case'messenger':{const p=a['value']===undefined?!![]:Boolean(a['value']);if(b['um']===undefined)return{'dim':a['dim'],'status':'unknown','reason':'messenger\x20binding\x20absent\x20from\x20demand\x20payload'};const q=b['um']!==null;return q===p?{'dim':a['dim'],'status':'satisfied','reason':'messenger\x20bound='+q}:{'dim':a['dim'],'status':'violated','reason':'messenger\x20bound='+q+',\x20gate\x20requires\x20'+p};}case'guard':{const r=a['value']===undefined?!![]:Boolean(a['value']);if(b['guards']===undefined)return{'dim':a['dim'],'status':'unknown','reason':'guard\x20list\x20absent\x20from\x20demand\x20payload'};const s=b['guards']['length']>0x0;return s===r?{'dim':a['dim'],'status':'satisfied','reason':'guarded='+s}:{'dim':a['dim'],'status':'violated','reason':'guarded='+s+',\x20gate\x20requires\x20'+r};}case'presenters':{if(c!=='gte'&&c!=='lte')return null;const t=bigIntValue(a['value']);if(t===undefined)return null;if(b['presenters_count']===undefined)return{'dim':a['dim'],'status':'unknown','reason':'presenters_count\x20absent\x20from\x20demand\x20payload'};const u=BigInt(b['presenters_count']),v=c==='gte'?u>=t:u<=t;return v?{'dim':a['dim'],'status':'satisfied','reason':'presenters_count\x20'+u+'\x20'+c+'\x20'+t}:{'dim':a['dim'],'status':'violated','reason':'presenters_count\x20'+u+'\x20fails\x20'+c+'\x20'+t};}case'owner':{if(c!=='in'&&c!=='not_in')return null;const w=asStringArray(a['value']);if(!w)return null;if(b['owner']===undefined)return{'dim':a['dim'],'status':'unknown','reason':'owner\x20absent\x20from\x20demand\x20payload'};const x=w['includes'](b['owner']),y=c==='in'?x:!x;return y?{'dim':a['dim'],'status':'satisfied','reason':'owner\x20'+c+'\x20list'}:{'dim':a['dim'],'status':'violated','reason':'owner\x20fails\x20'+c+'\x20list'};}default:return null;}}export function applyDemandPolicyGates(a,b){return applyGates(a,b,evalDemandGate,{'object':'','description':'','location':''});}export function policyToInjection(a){const b={},c=[],d=new Set(POLICY_WEIGHT_RULE_IDS);for(const [e,f]of Object['entries'](a['weights']??{})){if(d['has'](e))b[e]=f;else c['push']('weight\x20on\x20unregistered\x20rule\x20\x27'+e+'\x27\x20ignored\x20(client\x20engine\x20has:\x20'+POLICY_WEIGHT_RULE_IDS['join'](',\x20')+')');}return{'injection':{'overrides':{'rules':Object['fromEntries'](Object['entries'](b)['map'](([g,h])=>[g,{'weight':h}]))}},'applied':b,'ignored':c['sort']()};}export function applyPolicyRerank(a,b){const c=[],d=[...a]['sort']((k,l)=>l['result']['total']-k['result']['total']||k['service']['object']['localeCompare'](l['service']['object']));let e=d,f=![],g=0x0;const h=b['rerank']?.['diversity'];if(h){if(h['by']==='permission')c['push']('rerank.diversity\x20by\x20\x27permission\x27\x20not\x20enforceable\x20client-side\x20(no\x20permission\x20facet\x20on\x20candidates);\x20use\x20\x27owner\x27');else{const k=new Map(),l=[],n=[];for(const o of e){const p=o['service']['owner'];if(p===undefined){l['push'](o);continue;}const q=k['get'](p)??0x0;q<h['max_per_group']?(k['set'](p,q+0x1),l['push'](o)):n['push'](o);}e=[...l,...n],f=!![],g=n['length'];}}if(b['rerank']?.['explore']!==undefined)c['push']('rerank.explore\x20not\x20enforceable\x20in\x20this\x20build\x20(no\x20local\x20bandit\x20state)');if(b['rerank']?.['llm']!==undefined)c['push']('rerank.llm\x20not\x20enforceable\x20in\x20this\x20build\x20(deterministic\x20kernel\x20only)');if(b['rerank']?.['fairness']!==undefined)c['push']('rerank.fairness\x20not\x20enforceable\x20in\x20this\x20build\x20(no\x20exposure\x20accounting)');const i=b['output']?.['top_n'],j=i!==undefined?e['slice'](0x0,i):e;return{'matches':j,'order':'total\x20DESC,\x20object_id\x20ASC'+(f?',\x20diversity(owner)<='+h['max_per_group']:''),'diversity_applied':f,'deferred':g,'ignored':c['sort']()};}export function rerankDemandMatches(a,b){const c=applyPolicyRerank(a['map'](e=>({'service':{'object':e['demand']['object'],...e['demand']['owner']!==undefined?{'owner':e['demand']['owner']}:{}},'result':e['result']})),b),d=new Map(a['map'](e=>[e['demand']['object'],e]));return{...c,'matches':c['matches']['map'](e=>d['get'](e['service']['object']))};}function canonicalize(a){if(Array['isArray'](a))return a['map'](canonicalize);if(a&&typeof a==='object'){const b={};for(const c of Object['keys'](a)['sort']()){b[c]=canonicalize(a[c]);}return b;}return a;}export function policyHash(a){return createHash('sha256')['update'](JSON['stringify'](canonicalize(a)))['digest']('hex');}export function buildPolicyEffect(a,b,c,d,e=[],f='request'){const g=[...new Set([...b['ignored'],...c['ignored'],...d['ignored'],...e])]['sort']();if(a['recall']!==undefined)g['push']('section\x20\x27recall\x27\x20is\x20a\x20server-side\x20directive\x20—\x20not\x20sent\x20upstream\x20from\x20a\x20private\x20policy;\x20recall\x20stays\x20on\x20the\x20route\x20in\x20effect');if(a['verify']!==undefined)g['push']('section\x20\x27verify\x27\x20not\x20enforceable\x20client-side\x20in\x20this\x20build');return{'policy_id':a['policy_id'],'version':a['version'],'direction':a['direction']??'demand_to_supply','policy_hash':policyHash(a),'policy_source':f,'unknown_policy':a['unknown_policy']??'neutral_score','dropped':b['dropped'],'unknown_kept':b['unknown_notes'],'weights_applied':c['applied'],'rerank':d['order'],'deferred_by_diversity':d['deferred'],'ignored':g['sort'](),'privacy':'client_side_only\x20—\x20the\x20policy\x20and\x20its\x20hash\x20never\x20leave\x20this\x20device'};}
|
|
@@ -7,10 +7,4 @@ export interface Region {
|
|
|
7
7
|
}
|
|
8
8
|
export type RegionRelation = "exact" | "contains" | "overlap" | "compatible" | "mismatch";
|
|
9
9
|
export declare function parseRegion(raw: string): Region;
|
|
10
|
-
export interface RegionValidation {
|
|
11
|
-
region: Region;
|
|
12
|
-
valid: boolean;
|
|
13
|
-
reminder?: string;
|
|
14
|
-
}
|
|
15
|
-
export declare function validateRegionInput(raw: string): RegionValidation;
|
|
16
10
|
export declare function relateRegion(a: Region, b: Region): RegionRelation;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const REMOTE_KEYWORDS=['remote','online','anywhere'];export function parseRegion(a){const b=a?.['trim']()??'',c=b['toLowerCase'](),d=REMOTE_KEYWORDS['some'](e=>c['includes'](e));if(d)return{'mode':'remote','raw':b};return{'mode':'physical','raw':b};}export function
|
|
1
|
+
const REMOTE_KEYWORDS=['remote','online','anywhere'];export function parseRegion(a){const b=a?.['trim']()??'',c=b['toLowerCase'](),d=REMOTE_KEYWORDS['some'](e=>c['includes'](e));if(d)return{'mode':'remote','raw':b};return{'mode':'physical','raw':b};}export function relateRegion(c,d){if(c['mode']==='remote'||d['mode']==='remote')return'compatible';const e=normalizePhysical(c['raw']),f=normalizePhysical(d['raw']);if(!e||!f)return'mismatch';if(e===f)return'exact';if(e['includes'](f)||f['includes'](e))return'contains';if(regionRouteRelates(c['raw'],d['raw']))return'contains';if(c['province']&&d['province']&&c['province']===d['province'])return'overlap';return'mismatch';}function regionRouteRelates(a,b){const c=f=>{const g=[],h=f['split'](/->|→/);for(const i of h){for(const j of[i,...i['split'](',')]){const k=normalizePhysical(j);if(k&&!g['includes'](k))g['push'](k);}}return g;},d=c(a),e=c(b);for(const f of d){for(const g of e){if(f===g||f['includes'](g)||g['includes'](f))return!![];}}return![];}function normalizePhysical(a){return a['trim']()['toLowerCase']()['replace'](/\s+/g,'');}
|
|
@@ -6,4 +6,5 @@ export declare function defaultWeights(): Record<string, number>;
|
|
|
6
6
|
export declare function dimensionLabel(ruleId: string): string;
|
|
7
7
|
export declare function severityDeduction(severity: string): number;
|
|
8
8
|
export declare function levelFromScore(score: number): string;
|
|
9
|
-
export declare function gradeWord(side: "trust" | "risk", score: number): string;
|
|
9
|
+
export declare function gradeWord(side: "trust" | "risk" | "match", score: number): string;
|
|
10
|
+
export declare function matchGradeFromScore(score: number): string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{evaluationSection}from'../config/judgment.js';import{normalizeSeverity}from'../config/severity.js';export function defaultWeight(a){return evaluationSection()['weights'][a]??0x0;}export function defaultWeights(){return{...evaluationSection()['weights']};}export function dimensionLabel(a){return evaluationSection()['dimensions'][a]?.['label']??a;}export function severityDeduction(a){return evaluationSection()['severity_deduction'][normalizeSeverity(a)]??0x0;}export function levelFromScore(a){const b=evaluationSection()['level_bands'];for(const c of b){if(a>=c['min'])return c['level'];}return b[b['length']-0x1]?.['level']??'high';}export function gradeWord(a,b){const c=evaluationSection()['grade_words'][a];for(const d of c){if(b>=d['min'])return d['word'];}return c[c['length']-0x1]?.['word']??'unknown';}
|
|
1
|
+
import{evaluationSection}from'../config/judgment.js';import{normalizeSeverity}from'../config/severity.js';export function defaultWeight(a){return evaluationSection()['weights'][a]??0x0;}export function defaultWeights(){return{...evaluationSection()['weights']};}export function dimensionLabel(a){return evaluationSection()['dimensions'][a]?.['label']??a;}export function severityDeduction(a){return evaluationSection()['severity_deduction'][normalizeSeverity(a)]??0x0;}export function levelFromScore(a){const b=evaluationSection()['level_bands'];for(const c of b){if(a>=c['min'])return c['level'];}return b[b['length']-0x1]?.['level']??'high';}export function gradeWord(a,b){const c=evaluationSection()['grade_words'][a];if(!Array['isArray'](c))return'unknown';for(const d of c){if(b>=d['min'])return d['word'];}return c[c['length']-0x1]?.['word']??'unknown';}export function matchGradeFromScore(a){return gradeWord('match',a);}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export interface StructuredLine {
|
|
2
|
+
key: string;
|
|
3
|
+
raw_key: string;
|
|
4
|
+
value: string;
|
|
5
|
+
}
|
|
6
|
+
export declare const STRUCTURED_LINE_KEYS: readonly ["quote", "price", "terms", "timing", "contact"];
|
|
7
|
+
export declare function parseStructuredLines(text: string | null | undefined): StructuredLine[];
|
|
8
|
+
export declare function firstStructuredValue(lines: StructuredLine[], keys: readonly string[]): string | null;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const STRUCTURED_LINE_KEYS=['quote','price','terms','timing','contact'];const MAX_LINES_SCANNED=0x20,MAX_VALUE_LEN=0xc8,LINE_RE=/^([^::=]{1,32})[::=](.+)$/;export function parseStructuredLines(a){if(!a||typeof a!=='string')return[];const b=[],c=new Set();for(const d of a['split'](/\r?\n/)['slice'](0x0,MAX_LINES_SCANNED)){const e=d['trim']();if(e===''||e['includes']('://'))continue;const f=LINE_RE['exec'](e);if(!f)continue;const g=f[0x1]['trim'](),h=f[0x2]['trim']()['slice'](0x0,MAX_VALUE_LEN);if(g===''||h===''||/^\d+[.)]$/['test'](g))continue;const i=g['toLowerCase']();if(c['has'](i))continue;c['add'](i),b['push']({'key':i,'raw_key':g,'value':h});if(b['length']>=MAX_LINES_SCANNED)break;}return b;}export function firstStructuredValue(a,b){const c=new Set(b['map'](d=>d['toLowerCase']()));for(const d of a){if(c['has'](d['key']))return d['value'];}return null;}
|
|
@@ -86,12 +86,18 @@ export interface EvaluationFinding {
|
|
|
86
86
|
message: string;
|
|
87
87
|
deduction: number;
|
|
88
88
|
}
|
|
89
|
+
export interface RedFlagBasis {
|
|
90
|
+
flag: string;
|
|
91
|
+
basis: "object_defect" | "requirement_unmet";
|
|
92
|
+
rule_id?: string;
|
|
93
|
+
}
|
|
89
94
|
export interface EvaluationResult {
|
|
90
95
|
evaluation_id: string;
|
|
91
96
|
total: number;
|
|
92
97
|
level: EvaluationLevel;
|
|
93
98
|
breakdown: EvaluationBreakdown[];
|
|
94
99
|
red_flags: string[];
|
|
100
|
+
red_flag_basis?: RedFlagBasis[];
|
|
95
101
|
blocked: boolean;
|
|
96
102
|
trace: EvaluationTraceEntry[];
|
|
97
103
|
summary: string;
|