@wowok/agent-mcp 3.1.0 → 3.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/config/runtime.js +1 -1
- package/dist/customer/index.d.ts +3 -9
- package/dist/customer/index.js +1 -1
- package/dist/customer/industry-risks.d.ts +3 -17
- package/dist/customer/industry-risks.js +1 -1
- package/dist/customer/types.d.ts +1 -165
- package/dist/customer/types.js +1 -1
- package/dist/customer/user-preferences.d.ts +0 -49
- package/dist/customer/user-preferences.js +1 -1
- package/dist/evaluation/arbitration-game.js +1 -1
- package/dist/evaluation/architecture.spec.d.ts +1 -0
- package/dist/evaluation/architecture.spec.js +1 -0
- package/dist/evaluation/builtins/graph-service.d.ts +16 -0
- package/dist/evaluation/builtins/graph-service.js +1 -0
- package/dist/evaluation/builtins/graph-service.spec.d.ts +1 -0
- package/dist/evaluation/builtins/graph-service.spec.js +1 -0
- package/dist/evaluation/builtins/index.d.ts +1 -1
- package/dist/evaluation/builtins/index.js +1 -1
- package/dist/evaluation/builtins/purity.spec.d.ts +1 -0
- package/dist/evaluation/builtins/purity.spec.js +1 -0
- package/dist/evaluation/engine.js +1 -1
- package/dist/evaluation/facets/catalog.d.ts +19 -0
- package/dist/evaluation/facets/catalog.js +1 -0
- package/dist/evaluation/guard-scan.d.ts +10 -0
- package/dist/evaluation/guard-scan.js +1 -0
- package/dist/evaluation/location-match.js +1 -1
- package/dist/evaluation/standards.d.ts +31 -0
- package/dist/evaluation/standards.js +1 -0
- package/dist/evaluation/standards.spec.d.ts +1 -0
- package/dist/evaluation/standards.spec.js +1 -0
- package/dist/evaluation/types.d.ts +9 -0
- package/dist/experience/realtime-feedback.js +1 -1
- package/dist/extensions/index.d.ts +1 -1
- package/dist/extensions/index.js +1 -1
- package/dist/extensions/industry-layers.d.ts +6 -5
- package/dist/extensions/industry-layers.js +1 -1
- package/dist/extensions/industry-pack.js +1 -1
- package/dist/goal/GoalClassifier.js +1 -1
- package/dist/graph/onchain/analyze.d.ts +16 -3
- package/dist/graph/onchain/analyze.js +1 -1
- package/dist/graph/onchain/analyze.spec.js +1 -1
- package/dist/graph/onchain/dataplane.d.ts +1 -1
- package/dist/graph/onchain/dataplane.js +1 -1
- package/dist/graph/onchain/edge-batch.spec.d.ts +1 -0
- package/dist/graph/onchain/edge-batch.spec.js +1 -0
- package/dist/graph/onchain/edge-schema.d.ts +11 -3
- package/dist/graph/onchain/edge-schema.js +1 -1
- package/dist/graph/onchain/entity-profile.spec.d.ts +1 -0
- package/dist/graph/onchain/entity-profile.spec.js +1 -0
- package/dist/graph/onchain/event-history.spec.d.ts +1 -0
- package/dist/graph/onchain/event-history.spec.js +1 -0
- package/dist/graph/onchain/expand.js +1 -1
- package/dist/graph/onchain/extract-deep.spec.d.ts +1 -0
- package/dist/graph/onchain/extract-deep.spec.js +1 -0
- package/dist/graph/onchain/extract.d.ts +11 -3
- package/dist/graph/onchain/extract.js +1 -1
- package/dist/graph/onchain/facet-projection.d.ts +99 -0
- package/dist/graph/onchain/facet-projection.js +1 -0
- package/dist/graph/onchain/facet-projection.spec.d.ts +1 -0
- package/dist/graph/onchain/facet-projection.spec.js +1 -0
- package/dist/graph/onchain/facts.d.ts +103 -0
- package/dist/graph/onchain/facts.js +1 -0
- package/dist/graph/onchain/facts.spec.d.ts +1 -0
- package/dist/graph/onchain/facts.spec.js +1 -0
- package/dist/graph/onchain/field-manifest.d.ts +29 -0
- package/dist/graph/onchain/field-manifest.js +1 -0
- package/dist/graph/onchain/field-manifest.spec.d.ts +1 -0
- package/dist/graph/onchain/field-manifest.spec.js +1 -0
- package/dist/graph/onchain/fixtures.d.ts +80 -0
- package/dist/graph/onchain/fixtures.js +1 -0
- package/dist/graph/onchain/fixtures.spec.d.ts +1 -0
- package/dist/graph/onchain/fixtures.spec.js +1 -0
- package/dist/graph/onchain/index.d.ts +8 -2
- package/dist/graph/onchain/index.js +1 -1
- package/dist/graph/onchain/interest.js +1 -1
- package/dist/graph/onchain/label-lint.spec.d.ts +1 -0
- package/dist/graph/onchain/label-lint.spec.js +1 -0
- package/dist/graph/onchain/names.d.ts +23 -0
- package/dist/graph/onchain/names.js +1 -0
- package/dist/graph/onchain/names.spec.d.ts +1 -0
- package/dist/graph/onchain/names.spec.js +1 -0
- package/dist/graph/onchain/onchain.spec.js +1 -1
- package/dist/graph/onchain/proposal-graph.d.ts +11 -0
- package/dist/graph/onchain/proposal-graph.js +1 -0
- package/dist/graph/onchain/proposal-graph.spec.d.ts +1 -0
- package/dist/graph/onchain/proposal-graph.spec.js +1 -0
- package/dist/graph/onchain/sdk-batch.d.ts +5 -1
- package/dist/graph/onchain/sdk-batch.js +1 -1
- package/dist/graph/onchain/sdk-dataplane.js +1 -1
- package/dist/graph/onchain/strategy.d.ts +16 -0
- package/dist/graph/onchain/strategy.js +1 -1
- package/dist/graph/onchain/strategy.spec.js +1 -1
- package/dist/graph/onchain/table-ledger.spec.d.ts +1 -0
- package/dist/graph/onchain/table-ledger.spec.js +1 -0
- package/dist/graph/onchain/types.d.ts +51 -11
- package/dist/graph/onchain/viewport.d.ts +1 -0
- package/dist/graph/onchain/viewport.js +1 -1
- package/dist/harness/index.d.ts +1 -5
- package/dist/harness/index.js +1 -1
- package/dist/harness/verify.d.ts +6 -1
- package/dist/harness/verify.js +1 -1
- package/dist/index.js +1 -1
- package/dist/knowledge/allocation-ledger.d.ts +2 -0
- package/dist/knowledge/allocation-ledger.js +1 -1
- package/dist/knowledge/allocation-puzzle.js +1 -1
- package/dist/knowledge/allocation-risk.d.ts +2 -3
- package/dist/knowledge/allocation-risk.js +1 -1
- package/dist/knowledge/arb-risk.d.ts +0 -1
- package/dist/knowledge/arb-risk.js +1 -1
- package/dist/knowledge/arbitration-risk.d.ts +0 -2
- package/dist/knowledge/arbitration-risk.js +1 -1
- package/dist/knowledge/baselines/evaluation-baselines.json +79 -0
- package/dist/knowledge/baselines/guard-lint-baseline.spec.d.ts +1 -0
- package/dist/knowledge/baselines/guard-lint-baseline.spec.js +1 -0
- package/dist/knowledge/baselines/risk-baselines.spec.d.ts +1 -0
- package/dist/knowledge/baselines/risk-baselines.spec.js +1 -0
- package/dist/knowledge/baselines/risk-cases.d.ts +8 -0
- package/dist/knowledge/baselines/risk-cases.js +1 -0
- package/dist/knowledge/bridge-risk.d.ts +0 -1
- package/dist/knowledge/bridge-risk.js +1 -1
- package/dist/knowledge/contact-risk.d.ts +0 -1
- package/dist/knowledge/contact-risk.js +1 -1
- package/dist/knowledge/contract-invariants.d.ts +1 -0
- package/dist/knowledge/contract-invariants.js +1 -1
- package/dist/knowledge/demand-risk.d.ts +0 -1
- package/dist/knowledge/demand-risk.js +1 -1
- package/dist/knowledge/getting-started.js +1 -1
- package/dist/knowledge/guard-design-patterns.js +1 -1
- package/dist/knowledge/guard-eval.d.ts +15 -0
- package/dist/knowledge/guard-eval.js +1 -0
- package/dist/knowledge/guard-eval.spec.d.ts +1 -0
- package/dist/knowledge/guard-eval.spec.js +1 -0
- package/dist/knowledge/guard-field-cognition.d.ts +48 -0
- package/dist/knowledge/guard-field-cognition.js +1 -0
- package/dist/knowledge/guard-lint.d.ts +1 -1
- package/dist/knowledge/guard-lint.js +1 -1
- package/dist/knowledge/guard-risk.d.ts +4 -19
- package/dist/knowledge/guard-risk.js +1 -1
- package/dist/knowledge/index.d.ts +42 -43
- package/dist/knowledge/index.js +1 -1
- package/dist/knowledge/industry-registry.js +1 -1
- package/dist/knowledge/industry-rule-node.d.ts +7 -0
- package/dist/knowledge/industry-rule-node.js +1 -0
- package/dist/knowledge/industry-strategy.js +1 -1
- package/dist/knowledge/jsonrpc-enum.js +1 -1
- package/dist/knowledge/machine-risk.d.ts +0 -6
- package/dist/knowledge/machine-risk.js +1 -1
- package/dist/knowledge/order-risk.d.ts +1 -9
- package/dist/knowledge/order-risk.js +1 -1
- package/dist/knowledge/payment-risk.d.ts +0 -1
- package/dist/knowledge/payment-risk.js +1 -1
- package/dist/knowledge/permission-risk.d.ts +0 -3
- package/dist/knowledge/permission-risk.js +1 -1
- package/dist/knowledge/personal-risk.d.ts +0 -1
- package/dist/knowledge/personal-risk.js +1 -1
- package/dist/knowledge/progress-risk.d.ts +0 -2
- package/dist/knowledge/progress-risk.js +1 -1
- package/dist/knowledge/proof-risk.d.ts +0 -1
- package/dist/knowledge/proof-risk.js +1 -1
- package/dist/knowledge/puzzle-projections.d.ts +11 -0
- package/dist/knowledge/puzzle-projections.js +1 -0
- package/dist/knowledge/recipient-constraint.d.ts +6 -1
- package/dist/knowledge/recipient-constraint.js +1 -1
- package/dist/knowledge/registrar-risk.d.ts +0 -1
- package/dist/knowledge/registrar-risk.js +1 -1
- package/dist/knowledge/repository-risk.d.ts +0 -1
- package/dist/knowledge/repository-risk.js +1 -1
- package/dist/knowledge/resource-risk.d.ts +0 -1
- package/dist/knowledge/resource-risk.js +1 -1
- package/dist/knowledge/reward-risk.d.ts +1 -5
- package/dist/knowledge/reward-risk.js +1 -1
- package/dist/knowledge/rule-node-analyzers.d.ts +43 -0
- package/dist/knowledge/rule-node-analyzers.js +1 -0
- package/dist/knowledge/rule-node-analyzers.spec.d.ts +1 -0
- package/dist/knowledge/rule-node-analyzers.spec.js +1 -0
- package/dist/knowledge/rule-outcome.d.ts +5 -0
- package/dist/knowledge/rule-outcome.js +1 -0
- package/dist/knowledge/safety-rules.js +1 -1
- package/dist/knowledge/scenario-topology.js +1 -1
- package/dist/knowledge/service-allocator-audit-node.d.ts +3 -0
- package/dist/knowledge/service-allocator-audit-node.js +1 -0
- package/dist/knowledge/service-risk-node.js +1 -1
- package/dist/knowledge/service-risk.d.ts +0 -3
- package/dist/knowledge/service-risk.js +1 -1
- package/dist/knowledge/template-registry.js +1 -1
- package/dist/knowledge/tools-reference.js +1 -1
- package/dist/knowledge/treasury-risk.d.ts +2 -3
- package/dist/knowledge/treasury-risk.js +1 -1
- package/dist/knowledge/util-risk.d.ts +0 -1
- package/dist/knowledge/util-risk.js +1 -1
- package/dist/knowledge/workflow-guidance.d.ts +2 -0
- package/dist/knowledge/workflow-guidance.js +1 -1
- package/dist/monitor/MonitorLoop.js +1 -1
- package/dist/persona/bridge.js +1 -1
- package/dist/persona/facet-profile.d.ts +33 -0
- package/dist/persona/facet-profile.js +1 -0
- package/dist/persona/model.d.ts +2 -1
- package/dist/persona/model.js +1 -1
- package/dist/persona/strategy-intent.js +1 -1
- package/dist/persona/topology-focus.d.ts +2 -2
- package/dist/persona/topology-focus.js +1 -1
- package/dist/persona/types.d.ts +12 -0
- package/dist/playbooks/service-build/business-puzzle.js +1 -1
- package/dist/playbooks/service-build/facet-money.d.ts +22 -0
- package/dist/playbooks/service-build/facet-money.js +1 -0
- package/dist/playbooks/service-build/facet-money.spec.d.ts +1 -0
- package/dist/playbooks/service-build/facet-money.spec.js +1 -0
- package/dist/playbooks/service-build/intent-analyzer.js +1 -1
- package/dist/playbooks/service-build/machine-panorama.d.ts +3 -0
- package/dist/playbooks/service-build/machine-panorama.js +1 -1
- package/dist/playbooks/service-build/object-panorama.d.ts +27 -27
- package/dist/playbooks/service-build/object-panorama.js +1 -1
- package/dist/playbooks/service-build/pipeline-actions.d.ts +2 -2
- package/dist/playbooks/service-build/pipeline-actions.js +1 -1
- package/dist/playbooks/service-build/risk-aggregator.d.ts +2 -1
- package/dist/playbooks/service-build/risk-aggregator.js +1 -1
- package/dist/playbooks/service-build/service-panorama.d.ts +4 -9
- package/dist/playbooks/service-build/service-panorama.js +1 -1
- package/dist/playbooks/service-build/topology-evaluation.spec.d.ts +1 -0
- package/dist/playbooks/service-build/topology-evaluation.spec.js +1 -0
- package/dist/playbooks/service-build/topology-query.d.ts +13 -2
- package/dist/playbooks/service-build/topology-query.js +1 -1
- package/dist/review/arb.d.ts +0 -2
- package/dist/review/arb.js +1 -1
- package/dist/review/order.d.ts +0 -1
- package/dist/review/order.js +1 -1
- package/dist/role/profiles.js +1 -1
- package/dist/rules.d.ts +1 -2
- package/dist/rules.js +1 -1
- package/dist/safety/confirm-gate.js +1 -1
- package/dist/safety/preview.js +1 -1
- package/dist/schema/call/base.d.ts +3372 -668
- package/dist/schema/call/base.js +1 -1
- package/dist/schema/call/handler.js +1 -1
- package/dist/schema/call/receipt.d.ts +28 -0
- package/dist/schema/call/receipt.js +1 -0
- package/dist/schema/call/semantic-customer-advice.spec.d.ts +1 -0
- package/dist/schema/call/semantic-customer-advice.spec.js +1 -0
- package/dist/schema/call/semantic.d.ts +5 -2
- package/dist/schema/call/semantic.js +1 -1
- package/dist/schema/call/treasury.js +1 -1
- package/dist/schema/common/index.js +1 -1
- package/dist/schema/evaluation/index.d.ts +289 -211
- package/dist/schema/evaluation/index.js +1 -1
- package/dist/schema/goal/index.d.ts +1 -1
- package/dist/schema/goal/planning.d.ts +2 -2
- package/dist/schema/index.d.ts +0 -1
- package/dist/schema/index.js +1 -1
- package/dist/schema/industry-pack/index.d.ts +1 -1
- package/dist/schema/keeper/index.d.ts +1 -1
- package/dist/schema/local/index.js +1 -1
- package/dist/schema/operations.d.ts +28 -10
- package/dist/schema/operations.js +1 -1
- package/dist/schema/persona/index.d.ts +24 -24
- package/dist/schema/query/bi.d.ts +629 -14
- package/dist/schema/query/bi.js +1 -1
- package/dist/schema/query/index.d.ts +9 -9
- package/dist/schema/query/index.js +1 -1
- package/dist/schema/schema-version.js +1 -1
- package/dist/schema/workspace/index.d.ts +2 -2
- package/dist/schema-query-impl/index.js +1 -1
- package/dist/schemas/account_operation.output.json +10 -10
- package/dist/schemas/account_operation.schema.json +3 -3
- package/dist/schemas/bridge_operation.output.json +10 -10
- package/dist/schemas/evaluation_operation.output.json +697 -169
- package/dist/schemas/evaluation_operation.schema.json +5 -434
- package/dist/schemas/index.json +1 -7
- package/dist/schemas/keeper_operation.output.json +10 -10
- package/dist/schemas/local_history_operation.output.json +10 -10
- package/dist/schemas/local_info_operation.output.json +10 -10
- package/dist/schemas/local_mark_operation.output.json +10 -10
- package/dist/schemas/messenger_operation.output.json +10 -10
- package/dist/schemas/monitor_events.output.json +10 -10
- package/dist/schemas/monitor_subscription.output.json +10 -10
- package/dist/schemas/onchain_events.output.json +11 -11
- package/dist/schemas/onchain_operations.output.json +6369 -3736
- package/dist/schemas/onchain_operations.schema.json +48 -48
- package/dist/schemas/onchain_operations_allocation.schema.json +5 -5
- package/dist/schemas/onchain_operations_arbitration.schema.json +3 -3
- package/dist/schemas/onchain_operations_contact.schema.json +2 -2
- package/dist/schemas/onchain_operations_demand.schema.json +2 -2
- package/dist/schemas/onchain_operations_machine.schema.json +2 -2
- package/dist/schemas/onchain_operations_order.schema.json +2 -2
- package/dist/schemas/onchain_operations_payment.schema.json +2 -2
- package/dist/schemas/onchain_operations_permission.schema.json +2 -2
- package/dist/schemas/onchain_operations_progress.schema.json +2 -2
- package/dist/schemas/onchain_operations_repository.schema.json +2 -2
- package/dist/schemas/onchain_operations_reward.schema.json +6 -6
- package/dist/schemas/onchain_operations_service.schema.json +8 -8
- package/dist/schemas/onchain_operations_treasury.schema.json +10 -10
- package/dist/schemas/onchain_table_data.output.json +78 -84
- package/dist/schemas/query_toolkit.output.json +1087 -254
- package/dist/schemas/query_toolkit.schema.json +65 -3
- package/dist/strategy/collectors.js +1 -1
- package/dist/strategy/metrics.js +1 -1
- package/dist/task/playbook.js +1 -1
- package/dist/tools/handlers/bridge.js +1 -1
- package/dist/tools/handlers/config.js +1 -1
- package/dist/tools/handlers/dispatch-expectations.d.ts +3 -0
- package/dist/tools/handlers/dispatch-expectations.js +1 -0
- package/dist/tools/handlers/evaluation.js +1 -1
- package/dist/tools/handlers/evaluation.spec.js +1 -1
- package/dist/tools/handlers/onchain.js +1 -1
- package/dist/tools/handlers/query.js +1 -1
- package/dist/tools/index.js +1 -1
- package/dist/tools/registry/evaluation.d.ts +2 -0
- package/dist/tools/registry/evaluation.js +1 -0
- package/dist/tools/registry/monitor.js +1 -1
- package/dist/tools/registry/query.js +1 -1
- package/dist/tools/shared.d.ts +0 -1
- package/dist/tools/shared.js +1 -1
- package/dist/tools/wrap.js +1 -1
- package/package.json +4 -3
- package/dist/customer/customer-advice.d.ts +0 -32
- package/dist/customer/customer-advice.js +0 -1
- package/dist/customer/info-puzzle.d.ts +0 -146
- package/dist/customer/info-puzzle.js +0 -1
- package/dist/customer/order-strategy.d.ts +0 -17
- package/dist/customer/order-strategy.js +0 -1
- package/dist/customer/preorder-compare.d.ts +0 -24
- package/dist/customer/preorder-compare.js +0 -1
- package/dist/customer/reminder-system.d.ts +0 -42
- package/dist/customer/reminder-system.js +0 -1
- package/dist/customer/risk-assessment.d.ts +0 -13
- package/dist/customer/risk-assessment.js +0 -1
- package/dist/evaluation/builtins/service-risk.d.ts +0 -7
- package/dist/evaluation/builtins/service-risk.js +0 -1
- package/dist/knowledge/trust-metrics.d.ts +0 -66
- package/dist/knowledge/trust-metrics.js +0 -1
- package/dist/schema/trust/index.d.ts +0 -334
- package/dist/schema/trust/index.js +0 -1
- package/dist/schemas/trust_score.output.json +0 -847
- package/dist/schemas/trust_score.schema.json +0 -364
- package/dist/tools/handlers/trust.d.ts +0 -16
- package/dist/tools/handlers/trust.js +0 -1
- package/dist/tools/registry/trust.d.ts +0 -2
- package/dist/tools/registry/trust.js +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const GUARD_FIELD_COGNITION_VERSION='1.1.0';const NUMBER='number\x20(common::is_number_type)',U64='u64\x20exactly\x20(common::TYPE_U64)',ADDRESS='address\x20or\x20address-compatible\x20object\x20id';export const GUARD_FIELD_SITES=[{'object':'Treasury','field':'external_withdraw_guard[]\x20(AmountFromWithdrawGuard)','mode':'gate+source','extraction':[{'name':'identifier\x20(amount)','meaning':'Exact\x20withdraw\x20amount\x20moved\x20out\x20of\x20the\x20treasury\x20balance','allowedOrigins':['submission','fixed'],'typeConstraint':NUMBER,'configCheck':'external_withdraw_guard_add:\x20get_submission_value_type\x20must\x20be\x20Some\x20+\x20is_number_type\x20(E_IDENTIFIER_NOT_NUMBER_TYPE)','runtimeFallback':'submission_get\x20falls\x20back\x20to\x20the\x20fixed\x20table\x20value;\x20if\x20neither\x20exists\x20the\x20tx\x20aborts\x20(E_SUBMISSION_ID_NOT_FOUND)','riskNotes':['submission\x20origin\x20=\x20passport\x20builder\x20chooses\x20the\x20amount;\x20only\x20the\x20balance\x20check\x20(E_WITHDRAW_BALANCE_INSUFFICIENT)\x20bounds\x20it','fixed\x20origin\x20=\x20same\x20amount\x20every\x20withdrawal;\x20safe\x20default\x20for\x20allowance-style\x20guards','query\x20origin\x20is\x20impossible\x20for\x20this\x20slot\x20—\x20a\x20query\x20can\x20only\x20gate,\x20never\x20supply\x20the\x20amount']},{'name':'store_from_id\x20(optional)','meaning':'Secondary\x20slot\x20decoded\x20as\x20address;\x20recorded\x20in\x20Treasury\x20history\x20Record\x20for\x20traceability','allowedOrigins':['submission','fixed'],'typeConstraint':ADDRESS,'configCheck':'is_identifier_address_compatible\x20(E_STORE_FROM_ID_NOT_COMPATIBLE)','runtimeFallback':'None\x20->\x20Record.store_from_id\x20=\x20none','riskNotes':['Bookkeeping\x20only;\x20never\x20used\x20as\x20the\x20withdrawal\x20recipient']}],'gateBehavior':'passport::result_for_guard\x20must\x20pass\x20AND\x20the\x20guard\x20address\x20must\x20be\x20registered\x20in\x20external_withdraw_guard\x20(E_EXTERNAL_WITHDRAW_GUARD_NOT_FOUND)','setterChecklist':['Decide\x20who\x20builds\x20passports\x20against\x20this\x20guard\x20—\x20that\x20party\x20controls\x20a\x20submission-origin\x20amount','Prefer\x20a\x20fixed\x20amount\x20for\x20allowance\x20guards;\x20reserve\x20submission\x20amounts\x20for\x20flows\x20where\x20the\x20passport\x20builder\x20is\x20trusted\x20or\x20the\x20amount\x20is\x20re-verified\x20inside\x20the\x20guard\x20expression\x20(e.g.\x20compare\x20against\x20order.amount\x20via\x20query\x201561)','The\x20RECIPIENT\x20is\x20tx-supplied,\x20not\x20from\x20the\x20guard\x20—\x20constrain\x20it\x20inside\x20the\x20guard\x20expression\x20(e.g.\x20compare\x20a\x20submitted\x20address\x20against\x20an\x20expected\x20one)\x20if\x20destination\x20matters','Check\x20guard\x20is_depended\x20status\x20only\x20matters\x20if\x20this\x20guard\x20will\x20rely\x20on\x20others\x20(relies\x20<=\x204,\x20added\x20first)'],'auditorChecklist':['For\x20each\x20registered\x20guard:\x20classify\x20amount\x20slot\x20as\x20fixed\x20or\x20submission\x20(read\x20b_submission\x20in\x20the\x20table)','If\x20submission:\x20who\x20can\x20hold/build\x20a\x20passport\x20with\x20this\x20guard?\x20Can\x20a\x20stranger\x20drain\x20the\x20treasury\x20up\x20to\x20its\x20balance?','Does\x20the\x20guard\x20expression\x20bind\x20the\x20submission\x20to\x20on-chain\x20state\x20(order,\x20repository\x20data)\x20or\x20is\x20it\x20free-form?','Is\x20the\x20withdrawal\x20recipient\x20constrained\x20anywhere?']},{'object':'Treasury','field':'external_deposit_guard[]\x20(AmountFromDepositGuard)','mode':'gate+source','extraction':[{'name':'identifier\x20(amount,\x20Option)','meaning':'When\x20Some:\x20exact\x20deposit\x20amount\x20split\x20from\x20the\x20coin\x20(remainder\x20returned\x20to\x20caller).\x20When\x20None:\x20whole\x20coin\x20deposited','allowedOrigins':['submission','fixed'],'typeConstraint':NUMBER,'configCheck':'same\x20as\x20withdraw:\x20is_number_type\x20when\x20Some','runtimeFallback':'None\x20->\x20entire\x20coin\x20deposited;\x20Some\x20->\x20coin::split\x20to\x20`value`,\x20remainder\x20transferred\x20back\x20to\x20sender','riskNotes':['A\x20submission-origin\x20amount\x20below\x20the\x20coin\x20total\x20silently\x20returns\x20the\x20difference\x20to\x20the\x20caller\x20—\x20intended\x20for\x20partial\x20deposits','Deposits\x20cannot\x20steal\x20funds;\x20the\x20risk\x20direction\x20is\x20mis-recorded\x20history\x20only']},{'name':'store_from_id\x20(optional)','meaning':'Address\x20slot\x20recorded\x20on\x20the\x20deposit\x20Record','allowedOrigins':['submission','fixed'],'typeConstraint':ADDRESS,'configCheck':'is_identifier_address_compatible','runtimeFallback':'None\x20->\x20none','riskNotes':['Traceability\x20only']}],'gateBehavior':'result_for_guard\x20+\x20guard\x20must\x20be\x20registered\x20(E_EXTERNAL_DEPOSIT_GUARD_NOT_FOUND)','setterChecklist':['None\x20identifier\x20=\x20whole-coin\x20deposit;\x20Some\x20=\x20exact-amount\x20deposit\x20with\x20refund\x20of\x20the\x20remainder'],'auditorChecklist':['Confirm\x20the\x20amount\x20slot\x20origin\x20matches\x20the\x20intended\x20deposit\x20UX\x20(whole\x20vs\x20exact)']},{'object':'Reward','field':'guards[]\x20(RewardGuard)','mode':'gate+source','extraction':[{'name':'recipient\x20(Recipient::GuardIdentifier)','meaning':'Claim\x20payout\x20destination\x20address','allowedOrigins':['submission','fixed'],'typeConstraint':ADDRESS,'configCheck':'is_identifier_address\x20(E_RECIPIENT_IDENTIFIER_NOT_ADDRESS)','runtimeFallback':'Entity/Signer\x20variants\x20bypass\x20extraction\x20entirely','riskNotes':['submission\x20origin\x20=\x20passport\x20builder\x20redirects\x20the\x20payout\x20to\x20any\x20address\x20it\x20names']},{'name':'amount\x20(Amount::GuardU64Identifier)','meaning':'Claim\x20size\x20paid\x20from\x20the\x20Reward\x20balance','allowedOrigins':['submission','fixed'],'typeConstraint':U64,'configCheck':'get_submission_value_type\x20==\x20TYPE_U64\x20(E_AMOUNT_NOT_U64)','runtimeFallback':'Fixed(u64)\x20variant\x20bypasses\x20extraction','riskNotes':['submission\x20origin\x20=\x20passport\x20builder\x20decides\x20the\x20claim\x20size;\x20only\x20balance\x20and\x20per-recipient\x20record\x20bound\x20it']},{'name':'store_from_id\x20(optional)','meaning':'Address\x20slot\x20recorded\x20in\x20the\x20per-recipient\x20claim\x20Record','allowedOrigins':['submission','fixed'],'typeConstraint':ADDRESS,'configCheck':'is_identifier_address_compatible\x20(E_STORE_FROM_ID_NOT_COMPATIBLE)','runtimeFallback':'None\x20->\x20none','riskNotes':['Traceability\x20only']}],'gateBehavior':'claim:\x20result_for_guard\x20+\x20expiration_time\x20check\x20+\x20guard\x20registered\x20(E_GUARD_NOT_FOUND);\x20guard_not_added_expiration_time\x20freezes\x20the\x20guard\x20set','setterChecklist':['Recipient+amount\x20both\x20submission\x20=\x20the\x20passport\x20builder\x20fully\x20controls\x20who\x20gets\x20paid\x20how\x20much\x20—\x20acceptable\x20only\x20for\x20self-service\x20claim\x20flows\x20where\x20the\x20builder\x20IS\x20the\x20beneficiary','expiration_time\x20on\x20the\x20RewardGuard\x20bounds\x20the\x20window\x20(E_GUARD_EXPIRED)'],'auditorChecklist':['For\x20each\x20guard:\x20are\x20recipient/amount\x20fixed\x20or\x20submission?','If\x20submission:\x20does\x20the\x20guard\x20expression\x20bind\x20them\x20to\x20repository\x20data\x20(1167)\x20or\x20an\x20order\x20so\x20the\x20claim\x20is\x20justified?','Is\x20there\x20a\x20per-recipient\x20cap?\x20(Only\x20the\x20historical\x20record\x20total\x20accumulates;\x20there\x20is\x20no\x20per-claim\x20limit.)']},{'object':'Repository','field':'policies[].write_guard[]\x20(PolicyGuard)','mode':'gate+source','extraction':[{'name':'id_from_submission\x20(Option<u8>)','meaning':'Data-record\x20key\x20(address)\x20extracted\x20from\x20the\x20guard\x20instead\x20of\x20caller-supplied','allowedOrigins':['submission','fixed'],'typeConstraint':ADDRESS,'configCheck':'is_identifier_address_compatible\x20(E_INVALID_ID_IN_GUARD_TABLE)','runtimeFallback':'None\x20->\x20id\x20comes\x20from\x20the\x20caller\x20vector\x20or\x20gen_id\x20(clock/signer)','riskNotes':['Policy-level\x20conflicts:\x20id_from\x20=\x20Clock/Signer\x20FORBIDS\x20id_from_submission\x20(E_POLICY_ID_FROM_SUBMISSION_FORBIDDEN);\x20id_from\x20=\x20None\x20REQUIRES\x20a\x20non-empty\x20write_guard\x20(E_POLICY_WRITE_GUARD_REQUIRED)']},{'name':'data_from_submission\x20(Option<u8>)','meaning':'Data\x20payload\x20extracted\x20from\x20the\x20guard\x20instead\x20of\x20caller-supplied','allowedOrigins':['submission','fixed'],'typeConstraint':'any\x20repository-supported\x20value\x20type\x20(first\x20byte\x20=\x20value_type)','configCheck':'has_identifier\x20(E_INVALID_DATA_IN_GUARD_TABLE)','runtimeFallback':'None\x20->\x20data\x20comes\x20from\x20the\x20caller\x20vector','riskNotes':['Entry-point\x20routing\x20differs:\x20data_when_id_from_set_with_passport\x20consumes\x20data_from_submission;\x20id_data_with_passport\x20REJECTS\x20both\x20extraction\x20slots\x20(E_GUARD_SPECIFIED_ID_FROM_SUBMISSION);\x20id_data_mixed_with_passport\x20mixes\x20per-guard\x20extraction\x20with\x20caller\x20vectors','Setting\x20an\x20extraction\x20slot\x20on\x20a\x20guard\x20that\x20is\x20only\x20ever\x20used\x20via\x20id_data_with_passport\x20silently\x20means\x20\x27unused\x20config\x27\x20—\x20route\x20must\x20match']}],'gateBehavior':'write\x20path\x20must\x20find\x20the\x20guard\x20in\x20the\x20policy\x20(E_GUARD_SPECIFIED_NOT_IN_POLICY)\x20and\x20pass\x20result_for_guard\x20or\x20result_for_permission\x20(impack\x20membership)','setterChecklist':['Match\x20the\x20policy\x20id_from\x20with\x20the\x20guard\x20slots\x20(see\x20conflicts\x20above)','Pick\x20the\x20write\x20entry\x20point\x20first,\x20then\x20decide\x20which\x20extraction\x20slots\x20that\x20entry\x20point\x20actually\x20honors'],'auditorChecklist':['For\x20each\x20write_guard:\x20which\x20entry\x20points\x20can\x20reach\x20it\x20and\x20which\x20slots\x20do\x20those\x20entry\x20points\x20consume?','A\x20policy\x20with\x20write_guard\x20but\x20id_from=None\x20and\x20no\x20extraction\x20slots\x20still\x20gates\x20writes\x20—\x20verify\x20the\x20guard\x20expression\x20actually\x20restricts\x20who\x20can\x20write']},{'object':'Repository','field':'policies[].quote_guard\x20(Option<address>)','mode':'source','extraction':[{'name':'repository.data\x20(query\x201167\x20params:\x20key,\x20id)','meaning':'Read\x20authorization\x20for\x20private\x20repository\x20data\x20inside\x20guard\x20expressions','allowedOrigins':['query'],'typeConstraint':'(String\x20key,\x20Address\x20id)\x20pair','configCheck':'policy_quote_guard_set:\x20guard::is_depended\x20(relies\x20empty\x20+\x20immutable\x20+\x20rep\x20true,\x20E_NEED_DEPENDENT_GUARD)','runtimeFallback':'None\x20->\x201167\x20queries\x20abort\x20(GUARD_QUERY_OBJECT_INVALID\x20/\x20quote_guard\x20check)','riskNotes':['Runtime\x20check\x20is\x20hardcoded\x20in\x20passport.rs:\x20the\x20querying\x20guard\x20must\x20be\x20a\x20member\x20of\x20the\x20passport\x20impack\x20list','rep\x20flag\x20comes\x20from\x20the\x20native\x20parse\x20at\x20guard\x20creation\x20—\x20a\x20guard\x20that\x20fails\x20rep\x20cannot\x20serve\x20as\x20quote_guard']}],'gateBehavior':'No\x20direct\x20gate\x20—\x20this\x20guard\x20authorizes\x20DATA\x20READS\x20performed\x20by\x20other\x20guards','setterChecklist':['Only\x20a\x20fresh,\x20immutable,\x20reliance-free\x20guard\x20(is_depended)\x20qualifies','Register\x20it\x20on\x20the\x20same\x20Repository\x20whose\x20data\x20will\x20be\x20quoted'],'auditorChecklist':['Which\x20guards\x20rely\x20on\x20/\x20are\x20bundled\x20with\x20this\x20quote_guard\x20in\x20passports?\x20(impack\x20membership\x20decides)','Is\x20the\x20quoted\x20(key,id)\x20scoped\x20narrowly\x20enough,\x20or\x20does\x20one\x20quote_guard\x20open\x20the\x20whole\x20policy?']},{'object':'Arbitration','field':'voting_guard[]\x20(VotingGuard)','mode':'gate+source','extraction':[{'name':'vote_weight\x20(VoteValue::GuardIdentifier)','meaning':'Voter\x27s\x20weighted\x20voting\x20power','allowedOrigins':['submission','fixed'],'typeConstraint':NUMBER+',\x20value\x20<=\x20u32\x20max\x20(E_GUARD_IDENTIFIER_NUMBER_INVALID)','configCheck':'is_number_type\x20(E_GUARD_IDENTIFIER_NOT_NUMBER)','runtimeFallback':'FixedValue\x20variant\x20bypasses\x20extraction','riskNotes':['submission\x20origin\x20=\x20the\x20passport\x20builder\x20assigns\x20its\x20own\x20voting\x20weight\x20—\x20dangerous\x20unless\x20the\x20guard\x20expression\x20derives\x20the\x20weight\x20from\x20trusted\x20state\x20(e.g.\x20repository\x20holdings\x20via\x201167)']}],'gateBehavior':'vote_with_voting_guard:\x20result_for_guard\x20+\x20guard\x20registered\x20(E_VOTING_GUARD_NOT_FOUND)','setterChecklist':['Empty\x20voting_guard\x20=\x20open\x20voting\x20(everybody);\x20non-empty\x20=\x20only\x20listed\x20guards\x20may\x20vote','FixedValue\x20for\x20equal-weight\x20votes;\x20GuardIdentifier\x20only\x20when\x20the\x20expression\x20can\x20justify\x20the\x20weight'],'auditorChecklist':['If\x20GuardIdentifier:\x20can\x20a\x20voter\x20self-assign\x20a\x20maximal\x20weight\x20by\x20building\x20the\x20passport\x20alone?']},{'object':'Arbitration','field':'usage_guard\x20(Option<address>)','mode':'gate','extraction':[],'gateBehavior':'dispute_with_passport:\x20result_for_guard;\x20dispute()\x20without\x20a\x20passport\x20aborts\x20when\x20usage_guard\x20is\x20set\x20(E_NEED_PASSPORT).\x20Set\x20=\x20guarded\x20entry\x20to\x20filing\x20disputes','setterChecklist':['Set\x20to\x20restrict\x20who\x20can\x20open\x20disputes;\x20none\x20=\x20anyone\x20can\x20dispute'],'auditorChecklist':['Check\x20whether\x20disputing\x20requires\x20passing\x20this\x20guard\x20and\x20who\x20can\x20pass\x20it']},{'object':'Service','field':'buy_guard\x20(Option<address>)','mode':'gate','extraction':[],'gateBehavior':'buy_with_passport:\x20result_for_guard;\x20buy()\x20without\x20a\x20passport\x20aborts\x20when\x20set\x20(E_BUY_GUARD_PASSPORT_REQUIRED)','setterChecklist':['Pure\x20purchase\x20gate:\x20membership/whitelist/KYC\x20style;\x20no\x20slots\x20are\x20extracted'],'auditorChecklist':['Who\x20can\x20pass\x20it;\x20does\x20it\x20gate\x20every\x20sale\x20item\x20equally\x20(it\x20is\x20service-wide,\x20not\x20per-sale)']},{'object':'Demand','field':'guards[]\x20(ServiceGuard)','mode':'gate+source','extraction':[{'name':'service_identifier\x20(Option<u8>)','meaning':'Presented\x20Service\x20address;\x20overrides\x20the\x20caller-supplied\x20service\x20in\x20present_service','allowedOrigins':['submission','fixed'],'typeConstraint':'address\x20slot\x20whose\x20object\x20type\x20must\x20be\x20Service\x20(get_submission_object_type\x20at\x20guard_add)','configCheck':'object\x20type\x20check\x20against\x20the\x20guard\x20validated\x20table\x20(E_GUARD_IDS_TYPE_ERROR\x20at\x20verify)','runtimeFallback':'None\x20->\x20caller\x20names\x20the\x20presented\x20service\x20directly','riskNotes':['fixed\x20origin\x20hard-pins\x20which\x20Service\x20may\x20answer\x20this\x20Demand\x20through\x20this\x20guard','submission\x20origin\x20lets\x20the\x20passport\x20builder\x20pick\x20any\x20Service\x20—\x20verify\x20the\x20guard\x20expression\x20restricts\x20it']}],'gateBehavior':'present_with_passport:\x20result_for_guard\x20+\x20guard\x20registered\x20(E_GUARD_NOT_FOUND)','setterChecklist':['Set\x20service_identifier\x20to\x20pin\x20the\x20answering\x20service;\x20leave\x20None\x20for\x20open\x20presentation'],'auditorChecklist':['Origin\x20of\x20service_identifier;\x20if\x20submission,\x20who\x20can\x20present\x20what']},{'object':'Machine','field':'node.pair.forward.guard\x20(ForwardGuard)','mode':'gate+source','extraction':[{'name':'retained_submission\x20(vector<u8>\x20identifiers)','meaning':'Submission\x20values\x20retained\x20into\x20Progress\x20Holder.retained_submission\x20(e.g.\x20sub-order\x20/\x20procured-service\x20evidence)\x20when\x20the\x20forward\x20executes','allowedOrigins':['submission'],'typeConstraint':'identifiers\x20must\x20exist\x20as\x20submission\x20slots\x20(has_submissions,\x20E_RETAINED_SUBMISSION_ERROR)','configCheck':'forward_with_guard\x20validates\x20the\x20identifiers\x20against\x20the\x20guard\x20table','runtimeFallback':'empty\x20list\x20->\x20gate\x20only,\x20nothing\x20retained;\x20non-empty\x20->\x20passport::submissions_get\x20copies\x20the\x20values\x20into\x20the\x20session\x20history','riskNotes':['This\x20is\x20the\x20mechanism\x20that\x20carries\x20sub-order\x20data\x20from\x20an\x20operator\x27s\x20passport\x20into\x20the\x20order\x27s\x20Progress\x20history\x20—\x20downstream\x20analyzers\x20read\x20it\x20(queries\x201266-1268,\x201279)']}],'gateBehavior':'Progress.next_with_passport:\x20guard\x20is\x20the\x20optional\x20pre/post\x20verification\x20layer\x20for\x20advancing\x20a\x20node;\x20namedOperator/permissionIndex\x20can\x20be\x20replaced\x20by\x20a\x20guard','setterChecklist':['Choose\x20which\x20submission\x20slots\x20are\x20worth\x20retaining\x20as\x20durable\x20evidence','Remember\x20the\x20order\x20of\x20verification:\x20dependent\x20guards\x20must\x20be\x20added\x20to\x20the\x20passport\x20first'],'auditorChecklist':['For\x20each\x20guarded\x20forward:\x20does\x20the\x20retained\x20data\x20actually\x20prove\x20the\x20transition\x20claim\x20(sub-order\x20id,\x20amount)?']},{'object':'Allocation','field':'allocators[].guard\x20(Allocator)','mode':'gate+source','extraction':[{'name':'sharing\x20Recipient::GuardIdentifier','meaning':'Payout\x20recipient\x20address\x20for\x20that\x20sharing\x20line','allowedOrigins':['submission','fixed'],'typeConstraint':ADDRESS,'configCheck':'is_identifier_address\x20(ERECIPIENT_IDENTIFIER_NOT_ADDRESS)','runtimeFallback':'Entity/Signer\x20sharing\x20variants\x20bypass\x20extraction','riskNotes':['submission\x20origin\x20=\x20the\x20passport\x20builder\x20decides\x20the\x20split\x20destination\x20at\x20alloc()\x20time\x20—\x20the\x20ALC1\x20audit\x20treats\x20an\x20unbound\x20recipient\x20as\x20a\x20redirect\x20risk','for_object\x20anchor\x20(protocol\x20139):\x20when\x20the\x20Allocation\x27s\x20payment_info.for_object\x20is\x20Some,\x20alloc()\x20enforces\x20submitted\x20address\x20==\x20for_object\x20and\x20aborts\x20with\x20ERECIPIENT_NOT_FOR_OBJECT\x20(15)\x20on\x20mismatch\x20—\x20the\x20anchor\x20is\x20mechanism-enforced,\x20not\x20advisory','for_object\x20=\x20None\x20carries\x20NO\x20anchor:\x20nothing\x20is\x20enforced\x20on-chain\x20and\x20the\x20recipient\x20semantics\x20are\x20entirely\x20the\x20creator\x27s\x20business\x20(Allocation\x20is\x20a\x20generic\x20component;\x20only\x20host\x20flows\x20that\x20declare\x20a\x20binding\x20get\x20the\x20anchor)']}],'gateBehavior':'alloc:\x20the\x20passed\x20guard\x20address\x20must\x20equal\x20the\x20registered\x20allocator\x20guard;\x20result_for_guard\x20must\x20pass;\x20AllocationEvent\x20records\x20which\x20guard\x20ran','setterChecklist':['Bind\x20recipient\x20slots\x20inside\x20the\x20guard\x20expression\x20(signer\x20==\x20authorized\x20party,\x20state\x20==\x20expected\x20scope)\x20exactly\x20as\x20ALC1\x20expects','A\x20submission\x20slot\x20with\x20NO\x20scope\x20binding\x20=\x20HIGH\x20severity\x20finding','When\x20setting\x20payment_info:\x20for_object\x20=\x20Some\x20turns\x20it\x20into\x20an\x20enforced\x20anchor\x20—\x20every\x20GuardIdentifier\x20recipient\x20submission\x20must\x20equal\x20that\x20address\x20or\x20alloc()\x20aborts\x20(code\x2015);\x20verify\x20the\x20anchor\x20matches\x20the\x20intended\x20recipient\x20flow\x20BEFORE\x20create\x20(payment_info\x20is\x20immutable\x20after\x20create)','for_object\x20=\x20None\x20is\x20legal:\x20no\x20on-chain\x20anchor,\x20recipient\x20routing\x20is\x20then\x20purely\x20the\x20creator\x27s\x20design\x20—\x20flag\x20this\x20explicitly\x20in\x20the\x20plan\x20so\x20the\x20user\x20decides'],'auditorChecklist':['Cross-scenario\x20settlement\x20residual:\x20a\x20guard\x20bound\x20to\x20one\x20host\x20but\x20reusable\x20across\x20unrelated\x20callers\x20of\x20other\x20hosts','Every\x20submission\x20recipient\x20slot\x20must\x20have\x20a\x20scope\x20binding\x20(guard\x20expression\x20or\x20payment_info.for_object\x20anchor)\x20—\x20otherwise\x20funds\x20can\x20be\x20redirected','Check\x20payment_info.for_object:\x20Some\x20=\x20confirmed\x20enforced\x20anchor\x20(compare\x20against\x20intended\x20recipients);\x20None\x20=\x20trust-on-creator,\x20no\x20on-chain\x20enforcement\x20of\x20the\x20GuardIdentifier\x20destination']},{'object':'Payment','field':'info.for_guard\x20(PaymentInfo)','mode':'source','extraction':[{'name':'for_guard','meaning':'Provenance:\x20records\x20which\x20guard\x20context\x20produced\x20this\x20payment;\x20creates\x20an\x20object-linker\x20affiliation','allowedOrigins':['fixed'],'typeConstraint':'guard\x20address\x20(set\x20at\x20payment_info2_with_guard\x20/\x20payment_info_with_guard)','configCheck':'n/a\x20—\x20plain\x20address\x20copy','runtimeFallback':'None\x20->\x20no\x20provenance','riskNotes':['Not\x20a\x20gate,\x20not\x20a\x20submission\x20slot\x20—\x20pure\x20traceability\x20(queries\x201057/1058,\x201108/1109)']}],'gateBehavior':'None','setterChecklist':['Attach\x20for_guard\x20when\x20the\x20payment\x20originates\x20from\x20a\x20guarded\x20flow'],'auditorChecklist':['Use\x20it\x20to\x20trace\x20payment\x20history\x20back\x20to\x20the\x20guarding\x20decision']},{'object':'Permission','field':'table\x20keys\x20(guard\x20addresses\x20as\x20permission\x20subjects)','mode':'gate','extraction':[],'gateBehavior':'A\x20guard\x20ADDRESS\x20can\x20be\x20granted\x20permission\x20indexes\x20like\x20a\x20user.\x20assert_with_passport\x20collects\x20the\x20passport\x20impack\x20guard\x20list\x20and\x20checks\x20has_permission\x20against\x20it:\x20a\x20passing\x20guard\x20can\x20therefore\x20carry\x20authorization\x20for\x20the\x20whole\x20transaction','setterChecklist':['Granting\x20an\x20index\x20to\x20a\x20guard\x20address\x20delegates\x20that\x20authority\x20to\x20anyone\x20who\x20can\x20pass\x20the\x20guard\x20—\x20treat\x20like\x20a\x20role\x20grant'],'auditorChecklist':['List\x20permission\x20subjects\x20that\x20are\x20guard\x20addresses;\x20evaluate\x20who\x20can\x20pass\x20those\x20guards\x20(they\x20inherit\x20the\x20permission)']}];export const VALUE_ORIGIN_SEMANTICS={'fixed':'Value\x20baked\x20into\x20the\x20guard\x20table\x20(b_submission=false).\x20Deterministic\x20on\x20every\x20use;\x20frozen\x20after\x20create;\x20submission_get\x20falls\x20back\x20to\x20it\x20when\x20no\x20submission\x20is\x20supplied.','submission':'Value\x20supplied\x20by\x20the\x20passport\x20builder\x20at\x20guard_add\x20time\x20(b_submission=true),\x20type-checked\x20against\x20the\x20table.\x20Whoever\x20builds\x20the\x20passport\x20controls\x20the\x20value\x20—\x20always\x20ask\x20who\x20that\x20is.','query':'Value\x20that\x20exists\x20only\x20inside\x20the\x20guard\x20input\x20expression\x20(native\x20query\x20opcodes\x201xxx).\x20It\x20constrains\x20verification\x20(state\x20coupling)\x20but\x20is\x20never\x20extractable;\x20extraction\x20slots\x20must\x20be\x20fixed\x20or\x20submission.'};export const GUARD_PASSPORT_DOCTRINE=['submission_get\x20resolution\x20order:\x20passport\x20submission\x20value\x20->\x20fixed\x20guard\x20table\x20value\x20->\x20abort\x20(E_SUBMISSION_ID_NOT_FOUND).\x20A\x20slot\x20with\x20no\x20submission\x20and\x20no\x20fixed\x20value\x20aborts\x20the\x20host\x20call.','A\x20guard\x20only\x20participates\x20if\x20passport.result_for_guard\x20passes\x20for\x20it,\x20and\x20it\x20must\x20be\x20marked\x20impack\x20when\x20the\x20host\x20extracts\x20data\x20from\x20it\x20(result_for_permission\x20returns\x20impack\x20guards\x20only).','The\x20impack\x20list\x20is\x20snapshotted\x20before\x20verify()\x20runs;\x201167\x20quote_guard\x20membership\x20is\x20checked\x20against\x20this\x20snapshot\x20inside\x20the\x20native\x20verifier.','relies:\x20a\x20guard\x20may\x20depend\x20on\x20at\x20most\x204\x20other\x20guards\x20(MAX_DEPENDED_COUNT),\x20dependent\x20guards\x20must\x20be\x20added\x20to\x20the\x20passport\x20first,\x20and\x20the\x20combine\x20logic\x20is\x20relies_logic_and\x20(AND\x20default,\x20OR\x20optional).','is_depended(guard)\x20=\x20relies\x20empty\x20AND\x20immutable\x20AND\x20rep\x20—\x20the\x20only\x20shape\x20accepted\x20as\x20a\x20repository\x20quote_guard\x20or\x20as\x20a\x20relied-upon\x20guard.','Guards\x20are\x20frozen\x20on\x20create\x20(immutable=true);\x20changing\x20a\x20fixed\x20value\x20means\x20deploying\x20a\x20new\x20guard\x20and\x20re-registering\x20it\x20on\x20every\x20host\x20object.','Type\x20checks\x20happen\x20at\x20config\x20time\x20(get_submission_value_type\x20/\x20is_identifier_address\x20/\x20is_identifier_address_compatible)\x20and\x20at\x20passport\x20build\x20time\x20(make_submissions\x20compares\x20the\x20first\x20type\x20byte);\x20runtime\x20aborts\x20are\x20the\x20last\x20resort.','Allocation\x20for_object\x20anchor\x20(protocol\x20139):\x20the\x20Allocation\x27s\x20payment_info.for_object,\x20when\x20Some,\x20is\x20enforced\x20inside\x20alloc()\x20—\x20every\x20Recipient::GuardIdentifier\x20submission\x20must\x20equal\x20that\x20address\x20(abort\x20ERECIPIENT_NOT_FOR_OBJECT\x2015).\x20When\x20None,\x20no\x20anchor\x20exists\x20and\x20the\x20GuardIdentifier\x20destination\x20is\x20whoever\x20builds\x20the\x20passport\x27s\x20choice:\x20entirely\x20the\x20creator\x27s\x20business.\x20Allocation\x20is\x20a\x20generic\x20component\x20—\x20the\x20anchor\x20is\x20opt-in\x20per\x20instance,\x20not\x20a\x20host-flow\x20constant.'];export function guardSitesFor(a){return GUARD_FIELD_SITES['filter'](b=>b['object']['toLowerCase']()===a['toLowerCase']());}export function guardCognitionDoctrine(){return['Classify\x20the\x20mode\x20first:\x20pure\x20gate\x20(authorization\x20only),\x20pure\x20source\x20(data\x20only),\x20or\x20gate+source\x20(most\x20money\x20fields).','For\x20every\x20extracted\x20slot,\x20name\x20its\x20origin\x20(fixed\x20/\x20submission\x20/\x20query)\x20before\x20judging\x20safety.','For\x20submission\x20slots,\x20identify\x20the\x20passport\x20builder:\x20that\x20party\x20chooses\x20the\x20value.\x20Trace\x20what\x20constrains\x20it\x20(guard\x20expression,\x20host-side\x20balance/authorization\x20checks).','For\x20fixed\x20slots,\x20remember\x20immutability:\x20the\x20value\x20is\x20policy,\x20changed\x20only\x20by\x20re-issuing\x20the\x20guard.','For\x20query-coupled\x20guards,\x20map\x20each\x20query\x20id\x20to\x20its\x20data\x20dependency\x20(which\x20object,\x20which\x20field)\x20—\x20the\x20guard\x20is\x20only\x20as\x20fresh\x20as\x20the\x20queried\x20state.','Check\x20config-time\x20invariants:\x20type\x20of\x20each\x20slot,\x20registration\x20limits\x20(treasury\x20100\x20deposit\x20/\x20200\x20withdraw\x20/\x20reward\x20200\x20/\x20arbitration\x2050\x20/\x20repository\x2010\x20write\x20guards\x20per\x20policy),\x20relies\x20<=\x204,\x20submission\x20size\x20<=\x20256\x20bytes.','Report\x20any\x20submission\x20slot\x20that\x20decides\x20money\x20destination\x20or\x20amount\x20without\x20a\x20scope\x20binding\x20as\x20a\x20HIGH-severity\x20redirect\x20risk.'];}export const REPOSITORY_WRITE_ROUTE_MATRIX=[{'route':'data_when_id_from_set','purpose':'Unguarded\x20auto-id\x20write:\x20policy\x20has\x20NO\x20write\x20guards\x20and\x20id_from\x20is\x20Clock/Signer.','idSource':'clock','dataSource':'caller','honorsIdFromSubmission':![],'honorsDataFromSubmission':![],'guardRequirement':'policy-write-guard-must-be-empty','abortsOnUnhonoredSlots':![],'removeRoute':'data_remove_when_id_from_set'},{'route':'data_when_id_from_set_with_passport','purpose':'Guarded\x20auto-id\x20write:\x20id\x20auto-generated;\x20the\x20guard\x20authorizes\x20AND\x20may\x20supply\x20the\x20data\x20payload\x20via\x20data_from_submission.','idSource':'clock','dataSource':'submission-if-set-else-caller','honorsIdFromSubmission':![],'honorsDataFromSubmission':!![],'guardRequirement':'specified-guard-must-be-in-policy','abortsOnUnhonoredSlots':![],'removeRoute':'data_remove_when_id_from_set_with_passport'},{'route':'id_data','purpose':'Unguarded\x20manual\x20write:\x20caller\x20supplies\x20id\x20AND\x20data;\x20policy\x20must\x20have\x20no\x20write\x20guards.','idSource':'caller','dataSource':'caller','honorsIdFromSubmission':![],'honorsDataFromSubmission':![],'guardRequirement':'policy-write-guard-must-be-empty','abortsOnUnhonoredSlots':![],'removeRoute':'id_data_remove'},{'route':'id_data_with_passport','purpose':'Guarded\x20manual\x20write:\x20caller\x20supplies\x20id\x20AND\x20data;\x20the\x20guard\x20authorizes\x20only.\x20Extraction\x20slots\x20must\x20be\x20None.','idSource':'caller','dataSource':'caller','honorsIdFromSubmission':![],'honorsDataFromSubmission':![],'guardRequirement':'specified-guard-must-be-in-policy','abortsOnUnhonoredSlots':!![],'removeRoute':'id_data_remove_with_passport'},{'route':'id_data_mixed_with_passport','purpose':'Mixed\x20write:\x20per\x20specified\x20guard,\x20id\x20comes\x20from\x20id_from_submission\x20(else\x20caller\x20vector)\x20and\x20data\x20from\x20data_from_submission\x20(else\x20caller\x20vector).\x20Requires\x20policy\x20id_from\x20==\x20NONE.','idSource':'submission-if-set-else-caller','dataSource':'submission-if-set-else-caller','honorsIdFromSubmission':!![],'honorsDataFromSubmission':!![],'guardRequirement':'each-specified-guard-must-be-in-policy','abortsOnUnhonoredSlots':![],'removeRoute':'id_data_mixed_remove_with_passport'},{'route':'id_data_mixed_remove_with_passport','purpose':'Mixed\x20removal:\x20deletes\x20the\x20record\x20whose\x20id\x20is\x20extracted\x20from\x20id_from_submission.\x20Requires\x20the\x20slot\x20to\x20be\x20SET.','idSource':'submission-if-set-else-caller','dataSource':'none','honorsIdFromSubmission':!![],'honorsDataFromSubmission':![],'guardRequirement':'each-specified-guard-must-be-in-policy','abortsOnUnhonoredSlots':!![]}];export function repositoryRouteSlotConflicts(a){const b=[],{idFrom:c,writeGuardCount:d,idFromSubmissionSet:e,dataFromSubmissionSet:f,intendedRoute:g}=a;return c==='none'&&d===0x0&&b['push']('E_POLICY_WRITE_GUARD_REQUIRED:\x20id_from=NONE\x20with\x20an\x20empty\x20write_guard\x20lets\x20anyone\x20mutate\x20the\x20policy\x20data'),c!=='none'&&e&&b['push']('E_POLICY_ID_FROM_SUBMISSION_FORBIDDEN:\x20id\x20is\x20auto-generated\x20(clock/signer);\x20id_from_submission\x20can\x20never\x20fire'),(g==='id_data_with_passport'||g==='id_data_remove_with_passport')&&((e||f)&&b['push']('E_GUARD_SPECIFIED_ID_FROM_SUBMISSION:\x20the\x20chosen\x20route\x20rejects\x20every\x20extraction\x20slot;\x20use\x20id_data_mixed_with_passport\x20or\x20data_when_id_from_set_with_passport\x20instead')),g==='data_when_id_from_set_with_passport'&&e&&b['push']('id_from_submission\x20is\x20never\x20consumed\x20by\x20data_when_id_from_set_with_passport\x20(id\x20is\x20auto-generated);\x20the\x20slot\x20is\x20dead\x20config'),g==='id_data_mixed_with_passport'&&c!=='none'&&b['push']('E_POLICY_ID_FROM_NONE:\x20id_data_mixed_with_passport\x20requires\x20policy\x20id_from=NONE'),g==='id_data_mixed_remove_with_passport'&&!e&&b['push']('E_GUARD_NOT_SPECIFIED_ID_FROM_SUBMISSION:\x20mixed\x20removal\x20has\x20no\x20id\x20source;\x20set\x20id_from_submission\x20or\x20use\x20id_data_remove_with_passport'),b;}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { GuardRiskAssessment } from "./guard-risk.js";
|
|
2
2
|
export type DiagnosticSource = "sdk" | "lint" | "risk";
|
|
3
3
|
export type DiagnosticSeverity = "error" | "warning" | "info" | "hint";
|
|
4
4
|
export interface GuardDiagnostic {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{validateGuardData,MAX_DESCRIPTION_LENGTH,MAX_GUARD_TABLE_ITEM_LENGTH}from'@wowok/wowok';import{assessGuardRisks}from'./guard-risk.js';import{findScene,inferSceneFromAction}from'./guard-ledger.js';import{suggestTemplateForScene}from'./guard-templates.js';function deepClone(a){return JSON['parse'](JSON['stringify'](a));}function rootToString(a){return JSON['stringify'](a);}function hasSignerContext(a){const b=rootToString(a);return b['includes']('\x22Signer\x22')||b['includes']('\x22context\x22:\x22Signer\x22')||b['includes']('\x22context\x22:\x20\x22Signer\x22');}function getSubmissionEntries(a){return a['filter'](b=>b['b_submission']===!![]);}function inferValueType(a){if(typeof a==='string'){if(a['startsWith']('0x')&&a['length']>=0x3)return'Address';return'String';}if(typeof a==='number'){if(Number['isInteger'](a)){if(a>=0x0&&a<=0xff)return'U8';if(a>=0x0&&a<=0xffff)return'U16';return'U64';}return'U256';}if(typeof a==='boolean')return'Bool';if(Array['isArray'](a)){if(a['length']>0x0){const b=inferValueType(a[0x0]);if(b==='Address')return'Vec<Address>';if(b==='String')return'Vec<String>';if(b==='Bool')return'Vec<Bool>';}return'Vec<Address>';}return undefined;}function sdkIssueToDiagnostic(a){return{'code':a['code'],'message':a['message'],'severity':a['severity'],'source':'sdk','location':{'path':a['path']},'fix':{'description':'SDK\x20validation\x20failed\x20('+(a['sdk_error']??'InvalidParam')+');\x20manual\x20fix\x20required','auto_fixable':![]}};}async function checkSdkSyntax(a){const b=a['table']['map'](d=>({'identifier':d['identifier'],'b_submission':d['b_submission']??![],'value_type':d['value_type']??'Address','value':d['value'],'name':d['name']??''})),c=await validateGuardData({'description':a['description'],'table':b,'root':a['root'],'rely':a['rely']});return c['map'](sdkIssueToDiagnostic);}function checkSemanticErrors(a){const b=[],{table:c,root:d,binding_hint:e}=a,f=e?findScene(e['host_object']??'',e['binding_field']??''):undefined,g=getSubmissionEntries(c);if(g['length']>0x0&&d&&!hasSignerContext(d)){const h=g['some'](j=>j['value_type']==='Address'),i=f?.['id']==='service_order_allocators_guard'&&e?.['sharing_recipients']!==undefined&&e['sharing_recipients']['length']>0x0&&!e['sharing_recipients']['includes']('Signer');if(h&&!i){const j=g['filter'](k=>k['value_type']==='Address')['map'](k=>c['indexOf'](k));b['push']({'code':'LE-04','message':'Submitted\x20data\x20has\x20no\x20Signer\x20binding\x20(submission\x20forgery\x20risk)','severity':'error','source':'lint','location':{'path':j['map'](k=>'/table/'+k)['join']('\x20→\x20')},'fix':{'description':'Add\x20logic_equal(context(Signer),\x20identifier[N])\x20in\x20root\x20to\x20bind\x20the\x20submitter\x20identity','auto_fixable':![]}});}}if(f?.['id']==='arbitration_voting_guard'){const k=g['some'](l=>['U8','U16','U32','U64','U128','U256']['includes'](l['value_type']??''));if(k){const l=g['filter'](m=>['U8','U16','U32','U64','U128','U256']['includes'](m['value_type']??''))['map'](m=>c['indexOf'](m));b['push']({'code':'LE-05','message':'voting_guard\x20voting\x20weight\x20comes\x20from\x20submitted\x20data\x20(weight\x20forgery\x20risk)','severity':'error','source':'lint','location':{'path':l['map'](m=>'/table/'+m)['join']('\x20→\x20')},'fix':{'description':'Derive\x20arbitrator\x20weights\x20from\x20the\x20Arb\x20object\x20via\x20witness\x20(e.g.\x20105\x20TypeArbArbitration)\x20rather\x20than\x20submitting\x20them\x20directly','auto_fixable':![]}});}}if(f?.['id']==='gen_passport_guard'||e?.['action']==='gen_passport'){const m=rootToString(d);if(m['includes']('1167')||m['includes']('repository.data')){const n=m['includes']('quote_guard');n&&b['push']({'code':'LE-06','message':'repository.data\x20query\x20with\x20quote_guard:\x20rigid\x20verification\x20requirement\x20—\x20ensure\x20Passport\x20includes\x20quote_guard\x20verification\x20with\x20necessary\x20submissions\x20(e.g.,\x20Payment\x20proof)','severity':'info','source':'lint','location':{'path':'/root'},'fix':{'description':'Ensure\x20the\x20quote_guard\x20is\x20verified:\x20user\x20submits\x20Payment\x20via\x20Passport,\x20quote_guard\x20verifies\x20Payment\x20fields,\x20repository\x20data\x20query\x20passes','auto_fixable':![]}});}}if(e?.['host_object']&&f){const o=e['host_object'],p=c['filter'](q=>!q['b_submission']&&q['value_type']==='Address'&&typeof q['value']==='string'&&q['value']['startsWith']('0x')&&q['object_type']===o);if(p['length']>0x0){const q=p['map'](r=>c['indexOf'](r));b['push']({'code':'LE-07','message':'Circular\x20reference\x20uses\x20an\x20address\x20rather\x20than\x20a\x20name\x20(Host\x20Object\x20may\x20not\x20be\x20published\x20yet\x20when\x20the\x20Guard\x20is\x20created)','severity':'error','source':'lint','location':{'path':q['map'](r=>'/table/'+r+'/value')['join']('\x20→\x20')},'fix':{'description':'Change\x20value\x20from\x20an\x20address\x20to\x20an\x20object\x20name\x20(e.g.\x20\x22service1\x22);\x20the\x20SDK\x20will\x20resolve\x20it\x20to\x20an\x20address\x20after\x20the\x20Host\x20Object\x20is\x20published','auto_fixable':![]}});}}return b;}function checkSyntaxHints(a){const b=[],{table:c}=a;(!a['description']||a['description']['trim']()==='')&&b['push']({'code':'SH-01','message':'description\x20is\x20missing\x20or\x20empty','severity':'info','source':'lint','location':{'path':'/description'},'fix':{'description':'Add\x20a\x20description,\x20e.g.\x20\x27Service\x20buy_guard:\x20whitelist\x20validation\x27','auto_fixable':!![]}});for(let d=0x0;d<c['length'];d++){const e=c[d];(!e['name']||e['name']['trim']()==='')&&b['push']({'code':'SH-03','message':'table['+d+']\x20is\x20missing\x20name','severity':'warning','source':'lint','location':{'path':'/table/'+d+'/name'},'fix':{'description':'Add\x20a\x20name,\x20e.g.\x20\x22data\x20entry\x20'+e['identifier']+'\x22','auto_fixable':!![]}});}for(let f=0x0;f<c['length'];f++){const g=c[f];!g['value_type']&&b['push']({'code':'SH-05','message':'table['+f+']\x20is\x20missing\x20value_type','severity':'warning','source':'lint','location':{'path':'/table/'+f+'/value_type'},'fix':{'description':'Infer\x20value_type\x20from\x20value\x20(e.g.\x20Address/String/U64,\x20etc.)','auto_fixable':!![]}});}c['length']>MAX_GUARD_TABLE_ITEM_LENGTH&&b['push']({'code':'SH-07','message':'table\x20entry\x20count\x20'+c['length']+'\x20exceeds\x20the\x20maximum\x20limit\x20'+MAX_GUARD_TABLE_ITEM_LENGTH,'severity':'error','source':'lint','location':{'path':'/table'},'fix':{'description':'Slim\x20down\x20the\x20table\x20by\x20merging\x20similar\x20entries,\x20or\x20split\x20into\x20multiple\x20Guards\x20+\x20rely','auto_fixable':![]}});for(let h=0x0;h<c['length'];h++){c[h]['b_submission']===undefined&&b['push']({'code':'SH-10','message':'table['+h+']\x20b_submission\x20is\x20missing','severity':'info','source':'lint','location':{'path':'/table/'+h+'/b_submission'},'fix':{'description':'Set\x20to\x20false\x20(constant)\x20or\x20true\x20(submitted\x20data)','auto_fixable':!![]}});}for(let j=0x0;j<c['length'];j++){const k=c[j];k['b_submission']===!![]&&k['value']!==undefined&&k['value']!==null&&b['push']({'code':'SH-11','message':'table['+j+']\x20has\x20a\x20redundant\x20value\x20field\x20on\x20b_submission=true\x20entry\x20(the\x20verifier\x20supplies\x20the\x20value\x20at\x20runtime;\x20this\x20value\x20is\x20ignored\x20by\x20BCS\x20encoding\x20and\x20wastes\x20gas)','severity':'warning','source':'lint','location':{'path':'/table/'+j+'/value'},'fix':{'description':'Remove\x20the\x20value\x20field\x20—\x20it\x20is\x20ignored\x20for\x20b_submission=true\x20entries','auto_fixable':!![]}});}return b;}function checkSuggestions(a){const b=[],{root:c,binding_hint:d,table:e}=a;if(c){const g=rootToString(c);if(g['includes']('vec_contains_address')&&g['includes']('Signer'))b['push']({'code':'SG-01','message':'Matches\x20Pattern\x20P04\x20(whitelist\x20validation)','severity':'hint','source':'lint','location':{'path':'/root'},'fix':{'description':'Refer\x20to\x20the\x20P04\x20Pattern\x20to\x20ensure\x20best\x20practices','auto_fixable':![]}});else{if(g['includes']('logic_equal')&&g['includes']('Signer')){const h=e['some'](i=>!i['b_submission']&&i['value_type']==='Address'&&typeof i['value']==='string'&&i['value']['length']>0x0);h&&b['push']({'code':'SG-01','message':'Matches\x20Pattern\x20P04\x20(whitelist\x20validation\x20—\x20single-address\x20variant)','severity':'hint','source':'lint','location':{'path':'/root'},'fix':{'description':'P04\x20single-address\x20form;\x20for\x20multi-address\x20scenarios,\x20consider\x20vec_contains_address','auto_fixable':![]}});}}(g['includes']('logic_as_u256_greater')||g['includes']('logic_as_u256_lesser'))&&b['push']({'code':'SG-01','message':'Matches\x20Pattern\x20P02\x20(numeric\x20threshold\x20validation)','severity':'hint','source':'lint','location':{'path':'/root'},'fix':{'description':'Suitable\x20for\x20amount/quantity\x20threshold\x20validation\x20scenarios','auto_fixable':![]}}),g['includes']('convert_witness')&&b['push']({'code':'SG-01','message':'Matches\x20Pattern\x20P09\x20(witness-derived\x20validation)','severity':'hint','source':'lint','location':{'path':'/root'},'fix':{'description':'Suitable\x20for\x20cross-object\x20relationship\x20validation\x20(e.g.\x20Order→Progress)','auto_fixable':![]}});}if(d?.['action']){const i=['buy','forward','allocate','claim_reward','vote','dispute','write_repository','submit_progress','gen_passport'];if(i['includes'](d['action'])){const j=inferSceneFromAction(d['action']);if(j){const k=suggestTemplateForScene(j['id']);k&&b['push']({'code':'SG-02','message':'Recommended\x20scene\x20template:\x20'+k['name'],'severity':'hint','source':'lint','location':{'path':'/'},'fix':{'description':'Refer\x20to\x20template\x20'+k['id']+'\x20('+k['example_use_case']+')','auto_fixable':![]}});}}}const f=getSubmissionEntries(e);for(const l of f){const m=l['name']??'';if(m['length']<0xa||/^[a-z_]+$/i['test'](m)){const n=e['indexOf'](l);b['push']({'code':'SG-03','message':'table['+n+']\x20submitted\x20data\x20has\x20a\x20vague\x20name\x20description','severity':'info','source':'lint','location':{'path':'/table/'+n+'/name'},'fix':{'description':'Use\x20a\x20full\x20natural-language\x20description\x20(≥10\x20characters),\x20e.g.\x20\x27user-submitted\x20operation\x20type\x20(return/damage)\x27','auto_fixable':![]}});}}if(c){const o=rootToString(c),p=o['includes']('proof.signer'),q=o['includes']('proof.time'),r=o['includes']('calc_string_length'),s=f['some'](t=>t['value_type']==='String');if(p&&q)b['push']({'code':'SG-04','message':'Strict-mode\x20privacy-delivery\x20guard\x20detected\x20(proof.signer\x20+\x20proof.time).\x20'+'Recommended\x20three\x20conditions:\x20Signer==proof.signer\x20(submitter\x20accountability),\x20'+'proof.time>order.time\x20(freshness),\x20order.service==service\x20(project\x20binding).\x20'+'No\x20content\x20verification\x20—\x20only\x20submission\x20responsibility\x20(\x27whoever\x20benefits\x20bears\x20the\x20burden\x20of\x20proof\x27).','severity':'info','source':'lint','location':{'path':'/root'},'fix':{'description':'Ensure\x20all\x20three\x20conditions\x20are\x20present\x20(logic_and).\x20Refer\x20to\x20template\x20tpl_forward_privacy_delivery_proof.\x20'+'Query\x20IDs:\x20proof.signer=1958,\x20proof.time=1960,\x20order.time=1574,\x20order.service=1563.','auto_fixable':![]}});else r&&s&&b['push']({'code':'SG-04','message':'Broad-mode\x20privacy-delivery\x20guard\x20detected\x20(String\x20submission\x20+\x20length\x20check,\x20e.g.\x20Merkle\x20Root\x20length\x20==\x2066).\x20'+'This\x20trusts\x20the\x20submitter\x27s\x20honesty;\x20the\x20counterparty\x20can\x20dispute\x20by\x20checking\x20their\x20own\x20Messenger\x20conversation.\x20'+'Suitable\x20as\x20an\x20arbitration\x20basis,\x20not\x20a\x20fund-flow\x20gate.','severity':'info','source':'lint','location':{'path':'/root'},'fix':{'description':'For\x20stronger\x20assurance,\x20consider\x20strict\x20mode:\x20submit\x20a\x20Proof\x20object\x20address\x20(from\x20messenger.submitChainProof)\x20+\x20'+'Order\x20address,\x20then\x20verify\x20proof.signer/proof.time/order.service.\x20See\x20template\x20tpl_forward_privacy_delivery_proof.','auto_fixable':![]}});}return b;}export function autoFixGuard(a){const b=deepClone(a),c=[];(!b['description']||b['description']['trim']()==='')&&(b['description']='Guard\x20(table:\x20'+b['table']['length']+'\x20items,\x20root:\x20'+(b['root']?.['type']??'unknown')+')',c['push']({'diagnostic_code':'SH-01','description':'Fill\x20in\x20default\x20description','after':b['description'],'path':'/description'}));if(b['description']&&b['description']['length']>MAX_DESCRIPTION_LENGTH){const f=b['description'];b['description']=b['description']['substring'](0x0,MAX_DESCRIPTION_LENGTH),c['push']({'diagnostic_code':'G-001','description':'Truncate\x20description\x20to\x20'+MAX_DESCRIPTION_LENGTH+'\x20characters','before':f['length']+'\x20characters','after':b['description']['length']+'\x20characters','path':'/description'});}for(let g=0x0;g<b['table']['length'];g++){const h=b['table'][g];(!h['name']||h['name']['trim']()==='')&&(h['name']='data\x20entry\x20'+h['identifier'],c['push']({'diagnostic_code':'SH-03','description':'table['+g+']\x20fill\x20in\x20name','after':h['name'],'path':'/table/'+g+'/name'}));}for(let j=0x0;j<b['table']['length'];j++){const k=b['table'][j];if(!k['value_type']&&k['value']!==undefined&&k['value']!==null){const l=inferValueType(k['value']);l&&(k['value_type']=l,c['push']({'diagnostic_code':'SH-05','description':'table['+j+']\x20infer\x20value_type','after':l,'path':'/table/'+j+'/value_type'}));}}const d=new Map();let e=0x0;for(let m=0x0;m<b['table']['length'];m++){const n=b['table'][m];if(!d['has'](n['identifier']))d['set'](n['identifier'],e),n['identifier']!==e&&c['push']({'diagnostic_code':'G-007','description':'table['+m+']\x20identifier\x20'+n['identifier']+'\x20→\x20'+e,'before':String(n['identifier']),'after':String(e),'path':'/table/'+m+'/identifier'}),n['identifier']=e,e++;else{const o=n['identifier'];n['identifier']=e,d['set'](o,e),c['push']({'diagnostic_code':'G-007','description':'table['+m+']\x20identifier\x20'+o+'\x20duplicate\x20→\x20reallocated\x20to\x20'+e,'before':String(o),'after':String(e),'path':'/table/'+m+'/identifier'}),e++;}}for(let p=0x0;p<b['table']['length'];p++){const q=b['table'][p];q['b_submission']===undefined&&(q['b_submission']=![],c['push']({'diagnostic_code':'SH-10','description':'table['+p+']\x20b_submission\x20default\x20set\x20to\x20false','after':'false','path':'/table/'+p+'/b_submission'}));}if(b['rely']?.['guards']&&b['rely']['guards']['length']>0x0){const r=[...new Set(b['rely']['guards'])];r['length']!==b['rely']['guards']['length']&&(c['push']({'diagnostic_code':'G-009','description':'rely\x20deduplicate:\x20'+b['rely']['guards']['length']+'\x20→\x20'+r['length'],'before':JSON['stringify'](b['rely']['guards']),'after':JSON['stringify'](r),'path':'/rely/guards'}),b['rely']['guards']=r);}for(let s=0x0;s<b['table']['length'];s++){const t=b['table'][s];if(t['b_submission']===!![]&&t['value']!==undefined&&t['value']!==null){const u=JSON['stringify'](t['value']);delete t['value'],c['push']({'diagnostic_code':'SH-11','description':'table['+s+']\x20remove\x20redundant\x20value\x20on\x20b_submission=true\x20entry','before':u,'after':'(removed)','path':'/table/'+s+'/value'});}}return{'fixed':b,'actions':c};}export async function lintGuard(a,b){const c=b?.['auto_fix']??!![],{table:d,root:e,rely:f,binding_hint:g}=a,h=[];let i;const j=await checkSdkSyntax(a);h['push'](...j);const k=checkSemanticErrors(a);h['push'](...k);const l=checkSyntaxHints(a);h['push'](...l);let m,n=[];if(c){const {fixed:v,actions:w}=autoFixGuard(a);w['length']>0x0&&(m=v,n=w);}if(d['length']>0x0&&e){const x=g?findScene(g['host_object']??'',g['binding_field']??''):undefined,y=d['map'](z=>({'identifier':z['identifier'],'b_submission':z['b_submission']??![],'value_type':z['value_type']??'Address','value':z['value'],'name':z['name'],'object_type':z['object_type']}));i=assessGuardRisks({'table':y,'root':e,'rely':f,'scene':x,'sharing_recipients':g?.['sharing_recipients']});for(const z of i['risks']){const A=z['level']==='critical'||z['level']==='high'?'error':z['level']==='medium'?'warning':z['level']==='low'?'info':'hint',B=z['evidence']??'',C=B['startsWith']('/')?B:'/';h['push']({'code':z['id'],'message':'['+z['level']+']\x20'+z['title'],'severity':A,'source':'risk','location':{'path':C},'fix':{'description':z['mitigation'],'auto_fixable':![]}});}}const o=checkSuggestions(a);h['push'](...o);const p=h['filter'](D=>D['severity']==='error')['length'],q=h['filter'](D=>D['severity']==='warning')['length'],s=h['filter'](D=>D['severity']==='info'||D['severity']==='hint')['length'],t=p===0x0;let u;if(p>0x0)u='Fix\x20'+p+'\x20error(s)\x20and\x20re-run\x20lint';else q>0x0?u='Consider\x20addressing\x20'+q+'\x20warning(s),\x20then\x20submit\x20to\x20SDK\x20newGuard()\x20for\x20final\x20syntax\x20validation':u='lint\x20passed\x20(no\x20errors);\x20submit\x20to\x20SDK\x20newGuard()\x20for\x20final\x20syntax\x20validation\x20before\x20going\x20on-chain';return{'json_summary':{'table_count':d['length'],'root_type':e?.['type']??'unknown','has_rely':!!f?.['guards']?.['length'],'rely_count':f?.['guards']?.['length']??0x0,'has_description':!!a['description']},'diagnostics':h,'fixed_json':m,'fix_actions':n,'risk_assessment':i,'summary':{'errors':p,'warnings':q,'infos':s,'auto_fixes_applied':n['length'],'ready':t,'next_step':u}};}export async function isGuardReady(a){const b=await lintGuard(a,{'auto_fix':![]});return b['summary']['ready'];}export async function getGuardErrors(a){const b=await lintGuard(a,{'auto_fix':![]});return b['diagnostics']['filter'](c=>c['severity']==='error');}export function formatLintResult(a){const b=[];b['push']('===\x20Guard\x20JSON\x20Lint\x20Report\x20==='),b['push'](''),b['push']('Summary:'),b['push']('\x20\x20Errors:\x20\x20\x20\x20\x20'+a['summary']['errors']),b['push']('\x20\x20Warnings:\x20\x20\x20'+a['summary']['warnings']),b['push']('\x20\x20Infos:\x20\x20\x20\x20\x20\x20'+a['summary']['infos']),b['push']('\x20\x20Auto-fixes:\x20'+a['summary']['auto_fixes_applied']),b['push']('\x20\x20Ready:\x20\x20\x20\x20\x20\x20'+(a['summary']['ready']?'YES':'NO')),b['push']('\x20\x20Next\x20step:\x20\x20'+a['summary']['next_step']),b['push']('');if(a['fix_actions']['length']>0x0){b['push']('---\x20Auto-fix\x20Actions\x20---');for(const g of a['fix_actions']){b['push']('\x20\x20['+g['diagnostic_code']+']\x20'+g['description']),b['push']('\x20\x20\x20\x20Path:\x20'+g['path']),g['before']&&g['after']&&b['push']('\x20\x20\x20\x20'+g['before']+'\x20->\x20'+g['after']);}b['push']('');}const c=a['diagnostics']['filter'](h=>h['severity']==='error'),e=a['diagnostics']['filter'](h=>h['severity']==='warning'),f=a['diagnostics']['filter'](h=>h['severity']==='info'||h['severity']==='hint');if(c['length']>0x0){b['push']('---\x20Errors\x20(must\x20fix)\x20---');for(const h of c){b['push']('\x20\x20['+h['code']+']\x20('+h['source']+')\x20'+h['message']),b['push']('\x20\x20\x20\x20Path:\x20'+h['location']['path']);if(h['fix'])b['push']('\x20\x20\x20\x20Fix:\x20\x20'+h['fix']['description']);}b['push']('');}if(e['length']>0x0){b['push']('---\x20Warnings\x20(consider\x20fixing)\x20---');for(const i of e){b['push']('\x20\x20['+i['code']+']\x20('+i['source']+')\x20'+i['message']),b['push']('\x20\x20\x20\x20Path:\x20'+i['location']['path']);if(i['fix'])b['push']('\x20\x20\x20\x20Fix:\x20\x20'+i['fix']['description']);}b['push']('');}if(f['length']>0x0){b['push']('---\x20Info\x20&\x20Hints\x20---');for(const j of f){b['push']('\x20\x20['+j['code']+']\x20('+j['source']+')\x20'+j['message']),b['push']('\x20\x20\x20\x20Path:\x20'+j['location']['path']);}}return b['join']('\x0a');}
|
|
1
|
+
import{validateGuardData,MAX_DESCRIPTION_LENGTH,MAX_GUARD_TABLE_ITEM_LENGTH}from'@wowok/wowok';import{evaluateGuardDraft}from'./guard-eval.js';import{findScene,inferSceneFromAction}from'./guard-ledger.js';import{suggestTemplateForScene}from'./guard-templates.js';function deepClone(a){return JSON['parse'](JSON['stringify'](a));}function rootToString(a){return JSON['stringify'](a);}function hasSignerContext(a){const b=rootToString(a);return b['includes']('\x22Signer\x22')||b['includes']('\x22context\x22:\x22Signer\x22')||b['includes']('\x22context\x22:\x20\x22Signer\x22');}function getSubmissionEntries(a){return a['filter'](b=>b['b_submission']===!![]);}function inferValueType(a){if(typeof a==='string'){if(a['startsWith']('0x')&&a['length']>=0x3)return'Address';return'String';}if(typeof a==='number'){if(Number['isInteger'](a)){if(a>=0x0&&a<=0xff)return'U8';if(a>=0x0&&a<=0xffff)return'U16';return'U64';}return'U256';}if(typeof a==='boolean')return'Bool';if(Array['isArray'](a)){if(a['length']>0x0){const b=inferValueType(a[0x0]);if(b==='Address')return'Vec<Address>';if(b==='String')return'Vec<String>';if(b==='Bool')return'Vec<Bool>';}return'Vec<Address>';}return undefined;}function sdkIssueToDiagnostic(a){return{'code':a['code'],'message':a['message'],'severity':a['severity'],'source':'sdk','location':{'path':a['path']},'fix':{'description':'SDK\x20validation\x20failed\x20('+(a['sdk_error']??'InvalidParam')+');\x20manual\x20fix\x20required','auto_fixable':![]}};}async function checkSdkSyntax(a){const b=a['table']['map'](d=>({'identifier':d['identifier'],'b_submission':d['b_submission']??![],'value_type':d['value_type']??'Address','value':d['value'],'name':d['name']??''})),c=await validateGuardData({'description':a['description'],'table':b,'root':a['root'],'rely':a['rely']});return c['map'](sdkIssueToDiagnostic);}function checkSemanticErrors(a){const b=[],{table:c,root:d,binding_hint:e}=a,f=e?findScene(e['host_object']??'',e['binding_field']??''):undefined,g=getSubmissionEntries(c);if(g['length']>0x0&&d&&!hasSignerContext(d)){const h=g['some'](j=>j['value_type']==='Address'),i=f?.['id']==='service_order_allocators_guard'&&e?.['sharing_recipients']!==undefined&&e['sharing_recipients']['length']>0x0&&!e['sharing_recipients']['includes']('Signer');if(h&&!i){const j=g['filter'](k=>k['value_type']==='Address')['map'](k=>c['indexOf'](k));b['push']({'code':'LE-04','message':'Submitted\x20data\x20has\x20no\x20Signer\x20binding\x20(submission\x20forgery\x20risk)','severity':'error','source':'lint','location':{'path':j['map'](k=>'/table/'+k)['join']('\x20→\x20')},'fix':{'description':'Add\x20logic_equal(context(Signer),\x20identifier[N])\x20in\x20root\x20to\x20bind\x20the\x20submitter\x20identity','auto_fixable':![]}});}}if(f?.['id']==='arbitration_voting_guard'){const k=g['some'](l=>['U8','U16','U32','U64','U128','U256']['includes'](l['value_type']??''));if(k){const l=g['filter'](m=>['U8','U16','U32','U64','U128','U256']['includes'](m['value_type']??''))['map'](m=>c['indexOf'](m));b['push']({'code':'LE-05','message':'voting_guard\x20voting\x20weight\x20comes\x20from\x20submitted\x20data\x20(weight\x20forgery\x20risk)','severity':'error','source':'lint','location':{'path':l['map'](m=>'/table/'+m)['join']('\x20→\x20')},'fix':{'description':'Derive\x20arbitrator\x20weights\x20from\x20the\x20Arb\x20object\x20via\x20witness\x20(e.g.\x20105\x20TypeArbArbitration)\x20rather\x20than\x20submitting\x20them\x20directly','auto_fixable':![]}});}}if(f?.['id']==='gen_passport_guard'||e?.['action']==='gen_passport'){const m=rootToString(d);if(m['includes']('1167')||m['includes']('repository.data')){const n=m['includes']('quote_guard');n&&b['push']({'code':'LE-06','message':'repository.data\x20query\x20with\x20quote_guard:\x20rigid\x20verification\x20requirement\x20—\x20ensure\x20Passport\x20includes\x20quote_guard\x20verification\x20with\x20necessary\x20submissions\x20(e.g.,\x20Payment\x20proof)','severity':'info','source':'lint','location':{'path':'/root'},'fix':{'description':'Ensure\x20the\x20quote_guard\x20is\x20verified:\x20user\x20submits\x20Payment\x20via\x20Passport,\x20quote_guard\x20verifies\x20Payment\x20fields,\x20repository\x20data\x20query\x20passes','auto_fixable':![]}});}}if(e?.['host_object']&&f){const o=e['host_object'],p=c['filter'](q=>!q['b_submission']&&q['value_type']==='Address'&&typeof q['value']==='string'&&q['value']['startsWith']('0x')&&q['object_type']===o);if(p['length']>0x0){const q=p['map'](r=>c['indexOf'](r));b['push']({'code':'LE-07','message':'Circular\x20reference\x20uses\x20an\x20address\x20rather\x20than\x20a\x20name\x20(Host\x20Object\x20may\x20not\x20be\x20published\x20yet\x20when\x20the\x20Guard\x20is\x20created)','severity':'error','source':'lint','location':{'path':q['map'](r=>'/table/'+r+'/value')['join']('\x20→\x20')},'fix':{'description':'Change\x20value\x20from\x20an\x20address\x20to\x20an\x20object\x20name\x20(e.g.\x20\x22service1\x22);\x20the\x20SDK\x20will\x20resolve\x20it\x20to\x20an\x20address\x20after\x20the\x20Host\x20Object\x20is\x20published','auto_fixable':![]}});}}return b;}function checkSyntaxHints(a){const b=[],{table:c}=a;(!a['description']||a['description']['trim']()==='')&&b['push']({'code':'SH-01','message':'description\x20is\x20missing\x20or\x20empty','severity':'info','source':'lint','location':{'path':'/description'},'fix':{'description':'Add\x20a\x20description,\x20e.g.\x20\x27Service\x20buy_guard:\x20whitelist\x20validation\x27','auto_fixable':!![]}});for(let d=0x0;d<c['length'];d++){const e=c[d];(!e['name']||e['name']['trim']()==='')&&b['push']({'code':'SH-03','message':'table['+d+']\x20is\x20missing\x20name','severity':'warning','source':'lint','location':{'path':'/table/'+d+'/name'},'fix':{'description':'Add\x20a\x20name,\x20e.g.\x20\x22data\x20entry\x20'+e['identifier']+'\x22','auto_fixable':!![]}});}for(let f=0x0;f<c['length'];f++){const g=c[f];!g['value_type']&&b['push']({'code':'SH-05','message':'table['+f+']\x20is\x20missing\x20value_type','severity':'warning','source':'lint','location':{'path':'/table/'+f+'/value_type'},'fix':{'description':'Infer\x20value_type\x20from\x20value\x20(e.g.\x20Address/String/U64,\x20etc.)','auto_fixable':!![]}});}c['length']>MAX_GUARD_TABLE_ITEM_LENGTH&&b['push']({'code':'SH-07','message':'table\x20entry\x20count\x20'+c['length']+'\x20exceeds\x20the\x20maximum\x20limit\x20'+MAX_GUARD_TABLE_ITEM_LENGTH,'severity':'error','source':'lint','location':{'path':'/table'},'fix':{'description':'Slim\x20down\x20the\x20table\x20by\x20merging\x20similar\x20entries,\x20or\x20split\x20into\x20multiple\x20Guards\x20+\x20rely','auto_fixable':![]}});for(let h=0x0;h<c['length'];h++){c[h]['b_submission']===undefined&&b['push']({'code':'SH-10','message':'table['+h+']\x20b_submission\x20is\x20missing','severity':'info','source':'lint','location':{'path':'/table/'+h+'/b_submission'},'fix':{'description':'Set\x20to\x20false\x20(constant)\x20or\x20true\x20(submitted\x20data)','auto_fixable':!![]}});}for(let j=0x0;j<c['length'];j++){const k=c[j];k['b_submission']===!![]&&k['value']!==undefined&&k['value']!==null&&b['push']({'code':'SH-11','message':'table['+j+']\x20has\x20a\x20redundant\x20value\x20field\x20on\x20b_submission=true\x20entry\x20(the\x20verifier\x20supplies\x20the\x20value\x20at\x20runtime;\x20this\x20value\x20is\x20ignored\x20by\x20BCS\x20encoding\x20and\x20wastes\x20gas)','severity':'warning','source':'lint','location':{'path':'/table/'+j+'/value'},'fix':{'description':'Remove\x20the\x20value\x20field\x20—\x20it\x20is\x20ignored\x20for\x20b_submission=true\x20entries','auto_fixable':!![]}});}return b;}function checkSuggestions(a){const b=[],{root:c,binding_hint:d,table:e}=a;if(c){const g=rootToString(c);if(g['includes']('vec_contains_address')&&g['includes']('Signer'))b['push']({'code':'SG-01','message':'Matches\x20Pattern\x20P04\x20(whitelist\x20validation)','severity':'hint','source':'lint','location':{'path':'/root'},'fix':{'description':'Refer\x20to\x20the\x20P04\x20Pattern\x20to\x20ensure\x20best\x20practices','auto_fixable':![]}});else{if(g['includes']('logic_equal')&&g['includes']('Signer')){const h=e['some'](i=>!i['b_submission']&&i['value_type']==='Address'&&typeof i['value']==='string'&&i['value']['length']>0x0);h&&b['push']({'code':'SG-01','message':'Matches\x20Pattern\x20P04\x20(whitelist\x20validation\x20—\x20single-address\x20variant)','severity':'hint','source':'lint','location':{'path':'/root'},'fix':{'description':'P04\x20single-address\x20form;\x20for\x20multi-address\x20scenarios,\x20consider\x20vec_contains_address','auto_fixable':![]}});}}(g['includes']('logic_as_u256_greater')||g['includes']('logic_as_u256_lesser'))&&b['push']({'code':'SG-01','message':'Matches\x20Pattern\x20P02\x20(numeric\x20threshold\x20validation)','severity':'hint','source':'lint','location':{'path':'/root'},'fix':{'description':'Suitable\x20for\x20amount/quantity\x20threshold\x20validation\x20scenarios','auto_fixable':![]}}),g['includes']('convert_witness')&&b['push']({'code':'SG-01','message':'Matches\x20Pattern\x20P09\x20(witness-derived\x20validation)','severity':'hint','source':'lint','location':{'path':'/root'},'fix':{'description':'Suitable\x20for\x20cross-object\x20relationship\x20validation\x20(e.g.\x20Order→Progress)','auto_fixable':![]}});}if(d?.['action']){const i=['buy','forward','allocate','claim_reward','vote','dispute','write_repository','submit_progress','gen_passport'];if(i['includes'](d['action'])){const j=inferSceneFromAction(d['action']);if(j){const k=suggestTemplateForScene(j['id']);k&&b['push']({'code':'SG-02','message':'Recommended\x20scene\x20template:\x20'+k['name'],'severity':'hint','source':'lint','location':{'path':'/'},'fix':{'description':'Refer\x20to\x20template\x20'+k['id']+'\x20('+k['example_use_case']+')','auto_fixable':![]}});}}}const f=getSubmissionEntries(e);for(const l of f){const m=l['name']??'';if(m['length']<0xa||/^[a-z_]+$/i['test'](m)){const n=e['indexOf'](l);b['push']({'code':'SG-03','message':'table['+n+']\x20submitted\x20data\x20has\x20a\x20vague\x20name\x20description','severity':'info','source':'lint','location':{'path':'/table/'+n+'/name'},'fix':{'description':'Use\x20a\x20full\x20natural-language\x20description\x20(≥10\x20characters),\x20e.g.\x20\x27user-submitted\x20operation\x20type\x20(return/damage)\x27','auto_fixable':![]}});}}if(c){const o=rootToString(c),p=o['includes']('proof.signer'),q=o['includes']('proof.time'),r=o['includes']('calc_string_length'),s=f['some'](t=>t['value_type']==='String');if(p&&q)b['push']({'code':'SG-04','message':'Strict-mode\x20privacy-delivery\x20guard\x20detected\x20(proof.signer\x20+\x20proof.time).\x20'+'Recommended\x20three\x20conditions:\x20Signer==proof.signer\x20(submitter\x20accountability),\x20'+'proof.time>order.time\x20(freshness),\x20order.service==service\x20(project\x20binding).\x20'+'No\x20content\x20verification\x20—\x20only\x20submission\x20responsibility\x20(\x27whoever\x20benefits\x20bears\x20the\x20burden\x20of\x20proof\x27).','severity':'info','source':'lint','location':{'path':'/root'},'fix':{'description':'Ensure\x20all\x20three\x20conditions\x20are\x20present\x20(logic_and).\x20Refer\x20to\x20template\x20tpl_forward_privacy_delivery_proof.\x20'+'Query\x20IDs:\x20proof.signer=1958,\x20proof.time=1960,\x20order.time=1574,\x20order.service=1563.','auto_fixable':![]}});else r&&s&&b['push']({'code':'SG-04','message':'Broad-mode\x20privacy-delivery\x20guard\x20detected\x20(String\x20submission\x20+\x20length\x20check,\x20e.g.\x20Merkle\x20Root\x20length\x20==\x2066).\x20'+'This\x20trusts\x20the\x20submitter\x27s\x20honesty;\x20the\x20counterparty\x20can\x20dispute\x20by\x20checking\x20their\x20own\x20Messenger\x20conversation.\x20'+'Suitable\x20as\x20an\x20arbitration\x20basis,\x20not\x20a\x20fund-flow\x20gate.','severity':'info','source':'lint','location':{'path':'/root'},'fix':{'description':'For\x20stronger\x20assurance,\x20consider\x20strict\x20mode:\x20submit\x20a\x20Proof\x20object\x20address\x20(from\x20messenger.submitChainProof)\x20+\x20'+'Order\x20address,\x20then\x20verify\x20proof.signer/proof.time/order.service.\x20See\x20template\x20tpl_forward_privacy_delivery_proof.','auto_fixable':![]}});}return b;}export function autoFixGuard(a){const b=deepClone(a),c=[];(!b['description']||b['description']['trim']()==='')&&(b['description']='Guard\x20(table:\x20'+b['table']['length']+'\x20items,\x20root:\x20'+(b['root']?.['type']??'unknown')+')',c['push']({'diagnostic_code':'SH-01','description':'Fill\x20in\x20default\x20description','after':b['description'],'path':'/description'}));if(b['description']&&b['description']['length']>MAX_DESCRIPTION_LENGTH){const f=b['description'];b['description']=b['description']['substring'](0x0,MAX_DESCRIPTION_LENGTH),c['push']({'diagnostic_code':'G-001','description':'Truncate\x20description\x20to\x20'+MAX_DESCRIPTION_LENGTH+'\x20characters','before':f['length']+'\x20characters','after':b['description']['length']+'\x20characters','path':'/description'});}for(let g=0x0;g<b['table']['length'];g++){const h=b['table'][g];(!h['name']||h['name']['trim']()==='')&&(h['name']='data\x20entry\x20'+h['identifier'],c['push']({'diagnostic_code':'SH-03','description':'table['+g+']\x20fill\x20in\x20name','after':h['name'],'path':'/table/'+g+'/name'}));}for(let j=0x0;j<b['table']['length'];j++){const k=b['table'][j];if(!k['value_type']&&k['value']!==undefined&&k['value']!==null){const l=inferValueType(k['value']);l&&(k['value_type']=l,c['push']({'diagnostic_code':'SH-05','description':'table['+j+']\x20infer\x20value_type','after':l,'path':'/table/'+j+'/value_type'}));}}const d=new Map();let e=0x0;for(let m=0x0;m<b['table']['length'];m++){const n=b['table'][m];if(!d['has'](n['identifier']))d['set'](n['identifier'],e),n['identifier']!==e&&c['push']({'diagnostic_code':'G-007','description':'table['+m+']\x20identifier\x20'+n['identifier']+'\x20→\x20'+e,'before':String(n['identifier']),'after':String(e),'path':'/table/'+m+'/identifier'}),n['identifier']=e,e++;else{const o=n['identifier'];n['identifier']=e,d['set'](o,e),c['push']({'diagnostic_code':'G-007','description':'table['+m+']\x20identifier\x20'+o+'\x20duplicate\x20→\x20reallocated\x20to\x20'+e,'before':String(o),'after':String(e),'path':'/table/'+m+'/identifier'}),e++;}}for(let p=0x0;p<b['table']['length'];p++){const q=b['table'][p];q['b_submission']===undefined&&(q['b_submission']=![],c['push']({'diagnostic_code':'SH-10','description':'table['+p+']\x20b_submission\x20default\x20set\x20to\x20false','after':'false','path':'/table/'+p+'/b_submission'}));}if(b['rely']?.['guards']&&b['rely']['guards']['length']>0x0){const r=[...new Set(b['rely']['guards'])];r['length']!==b['rely']['guards']['length']&&(c['push']({'diagnostic_code':'G-009','description':'rely\x20deduplicate:\x20'+b['rely']['guards']['length']+'\x20→\x20'+r['length'],'before':JSON['stringify'](b['rely']['guards']),'after':JSON['stringify'](r),'path':'/rely/guards'}),b['rely']['guards']=r);}for(let s=0x0;s<b['table']['length'];s++){const t=b['table'][s];if(t['b_submission']===!![]&&t['value']!==undefined&&t['value']!==null){const u=JSON['stringify'](t['value']);delete t['value'],c['push']({'diagnostic_code':'SH-11','description':'table['+s+']\x20remove\x20redundant\x20value\x20on\x20b_submission=true\x20entry','before':u,'after':'(removed)','path':'/table/'+s+'/value'});}}return{'fixed':b,'actions':c};}export async function lintGuard(a,b){const c=b?.['auto_fix']??!![],{table:d,root:e,rely:f,binding_hint:g}=a,h=[];let i;const j=await checkSdkSyntax(a);h['push'](...j);const k=checkSemanticErrors(a);h['push'](...k);const l=checkSyntaxHints(a);h['push'](...l);let m,n=[];if(c){const {fixed:v,actions:w}=autoFixGuard(a);w['length']>0x0&&(m=v,n=w);}if(d['length']>0x0&&e){const x=g?findScene(g['host_object']??'',g['binding_field']??''):undefined,y=d['map'](A=>({'identifier':A['identifier'],'b_submission':A['b_submission']??![],'value_type':A['value_type']??'Address','value':A['value'],'name':A['name'],'object_type':A['object_type']})),z=evaluateGuardDraft({'table':y,'root':e,'rely':f,'scene':x,'sharing_recipients':g?.['sharing_recipients']});i=z['assessment'];for(const A of i['risks']){const B=A['level']==='critical'||A['level']==='high'?'error':A['level']==='medium'?'warning':A['level']==='low'?'info':'hint',C=A['evidence']??'',D=C['startsWith']('/')?C:'/';h['push']({'code':A['id'],'message':'['+A['level']+']\x20'+A['title'],'severity':B,'source':'risk','location':{'path':D},'fix':{'description':A['mitigation'],'auto_fixable':![]}});}}const o=checkSuggestions(a);h['push'](...o);const p=h['filter'](E=>E['severity']==='error')['length'],q=h['filter'](E=>E['severity']==='warning')['length'],s=h['filter'](E=>E['severity']==='info'||E['severity']==='hint')['length'],t=p===0x0;let u;if(p>0x0)u='Fix\x20'+p+'\x20error(s)\x20and\x20re-run\x20lint';else q>0x0?u='Consider\x20addressing\x20'+q+'\x20warning(s),\x20then\x20submit\x20to\x20SDK\x20newGuard()\x20for\x20final\x20syntax\x20validation':u='lint\x20passed\x20(no\x20errors);\x20submit\x20to\x20SDK\x20newGuard()\x20for\x20final\x20syntax\x20validation\x20before\x20going\x20on-chain';return{'json_summary':{'table_count':d['length'],'root_type':e?.['type']??'unknown','has_rely':!!f?.['guards']?.['length'],'rely_count':f?.['guards']?.['length']??0x0,'has_description':!!a['description']},'diagnostics':h,'fixed_json':m,'fix_actions':n,'risk_assessment':i,'summary':{'errors':p,'warnings':q,'infos':s,'auto_fixes_applied':n['length'],'ready':t,'next_step':u}};}export async function isGuardReady(a){const b=await lintGuard(a,{'auto_fix':![]});return b['summary']['ready'];}export async function getGuardErrors(a){const b=await lintGuard(a,{'auto_fix':![]});return b['diagnostics']['filter'](c=>c['severity']==='error');}export function formatLintResult(a){const b=[];b['push']('===\x20Guard\x20JSON\x20Lint\x20Report\x20==='),b['push'](''),b['push']('Summary:'),b['push']('\x20\x20Errors:\x20\x20\x20\x20\x20'+a['summary']['errors']),b['push']('\x20\x20Warnings:\x20\x20\x20'+a['summary']['warnings']),b['push']('\x20\x20Infos:\x20\x20\x20\x20\x20\x20'+a['summary']['infos']),b['push']('\x20\x20Auto-fixes:\x20'+a['summary']['auto_fixes_applied']),b['push']('\x20\x20Ready:\x20\x20\x20\x20\x20\x20'+(a['summary']['ready']?'YES':'NO')),b['push']('\x20\x20Next\x20step:\x20\x20'+a['summary']['next_step']),b['push']('');if(a['fix_actions']['length']>0x0){b['push']('---\x20Auto-fix\x20Actions\x20---');for(const g of a['fix_actions']){b['push']('\x20\x20['+g['diagnostic_code']+']\x20'+g['description']),b['push']('\x20\x20\x20\x20Path:\x20'+g['path']),g['before']&&g['after']&&b['push']('\x20\x20\x20\x20'+g['before']+'\x20->\x20'+g['after']);}b['push']('');}const c=a['diagnostics']['filter'](h=>h['severity']==='error'),e=a['diagnostics']['filter'](h=>h['severity']==='warning'),f=a['diagnostics']['filter'](h=>h['severity']==='info'||h['severity']==='hint');if(c['length']>0x0){b['push']('---\x20Errors\x20(must\x20fix)\x20---');for(const h of c){b['push']('\x20\x20['+h['code']+']\x20('+h['source']+')\x20'+h['message']),b['push']('\x20\x20\x20\x20Path:\x20'+h['location']['path']);if(h['fix'])b['push']('\x20\x20\x20\x20Fix:\x20\x20'+h['fix']['description']);}b['push']('');}if(e['length']>0x0){b['push']('---\x20Warnings\x20(consider\x20fixing)\x20---');for(const i of e){b['push']('\x20\x20['+i['code']+']\x20('+i['source']+')\x20'+i['message']),b['push']('\x20\x20\x20\x20Path:\x20'+i['location']['path']);if(i['fix'])b['push']('\x20\x20\x20\x20Fix:\x20\x20'+i['fix']['description']);}b['push']('');}if(f['length']>0x0){b['push']('---\x20Info\x20&\x20Hints\x20---');for(const j of f){b['push']('\x20\x20['+j['code']+']\x20('+j['source']+')\x20'+j['message']),b['push']('\x20\x20\x20\x20Path:\x20'+j['location']['path']);}}return b['join']('\x0a');}
|
|
@@ -1,17 +1,4 @@
|
|
|
1
1
|
import type { GuardScene } from "./guard-ledger.js";
|
|
2
|
-
export declare const GUARD_COGNITIVE_PRINCIPLES: readonly [{
|
|
3
|
-
readonly id: "P1";
|
|
4
|
-
readonly title: "Guard validation always precedes the operation";
|
|
5
|
-
readonly statement: string;
|
|
6
|
-
readonly code_evidence: string;
|
|
7
|
-
readonly legitimate_exception: string;
|
|
8
|
-
readonly scope: "Applies when a Guard queries state of the SAME object the operation mutates.";
|
|
9
|
-
}, {
|
|
10
|
-
readonly id: "P2";
|
|
11
|
-
readonly title: "Guard is CREATE-only and immutable";
|
|
12
|
-
readonly statement: string;
|
|
13
|
-
readonly scope: "Applies to all Guard lifecycle decisions.";
|
|
14
|
-
}];
|
|
15
2
|
export type GuardStakeholder = "customer" | "provider" | "arbitrator" | "claimant" | "system";
|
|
16
3
|
export type RiskLevel = "critical" | "high" | "medium" | "low";
|
|
17
4
|
export type DataSourceClass = "type1_onchain_constant" | "type2_witness_derived" | "type3_submitted_object" | "type4_system_context" | "cross_type";
|
|
@@ -61,15 +48,15 @@ export interface RiskCheckContext {
|
|
|
61
48
|
operation_type?: string;
|
|
62
49
|
sharing_recipients?: ("Signer" | "Entity" | "GuardIdentifier")[];
|
|
63
50
|
}
|
|
64
|
-
export declare
|
|
51
|
+
export declare const RISK_RULES: RiskRule[];
|
|
52
|
+
export declare function runGuardRulePack(ctx: RiskCheckContext): GuardRisk[];
|
|
53
|
+
export declare function assembleGuardAssessment(params: {
|
|
65
54
|
table: RiskCheckContext["table"];
|
|
66
55
|
root: any;
|
|
67
56
|
rely?: RiskCheckContext["rely"];
|
|
68
57
|
scene?: GuardScene;
|
|
69
|
-
operation_type?: string;
|
|
70
58
|
sharing_recipients?: RiskCheckContext["sharing_recipients"];
|
|
71
|
-
}): GuardRiskAssessment;
|
|
72
|
-
export declare function assessGuardRisksForOperation(operation_type: string, data: any): GuardRiskAssessment | null;
|
|
59
|
+
}, risks: GuardRisk[]): GuardRiskAssessment;
|
|
73
60
|
export declare function getRiskSummary(assessment: GuardRiskAssessment): {
|
|
74
61
|
risk_count: number;
|
|
75
62
|
critical_count: number;
|
|
@@ -77,6 +64,4 @@ export declare function getRiskSummary(assessment: GuardRiskAssessment): {
|
|
|
77
64
|
needs_human_review: boolean;
|
|
78
65
|
top_risks: string[];
|
|
79
66
|
};
|
|
80
|
-
export declare function getRiskRulesByDataSourceClass(dataSourceClass: DataSourceClass): RiskRule[];
|
|
81
|
-
export declare function getAllRiskRules(): RiskRule[];
|
|
82
67
|
export declare function getRiskRulesCount(): number;
|