@wowok/agent-mcp 2.7.1 → 2.7.2
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/index.js +1 -1
- package/dist/config/runtime.js +1 -238
- package/dist/customer/customer-advice.js +1 -130
- package/dist/customer/index.js +1 -11
- package/dist/customer/industry-risks.js +1 -438
- package/dist/customer/info-puzzle.js +1 -681
- package/dist/customer/order-monitor.js +1 -328
- package/dist/customer/order-strategy.js +1 -373
- package/dist/customer/post-purchase.js +1 -351
- package/dist/customer/preorder-compare.js +1 -34
- package/dist/customer/reminder-system.js +1 -316
- package/dist/customer/risk-assessment.js +1 -397
- package/dist/customer/types.js +1 -13
- package/dist/customer/user-preferences.js +1 -460
- package/dist/evaluation/arbitration-game.d.ts +9 -2
- package/dist/evaluation/arbitration-game.js +1 -48
- package/dist/evaluation/builtins/demand-match.js +1 -153
- package/dist/evaluation/builtins/index.js +1 -10
- package/dist/evaluation/builtins/service-risk.js +1 -55
- package/dist/evaluation/capability.js +1 -13
- package/dist/evaluation/composer.js +1 -40
- package/dist/evaluation/engine.js +1 -175
- package/dist/evaluation/extract.js +1 -115
- package/dist/evaluation/game-strategy.d.ts +27 -0
- package/dist/evaluation/game-strategy.js +1 -0
- package/dist/evaluation/gap.js +1 -100
- package/dist/evaluation/index.d.ts +1 -0
- package/dist/evaluation/index.js +1 -11
- package/dist/evaluation/node-game.d.ts +31 -3
- package/dist/evaluation/node-game.js +1 -57
- package/dist/evaluation/region.js +1 -36
- package/dist/evaluation/types.d.ts +1 -0
- package/dist/evaluation/types.js +1 -1
- package/dist/evaluation/user-injection.js +1 -27
- package/dist/experience/experience-reuse.js +1 -103
- package/dist/experience/index.js +1 -5
- package/dist/experience/intent-distill.js +1 -83
- package/dist/experience/realtime-feedback.js +1 -94
- package/dist/experience/types.js +1 -1
- package/dist/experience/user-profile.js +1 -171
- package/dist/extensions/business-modules.js +1 -287
- package/dist/extensions/capability-manifest.js +1 -781
- package/dist/extensions/constraint-registry.js +1 -198
- package/dist/extensions/index.js +1 -6
- package/dist/extensions/metric-registry.js +1 -257
- package/dist/extensions/mode-evaluator.js +1 -170
- package/dist/extensions/modes.js +1 -499
- package/dist/extensions/registry.js +1 -717
- package/dist/extensions/types.js +1 -1
- package/dist/harness/auto-escalation.js +1 -68
- package/dist/harness/checkpoint.js +1 -129
- package/dist/harness/index.js +1 -78
- package/dist/harness/plan.js +1 -315
- package/dist/harness/recover.js +1 -139
- package/dist/harness/types.js +1 -1
- package/dist/harness/verify.js +1 -237
- package/dist/index.js +1 -273
- package/dist/intent/enrich.js +1 -67
- package/dist/intent/index.js +1 -60
- package/dist/intent/matcher.js +1 -81
- package/dist/intent/store.js +1 -55
- package/dist/intent/types.js +1 -10
- package/dist/knowledge/acquisition-flywheel.js +1 -192
- package/dist/knowledge/allocation-confirm.js +1 -534
- package/dist/knowledge/allocation-context.js +1 -249
- package/dist/knowledge/allocation-ledger.js +1 -463
- package/dist/knowledge/allocation-puzzle.js +1 -298
- package/dist/knowledge/allocation-risk.js +1 -568
- package/dist/knowledge/allocation-templates.js +1 -970
- package/dist/knowledge/allocation-translation.js +1 -585
- package/dist/knowledge/arb-risk.js +1 -210
- package/dist/knowledge/arbitration-confirm.js +1 -559
- package/dist/knowledge/arbitration-context.js +1 -505
- package/dist/knowledge/arbitration-ledger.js +1 -521
- package/dist/knowledge/arbitration-puzzle.js +1 -304
- package/dist/knowledge/arbitration-risk.js +1 -423
- package/dist/knowledge/arbitration-templates.js +1 -276
- package/dist/knowledge/arbitration-translation.js +1 -487
- package/dist/knowledge/arbitration-trust.js +1 -117
- package/dist/knowledge/audit-rules.js +1 -141
- package/dist/knowledge/bridge-risk.js +1 -263
- package/dist/knowledge/contact-risk.js +1 -200
- package/dist/knowledge/contact-templates.js +1 -60
- package/dist/knowledge/demand-confirm.js +1 -206
- package/dist/knowledge/demand-matching.js +1 -132
- package/dist/knowledge/demand-risk.js +1 -240
- package/dist/knowledge/demand-translation.js +1 -354
- package/dist/knowledge/deployment-scanner.js +1 -823
- package/dist/knowledge/dynamic-pricing.js +1 -87
- package/dist/knowledge/examples-scanner-cli.js +1 -26
- package/dist/knowledge/examples-scanner.js +1 -843
- package/dist/knowledge/flywheel-loop.js +1 -404
- package/dist/knowledge/fund-layer.js +1 -973
- package/dist/knowledge/glossary.js +1 -211
- package/dist/knowledge/guard-confirm.js +1 -406
- package/dist/knowledge/guard-context.js +1 -287
- package/dist/knowledge/guard-design-patterns.js +1 -360
- package/dist/knowledge/guard-ledger.js +1 -260
- package/dist/knowledge/guard-lint.js +1 -670
- package/dist/knowledge/guard-migration.js +1 -228
- package/dist/knowledge/guard-puzzle.js +1 -805
- package/dist/knowledge/guard-render.js +1 -700
- package/dist/knowledge/guard-risk.js +1 -1879
- package/dist/knowledge/guard-submission-prompt.js +1 -171
- package/dist/knowledge/guard-templates.js +1 -1105
- package/dist/knowledge/guard-translation.js +1 -1119
- package/dist/knowledge/index.js +1 -436
- package/dist/knowledge/industry-evolution.js +1 -323
- package/dist/knowledge/industry-generalizer.js +1 -381
- package/dist/knowledge/industry-registry.js +1 -174
- package/dist/knowledge/intent-metrics.d.ts +4 -3
- package/dist/knowledge/intent-metrics.js +1 -566
- package/dist/knowledge/machine-confirm.js +1 -559
- package/dist/knowledge/machine-context.js +1 -833
- package/dist/knowledge/machine-ledger.js +1 -338
- package/dist/knowledge/machine-puzzle.js +1 -494
- package/dist/knowledge/machine-render.js +1 -565
- package/dist/knowledge/machine-risk.js +1 -669
- package/dist/knowledge/machine-templates.js +1 -1597
- package/dist/knowledge/machine-topology.js +1 -234
- package/dist/knowledge/machine-translation.js +1 -513
- package/dist/knowledge/mcp-schema-audit-cli.js +1 -45
- package/dist/knowledge/mcp-schema-audit.js +1 -777
- package/dist/knowledge/onchain-constants.js +1 -35
- package/dist/knowledge/order-confirm.js +1 -573
- package/dist/knowledge/order-context.js +1 -390
- package/dist/knowledge/order-ledger.js +1 -341
- package/dist/knowledge/order-puzzle.js +1 -255
- package/dist/knowledge/order-risk.js +1 -653
- package/dist/knowledge/order-templates.js +1 -368
- package/dist/knowledge/order-translation.js +1 -550
- package/dist/knowledge/overrides-loader.js +1 -65
- package/dist/knowledge/passport-confirm.js +1 -531
- package/dist/knowledge/passport-context.js +1 -306
- package/dist/knowledge/passport-ledger.js +1 -282
- package/dist/knowledge/passport-puzzle.js +1 -333
- package/dist/knowledge/passport-risk.js +1 -450
- package/dist/knowledge/passport-templates.js +1 -568
- package/dist/knowledge/passport-translation.js +1 -516
- package/dist/knowledge/payment-risk.js +1 -249
- package/dist/knowledge/permission-confirm.js +1 -426
- package/dist/knowledge/permission-context.js +1 -224
- package/dist/knowledge/permission-ledger.js +1 -403
- package/dist/knowledge/permission-puzzle.js +1 -173
- package/dist/knowledge/permission-risk.js +1 -411
- package/dist/knowledge/permission-templates.js +1 -234
- package/dist/knowledge/permission-translation.js +1 -350
- package/dist/knowledge/personal-risk.js +1 -212
- package/dist/knowledge/process-model.js +1 -160
- package/dist/knowledge/progress-confirm.js +1 -456
- package/dist/knowledge/progress-context.js +1 -452
- package/dist/knowledge/progress-ledger.js +1 -330
- package/dist/knowledge/progress-puzzle.js +1 -219
- package/dist/knowledge/progress-risk.js +1 -461
- package/dist/knowledge/progress-templates.js +1 -228
- package/dist/knowledge/progress-translation.js +1 -405
- package/dist/knowledge/proof-confirm.js +1 -187
- package/dist/knowledge/proof-risk.js +1 -207
- package/dist/knowledge/proof-translation.js +1 -283
- package/dist/knowledge/registrar-risk.js +1 -217
- package/dist/knowledge/repository-confirm.js +1 -286
- package/dist/knowledge/repository-risk.js +1 -373
- package/dist/knowledge/repository-translation.js +1 -445
- package/dist/knowledge/reputation-rules.js +1 -99
- package/dist/knowledge/resource-risk.js +1 -157
- package/dist/knowledge/reward-confirm.js +1 -526
- package/dist/knowledge/reward-context.js +1 -504
- package/dist/knowledge/reward-ledger.js +1 -502
- package/dist/knowledge/reward-puzzle.js +1 -300
- package/dist/knowledge/reward-risk.js +1 -627
- package/dist/knowledge/reward-templates.js +1 -197
- package/dist/knowledge/reward-translation.js +1 -501
- package/dist/knowledge/safety-rules.js +1 -404
- package/dist/knowledge/scenario-modes.js +1 -321
- package/dist/knowledge/service-confirm.js +1 -807
- package/dist/knowledge/service-context.js +1 -403
- package/dist/knowledge/service-ledger.js +1 -609
- package/dist/knowledge/service-puzzle.js +1 -236
- package/dist/knowledge/service-risk.js +1 -651
- package/dist/knowledge/service-templates.js +1 -456
- package/dist/knowledge/service-translation.js +1 -622
- package/dist/knowledge/template-registry.js +1 -353
- package/dist/knowledge/tool-constraints.js +1 -195
- package/dist/knowledge/tools-reference.js +1 -178
- package/dist/knowledge/treasury-confirm.js +1 -512
- package/dist/knowledge/treasury-context.js +1 -363
- package/dist/knowledge/treasury-ledger.js +1 -300
- package/dist/knowledge/treasury-puzzle.js +1 -216
- package/dist/knowledge/treasury-risk.js +1 -440
- package/dist/knowledge/treasury-templates.js +1 -358
- package/dist/knowledge/treasury-translation.js +1 -498
- package/dist/knowledge/trust-metrics.js +1 -198
- package/dist/knowledge/util-risk.js +1 -135
- package/dist/loop-engineering/aggregate.js +1 -132
- package/dist/loop-engineering/context-collect.js +1 -83
- package/dist/loop-engineering/diagnose.js +1 -273
- package/dist/loop-engineering/improve.js +1 -405
- package/dist/loop-engineering/index.js +1 -4
- package/dist/loop-engineering/pipeline.js +1 -56
- package/dist/mode-market/index.js +1 -3
- package/dist/mode-market/registry.js +1 -124
- package/dist/mode-market/review.js +1 -214
- package/dist/mode-market/submission.js +1 -85
- package/dist/participation/collaborator-interest.d.ts +23 -0
- package/dist/participation/collaborator-interest.js +1 -0
- package/dist/participation/customer-interest.d.ts +25 -0
- package/dist/participation/customer-interest.js +1 -0
- package/dist/participation/merchant-interest.js +1 -100
- package/dist/participation/radar-core.d.ts +13 -3
- package/dist/participation/radar-core.js +1 -269
- package/dist/participation/supplier-interest.d.ts +25 -0
- package/dist/participation/supplier-interest.js +1 -0
- package/dist/persona/analyzer.js +1 -66
- package/dist/persona/bridge.js +1 -86
- package/dist/persona/defaults.js +1 -195
- package/dist/persona/experience-bridge.js +1 -23
- package/dist/persona/index.js +1 -71
- package/dist/persona/model.js +1 -111
- package/dist/persona/store.js +1 -62
- package/dist/persona/types.d.ts +3 -1
- package/dist/persona/types.js +1 -5
- package/dist/project/business-puzzle.js +1 -383
- package/dist/project/context-assembly.js +1 -254
- package/dist/project/deployment-bridge.js +1 -120
- package/dist/project/deployment-doc.js +1 -1126
- package/dist/project/edit-planner.js +1 -1342
- package/dist/project/evaluation.js +1 -2011
- package/dist/project/game-theory.js +1 -177
- package/dist/project/graph-builder.js +1 -656
- package/dist/project/graph.js +1 -340
- package/dist/project/handlers.js +1 -1784
- package/dist/project/index.d.ts +1 -0
- package/dist/project/index.js +1 -301
- package/dist/project/intent-analyzer.js +1 -149
- package/dist/project/machine-nodes.js +1 -36
- package/dist/project/merchant-guide.js +1 -264
- package/dist/project/migration.js +1 -125
- package/dist/project/mode-actions.js +1 -309
- package/dist/project/namespace.js +1 -206
- package/dist/project/participation-radar.js +1 -428
- package/dist/project/pipeline-actions.js +1 -109
- package/dist/project/project-store.js +1 -422
- package/dist/project/query.js +1 -153
- package/dist/project/reverse-mapping.d.ts +34 -0
- package/dist/project/reverse-mapping.js +1 -0
- package/dist/project/risk-aggregator.js +1 -295
- package/dist/project/rollback-policy.js +1 -290
- package/dist/project/semantic-assembler.js +1 -345
- package/dist/project/semantic-graph.js +1 -292
- package/dist/project/stage-gate.js +1 -369
- package/dist/project/substep-trace.js +1 -332
- package/dist/project/task-tracker.js +1 -78
- package/dist/role/derivation.d.ts +18 -0
- package/dist/role/derivation.js +1 -0
- package/dist/role/index.d.ts +5 -0
- package/dist/role/index.js +1 -0
- package/dist/role/model.d.ts +8 -0
- package/dist/role/model.js +1 -0
- package/dist/role/resolution.d.ts +11 -0
- package/dist/role/resolution.js +1 -0
- package/dist/role/types.d.ts +11 -0
- package/dist/role/types.js +1 -0
- package/dist/rules.js +1 -52
- package/dist/safety/confirm-gate.js +1 -88
- package/dist/safety/index.js +1 -3
- package/dist/safety/preview.js +1 -52
- package/dist/schema/call/allocation.js +1 -34
- package/dist/schema/call/arbitration.js +1 -113
- package/dist/schema/call/base.d.ts +15 -15
- package/dist/schema/call/base.js +1 -370
- package/dist/schema/call/bridge-handler.js +1 -265
- package/dist/schema/call/bridge.d.ts +7 -7
- package/dist/schema/call/bridge.js +1 -458
- package/dist/schema/call/contact.js +1 -37
- package/dist/schema/call/demand.js +1 -47
- package/dist/schema/call/guard.js +1 -161
- package/dist/schema/call/handler.js +1 -322
- package/dist/schema/call/index.js +1 -20
- package/dist/schema/call/machine.js +1 -193
- package/dist/schema/call/order.js +1 -35
- package/dist/schema/call/payment.js +1 -37
- package/dist/schema/call/permission-handler.js +1 -54
- package/dist/schema/call/permission.js +1 -105
- package/dist/schema/call/personal.js +1 -78
- package/dist/schema/call/progress.js +1 -47
- package/dist/schema/call/proof.js +1 -33
- package/dist/schema/call/repository.js +1 -77
- package/dist/schema/call/reward.js +1 -30
- package/dist/schema/call/semantic.js +1 -1679
- package/dist/schema/call/service.js +1 -184
- package/dist/schema/call/treasury.js +1 -71
- package/dist/schema/common/index.js +1 -407
- package/dist/schema/config/index.js +1 -68
- package/dist/schema/evaluation/index.d.ts +213 -16
- package/dist/schema/evaluation/index.js +1 -356
- package/dist/schema/index.js +1 -17
- package/dist/schema/intent-radar/index.d.ts +13 -13
- package/dist/schema/intent-radar/index.js +1 -89
- package/dist/schema/local/index.d.ts +21 -21
- package/dist/schema/local/index.js +1 -927
- package/dist/schema/local/wip.js +1 -187
- package/dist/schema/messenger/index.d.ts +7 -7
- package/dist/schema/messenger/index.js +1 -475
- package/dist/schema/operations.d.ts +7 -7
- package/dist/schema/operations.js +1 -520
- package/dist/schema/persona/index.d.ts +54 -54
- package/dist/schema/persona/index.js +1 -148
- package/dist/schema/project/index.d.ts +94 -48
- package/dist/schema/project/index.js +1 -2057
- package/dist/schema/query/index.d.ts +423 -7
- package/dist/schema/query/index.js +1 -1646
- package/dist/schema/schema-query/index.js +1 -104
- package/dist/schema/schema-version.js +1 -76
- package/dist/schema/sync-layer4.js +1 -286
- package/dist/schema/task-status.js +1 -36
- package/dist/schema/trust/index.js +1 -314
- package/dist/schema/utils/guard-parser.js +1 -419
- package/dist/schema/utils/guard-query-utils.js +1 -46
- package/dist/schema/utils/node-parser.js +1 -369
- package/dist/schema/utils/object-type-utils.js +1 -35
- package/dist/schema/utils/permission-index-utils.js +1 -7
- package/dist/schema/utils/permission-machine-check.js +1 -121
- package/dist/schema/utils/skills-recommendation.js +1 -77
- package/dist/schema-query/index.js +1 -810
- package/dist/schemas/account_operation.output.json +5 -2
- package/dist/schemas/bridge_operation.output.json +5 -2
- package/dist/schemas/evaluation_operation.output.json +112 -7
- package/dist/schemas/evaluation_operation.schema.json +93 -6
- package/dist/schemas/index.json +1 -1
- package/dist/schemas/intent_radar.output.json +4 -1
- package/dist/schemas/intent_radar.schema.json +4 -1
- package/dist/schemas/local_info_operation.output.json +5 -2
- package/dist/schemas/local_mark_operation.output.json +5 -2
- package/dist/schemas/messenger_operation.output.json +5 -2
- package/dist/schemas/onchain_events.output.json +5 -2
- package/dist/schemas/onchain_operations.output.json +5 -2
- package/dist/schemas/onchain_operations.schema.json +4 -4
- package/dist/schemas/onchain_operations_allocation.schema.json +1 -1
- package/dist/schemas/onchain_operations_machine.schema.json +2 -2
- package/dist/schemas/onchain_operations_service.schema.json +1 -1
- package/dist/schemas/onchain_table_data.output.json +6 -3
- package/dist/schemas/persona_operation.output.json +4 -1
- package/dist/schemas/persona_operation.schema.json +4 -1
- package/dist/schemas/project_operation.output.json +28 -8
- package/dist/schemas/query_toolkit.output.json +8 -5
- package/dist/schemas/wowok_buildin_info.output.json +132 -0
- package/dist/schemas/wowok_buildin_info.schema.json +14 -0
- package/dist/telemetry/index.js +1 -112
- package/dist/telemetry/redact.js +1 -23
- package/dist/telemetry/storage.js +1 -80
- package/dist/tools/handlers/bridge.js +1 -1
- package/dist/tools/handlers/config.js +1 -74
- package/dist/tools/handlers/evaluation.js +1 -123
- package/dist/tools/handlers/file-export.js +1 -90
- package/dist/tools/handlers/intent-radar.js +1 -76
- package/dist/tools/handlers/local.js +1 -53
- package/dist/tools/handlers/messenger.js +1 -188
- package/dist/tools/handlers/onchain.js +1 -1180
- package/dist/tools/handlers/persona.js +1 -89
- package/dist/tools/handlers/project.js +1 -211
- package/dist/tools/handlers/query.js +1 -434
- package/dist/tools/handlers/schema-query.js +1 -176
- package/dist/tools/handlers/task-status.js +1 -26
- package/dist/tools/handlers/trust.js +1 -380
- package/dist/tools/handlers/wip.js +1 -90
- package/dist/tools/index.js +1 -1382
- package/dist/tools/retry.js +1 -85
- package/dist/tools/rules-hook.js +1 -23
- package/dist/tools/shared.js +1 -130
- package/dist/tools/types.js +1 -1
- package/dist/tools/upgrade-check.d.ts +19 -0
- package/dist/tools/upgrade-check.js +1 -0
- package/dist/tools/wip-deploy-assist.js +1 -306
- package/dist/tools/wrap.js +1 -500
- package/package.json +4 -2
|
@@ -1,360 +1 @@
|
|
|
1
|
-
export const GUARD_DESIGN_PATTERNS = [
|
|
2
|
-
{
|
|
3
|
-
id: "pattern.identity_check_single",
|
|
4
|
-
business_requirement: "Only the author can purchase this service (strict single-identity)",
|
|
5
|
-
data_source: "SystemContext",
|
|
6
|
-
host: "service_buy_guard",
|
|
7
|
-
verifier_level: "level1_strict_single",
|
|
8
|
-
logic_summary: "logic_equal[context(Signer), identifier[N](fixed_address)]",
|
|
9
|
-
key_queries: [],
|
|
10
|
-
mitigated_risks: ["R-C4-04"],
|
|
11
|
-
notes: [
|
|
12
|
-
"Maximally secure but maximally inconvenient",
|
|
13
|
-
"If address is unavailable (key loss, rotation), Guard permanently blocks",
|
|
14
|
-
"Avoid unless role is permanently tied to one address",
|
|
15
|
-
],
|
|
16
|
-
},
|
|
17
|
-
{
|
|
18
|
-
id: "pattern.identity_check_allowlist",
|
|
19
|
-
business_requirement: "Customer must be in an allowlist to purchase",
|
|
20
|
-
data_source: "SystemContext",
|
|
21
|
-
host: "service_buy_guard",
|
|
22
|
-
verifier_level: "level2_identity_set",
|
|
23
|
-
logic_summary: "vec_contains_address[identifier[N](allowlist_vec), context(Signer)]",
|
|
24
|
-
key_queries: [],
|
|
25
|
-
mitigated_risks: ["R-C4-04"],
|
|
26
|
-
notes: ["Allowlist stored as Address vector in table constant"],
|
|
27
|
-
},
|
|
28
|
-
{
|
|
29
|
-
id: "pattern.identity_check_order_holder",
|
|
30
|
-
business_requirement: "Only order owner or agent can perform operation",
|
|
31
|
-
data_source: "OnChainConstant",
|
|
32
|
-
host: "machine_forward",
|
|
33
|
-
verifier_level: "level2_identity_set",
|
|
34
|
-
logic_summary: "logic_or[logic_equal[query(1562 order.owner), context(Signer)], query(1567 order.agent has, Signer)]",
|
|
35
|
-
key_queries: ["order.owner", "order.agent has"],
|
|
36
|
-
mitigated_risks: ["R-C4-04", "R-C3-06"],
|
|
37
|
-
notes: [
|
|
38
|
-
"1562 returns Address → wrap in logic_equal",
|
|
39
|
-
"1567 returns Bool → use directly as logic_or child",
|
|
40
|
-
"Recommended Level 2 alternative to Level 1 strict binding",
|
|
41
|
-
],
|
|
42
|
-
},
|
|
43
|
-
{
|
|
44
|
-
id: "pattern.identity_check_service_provider_dynamic",
|
|
45
|
-
business_requirement: "Verify caller is service's current permission owner (survives permission rotation)",
|
|
46
|
-
data_source: "SubmittedObject",
|
|
47
|
-
host: "machine_forward",
|
|
48
|
-
verifier_level: "level2_identity_set",
|
|
49
|
-
logic_summary: "logic_and[logic_equal[query(1488 service.permission), identifier[N](submitted_perm)], logic_or[logic_equal[query(1002 permission.owner), context(Signer)], query(1004 permission.admin has, Signer)]]",
|
|
50
|
-
key_queries: ["service.permission", "permission.owner", "permission.admin has"],
|
|
51
|
-
mitigated_risks: ["R-C4-04", "R-C3-05"],
|
|
52
|
-
notes: [
|
|
53
|
-
"Dynamic permission address (RECOMMENDED) — survives Service permission rotation",
|
|
54
|
-
"Caller submits permission address; Guard verifies match then checks identity",
|
|
55
|
-
"More complex than static but far more robust",
|
|
56
|
-
],
|
|
57
|
-
},
|
|
58
|
-
{
|
|
59
|
-
id: "pattern.time_lock_progress",
|
|
60
|
-
business_requirement: "Customer must wait N hours before completing (time-lock)",
|
|
61
|
-
data_source: "WitnessDerived",
|
|
62
|
-
host: "machine_forward",
|
|
63
|
-
verifier_level: "none",
|
|
64
|
-
logic_summary: "logic_as_u256_ge[context(Clock), calc_number_add[query(1272 progress.current_time, witness=OrderProgress), identifier[N](duration_ms)]]",
|
|
65
|
-
key_queries: ["progress.current_time"],
|
|
66
|
-
witness_types: ["OrderProgress"],
|
|
67
|
-
mitigated_risks: [],
|
|
68
|
-
notes: [
|
|
69
|
-
"Use convert_witness=100 (OrderProgress) to derive Progress from submitted Order ID",
|
|
70
|
-
"Duration in milliseconds — test with small values first",
|
|
71
|
-
],
|
|
72
|
-
},
|
|
73
|
-
{
|
|
74
|
-
id: "pattern.time_lock_absolute",
|
|
75
|
-
business_requirement: "Operation allowed only after a fixed timestamp",
|
|
76
|
-
data_source: "SystemContext",
|
|
77
|
-
host: "service_buy_guard",
|
|
78
|
-
verifier_level: "none",
|
|
79
|
-
logic_summary: "logic_as_u256_ge[context(Clock), identifier[N](release_timestamp)]",
|
|
80
|
-
key_queries: [],
|
|
81
|
-
mitigated_risks: [],
|
|
82
|
-
notes: ["Useful for pre-sale windows, embargo periods"],
|
|
83
|
-
},
|
|
84
|
-
{
|
|
85
|
-
id: "pattern.repository_data_check",
|
|
86
|
-
business_requirement: "External data must match expected value (e.g., weather, price feed)",
|
|
87
|
-
data_source: "OnChainConstant",
|
|
88
|
-
host: "machine_forward",
|
|
89
|
-
verifier_level: "none",
|
|
90
|
-
logic_summary: "logic_equal[query(1167 repository.data, policy, key), identifier[N](expected_value)]",
|
|
91
|
-
key_queries: ["repository.data"],
|
|
92
|
-
mitigated_risks: [],
|
|
93
|
-
notes: [
|
|
94
|
-
"Repository address declared as table constant",
|
|
95
|
-
"Timestamp keys may need convert_number_address",
|
|
96
|
-
"quote_guard context: fails in gen_passport (impack_list empty), works in on-chain business operations (see R-X1-10)",
|
|
97
|
-
],
|
|
98
|
-
},
|
|
99
|
-
{
|
|
100
|
-
id: "pattern.repository_quote_guard_subscription",
|
|
101
|
-
business_requirement: "Repository data access requires payment proof (subscription revenue model)",
|
|
102
|
-
data_source: "SubmittedObject",
|
|
103
|
-
host: "repository_write",
|
|
104
|
-
verifier_level: "level3_scene_combined",
|
|
105
|
-
logic_summary: "Repository policy sets quote_guard (is_depended: immutable + rep=true). " +
|
|
106
|
-
"When a Guard queries this Repository's data (query 1167), check_repository_quote_guard verifies " +
|
|
107
|
-
"the quote_guard is in impack_list. The quote_guard itself verifies a submitted Payment " +
|
|
108
|
-
"(payment.info.for matches Repository, payment.amount meets subscription price). " +
|
|
109
|
-
"User submits Payment via Passport → quote_guard verified → added to impack_list → query 1167 passes.",
|
|
110
|
-
key_queries: ["repository.data", "payment.info.for", "payment.amount"],
|
|
111
|
-
mitigated_risks: ["R-X1-10"],
|
|
112
|
-
applicable_industries: ["subscription", "travel", "rental", "education"],
|
|
113
|
-
notes: [
|
|
114
|
-
"VERIFIED: passport.rs#L545-612 (check_repository_quote_guard), passport.rs#L758-769 (trigger at query_id==1167)",
|
|
115
|
-
"Repository.owner_receive<T> accepts Payment as subscription revenue (repository.move#L714-717)",
|
|
116
|
-
"quote_guard must be is_depended: immutable=true, relies empty, rep=true (guard.move#L133-135)",
|
|
117
|
-
"VERIFIER-EVIDENCE DESIGN: user submits valid Payment, quote_guard verifies Payment fields — no affiliation needed",
|
|
118
|
-
"gen_passport context: quote_guard fails (impack_list empty) — only use for on-chain business operations",
|
|
119
|
-
"Business model: data provider publishes weather/market/oracle data to Repository, " +
|
|
120
|
-
"users pay subscription to access data in their Machine flows",
|
|
121
|
-
],
|
|
122
|
-
},
|
|
123
|
-
{
|
|
124
|
-
id: "pattern.supply_chain_suborder_verification",
|
|
125
|
-
business_requirement: "Sub-service purchase requires ownership of main service order (supply chain milestone unlock)",
|
|
126
|
-
data_source: "SubmittedObject",
|
|
127
|
-
host: "service_buy_guard",
|
|
128
|
-
verifier_level: "level2_identity_set",
|
|
129
|
-
logic_summary: "Sub-service buy_guard verifies submitted main Order: " +
|
|
130
|
-
"logic_and[logic_equal[query(order.owner), context(Signer)], logic_equal[query(order.service), identifier[N](main_service_address)]]. " +
|
|
131
|
-
"User submits main Order via Passport (b_submission=true), buy_guard verifies ownership + service match.",
|
|
132
|
-
key_queries: ["order.owner", "order.service"],
|
|
133
|
-
mitigated_risks: ["R-C3-05"],
|
|
134
|
-
applicable_industries: ["travel", "rental", "education", "freelance"],
|
|
135
|
-
notes: [
|
|
136
|
-
"VERIFIER-EVIDENCE DESIGN: user submits main Order as evidence, buy_guard verifies order.owner==Signer AND order.service==main_service",
|
|
137
|
-
"Each milestone = one sub-order with its own Service + buy_guard referencing the main order",
|
|
138
|
-
"Main flow can branch to different sub-services based on Machine node progression",
|
|
139
|
-
"No parent_order field needed — relationship verified via buy_guard querying submitted Order fields",
|
|
140
|
-
"Enables supply chain composition: main service → multiple sub-services with conditional access",
|
|
141
|
-
],
|
|
142
|
-
},
|
|
143
|
-
{
|
|
144
|
-
id: "pattern.payment_exception_compensation",
|
|
145
|
-
business_requirement: "Exception branch triggers compensation Payment (e.g., delivery delay > 30min auto-compensates customer)",
|
|
146
|
-
data_source: "SubmittedObject",
|
|
147
|
-
host: "machine_forward",
|
|
148
|
-
verifier_level: "level3_scene_combined",
|
|
149
|
-
logic_summary: "Exception forward guard verifies 4-dimensional anti-reuse binding: logic_and[" +
|
|
150
|
-
"logic_equal[query(payment.info.for), identifier[N](order_address)], " +
|
|
151
|
-
"logic_equal[query(payment.info.guard), identifier[N](this_guard_address)], " +
|
|
152
|
-
"logic_as_u256_ge[query(payment.amount), identifier[N](compensation_amount)], " +
|
|
153
|
-
"logic_as_u256_equal[query(payment.info.index), query(progress.history count)], " +
|
|
154
|
-
"logic_string_nocase_equal[query(payment.info.remark), query(progress.current)]]. " +
|
|
155
|
-
"Treasury withdraws to customer with PaymentInfo(for_object=order, for_guard=this, index=history_count_at_creation, remark=node_name). " +
|
|
156
|
-
"Customer submits Payment via Passport; guard verifies index matches current unique step (progress.history count, U64, monotonically increasing — unique even in cycles) AND remark matches current node name (progress.current, String — may repeat across cycles but bound to this step by index).",
|
|
157
|
-
key_queries: [
|
|
158
|
-
"payment.info.for",
|
|
159
|
-
"payment.info.guard",
|
|
160
|
-
"payment.info.index",
|
|
161
|
-
"payment.info.remark",
|
|
162
|
-
"payment.amount",
|
|
163
|
-
"progress.history count",
|
|
164
|
-
"progress.current",
|
|
165
|
-
],
|
|
166
|
-
mitigated_risks: [],
|
|
167
|
-
applicable_industries: ["rental", "travel", "general", "freelance"],
|
|
168
|
-
notes: [
|
|
169
|
-
"VERIFIED: payment.move#L66-71 (PaymentInfo: for_object, for_guard, remark, index), payment.move#L82-86 (payment_info_with_guard)",
|
|
170
|
-
"VERIFIED: treasury.move#L249-264 (withdraw creates Payment via payment::new_singleton + from_object_set)",
|
|
171
|
-
"Payment is freeze_object (immutable, payment.move#L160) — cannot be modified after creation",
|
|
172
|
-
"VERIFIED INDEX QUERY: progress.history count (id 1273, U64) — guard-ins.ts#L1228-1237. From progress.move L440-441 (session_accomplish pushes a new History entry) + L475/L482 (parent_table_vec::length returns current session id). This count is the unique monotonically increasing step index — even in cycles, each entry has a different count.",
|
|
173
|
-
"VERIFIED NODE NAME QUERY: progress.current (id 1253, String) — guard-ins.ts#L1025-1032. Returns the current node name. A node CAN be entered multiple times in cycles, so node name alone is NOT unique — it MUST be paired with progress.history count for uniqueness.",
|
|
174
|
-
"DESIGN INTENT (USER): to validate index (U64 type), use progress.history count (unique, non-repeating); to validate node name (may repeat in cycles), store it in PaymentInfo.remark and do string comparison with progress.current.",
|
|
175
|
-
"ANTI-REUSE 4-DIMENSIONAL BINDING: for_object (Order) + for_guard (Guard) + index (unique step via progress.history count) + remark (node name via progress.current). Same Payment cannot be reused in other contexts — at least one field will mismatch.",
|
|
176
|
-
"VERIFIER-EVIDENCE DESIGN: customer submits Payment, guard verifies binding fields match current context",
|
|
177
|
-
"Enables user-friendly exception handling: delay → auto-compensation → friendly branch flow",
|
|
178
|
-
"No affiliation registration needed — guard only verifies submitted Payment's field accuracy",
|
|
179
|
-
],
|
|
180
|
-
},
|
|
181
|
-
{
|
|
182
|
-
id: "pattern.verifier_evidence_philosophy",
|
|
183
|
-
business_requirement: "Guard design philosophy: verifier provides evidence, guard verifies logic + data accuracy (NOT data discovery)",
|
|
184
|
-
data_source: "SubmittedObject",
|
|
185
|
-
host: "gen_passport",
|
|
186
|
-
verifier_level: "none",
|
|
187
|
-
logic_summary: "Guard is a PURE VERIFICATION engine. Participants submit evidence (Payment, Order, Proof, etc.) " +
|
|
188
|
-
"via Passport submissions (b_submission=true). Guard verifies: (1) logic completeness, (2) data usage accuracy. " +
|
|
189
|
-
"Guard does NOT discover/fetch objects via affiliation. Affiliation is for object lifecycle bookkeeping, " +
|
|
190
|
-
"NOT for guard data discovery.",
|
|
191
|
-
key_queries: [],
|
|
192
|
-
mitigated_risks: ["R-C3-05", "R-C3-06"],
|
|
193
|
-
notes: [
|
|
194
|
-
"CORE PRINCIPLE: Guard only validates submitted evidence — it never fetches data on its own",
|
|
195
|
-
"For Payment verification: user submits valid Payment → guard checks for_object/for_guard/index match",
|
|
196
|
-
"For multi-order verification: verifier submits Order data → guard checks service/owner relationships",
|
|
197
|
-
"For Repository access: user submits Payment → quote_guard verifies → impack_list updated → data query passes",
|
|
198
|
-
"Type 3 (SubmittedObject) data source class embodies this philosophy — b_submission=true entries",
|
|
199
|
-
"This pattern is foundational for all guard designs — always prefer verifier-evidence over complex object discovery",
|
|
200
|
-
],
|
|
201
|
-
},
|
|
202
|
-
{
|
|
203
|
-
id: "pattern.progress_state_check",
|
|
204
|
-
business_requirement: "Specific forward has been accomplished (customer confirms delivery)",
|
|
205
|
-
data_source: "WitnessDerived",
|
|
206
|
-
host: "reward_claim",
|
|
207
|
-
verifier_level: "none",
|
|
208
|
-
logic_summary: "logic_equal[query_progress_history_find(...).accomplished, identifier[N](true)]",
|
|
209
|
-
key_queries: ["progress.current", "progress.current_time"],
|
|
210
|
-
witness_types: ["OrderProgress"],
|
|
211
|
-
mitigated_risks: [],
|
|
212
|
-
notes: ["Chain query_progress_history_find → query_progress_history_session_forward_find"],
|
|
213
|
-
},
|
|
214
|
-
{
|
|
215
|
-
id: "pattern.reward_one_time_claim",
|
|
216
|
-
business_requirement: "User can only claim reward once (no prior claims)",
|
|
217
|
-
data_source: "OnChainConstant",
|
|
218
|
-
host: "reward_claim",
|
|
219
|
-
verifier_level: "none",
|
|
220
|
-
logic_summary: "logic_equal[query_reward_record_count(recipient=Signer), identifier[N](0)]",
|
|
221
|
-
key_queries: ["reward.record_count"],
|
|
222
|
-
mitigated_risks: [],
|
|
223
|
-
notes: ["Record count check prevents double-claim"],
|
|
224
|
-
},
|
|
225
|
-
{
|
|
226
|
-
id: "pattern.reward_multi_condition",
|
|
227
|
-
business_requirement: "Order payment > threshold AND reached 'complete' to claim reward",
|
|
228
|
-
data_source: "WitnessDerived",
|
|
229
|
-
host: "reward_claim",
|
|
230
|
-
verifier_level: "none",
|
|
231
|
-
logic_summary: "logic_and[logic_as_u256_gt[query(order.amount), threshold], logic_equal[query(progress.current), 'complete'], logic_equal[query(order.service), identifier[N](expected_service)]]",
|
|
232
|
-
key_queries: ["order.amount", "progress.current", "order.service"],
|
|
233
|
-
witness_types: ["OrderProgress"],
|
|
234
|
-
mitigated_risks: ["R-C3-05"],
|
|
235
|
-
notes: ["Multi-condition: amount + progress state + service match"],
|
|
236
|
-
},
|
|
237
|
-
{
|
|
238
|
-
id: "pattern.arbitration_voting_weight",
|
|
239
|
-
business_requirement: "Vote weight equals reputation score (dynamic weight from Passport)",
|
|
240
|
-
data_source: "SubmittedObject",
|
|
241
|
-
host: "arbitration_voting",
|
|
242
|
-
verifier_level: "none",
|
|
243
|
-
logic_summary: "GuardIdentifier extracts numeric value from Passport submission",
|
|
244
|
-
key_queries: [],
|
|
245
|
-
mitigated_risks: ["R-C3-02"],
|
|
246
|
-
notes: [
|
|
247
|
-
"Table needs numeric submission entry at referenced index",
|
|
248
|
-
"Weight must come from on-chain EntityRegistrar, not submission",
|
|
249
|
-
"BINDING_01: voting_guard GuardIdentifier must be numeric (U8-U256)",
|
|
250
|
-
],
|
|
251
|
-
},
|
|
252
|
-
{
|
|
253
|
-
id: "pattern.arbitration_membership_check",
|
|
254
|
-
business_requirement: "Only premium members can file disputes",
|
|
255
|
-
data_source: "OnChainConstant",
|
|
256
|
-
host: "arbitration_usage",
|
|
257
|
-
verifier_level: "none",
|
|
258
|
-
logic_summary: "logic_and[query(entity exists), logic_as_u256_ge[query(entity tier), identifier[N](premium_tier)]]",
|
|
259
|
-
key_queries: ["entity.registrar", "entity.linker"],
|
|
260
|
-
mitigated_risks: [],
|
|
261
|
-
notes: ["ENTITY_REGISTRAR_ADDRESS (0xaab) / ENTITY_LINKER_ADDRESS (0xaaa) must be in table"],
|
|
262
|
-
},
|
|
263
|
-
{
|
|
264
|
-
id: "pattern.scene_allocator_entity_recipient",
|
|
265
|
-
business_requirement: "Service allocator with sharing.who=Entity — no Signer binding needed",
|
|
266
|
-
data_source: "OnChainConstant",
|
|
267
|
-
host: "service_allocator_guard",
|
|
268
|
-
verifier_level: "level3_scene_combined",
|
|
269
|
-
logic_summary: "Scene verifies fund flow safety — Guard only validates allocation rules",
|
|
270
|
-
key_queries: ["service.permission", "order.amount"],
|
|
271
|
-
mitigated_risks: ["R-C3-06"],
|
|
272
|
-
notes: [
|
|
273
|
-
"Funds flow to fixed Treasury/address regardless of caller",
|
|
274
|
-
"sharing.who=Entity already guarantees recipient safety",
|
|
275
|
-
"No Signer binding required — R-C3-06 safe",
|
|
276
|
-
],
|
|
277
|
-
},
|
|
278
|
-
{
|
|
279
|
-
id: "pattern.scene_machine_forward_operator",
|
|
280
|
-
business_requirement: "Machine forward with permissionIndex/namedOperator already verifies operator",
|
|
281
|
-
data_source: "OnChainConstant",
|
|
282
|
-
host: "machine_forward",
|
|
283
|
-
verifier_level: "level3_scene_combined",
|
|
284
|
-
logic_summary: "Forward's permissionIndex/namedOperator verifies operator — Guard only validates submitted data",
|
|
285
|
-
key_queries: [],
|
|
286
|
-
mitigated_risks: [],
|
|
287
|
-
notes: [
|
|
288
|
-
"Scene verifies operator permission via permissionIndex/namedOperator",
|
|
289
|
-
"Signer binding only needed if submitted data must belong to operator",
|
|
290
|
-
"Evaluate scene before adding Signer binding",
|
|
291
|
-
],
|
|
292
|
-
},
|
|
293
|
-
];
|
|
294
|
-
export const VERIFIER_LEVEL_GUIDANCE = [
|
|
295
|
-
{
|
|
296
|
-
level: "level1_strict_single",
|
|
297
|
-
pattern: "logic_equal[context(Signer), identifier[N](fixed_address)]",
|
|
298
|
-
when_to_use: "Role permanently tied to one address AND designer accepts lock-in risk",
|
|
299
|
-
risk_rules: ["R-C4-04"],
|
|
300
|
-
recommendation: "avoid",
|
|
301
|
-
},
|
|
302
|
-
{
|
|
303
|
-
level: "level2_identity_set",
|
|
304
|
-
pattern: "logic_or of multiple identity checks",
|
|
305
|
-
when_to_use: "Role-based access — multiple authorized identities",
|
|
306
|
-
risk_rules: ["R-C4-04 (suppressed)"],
|
|
307
|
-
recommendation: "recommended",
|
|
308
|
-
},
|
|
309
|
-
{
|
|
310
|
-
level: "level3_scene_combined",
|
|
311
|
-
pattern: "Scene itself verifies identity — no Signer binding needed",
|
|
312
|
-
when_to_use: "Scene's host object already verifies operator (e.g., Machine forward, sharing.who=Entity)",
|
|
313
|
-
risk_rules: [],
|
|
314
|
-
recommendation: "default",
|
|
315
|
-
},
|
|
316
|
-
{
|
|
317
|
-
level: "none",
|
|
318
|
-
pattern: "No Signer binding required",
|
|
319
|
-
when_to_use: "Resource flow matters more than caller identity",
|
|
320
|
-
risk_rules: [],
|
|
321
|
-
recommendation: "default",
|
|
322
|
-
},
|
|
323
|
-
];
|
|
324
|
-
export function getGuardDesignPattern(id) {
|
|
325
|
-
return GUARD_DESIGN_PATTERNS.find((p) => p.id === id);
|
|
326
|
-
}
|
|
327
|
-
export function searchGuardDesignPatterns(query) {
|
|
328
|
-
const q = query.toLowerCase();
|
|
329
|
-
return GUARD_DESIGN_PATTERNS.filter((p) => {
|
|
330
|
-
if (p.business_requirement.toLowerCase().includes(q))
|
|
331
|
-
return true;
|
|
332
|
-
if (p.logic_summary.toLowerCase().includes(q))
|
|
333
|
-
return true;
|
|
334
|
-
if (p.key_queries.some((k) => k.toLowerCase().includes(q)))
|
|
335
|
-
return true;
|
|
336
|
-
return false;
|
|
337
|
-
});
|
|
338
|
-
}
|
|
339
|
-
export function getPatternsByHost(host) {
|
|
340
|
-
return GUARD_DESIGN_PATTERNS.filter((p) => p.host === host);
|
|
341
|
-
}
|
|
342
|
-
export function getPatternsByIndustry(industry) {
|
|
343
|
-
return GUARD_DESIGN_PATTERNS.filter((p) => p.applicable_industries?.includes(industry));
|
|
344
|
-
}
|
|
345
|
-
export function getPatternsByDataSourceClass(source) {
|
|
346
|
-
return GUARD_DESIGN_PATTERNS.filter((p) => p.data_source === source);
|
|
347
|
-
}
|
|
348
|
-
export function getVerifierLevelGuidance(level) {
|
|
349
|
-
return VERIFIER_LEVEL_GUIDANCE.find((g) => g.level === level);
|
|
350
|
-
}
|
|
351
|
-
export function suggestPatternForRequirement(requirement) {
|
|
352
|
-
const matches = searchGuardDesignPatterns(requirement);
|
|
353
|
-
if (matches.length === 0) {
|
|
354
|
-
const fallback = GUARD_DESIGN_PATTERNS[0];
|
|
355
|
-
return { best: fallback, alternatives: [] };
|
|
356
|
-
}
|
|
357
|
-
const [best, ...alternatives] = matches;
|
|
358
|
-
return { best, alternatives };
|
|
359
|
-
}
|
|
360
|
-
export const GUARD_DESIGN_PATTERNS_VERSION = 1;
|
|
1
|
+
export const GUARD_DESIGN_PATTERNS=[{'id':'pattern.identity_check_single','business_requirement':'Only\x20the\x20author\x20can\x20purchase\x20this\x20service\x20(strict\x20single-identity)','data_source':'SystemContext','host':'service_buy_guard','verifier_level':'level1_strict_single','logic_summary':'logic_equal[context(Signer),\x20identifier[N](fixed_address)]','key_queries':[],'mitigated_risks':['R-C4-04'],'notes':['Maximally\x20secure\x20but\x20maximally\x20inconvenient','If\x20address\x20is\x20unavailable\x20(key\x20loss,\x20rotation),\x20Guard\x20permanently\x20blocks','Avoid\x20unless\x20role\x20is\x20permanently\x20tied\x20to\x20one\x20address']},{'id':'pattern.identity_check_allowlist','business_requirement':'Customer\x20must\x20be\x20in\x20an\x20allowlist\x20to\x20purchase','data_source':'SystemContext','host':'service_buy_guard','verifier_level':'level2_identity_set','logic_summary':'vec_contains_address[identifier[N](allowlist_vec),\x20context(Signer)]','key_queries':[],'mitigated_risks':['R-C4-04'],'notes':['Allowlist\x20stored\x20as\x20Address\x20vector\x20in\x20table\x20constant']},{'id':'pattern.identity_check_order_holder','business_requirement':'Only\x20order\x20owner\x20or\x20agent\x20can\x20perform\x20operation','data_source':'OnChainConstant','host':'machine_forward','verifier_level':'level2_identity_set','logic_summary':'logic_or[logic_equal[query(1562\x20order.owner),\x20context(Signer)],\x20query(1567\x20order.agent\x20has,\x20Signer)]','key_queries':['order.owner','order.agent\x20has'],'mitigated_risks':['R-C4-04','R-C3-06'],'notes':['1562\x20returns\x20Address\x20→\x20wrap\x20in\x20logic_equal','1567\x20returns\x20Bool\x20→\x20use\x20directly\x20as\x20logic_or\x20child','Recommended\x20Level\x202\x20alternative\x20to\x20Level\x201\x20strict\x20binding']},{'id':'pattern.identity_check_service_provider_dynamic','business_requirement':'Verify\x20caller\x20is\x20service\x27s\x20current\x20permission\x20owner\x20(survives\x20permission\x20rotation)','data_source':'SubmittedObject','host':'machine_forward','verifier_level':'level2_identity_set','logic_summary':'logic_and[logic_equal[query(1488\x20service.permission),\x20identifier[N](submitted_perm)],\x20logic_or[logic_equal[query(1002\x20permission.owner),\x20context(Signer)],\x20query(1004\x20permission.admin\x20has,\x20Signer)]]','key_queries':['service.permission','permission.owner','permission.admin\x20has'],'mitigated_risks':['R-C4-04','R-C3-05'],'notes':['Dynamic\x20permission\x20address\x20(RECOMMENDED)\x20—\x20survives\x20Service\x20permission\x20rotation','Caller\x20submits\x20permission\x20address;\x20Guard\x20verifies\x20match\x20then\x20checks\x20identity','More\x20complex\x20than\x20static\x20but\x20far\x20more\x20robust']},{'id':'pattern.time_lock_progress','business_requirement':'Customer\x20must\x20wait\x20N\x20hours\x20before\x20completing\x20(time-lock)','data_source':'WitnessDerived','host':'machine_forward','verifier_level':'none','logic_summary':'logic_as_u256_ge[context(Clock),\x20calc_number_add[query(1272\x20progress.current_time,\x20witness=OrderProgress),\x20identifier[N](duration_ms)]]','key_queries':['progress.current_time'],'witness_types':['OrderProgress'],'mitigated_risks':[],'notes':['Use\x20convert_witness=100\x20(OrderProgress)\x20to\x20derive\x20Progress\x20from\x20submitted\x20Order\x20ID','Duration\x20in\x20milliseconds\x20—\x20test\x20with\x20small\x20values\x20first']},{'id':'pattern.time_lock_absolute','business_requirement':'Operation\x20allowed\x20only\x20after\x20a\x20fixed\x20timestamp','data_source':'SystemContext','host':'service_buy_guard','verifier_level':'none','logic_summary':'logic_as_u256_ge[context(Clock),\x20identifier[N](release_timestamp)]','key_queries':[],'mitigated_risks':[],'notes':['Useful\x20for\x20pre-sale\x20windows,\x20embargo\x20periods']},{'id':'pattern.repository_data_check','business_requirement':'External\x20data\x20must\x20match\x20expected\x20value\x20(e.g.,\x20weather,\x20price\x20feed)','data_source':'OnChainConstant','host':'machine_forward','verifier_level':'none','logic_summary':'logic_equal[query(1167\x20repository.data,\x20policy,\x20key),\x20identifier[N](expected_value)]','key_queries':['repository.data'],'mitigated_risks':[],'notes':['Repository\x20address\x20declared\x20as\x20table\x20constant','Timestamp\x20keys\x20may\x20need\x20convert_number_address','quote_guard\x20context:\x20fails\x20in\x20gen_passport\x20(impack_list\x20empty),\x20works\x20in\x20on-chain\x20business\x20operations\x20(see\x20R-X1-10)']},{'id':'pattern.repository_quote_guard_subscription','business_requirement':'Repository\x20data\x20access\x20requires\x20payment\x20proof\x20(subscription\x20revenue\x20model)','data_source':'SubmittedObject','host':'repository_write','verifier_level':'level3_scene_combined','logic_summary':'Repository\x20policy\x20sets\x20quote_guard\x20(is_depended:\x20immutable\x20+\x20rep=true).\x20'+'When\x20a\x20Guard\x20queries\x20this\x20Repository\x27s\x20data\x20(query\x201167),\x20check_repository_quote_guard\x20verifies\x20'+'the\x20quote_guard\x20is\x20in\x20impack_list.\x20The\x20quote_guard\x20itself\x20verifies\x20a\x20submitted\x20Payment\x20'+'(payment.info.for\x20matches\x20Repository,\x20payment.amount\x20meets\x20subscription\x20price).\x20'+'User\x20submits\x20Payment\x20via\x20Passport\x20→\x20quote_guard\x20verified\x20→\x20added\x20to\x20impack_list\x20→\x20query\x201167\x20passes.','key_queries':['repository.data','payment.info.for','payment.amount'],'mitigated_risks':['R-X1-10'],'applicable_industries':['subscription','travel','rental','education'],'notes':['VERIFIED:\x20passport.rs#L545-612\x20(check_repository_quote_guard),\x20passport.rs#L758-769\x20(trigger\x20at\x20query_id==1167)','Repository.owner_receive<T>\x20accepts\x20Payment\x20as\x20subscription\x20revenue\x20(repository.move#L714-717)','quote_guard\x20must\x20be\x20is_depended:\x20immutable=true,\x20relies\x20empty,\x20rep=true\x20(guard.move#L133-135)','VERIFIER-EVIDENCE\x20DESIGN:\x20user\x20submits\x20valid\x20Payment,\x20quote_guard\x20verifies\x20Payment\x20fields\x20—\x20no\x20affiliation\x20needed','gen_passport\x20context:\x20quote_guard\x20fails\x20(impack_list\x20empty)\x20—\x20only\x20use\x20for\x20on-chain\x20business\x20operations','Business\x20model:\x20data\x20provider\x20publishes\x20weather/market/oracle\x20data\x20to\x20Repository,\x20'+'users\x20pay\x20subscription\x20to\x20access\x20data\x20in\x20their\x20Machine\x20flows']},{'id':'pattern.supply_chain_suborder_verification','business_requirement':'Sub-service\x20purchase\x20requires\x20ownership\x20of\x20main\x20service\x20order\x20(supply\x20chain\x20milestone\x20unlock)','data_source':'SubmittedObject','host':'service_buy_guard','verifier_level':'level2_identity_set','logic_summary':'Sub-service\x20buy_guard\x20verifies\x20submitted\x20main\x20Order:\x20'+'logic_and[logic_equal[query(order.owner),\x20context(Signer)],\x20logic_equal[query(order.service),\x20identifier[N](main_service_address)]].\x20'+'User\x20submits\x20main\x20Order\x20via\x20Passport\x20(b_submission=true),\x20buy_guard\x20verifies\x20ownership\x20+\x20service\x20match.','key_queries':['order.owner','order.service'],'mitigated_risks':['R-C3-05'],'applicable_industries':['travel','rental','education','freelance'],'notes':['VERIFIER-EVIDENCE\x20DESIGN:\x20user\x20submits\x20main\x20Order\x20as\x20evidence,\x20buy_guard\x20verifies\x20order.owner==Signer\x20AND\x20order.service==main_service','Each\x20milestone\x20=\x20one\x20sub-order\x20with\x20its\x20own\x20Service\x20+\x20buy_guard\x20referencing\x20the\x20main\x20order','Main\x20flow\x20can\x20branch\x20to\x20different\x20sub-services\x20based\x20on\x20Machine\x20node\x20progression','No\x20parent_order\x20field\x20needed\x20—\x20relationship\x20verified\x20via\x20buy_guard\x20querying\x20submitted\x20Order\x20fields','Enables\x20supply\x20chain\x20composition:\x20main\x20service\x20→\x20multiple\x20sub-services\x20with\x20conditional\x20access']},{'id':'pattern.payment_exception_compensation','business_requirement':'Exception\x20branch\x20triggers\x20compensation\x20Payment\x20(e.g.,\x20delivery\x20delay\x20>\x2030min\x20auto-compensates\x20customer)','data_source':'SubmittedObject','host':'machine_forward','verifier_level':'level3_scene_combined','logic_summary':'Exception\x20forward\x20guard\x20verifies\x204-dimensional\x20anti-reuse\x20binding:\x20logic_and['+'logic_equal[query(payment.info.for),\x20identifier[N](order_address)],\x20'+'logic_equal[query(payment.info.guard),\x20identifier[N](this_guard_address)],\x20'+'logic_as_u256_ge[query(payment.amount),\x20identifier[N](compensation_amount)],\x20'+'logic_as_u256_equal[query(payment.info.index),\x20query(progress.history\x20count)],\x20'+'logic_string_nocase_equal[query(payment.info.remark),\x20query(progress.current)]].\x20'+'Treasury\x20withdraws\x20to\x20customer\x20with\x20PaymentInfo(for_object=order,\x20for_guard=this,\x20index=history_count_at_creation,\x20remark=node_name).\x20'+'Customer\x20submits\x20Payment\x20via\x20Passport;\x20guard\x20verifies\x20index\x20matches\x20current\x20unique\x20step\x20(progress.history\x20count,\x20U64,\x20monotonically\x20increasing\x20—\x20unique\x20even\x20in\x20cycles)\x20AND\x20remark\x20matches\x20current\x20node\x20name\x20(progress.current,\x20String\x20—\x20may\x20repeat\x20across\x20cycles\x20but\x20bound\x20to\x20this\x20step\x20by\x20index).','key_queries':['payment.info.for','payment.info.guard','payment.info.index','payment.info.remark','payment.amount','progress.history\x20count','progress.current'],'mitigated_risks':[],'applicable_industries':['rental','travel','general','freelance'],'notes':['VERIFIED:\x20payment.move#L66-71\x20(PaymentInfo:\x20for_object,\x20for_guard,\x20remark,\x20index),\x20payment.move#L82-86\x20(payment_info_with_guard)','VERIFIED:\x20treasury.move#L249-264\x20(withdraw\x20creates\x20Payment\x20via\x20payment::new_singleton\x20+\x20from_object_set)','Payment\x20is\x20freeze_object\x20(immutable,\x20payment.move#L160)\x20—\x20cannot\x20be\x20modified\x20after\x20creation','VERIFIED\x20INDEX\x20QUERY:\x20progress.history\x20count\x20(id\x201273,\x20U64)\x20—\x20guard-ins.ts#L1228-1237.\x20From\x20progress.move\x20L440-441\x20(session_accomplish\x20pushes\x20a\x20new\x20History\x20entry)\x20+\x20L475/L482\x20(parent_table_vec::length\x20returns\x20current\x20session\x20id).\x20This\x20count\x20is\x20the\x20unique\x20monotonically\x20increasing\x20step\x20index\x20—\x20even\x20in\x20cycles,\x20each\x20entry\x20has\x20a\x20different\x20count.','VERIFIED\x20NODE\x20NAME\x20QUERY:\x20progress.current\x20(id\x201253,\x20String)\x20—\x20guard-ins.ts#L1025-1032.\x20Returns\x20the\x20current\x20node\x20name.\x20A\x20node\x20CAN\x20be\x20entered\x20multiple\x20times\x20in\x20cycles,\x20so\x20node\x20name\x20alone\x20is\x20NOT\x20unique\x20—\x20it\x20MUST\x20be\x20paired\x20with\x20progress.history\x20count\x20for\x20uniqueness.','DESIGN\x20INTENT\x20(USER):\x20to\x20validate\x20index\x20(U64\x20type),\x20use\x20progress.history\x20count\x20(unique,\x20non-repeating);\x20to\x20validate\x20node\x20name\x20(may\x20repeat\x20in\x20cycles),\x20store\x20it\x20in\x20PaymentInfo.remark\x20and\x20do\x20string\x20comparison\x20with\x20progress.current.','ANTI-REUSE\x204-DIMENSIONAL\x20BINDING:\x20for_object\x20(Order)\x20+\x20for_guard\x20(Guard)\x20+\x20index\x20(unique\x20step\x20via\x20progress.history\x20count)\x20+\x20remark\x20(node\x20name\x20via\x20progress.current).\x20Same\x20Payment\x20cannot\x20be\x20reused\x20in\x20other\x20contexts\x20—\x20at\x20least\x20one\x20field\x20will\x20mismatch.','VERIFIER-EVIDENCE\x20DESIGN:\x20customer\x20submits\x20Payment,\x20guard\x20verifies\x20binding\x20fields\x20match\x20current\x20context','Enables\x20user-friendly\x20exception\x20handling:\x20delay\x20→\x20auto-compensation\x20→\x20friendly\x20branch\x20flow','No\x20affiliation\x20registration\x20needed\x20—\x20guard\x20only\x20verifies\x20submitted\x20Payment\x27s\x20field\x20accuracy']},{'id':'pattern.verifier_evidence_philosophy','business_requirement':'Guard\x20design\x20philosophy:\x20verifier\x20provides\x20evidence,\x20guard\x20verifies\x20logic\x20+\x20data\x20accuracy\x20(NOT\x20data\x20discovery)','data_source':'SubmittedObject','host':'gen_passport','verifier_level':'none','logic_summary':'Guard\x20is\x20a\x20PURE\x20VERIFICATION\x20engine.\x20Participants\x20submit\x20evidence\x20(Payment,\x20Order,\x20Proof,\x20etc.)\x20'+'via\x20Passport\x20submissions\x20(b_submission=true).\x20Guard\x20verifies:\x20(1)\x20logic\x20completeness,\x20(2)\x20data\x20usage\x20accuracy.\x20'+'Guard\x20does\x20NOT\x20discover/fetch\x20objects\x20via\x20affiliation.\x20Affiliation\x20is\x20for\x20object\x20lifecycle\x20bookkeeping,\x20'+'NOT\x20for\x20guard\x20data\x20discovery.','key_queries':[],'mitigated_risks':['R-C3-05','R-C3-06'],'notes':['CORE\x20PRINCIPLE:\x20Guard\x20only\x20validates\x20submitted\x20evidence\x20—\x20it\x20never\x20fetches\x20data\x20on\x20its\x20own','For\x20Payment\x20verification:\x20user\x20submits\x20valid\x20Payment\x20→\x20guard\x20checks\x20for_object/for_guard/index\x20match','For\x20multi-order\x20verification:\x20verifier\x20submits\x20Order\x20data\x20→\x20guard\x20checks\x20service/owner\x20relationships','For\x20Repository\x20access:\x20user\x20submits\x20Payment\x20→\x20quote_guard\x20verifies\x20→\x20impack_list\x20updated\x20→\x20data\x20query\x20passes','Type\x203\x20(SubmittedObject)\x20data\x20source\x20class\x20embodies\x20this\x20philosophy\x20—\x20b_submission=true\x20entries','This\x20pattern\x20is\x20foundational\x20for\x20all\x20guard\x20designs\x20—\x20always\x20prefer\x20verifier-evidence\x20over\x20complex\x20object\x20discovery']},{'id':'pattern.progress_state_check','business_requirement':'Specific\x20forward\x20has\x20been\x20accomplished\x20(customer\x20confirms\x20delivery)','data_source':'WitnessDerived','host':'reward_claim','verifier_level':'none','logic_summary':'logic_equal[query_progress_history_find(...).accomplished,\x20identifier[N](true)]','key_queries':['progress.current','progress.current_time'],'witness_types':['OrderProgress'],'mitigated_risks':[],'notes':['Chain\x20query_progress_history_find\x20→\x20query_progress_history_session_forward_find']},{'id':'pattern.reward_one_time_claim','business_requirement':'User\x20can\x20only\x20claim\x20reward\x20once\x20(no\x20prior\x20claims)','data_source':'OnChainConstant','host':'reward_claim','verifier_level':'none','logic_summary':'logic_equal[query_reward_record_count(recipient=Signer),\x20identifier[N](0)]','key_queries':['reward.record_count'],'mitigated_risks':[],'notes':['Record\x20count\x20check\x20prevents\x20double-claim']},{'id':'pattern.reward_multi_condition','business_requirement':'Order\x20payment\x20>\x20threshold\x20AND\x20reached\x20\x27complete\x27\x20to\x20claim\x20reward','data_source':'WitnessDerived','host':'reward_claim','verifier_level':'none','logic_summary':'logic_and[logic_as_u256_gt[query(order.amount),\x20threshold],\x20logic_equal[query(progress.current),\x20\x27complete\x27],\x20logic_equal[query(order.service),\x20identifier[N](expected_service)]]','key_queries':['order.amount','progress.current','order.service'],'witness_types':['OrderProgress'],'mitigated_risks':['R-C3-05'],'notes':['Multi-condition:\x20amount\x20+\x20progress\x20state\x20+\x20service\x20match']},{'id':'pattern.arbitration_voting_weight','business_requirement':'Vote\x20weight\x20equals\x20reputation\x20score\x20(dynamic\x20weight\x20from\x20Passport)','data_source':'SubmittedObject','host':'arbitration_voting','verifier_level':'none','logic_summary':'GuardIdentifier\x20extracts\x20numeric\x20value\x20from\x20Passport\x20submission','key_queries':[],'mitigated_risks':['R-C3-02'],'notes':['Table\x20needs\x20numeric\x20submission\x20entry\x20at\x20referenced\x20index','Weight\x20must\x20come\x20from\x20on-chain\x20EntityRegistrar,\x20not\x20submission','BINDING_01:\x20voting_guard\x20GuardIdentifier\x20must\x20be\x20numeric\x20(U8-U256)']},{'id':'pattern.arbitration_membership_check','business_requirement':'Only\x20premium\x20members\x20can\x20file\x20disputes','data_source':'OnChainConstant','host':'arbitration_usage','verifier_level':'none','logic_summary':'logic_and[query(entity\x20exists),\x20logic_as_u256_ge[query(entity\x20tier),\x20identifier[N](premium_tier)]]','key_queries':['entity.registrar','entity.linker'],'mitigated_risks':[],'notes':['ENTITY_REGISTRAR_ADDRESS\x20(0xaab)\x20/\x20ENTITY_LINKER_ADDRESS\x20(0xaaa)\x20must\x20be\x20in\x20table']},{'id':'pattern.scene_allocator_entity_recipient','business_requirement':'Service\x20allocator\x20with\x20sharing.who=Entity\x20—\x20no\x20Signer\x20binding\x20needed','data_source':'OnChainConstant','host':'service_allocator_guard','verifier_level':'level3_scene_combined','logic_summary':'Scene\x20verifies\x20fund\x20flow\x20safety\x20—\x20Guard\x20only\x20validates\x20allocation\x20rules','key_queries':['service.permission','order.amount'],'mitigated_risks':['R-C3-06'],'notes':['Funds\x20flow\x20to\x20fixed\x20Treasury/address\x20regardless\x20of\x20caller','sharing.who=Entity\x20already\x20guarantees\x20recipient\x20safety','No\x20Signer\x20binding\x20required\x20—\x20R-C3-06\x20safe']},{'id':'pattern.scene_machine_forward_operator','business_requirement':'Machine\x20forward\x20with\x20permissionIndex/namedOperator\x20already\x20verifies\x20operator','data_source':'OnChainConstant','host':'machine_forward','verifier_level':'level3_scene_combined','logic_summary':'Forward\x27s\x20permissionIndex/namedOperator\x20verifies\x20operator\x20—\x20Guard\x20only\x20validates\x20submitted\x20data','key_queries':[],'mitigated_risks':[],'notes':['Scene\x20verifies\x20operator\x20permission\x20via\x20permissionIndex/namedOperator','Signer\x20binding\x20only\x20needed\x20if\x20submitted\x20data\x20must\x20belong\x20to\x20operator','Evaluate\x20scene\x20before\x20adding\x20Signer\x20binding']}];export const VERIFIER_LEVEL_GUIDANCE=[{'level':'level1_strict_single','pattern':'logic_equal[context(Signer),\x20identifier[N](fixed_address)]','when_to_use':'Role\x20permanently\x20tied\x20to\x20one\x20address\x20AND\x20designer\x20accepts\x20lock-in\x20risk','risk_rules':['R-C4-04'],'recommendation':'avoid'},{'level':'level2_identity_set','pattern':'logic_or\x20of\x20multiple\x20identity\x20checks','when_to_use':'Role-based\x20access\x20—\x20multiple\x20authorized\x20identities','risk_rules':['R-C4-04\x20(suppressed)'],'recommendation':'recommended'},{'level':'level3_scene_combined','pattern':'Scene\x20itself\x20verifies\x20identity\x20—\x20no\x20Signer\x20binding\x20needed','when_to_use':'Scene\x27s\x20host\x20object\x20already\x20verifies\x20operator\x20(e.g.,\x20Machine\x20forward,\x20sharing.who=Entity)','risk_rules':[],'recommendation':'default'},{'level':'none','pattern':'No\x20Signer\x20binding\x20required','when_to_use':'Resource\x20flow\x20matters\x20more\x20than\x20caller\x20identity','risk_rules':[],'recommendation':'default'}];export function getGuardDesignPattern(a){return GUARD_DESIGN_PATTERNS['find'](b=>b['id']===a);}export function searchGuardDesignPatterns(a){const b=a['toLowerCase']();return GUARD_DESIGN_PATTERNS['filter'](c=>{if(c['business_requirement']['toLowerCase']()['includes'](b))return!![];if(c['logic_summary']['toLowerCase']()['includes'](b))return!![];if(c['key_queries']['some'](d=>d['toLowerCase']()['includes'](b)))return!![];return![];});}export function getPatternsByHost(a){return GUARD_DESIGN_PATTERNS['filter'](b=>b['host']===a);}export function getPatternsByIndustry(a){return GUARD_DESIGN_PATTERNS['filter'](b=>b['applicable_industries']?.['includes'](a));}export function getPatternsByDataSourceClass(a){return GUARD_DESIGN_PATTERNS['filter'](b=>b['data_source']===a);}export function getVerifierLevelGuidance(a){return VERIFIER_LEVEL_GUIDANCE['find'](b=>b['level']===a);}export function suggestPatternForRequirement(a){const b=searchGuardDesignPatterns(a);if(b['length']===0x0){const e=GUARD_DESIGN_PATTERNS[0x0];return{'best':e,'alternatives':[]};}const [c,...d]=b;return{'best':c,'alternatives':d};}export const GUARD_DESIGN_PATTERNS_VERSION=0x1;
|