@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,573 +1 @@
|
|
|
1
|
-
import { MAX_AGENT_COUNT, MAX_DISPUTE_COUNT, } from "@wowok/wowok";
|
|
2
|
-
import { assessOrderRisks, } from "./order-risk.js";
|
|
3
|
-
export const ORDER_PUBLISH_CHECKLIST = [
|
|
4
|
-
{ id: "C-O-01", description: "Order object address is valid (must start with 0x, length >= 40)", passed: false, message: "" },
|
|
5
|
-
{ id: "C-O-02", description: "Operation is NOT direct order::create (Order created via service::buy)", passed: false, message: "" },
|
|
6
|
-
{ id: "C-O-03", description: `agent count <= MAX_AGENT_COUNT (${MAX_AGENT_COUNT}) — ⚠️ actual allows 11 due to <= bug`, passed: false, message: "" },
|
|
7
|
-
{ id: "C-O-04", description: `dispute count < MAX_DISPUTE_COUNT (${MAX_DISPUTE_COUNT}) — cannot file 11th dispute`, passed: false, message: "" },
|
|
8
|
-
{ id: "C-O-05", description: "claimed_by is None (no terminal claim state) — required for arb_confirm/arb_objection/arb_claim_compensation", passed: false, message: "" },
|
|
9
|
-
{ id: "C-O-06", description: "L1 operations (receive/transfer_to/agent_set) called by OWNER only", passed: false, message: "" },
|
|
10
|
-
{ id: "C-O-07", description: "L2 operations (required_info/progress/arb_*) called by owner OR agent", passed: false, message: "" },
|
|
11
|
-
{ id: "C-O-08", description: "agent_set / owner_change called BEFORE Progress binding (frozen after)", passed: false, message: "" },
|
|
12
|
-
{ id: "C-O-09", description: "receive called only when Progress is at terminal node (not delivering)", passed: false, message: "" },
|
|
13
|
-
{ id: "C-O-10", description: "transfer_to / arb_claim_compensation / arb_objection are IRREVERSIBLE — double-confirm", passed: false, message: "" },
|
|
14
|
-
{ id: "C-O-11", description: "required_info is Contact object OR WTS Proof object OR null (clear)", passed: false, message: "" },
|
|
15
|
-
{ id: "C-O-12", description: "Service is published AND not paused (for service::buy flow)", passed: false, message: "" },
|
|
16
|
-
{ id: "C-O-13", description: "Agent CANNOT receive payments — only owner can call receive", passed: false, message: "" },
|
|
17
|
-
{ id: "C-O-14", description: "arb_claim_compensation requires Arb in Arbitrated state", passed: false, message: "" },
|
|
18
|
-
{ id: "C-O-15", description: "Order has 14 fields — SDK uses 'builder' for Move's 'owner' (naming deviation)", passed: false, message: "" },
|
|
19
|
-
];
|
|
20
|
-
function isValidAddress(addr) {
|
|
21
|
-
return typeof addr === "string" && addr.startsWith("0x") && addr.length >= 40;
|
|
22
|
-
}
|
|
23
|
-
function runStaticChecklist(input) {
|
|
24
|
-
const items = ORDER_PUBLISH_CHECKLIST.map(c => ({ ...c }));
|
|
25
|
-
const data = input.order_json;
|
|
26
|
-
const state = input.current_state ?? {};
|
|
27
|
-
const caller = input.caller ?? {};
|
|
28
|
-
const co01 = items.find(i => i.id === "C-O-01");
|
|
29
|
-
if (!data.object) {
|
|
30
|
-
co01.passed = false;
|
|
31
|
-
co01.message = "Order object address is required (creation goes via service::buy, not here)";
|
|
32
|
-
}
|
|
33
|
-
else if (!isValidAddress(data.object)) {
|
|
34
|
-
co01.passed = false;
|
|
35
|
-
co01.message = `Invalid Order address: ${data.object}`;
|
|
36
|
-
}
|
|
37
|
-
else {
|
|
38
|
-
co01.passed = true;
|
|
39
|
-
}
|
|
40
|
-
const co02 = items.find(i => i.id === "C-O-02");
|
|
41
|
-
co02.passed = true;
|
|
42
|
-
co02.message = "CallOrder_Data has no create op — Order creation goes via service::buy";
|
|
43
|
-
const co03 = items.find(i => i.id === "C-O-03");
|
|
44
|
-
if (data.agent) {
|
|
45
|
-
const count = data.agent.length;
|
|
46
|
-
const docValid = count <= MAX_AGENT_COUNT;
|
|
47
|
-
co03.passed = docValid;
|
|
48
|
-
co03.message = docValid
|
|
49
|
-
? (count === MAX_AGENT_COUNT ? `${count} agents (at doc limit; actual allows 11 due to bug)` : `${count} agents`)
|
|
50
|
-
: `${count} agents > MAX_AGENT_COUNT (${MAX_AGENT_COUNT}) — will abort E_MAX_AGENT_COUNT (note: actual allows 11 due to <= bug)`;
|
|
51
|
-
}
|
|
52
|
-
else {
|
|
53
|
-
co03.passed = true;
|
|
54
|
-
}
|
|
55
|
-
const co04 = items.find(i => i.id === "C-O-04");
|
|
56
|
-
const disputeCount = state.dispute_count ?? 0;
|
|
57
|
-
if (data.arb_confirm) {
|
|
58
|
-
const valid = disputeCount < MAX_DISPUTE_COUNT;
|
|
59
|
-
co04.passed = valid;
|
|
60
|
-
co04.message = valid ? `${disputeCount} existing disputes` : `${disputeCount} disputes already at MAX_DISPUTE_COUNT (${MAX_DISPUTE_COUNT}) — next dispute() will abort E_MAX_DISPUTE_COUNT`;
|
|
61
|
-
}
|
|
62
|
-
else {
|
|
63
|
-
co04.passed = true;
|
|
64
|
-
}
|
|
65
|
-
const co05 = items.find(i => i.id === "C-O-05");
|
|
66
|
-
if (data.arb_confirm || data.arb_objection || data.arb_claim_compensation) {
|
|
67
|
-
const valid = !state.claimed_by_set;
|
|
68
|
-
co05.passed = valid;
|
|
69
|
-
co05.message = valid ? "claimed_by is None — arb operations allowed" : "claimed_by is SET — arb operations blocked (E_ORDER_ALREADY_CLAIMED, IRREVERSIBLE)";
|
|
70
|
-
}
|
|
71
|
-
else {
|
|
72
|
-
co05.passed = true;
|
|
73
|
-
}
|
|
74
|
-
const co06 = items.find(i => i.id === "C-O-06");
|
|
75
|
-
const isL1Op = !!(data.receive || data.transfer_to || data.agent);
|
|
76
|
-
if (isL1Op) {
|
|
77
|
-
const valid = !!caller.is_owner;
|
|
78
|
-
co06.passed = valid;
|
|
79
|
-
co06.message = valid ? "Caller is owner — L1 allowed" : "Caller is NOT owner — L1 operation blocked (E_OWNER)";
|
|
80
|
-
}
|
|
81
|
-
else {
|
|
82
|
-
co06.passed = true;
|
|
83
|
-
}
|
|
84
|
-
const co07 = items.find(i => i.id === "C-O-07");
|
|
85
|
-
const isL2Op = !!(data.required_info !== undefined || data.progress || data.arb_confirm || data.arb_objection || data.arb_claim_compensation);
|
|
86
|
-
if (isL2Op) {
|
|
87
|
-
const valid = !!caller.is_owner || !!caller.is_agent;
|
|
88
|
-
co07.passed = valid;
|
|
89
|
-
co07.message = valid ? "Caller is owner or agent — L2 allowed" : "Caller is NEITHER owner NOR agent — L2 blocked (E_PERMISSION)";
|
|
90
|
-
}
|
|
91
|
-
else {
|
|
92
|
-
co07.passed = true;
|
|
93
|
-
}
|
|
94
|
-
const co08 = items.find(i => i.id === "C-O-08");
|
|
95
|
-
if (data.agent || (data.transfer_to && !state.progress_bound)) {
|
|
96
|
-
if (data.agent) {
|
|
97
|
-
const valid = !state.progress_bound;
|
|
98
|
-
co08.passed = valid;
|
|
99
|
-
co08.message = valid ? "Progress not bound — agent_set allowed" : "Progress BOUND — agent_set aborts E_PROGRESS_NOT_SPECIFIED (frozen)";
|
|
100
|
-
}
|
|
101
|
-
else {
|
|
102
|
-
co08.passed = true;
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
else {
|
|
106
|
-
co08.passed = true;
|
|
107
|
-
}
|
|
108
|
-
const co09 = items.find(i => i.id === "C-O-09");
|
|
109
|
-
if (data.receive) {
|
|
110
|
-
const valid = !!state.progress_at_terminal;
|
|
111
|
-
co09.passed = valid;
|
|
112
|
-
co09.message = valid ? "Progress at terminal — receive allowed" : "Progress NOT at terminal — receive aborts E_ORDER_DELIVERING";
|
|
113
|
-
}
|
|
114
|
-
else {
|
|
115
|
-
co09.passed = true;
|
|
116
|
-
}
|
|
117
|
-
const co10 = items.find(i => i.id === "C-O-10");
|
|
118
|
-
const isIrreversible = !!(data.transfer_to || data.arb_claim_compensation || data.arb_objection);
|
|
119
|
-
if (isIrreversible) {
|
|
120
|
-
co10.passed = false;
|
|
121
|
-
co10.message = "Pending user confirmation in Layer 3 (irreversible operation)";
|
|
122
|
-
}
|
|
123
|
-
else {
|
|
124
|
-
co10.passed = true;
|
|
125
|
-
}
|
|
126
|
-
const co11 = items.find(i => i.id === "C-O-11");
|
|
127
|
-
if (data.required_info !== undefined) {
|
|
128
|
-
const valid = data.required_info === null || isValidAddress(data.required_info);
|
|
129
|
-
co11.passed = valid;
|
|
130
|
-
co11.message = valid
|
|
131
|
-
? (data.required_info === null ? "required_info = null (clear)" : "required_info is valid address (Contact or WTS Proof)")
|
|
132
|
-
: `Invalid required_info: ${data.required_info}`;
|
|
133
|
-
}
|
|
134
|
-
else {
|
|
135
|
-
co11.passed = true;
|
|
136
|
-
}
|
|
137
|
-
const co12 = items.find(i => i.id === "C-O-12");
|
|
138
|
-
co12.passed = true;
|
|
139
|
-
co12.message = "Service check applies only to service::buy flow (not CallOrder_Data)";
|
|
140
|
-
const co13 = items.find(i => i.id === "C-O-13");
|
|
141
|
-
if (data.receive && caller.is_agent && !caller.is_owner) {
|
|
142
|
-
co13.passed = false;
|
|
143
|
-
co13.message = "Agent CANNOT receive payments — only owner can call receive (L1)";
|
|
144
|
-
}
|
|
145
|
-
else {
|
|
146
|
-
co13.passed = true;
|
|
147
|
-
}
|
|
148
|
-
const co14 = items.find(i => i.id === "C-O-14");
|
|
149
|
-
if (data.arb_claim_compensation) {
|
|
150
|
-
co14.passed = true;
|
|
151
|
-
co14.message = "Arb Arbitrated state verified in Layer 4 (Environment)";
|
|
152
|
-
}
|
|
153
|
-
else {
|
|
154
|
-
co14.passed = true;
|
|
155
|
-
}
|
|
156
|
-
const co15 = items.find(i => i.id === "C-O-15");
|
|
157
|
-
co15.passed = true;
|
|
158
|
-
co15.message = "Informational: SDK ObjectOrder.builder ↔ Move Order.owner (only naming deviation in 22 objects)";
|
|
159
|
-
return {
|
|
160
|
-
all_passed: items.filter(i => i.id !== "C-O-10").every(i => i.passed),
|
|
161
|
-
items,
|
|
162
|
-
};
|
|
163
|
-
}
|
|
164
|
-
function adaptRiskAssessment(input) {
|
|
165
|
-
const data = input.order_json;
|
|
166
|
-
const state = input.current_state ?? {};
|
|
167
|
-
const caller = input.caller ?? {};
|
|
168
|
-
let operation;
|
|
169
|
-
if (data.agent)
|
|
170
|
-
operation = "agent_set";
|
|
171
|
-
else if (data.required_info !== undefined)
|
|
172
|
-
operation = "required_info_update";
|
|
173
|
-
else if (data.progress)
|
|
174
|
-
operation = "progress_advance";
|
|
175
|
-
else if (data.arb_confirm)
|
|
176
|
-
operation = "arb_confirm";
|
|
177
|
-
else if (data.arb_objection)
|
|
178
|
-
operation = "arb_objection";
|
|
179
|
-
else if (data.arb_claim_compensation)
|
|
180
|
-
operation = "arb_claim_compensation";
|
|
181
|
-
else if (data.receive)
|
|
182
|
-
operation = "receive";
|
|
183
|
-
else if (data.transfer_to)
|
|
184
|
-
operation = "transfer_to";
|
|
185
|
-
const ctx = {
|
|
186
|
-
object: data.object,
|
|
187
|
-
operation,
|
|
188
|
-
is_buy_operation: false,
|
|
189
|
-
agent_set: data.agent ? { agents: data.agent } : undefined,
|
|
190
|
-
current_dispute_count: state.dispute_count,
|
|
191
|
-
claimed_by_set: state.claimed_by_set,
|
|
192
|
-
progress_bound: state.progress_bound,
|
|
193
|
-
progress_at_terminal: state.progress_at_terminal,
|
|
194
|
-
service_published: state.service_published,
|
|
195
|
-
service_paused: state.service_paused,
|
|
196
|
-
current_service_machine: state.current_service_machine,
|
|
197
|
-
order_machine_snapshot: state.order_machine_snapshot,
|
|
198
|
-
transfer_to_new_owner: data.transfer_to,
|
|
199
|
-
caller_is_owner: caller.is_owner,
|
|
200
|
-
caller_is_agent: caller.is_agent,
|
|
201
|
-
};
|
|
202
|
-
return assessOrderRisks(ctx);
|
|
203
|
-
}
|
|
204
|
-
export const ORDER_CONFIRMATION_QUESTIONS = [
|
|
205
|
-
{
|
|
206
|
-
id: "QO1",
|
|
207
|
-
question: "Is the Order object address correct? Verify it matches the intended Order (check on explorer).",
|
|
208
|
-
requires_explicit_yes: true,
|
|
209
|
-
},
|
|
210
|
-
{
|
|
211
|
-
id: "QO2",
|
|
212
|
-
question: "If setting agent list: are all agent addresses trusted parties? Agents can advance Progress and file arbitration but CANNOT receive payments.",
|
|
213
|
-
requires_explicit_yes: true,
|
|
214
|
-
related_risk_ids: ["R-O-3-01"],
|
|
215
|
-
},
|
|
216
|
-
{
|
|
217
|
-
id: "QO3",
|
|
218
|
-
question: "If filing arbitration (arb_confirm): have you attached all evidence? This operation is IRREVERSIBLE — once filed, the Arb process cannot be cancelled.",
|
|
219
|
-
requires_explicit_yes: true,
|
|
220
|
-
related_risk_ids: ["R-O-4-04"],
|
|
221
|
-
},
|
|
222
|
-
{
|
|
223
|
-
id: "QO4",
|
|
224
|
-
question: "⚠️⚠️ If claiming compensation (arb_claim_compensation): do you confirm this is the FINAL Arb ruling? After claim, claimed_by is set IRREVERSIBLY — NO new disputes can ever be filed.",
|
|
225
|
-
requires_explicit_yes: true,
|
|
226
|
-
related_risk_ids: ["R-O-3-03", "R-O-4-04"],
|
|
227
|
-
},
|
|
228
|
-
{
|
|
229
|
-
id: "QO5",
|
|
230
|
-
question: "⚠️⚠️ If transferring ownership (transfer_to): do you confirm the new owner address is correct? This is IRREVERSIBLE — new owner takes over ALL permissions including payment receipt.",
|
|
231
|
-
requires_explicit_yes: true,
|
|
232
|
-
related_risk_ids: ["R-O-4-06"],
|
|
233
|
-
},
|
|
234
|
-
{
|
|
235
|
-
id: "QO6",
|
|
236
|
-
question: "If advancing Progress: are you sure about the target node? Node transitions are IRREVERSIBLE — no backward movement is possible.",
|
|
237
|
-
requires_explicit_yes: true,
|
|
238
|
-
related_risk_ids: ["R-O-4-03"],
|
|
239
|
-
},
|
|
240
|
-
{
|
|
241
|
-
id: "QO7",
|
|
242
|
-
question: "If receiving payment: have you verified the receiving object ID and the amount? Funds are forwarded to the owner address immediately.",
|
|
243
|
-
requires_explicit_yes: false,
|
|
244
|
-
},
|
|
245
|
-
{
|
|
246
|
-
id: "QO8",
|
|
247
|
-
question: "Have you exported the current Order state as a backup before this operation? (Recommended for irreversible ops.)",
|
|
248
|
-
requires_explicit_yes: false,
|
|
249
|
-
},
|
|
250
|
-
];
|
|
251
|
-
function processUserConfirmation(input, assessment) {
|
|
252
|
-
const data = input.order_json;
|
|
253
|
-
let questions = [...ORDER_CONFIRMATION_QUESTIONS];
|
|
254
|
-
if (!data.agent)
|
|
255
|
-
questions = questions.filter(q => q.id !== "QO2");
|
|
256
|
-
if (!data.arb_confirm)
|
|
257
|
-
questions = questions.filter(q => q.id !== "QO3");
|
|
258
|
-
if (!data.arb_claim_compensation)
|
|
259
|
-
questions = questions.filter(q => q.id !== "QO4");
|
|
260
|
-
if (!data.transfer_to)
|
|
261
|
-
questions = questions.filter(q => q.id !== "QO5");
|
|
262
|
-
if (!data.progress)
|
|
263
|
-
questions = questions.filter(q => q.id !== "QO6");
|
|
264
|
-
if (!data.receive)
|
|
265
|
-
questions = questions.filter(q => q.id !== "QO7");
|
|
266
|
-
if (input.skip_user_confirmation) {
|
|
267
|
-
return {
|
|
268
|
-
questions_asked: questions,
|
|
269
|
-
responses: questions.map(q => ({ question_id: q.id, response: "yes" })),
|
|
270
|
-
all_confirmed: true,
|
|
271
|
-
};
|
|
272
|
-
}
|
|
273
|
-
return {
|
|
274
|
-
questions_asked: questions,
|
|
275
|
-
responses: [],
|
|
276
|
-
all_confirmed: false,
|
|
277
|
-
};
|
|
278
|
-
}
|
|
279
|
-
function verifyEnvironment(input) {
|
|
280
|
-
const checks = [];
|
|
281
|
-
const data = input.order_json;
|
|
282
|
-
const state = input.current_state ?? {};
|
|
283
|
-
const caller = input.caller ?? {};
|
|
284
|
-
if (data.object) {
|
|
285
|
-
checks.push({
|
|
286
|
-
name: "order_exists",
|
|
287
|
-
passed: true,
|
|
288
|
-
message: `Order ${data.object} assumed to exist (verify via explorer)`,
|
|
289
|
-
});
|
|
290
|
-
}
|
|
291
|
-
const isL1Op = !!(data.receive || data.transfer_to || data.agent);
|
|
292
|
-
const isL2Op = !!(data.required_info !== undefined || data.progress || data.arb_confirm || data.arb_objection || data.arb_claim_compensation);
|
|
293
|
-
if (isL1Op) {
|
|
294
|
-
checks.push({
|
|
295
|
-
name: "signer_is_owner",
|
|
296
|
-
passed: !!caller.is_owner,
|
|
297
|
-
message: caller.is_owner
|
|
298
|
-
? "Signer is owner — L1 allowed"
|
|
299
|
-
: "Signer is NOT owner — L1 operation will abort E_OWNER",
|
|
300
|
-
});
|
|
301
|
-
}
|
|
302
|
-
else if (isL2Op) {
|
|
303
|
-
const hasPerm = !!caller.is_owner || !!caller.is_agent;
|
|
304
|
-
checks.push({
|
|
305
|
-
name: "signer_is_owner_or_agent",
|
|
306
|
-
passed: hasPerm,
|
|
307
|
-
message: hasPerm
|
|
308
|
-
? `Signer is ${caller.is_owner ? "owner" : "agent"} — L2 allowed`
|
|
309
|
-
: "Signer is NEITHER owner NOR agent — L2 will abort E_PERMISSION",
|
|
310
|
-
});
|
|
311
|
-
}
|
|
312
|
-
if (data.arb_confirm || data.arb_objection || data.arb_claim_compensation) {
|
|
313
|
-
checks.push({
|
|
314
|
-
name: "claimed_by_is_none",
|
|
315
|
-
passed: !state.claimed_by_set,
|
|
316
|
-
message: state.claimed_by_set
|
|
317
|
-
? "claimed_by is SET — arb operations blocked (E_ORDER_ALREADY_CLAIMED, IRREVERSIBLE)"
|
|
318
|
-
: "claimed_by is None — arb operations allowed",
|
|
319
|
-
});
|
|
320
|
-
}
|
|
321
|
-
if (data.receive) {
|
|
322
|
-
checks.push({
|
|
323
|
-
name: "progress_at_terminal",
|
|
324
|
-
passed: !!state.progress_at_terminal,
|
|
325
|
-
message: state.progress_at_terminal
|
|
326
|
-
? "Progress at terminal — receive allowed"
|
|
327
|
-
: "Progress NOT at terminal — receive aborts E_ORDER_DELIVERING",
|
|
328
|
-
});
|
|
329
|
-
}
|
|
330
|
-
if (data.agent) {
|
|
331
|
-
checks.push({
|
|
332
|
-
name: "progress_not_bound",
|
|
333
|
-
passed: !state.progress_bound,
|
|
334
|
-
message: state.progress_bound
|
|
335
|
-
? "Progress BOUND — agent_set aborts E_PROGRESS_NOT_SPECIFIED (frozen)"
|
|
336
|
-
: "Progress not bound — agent_set allowed",
|
|
337
|
-
});
|
|
338
|
-
}
|
|
339
|
-
if (data.arb_confirm) {
|
|
340
|
-
const count = state.dispute_count ?? 0;
|
|
341
|
-
const valid = count < MAX_DISPUTE_COUNT;
|
|
342
|
-
checks.push({
|
|
343
|
-
name: "dispute_count_below_max",
|
|
344
|
-
passed: valid,
|
|
345
|
-
message: valid
|
|
346
|
-
? `${count} disputes (< MAX_DISPUTE_COUNT ${MAX_DISPUTE_COUNT})`
|
|
347
|
-
: `${count} disputes at MAX_DISPUTE_COUNT — next dispute() aborts E_MAX_DISPUTE_COUNT`,
|
|
348
|
-
});
|
|
349
|
-
}
|
|
350
|
-
if (state.service_published === false) {
|
|
351
|
-
checks.push({
|
|
352
|
-
name: "service_published",
|
|
353
|
-
passed: false,
|
|
354
|
-
message: "Service is NOT published — service::buy will fail",
|
|
355
|
-
});
|
|
356
|
-
}
|
|
357
|
-
if (state.service_paused === true) {
|
|
358
|
-
checks.push({
|
|
359
|
-
name: "service_not_paused",
|
|
360
|
-
passed: false,
|
|
361
|
-
message: "Service is PAUSED — service::buy will fail",
|
|
362
|
-
});
|
|
363
|
-
}
|
|
364
|
-
const allPassed = checks.every(c => c.passed);
|
|
365
|
-
return { passed: allPassed, checks };
|
|
366
|
-
}
|
|
367
|
-
export const ORDER_CONFIRM_VERSION = "1.0.0";
|
|
368
|
-
export function runOrderConfirmGate(input) {
|
|
369
|
-
const layersPassed = [];
|
|
370
|
-
const layersFailed = [];
|
|
371
|
-
const checklist = runStaticChecklist(input);
|
|
372
|
-
if (!checklist.all_passed) {
|
|
373
|
-
layersFailed.push("L1_checklist");
|
|
374
|
-
return {
|
|
375
|
-
status: "blocked_checklist",
|
|
376
|
-
checklist_result: checklist,
|
|
377
|
-
confirmation_text: generateConfirmationText(input, checklist),
|
|
378
|
-
block_reason: `Checklist failed: ${checklist.items.filter(i => !i.passed).map(i => i.id).join(", ")}`,
|
|
379
|
-
decision_record: {
|
|
380
|
-
timestamp: new Date().toISOString(),
|
|
381
|
-
gate_version: ORDER_CONFIRM_VERSION,
|
|
382
|
-
final_status: "blocked_checklist",
|
|
383
|
-
layers_passed: layersPassed,
|
|
384
|
-
layers_failed: layersFailed,
|
|
385
|
-
},
|
|
386
|
-
};
|
|
387
|
-
}
|
|
388
|
-
layersPassed.push("L1_checklist");
|
|
389
|
-
const assessment = adaptRiskAssessment(input);
|
|
390
|
-
const hasCritical = assessment.risks.some(r => r.level === "CRITICAL");
|
|
391
|
-
if (hasCritical) {
|
|
392
|
-
layersFailed.push("L2_risk");
|
|
393
|
-
return {
|
|
394
|
-
status: "blocked_risk",
|
|
395
|
-
checklist_result: checklist,
|
|
396
|
-
risk_result: assessment,
|
|
397
|
-
confirmation_text: generateConfirmationText(input, checklist, assessment),
|
|
398
|
-
block_reason: `CRITICAL risks: ${assessment.risks.filter(r => r.level === "CRITICAL").map(r => r.id).join(", ")}`,
|
|
399
|
-
decision_record: {
|
|
400
|
-
timestamp: new Date().toISOString(),
|
|
401
|
-
gate_version: ORDER_CONFIRM_VERSION,
|
|
402
|
-
final_status: "blocked_risk",
|
|
403
|
-
layers_passed: layersPassed,
|
|
404
|
-
layers_failed: layersFailed,
|
|
405
|
-
},
|
|
406
|
-
};
|
|
407
|
-
}
|
|
408
|
-
layersPassed.push("L2_risk");
|
|
409
|
-
const userConf = processUserConfirmation(input, assessment);
|
|
410
|
-
if (!userConf.all_confirmed) {
|
|
411
|
-
const isIrreversible = !!(input.order_json.transfer_to || input.order_json.arb_claim_compensation || input.order_json.arb_objection);
|
|
412
|
-
if (isIrreversible) {
|
|
413
|
-
const co10 = checklist.items.find(i => i.id === "C-O-10");
|
|
414
|
-
if (co10) {
|
|
415
|
-
const relevantQIds = [];
|
|
416
|
-
if (input.order_json.transfer_to)
|
|
417
|
-
relevantQIds.push("QO5");
|
|
418
|
-
if (input.order_json.arb_claim_compensation)
|
|
419
|
-
relevantQIds.push("QO4");
|
|
420
|
-
if (input.order_json.arb_objection)
|
|
421
|
-
relevantQIds.push("QO3");
|
|
422
|
-
const confirmed = relevantQIds.every(qid => {
|
|
423
|
-
const r = userConf.responses.find(r => r.question_id === qid);
|
|
424
|
-
return r?.response === "yes";
|
|
425
|
-
});
|
|
426
|
-
co10.passed = confirmed;
|
|
427
|
-
co10.message = confirmed ? "" : "Irreversible operation not confirmed by user";
|
|
428
|
-
}
|
|
429
|
-
}
|
|
430
|
-
if (isIrreversible) {
|
|
431
|
-
const co10 = checklist.items.find(i => i.id === "C-O-10");
|
|
432
|
-
if (co10 && !co10.passed) {
|
|
433
|
-
layersFailed.push("L3_user");
|
|
434
|
-
return {
|
|
435
|
-
status: "blocked_user",
|
|
436
|
-
checklist_result: checklist,
|
|
437
|
-
risk_result: assessment,
|
|
438
|
-
user_confirmation: userConf,
|
|
439
|
-
confirmation_text: generateConfirmationText(input, checklist, assessment),
|
|
440
|
-
block_reason: "User did not confirm irreversible operation",
|
|
441
|
-
decision_record: {
|
|
442
|
-
timestamp: new Date().toISOString(),
|
|
443
|
-
gate_version: ORDER_CONFIRM_VERSION,
|
|
444
|
-
final_status: "blocked_user",
|
|
445
|
-
layers_passed: layersPassed,
|
|
446
|
-
layers_failed: layersFailed,
|
|
447
|
-
},
|
|
448
|
-
};
|
|
449
|
-
}
|
|
450
|
-
}
|
|
451
|
-
}
|
|
452
|
-
layersPassed.push("L3_user");
|
|
453
|
-
if (input.skip_environment_check) {
|
|
454
|
-
layersPassed.push("L4_environment");
|
|
455
|
-
}
|
|
456
|
-
else {
|
|
457
|
-
const env = verifyEnvironment(input);
|
|
458
|
-
if (!env.passed) {
|
|
459
|
-
layersFailed.push("L4_environment");
|
|
460
|
-
return {
|
|
461
|
-
status: "blocked_environment",
|
|
462
|
-
checklist_result: checklist,
|
|
463
|
-
risk_result: assessment,
|
|
464
|
-
user_confirmation: userConf,
|
|
465
|
-
environment_result: env,
|
|
466
|
-
confirmation_text: generateConfirmationText(input, checklist, assessment),
|
|
467
|
-
block_reason: `Environment check failed: ${env.checks.filter(c => !c.passed).map(c => c.name).join(", ")}`,
|
|
468
|
-
decision_record: {
|
|
469
|
-
timestamp: new Date().toISOString(),
|
|
470
|
-
gate_version: ORDER_CONFIRM_VERSION,
|
|
471
|
-
final_status: "blocked_environment",
|
|
472
|
-
layers_passed: layersPassed,
|
|
473
|
-
layers_failed: layersFailed,
|
|
474
|
-
},
|
|
475
|
-
};
|
|
476
|
-
}
|
|
477
|
-
layersPassed.push("L4_environment");
|
|
478
|
-
}
|
|
479
|
-
return {
|
|
480
|
-
status: "approved",
|
|
481
|
-
checklist_result: checklist,
|
|
482
|
-
risk_result: assessment,
|
|
483
|
-
user_confirmation: userConf,
|
|
484
|
-
confirmation_text: generateConfirmationText(input, checklist, assessment),
|
|
485
|
-
decision_record: {
|
|
486
|
-
timestamp: new Date().toISOString(),
|
|
487
|
-
gate_version: ORDER_CONFIRM_VERSION,
|
|
488
|
-
final_status: "approved",
|
|
489
|
-
layers_passed: layersPassed,
|
|
490
|
-
layers_failed: layersFailed,
|
|
491
|
-
},
|
|
492
|
-
};
|
|
493
|
-
}
|
|
494
|
-
function generateConfirmationText(input, checklist, assessment) {
|
|
495
|
-
const lines = [];
|
|
496
|
-
const data = input.order_json;
|
|
497
|
-
lines.push("═══ Order Confirmation ═══");
|
|
498
|
-
lines.push("");
|
|
499
|
-
if (data.object) {
|
|
500
|
-
lines.push(`Order: ${data.object}`);
|
|
501
|
-
}
|
|
502
|
-
else {
|
|
503
|
-
lines.push("Order: (no address — invalid for CallOrder_Data)");
|
|
504
|
-
}
|
|
505
|
-
lines.push("");
|
|
506
|
-
lines.push("─ Operations ──────────────────");
|
|
507
|
-
if (data.agent)
|
|
508
|
-
lines.push(`- ⚠️ Set agent list: ${data.agent.length} agent(s) [L1, owner-only, frozen after progress]`);
|
|
509
|
-
if (data.required_info !== undefined)
|
|
510
|
-
lines.push(`- required_info: ${data.required_info === null ? "(clear)" : data.required_info} [L2]`);
|
|
511
|
-
if (data.progress)
|
|
512
|
-
lines.push(`- Advance Progress: ${data.progress.next_node_name ?? "?"} [L2, irreversible]`);
|
|
513
|
-
if (data.arb_confirm)
|
|
514
|
-
lines.push(`- ⚠️ File arbitration: ${data.arb_confirm.arb} [L2, irreversible]`);
|
|
515
|
-
if (data.arb_objection)
|
|
516
|
-
lines.push(`- ⚠️ Object to Arb: ${data.arb_objection.arb} [L2, irreversible]`);
|
|
517
|
-
if (data.arb_claim_compensation)
|
|
518
|
-
lines.push(`- ⚠️⚠️ Claim compensation: ${data.arb_claim_compensation.arb} [L2, ONE-TIME, IRREVERSIBLE]`);
|
|
519
|
-
if (data.receive)
|
|
520
|
-
lines.push(`- Receive: ${data.receive.received} [L1, owner-only]`);
|
|
521
|
-
if (data.transfer_to)
|
|
522
|
-
lines.push(`- ⚠️⚠️ Transfer ownership to: ${data.transfer_to} [L1, IRREVERSIBLE]`);
|
|
523
|
-
lines.push("");
|
|
524
|
-
lines.push("─ Checklist ──────────────────");
|
|
525
|
-
for (const item of checklist.items) {
|
|
526
|
-
const mark = item.passed ? "✓" : "✗";
|
|
527
|
-
lines.push(` ${mark} ${item.id}: ${item.description}${item.message ? " — " + item.message : ""}`);
|
|
528
|
-
}
|
|
529
|
-
lines.push("");
|
|
530
|
-
if (assessment) {
|
|
531
|
-
lines.push("─ Risk Assessment ──────────────────");
|
|
532
|
-
lines.push(`Overall: ${assessment.overall_risk}`);
|
|
533
|
-
lines.push(`Detected: ${assessment.risks.length} risk(s)`);
|
|
534
|
-
for (const r of assessment.risks) {
|
|
535
|
-
lines.push(` [${r.level}] ${r.id}: ${r.title}`);
|
|
536
|
-
}
|
|
537
|
-
lines.push("");
|
|
538
|
-
}
|
|
539
|
-
return lines.join("\n");
|
|
540
|
-
}
|
|
541
|
-
export function progressiveOrderCheck(input) {
|
|
542
|
-
const checklist = runStaticChecklist(input);
|
|
543
|
-
if (!checklist.all_passed) {
|
|
544
|
-
return {
|
|
545
|
-
stage: "checklist",
|
|
546
|
-
status: "fail",
|
|
547
|
-
message: `Checklist failed: ${checklist.items.filter(i => !i.passed).map(i => i.id).join(", ")}`,
|
|
548
|
-
next_action: "Fix failing checklist items",
|
|
549
|
-
};
|
|
550
|
-
}
|
|
551
|
-
const assessment = adaptRiskAssessment(input);
|
|
552
|
-
if (assessment.risks.some(r => r.level === "CRITICAL")) {
|
|
553
|
-
return {
|
|
554
|
-
stage: "risk",
|
|
555
|
-
status: "fail",
|
|
556
|
-
message: `CRITICAL risks: ${assessment.risks.filter(r => r.level === "CRITICAL").map(r => r.id).join(", ")}`,
|
|
557
|
-
next_action: "Resolve CRITICAL risks before proceeding",
|
|
558
|
-
};
|
|
559
|
-
}
|
|
560
|
-
if (assessment.needs_human_review) {
|
|
561
|
-
return {
|
|
562
|
-
stage: "confirmation",
|
|
563
|
-
status: "pending",
|
|
564
|
-
message: "Human review required for HIGH risks",
|
|
565
|
-
next_action: "Confirm risk acceptance",
|
|
566
|
-
};
|
|
567
|
-
}
|
|
568
|
-
return {
|
|
569
|
-
stage: "complete",
|
|
570
|
-
status: "pass",
|
|
571
|
-
message: "All checks passed",
|
|
572
|
-
};
|
|
573
|
-
}
|
|
1
|
+
import{MAX_AGENT_COUNT,MAX_DISPUTE_COUNT}from'@wowok/wowok';import{assessOrderRisks}from'./order-risk.js';export const ORDER_PUBLISH_CHECKLIST=[{'id':'C-O-01','description':'Order\x20object\x20address\x20is\x20valid\x20(must\x20start\x20with\x200x,\x20length\x20>=\x2040)','passed':![],'message':''},{'id':'C-O-02','description':'Operation\x20is\x20NOT\x20direct\x20order::create\x20(Order\x20created\x20via\x20service::buy)','passed':![],'message':''},{'id':'C-O-03','description':'agent\x20count\x20<=\x20MAX_AGENT_COUNT\x20('+MAX_AGENT_COUNT+')\x20—\x20⚠️\x20actual\x20allows\x2011\x20due\x20to\x20<=\x20bug','passed':![],'message':''},{'id':'C-O-04','description':'dispute\x20count\x20<\x20MAX_DISPUTE_COUNT\x20('+MAX_DISPUTE_COUNT+')\x20—\x20cannot\x20file\x2011th\x20dispute','passed':![],'message':''},{'id':'C-O-05','description':'claimed_by\x20is\x20None\x20(no\x20terminal\x20claim\x20state)\x20—\x20required\x20for\x20arb_confirm/arb_objection/arb_claim_compensation','passed':![],'message':''},{'id':'C-O-06','description':'L1\x20operations\x20(receive/transfer_to/agent_set)\x20called\x20by\x20OWNER\x20only','passed':![],'message':''},{'id':'C-O-07','description':'L2\x20operations\x20(required_info/progress/arb_*)\x20called\x20by\x20owner\x20OR\x20agent','passed':![],'message':''},{'id':'C-O-08','description':'agent_set\x20/\x20owner_change\x20called\x20BEFORE\x20Progress\x20binding\x20(frozen\x20after)','passed':![],'message':''},{'id':'C-O-09','description':'receive\x20called\x20only\x20when\x20Progress\x20is\x20at\x20terminal\x20node\x20(not\x20delivering)','passed':![],'message':''},{'id':'C-O-10','description':'transfer_to\x20/\x20arb_claim_compensation\x20/\x20arb_objection\x20are\x20IRREVERSIBLE\x20—\x20double-confirm','passed':![],'message':''},{'id':'C-O-11','description':'required_info\x20is\x20Contact\x20object\x20OR\x20WTS\x20Proof\x20object\x20OR\x20null\x20(clear)','passed':![],'message':''},{'id':'C-O-12','description':'Service\x20is\x20published\x20AND\x20not\x20paused\x20(for\x20service::buy\x20flow)','passed':![],'message':''},{'id':'C-O-13','description':'Agent\x20CANNOT\x20receive\x20payments\x20—\x20only\x20owner\x20can\x20call\x20receive','passed':![],'message':''},{'id':'C-O-14','description':'arb_claim_compensation\x20requires\x20Arb\x20in\x20Arbitrated\x20state','passed':![],'message':''},{'id':'C-O-15','description':'Order\x20has\x2014\x20fields\x20—\x20SDK\x20uses\x20\x27builder\x27\x20for\x20Move\x27s\x20\x27owner\x27\x20(naming\x20deviation)','passed':![],'message':''}];function isValidAddress(a){return typeof a==='string'&&a['startsWith']('0x')&&a['length']>=0x28;}function runStaticChecklist(a){const b=ORDER_PUBLISH_CHECKLIST['map'](y=>({...y})),c=a['order_json'],d=a['current_state']??{},e=a['caller']??{},f=b['find'](y=>y['id']==='C-O-01');if(!c['object'])f['passed']=![],f['message']='Order\x20object\x20address\x20is\x20required\x20(creation\x20goes\x20via\x20service::buy,\x20not\x20here)';else!isValidAddress(c['object'])?(f['passed']=![],f['message']='Invalid\x20Order\x20address:\x20'+c['object']):f['passed']=!![];const g=b['find'](y=>y['id']==='C-O-02');g['passed']=!![],g['message']='CallOrder_Data\x20has\x20no\x20create\x20op\x20—\x20Order\x20creation\x20goes\x20via\x20service::buy';const h=b['find'](y=>y['id']==='C-O-03');if(c['agent']){const y=c['agent']['length'],z=y<=MAX_AGENT_COUNT;h['passed']=z,h['message']=z?y===MAX_AGENT_COUNT?y+'\x20agents\x20(at\x20doc\x20limit;\x20actual\x20allows\x2011\x20due\x20to\x20bug)':y+'\x20agents':y+'\x20agents\x20>\x20MAX_AGENT_COUNT\x20('+MAX_AGENT_COUNT+')\x20—\x20will\x20abort\x20E_MAX_AGENT_COUNT\x20(note:\x20actual\x20allows\x2011\x20due\x20to\x20<=\x20bug)';}else h['passed']=!![];const i=b['find'](A=>A['id']==='C-O-04'),j=d['dispute_count']??0x0;if(c['arb_confirm']){const A=j<MAX_DISPUTE_COUNT;i['passed']=A,i['message']=A?j+'\x20existing\x20disputes':j+'\x20disputes\x20already\x20at\x20MAX_DISPUTE_COUNT\x20('+MAX_DISPUTE_COUNT+')\x20—\x20next\x20dispute()\x20will\x20abort\x20E_MAX_DISPUTE_COUNT';}else i['passed']=!![];const k=b['find'](B=>B['id']==='C-O-05');if(c['arb_confirm']||c['arb_objection']||c['arb_claim_compensation']){const B=!d['claimed_by_set'];k['passed']=B,k['message']=B?'claimed_by\x20is\x20None\x20—\x20arb\x20operations\x20allowed':'claimed_by\x20is\x20SET\x20—\x20arb\x20operations\x20blocked\x20(E_ORDER_ALREADY_CLAIMED,\x20IRREVERSIBLE)';}else k['passed']=!![];const l=b['find'](C=>C['id']==='C-O-06'),m=!!(c['receive']||c['transfer_to']||c['agent']);if(m){const C=!!e['is_owner'];l['passed']=C,l['message']=C?'Caller\x20is\x20owner\x20—\x20L1\x20allowed':'Caller\x20is\x20NOT\x20owner\x20—\x20L1\x20operation\x20blocked\x20(E_OWNER)';}else l['passed']=!![];const n=b['find'](D=>D['id']==='C-O-07'),o=!!(c['required_info']!==undefined||c['progress']||c['arb_confirm']||c['arb_objection']||c['arb_claim_compensation']);if(o){const D=!!e['is_owner']||!!e['is_agent'];n['passed']=D,n['message']=D?'Caller\x20is\x20owner\x20or\x20agent\x20—\x20L2\x20allowed':'Caller\x20is\x20NEITHER\x20owner\x20NOR\x20agent\x20—\x20L2\x20blocked\x20(E_PERMISSION)';}else n['passed']=!![];const p=b['find'](E=>E['id']==='C-O-08');if(c['agent']||c['transfer_to']&&!d['progress_bound']){if(c['agent']){const E=!d['progress_bound'];p['passed']=E,p['message']=E?'Progress\x20not\x20bound\x20—\x20agent_set\x20allowed':'Progress\x20BOUND\x20—\x20agent_set\x20aborts\x20E_PROGRESS_NOT_SPECIFIED\x20(frozen)';}else p['passed']=!![];}else p['passed']=!![];const q=b['find'](F=>F['id']==='C-O-09');if(c['receive']){const F=!!d['progress_at_terminal'];q['passed']=F,q['message']=F?'Progress\x20at\x20terminal\x20—\x20receive\x20allowed':'Progress\x20NOT\x20at\x20terminal\x20—\x20receive\x20aborts\x20E_ORDER_DELIVERING';}else q['passed']=!![];const r=b['find'](G=>G['id']==='C-O-10'),s=!!(c['transfer_to']||c['arb_claim_compensation']||c['arb_objection']);s?(r['passed']=![],r['message']='Pending\x20user\x20confirmation\x20in\x20Layer\x203\x20(irreversible\x20operation)'):r['passed']=!![];const t=b['find'](G=>G['id']==='C-O-11');if(c['required_info']!==undefined){const G=c['required_info']===null||isValidAddress(c['required_info']);t['passed']=G,t['message']=G?c['required_info']===null?'required_info\x20=\x20null\x20(clear)':'required_info\x20is\x20valid\x20address\x20(Contact\x20or\x20WTS\x20Proof)':'Invalid\x20required_info:\x20'+c['required_info'];}else t['passed']=!![];const u=b['find'](H=>H['id']==='C-O-12');u['passed']=!![],u['message']='Service\x20check\x20applies\x20only\x20to\x20service::buy\x20flow\x20(not\x20CallOrder_Data)';const v=b['find'](H=>H['id']==='C-O-13');c['receive']&&e['is_agent']&&!e['is_owner']?(v['passed']=![],v['message']='Agent\x20CANNOT\x20receive\x20payments\x20—\x20only\x20owner\x20can\x20call\x20receive\x20(L1)'):v['passed']=!![];const w=b['find'](H=>H['id']==='C-O-14');c['arb_claim_compensation']?(w['passed']=!![],w['message']='Arb\x20Arbitrated\x20state\x20verified\x20in\x20Layer\x204\x20(Environment)'):w['passed']=!![];const x=b['find'](H=>H['id']==='C-O-15');return x['passed']=!![],x['message']='Informational:\x20SDK\x20ObjectOrder.builder\x20↔\x20Move\x20Order.owner\x20(only\x20naming\x20deviation\x20in\x2022\x20objects)',{'all_passed':b['filter'](H=>H['id']!=='C-O-10')['every'](H=>H['passed']),'items':b};}function adaptRiskAssessment(a){const b=a['order_json'],c=a['current_state']??{},d=a['caller']??{};let e;if(b['agent'])e='agent_set';else{if(b['required_info']!==undefined)e='required_info_update';else{if(b['progress'])e='progress_advance';else{if(b['arb_confirm'])e='arb_confirm';else{if(b['arb_objection'])e='arb_objection';else{if(b['arb_claim_compensation'])e='arb_claim_compensation';else{if(b['receive'])e='receive';else{if(b['transfer_to'])e='transfer_to';}}}}}}}const f={'object':b['object'],'operation':e,'is_buy_operation':![],'agent_set':b['agent']?{'agents':b['agent']}:undefined,'current_dispute_count':c['dispute_count'],'claimed_by_set':c['claimed_by_set'],'progress_bound':c['progress_bound'],'progress_at_terminal':c['progress_at_terminal'],'service_published':c['service_published'],'service_paused':c['service_paused'],'current_service_machine':c['current_service_machine'],'order_machine_snapshot':c['order_machine_snapshot'],'transfer_to_new_owner':b['transfer_to'],'caller_is_owner':d['is_owner'],'caller_is_agent':d['is_agent']};return assessOrderRisks(f);}export const ORDER_CONFIRMATION_QUESTIONS=[{'id':'QO1','question':'Is\x20the\x20Order\x20object\x20address\x20correct?\x20Verify\x20it\x20matches\x20the\x20intended\x20Order\x20(check\x20on\x20explorer).','requires_explicit_yes':!![]},{'id':'QO2','question':'If\x20setting\x20agent\x20list:\x20are\x20all\x20agent\x20addresses\x20trusted\x20parties?\x20Agents\x20can\x20advance\x20Progress\x20and\x20file\x20arbitration\x20but\x20CANNOT\x20receive\x20payments.','requires_explicit_yes':!![],'related_risk_ids':['R-O-3-01']},{'id':'QO3','question':'If\x20filing\x20arbitration\x20(arb_confirm):\x20have\x20you\x20attached\x20all\x20evidence?\x20This\x20operation\x20is\x20IRREVERSIBLE\x20—\x20once\x20filed,\x20the\x20Arb\x20process\x20cannot\x20be\x20cancelled.','requires_explicit_yes':!![],'related_risk_ids':['R-O-4-04']},{'id':'QO4','question':'⚠️⚠️\x20If\x20claiming\x20compensation\x20(arb_claim_compensation):\x20do\x20you\x20confirm\x20this\x20is\x20the\x20FINAL\x20Arb\x20ruling?\x20After\x20claim,\x20claimed_by\x20is\x20set\x20IRREVERSIBLY\x20—\x20NO\x20new\x20disputes\x20can\x20ever\x20be\x20filed.','requires_explicit_yes':!![],'related_risk_ids':['R-O-3-03','R-O-4-04']},{'id':'QO5','question':'⚠️⚠️\x20If\x20transferring\x20ownership\x20(transfer_to):\x20do\x20you\x20confirm\x20the\x20new\x20owner\x20address\x20is\x20correct?\x20This\x20is\x20IRREVERSIBLE\x20—\x20new\x20owner\x20takes\x20over\x20ALL\x20permissions\x20including\x20payment\x20receipt.','requires_explicit_yes':!![],'related_risk_ids':['R-O-4-06']},{'id':'QO6','question':'If\x20advancing\x20Progress:\x20are\x20you\x20sure\x20about\x20the\x20target\x20node?\x20Node\x20transitions\x20are\x20IRREVERSIBLE\x20—\x20no\x20backward\x20movement\x20is\x20possible.','requires_explicit_yes':!![],'related_risk_ids':['R-O-4-03']},{'id':'QO7','question':'If\x20receiving\x20payment:\x20have\x20you\x20verified\x20the\x20receiving\x20object\x20ID\x20and\x20the\x20amount?\x20Funds\x20are\x20forwarded\x20to\x20the\x20owner\x20address\x20immediately.','requires_explicit_yes':![]},{'id':'QO8','question':'Have\x20you\x20exported\x20the\x20current\x20Order\x20state\x20as\x20a\x20backup\x20before\x20this\x20operation?\x20(Recommended\x20for\x20irreversible\x20ops.)','requires_explicit_yes':![]}];function processUserConfirmation(a,b){const c=a['order_json'];let d=[...ORDER_CONFIRMATION_QUESTIONS];if(!c['agent'])d=d['filter'](e=>e['id']!=='QO2');if(!c['arb_confirm'])d=d['filter'](e=>e['id']!=='QO3');if(!c['arb_claim_compensation'])d=d['filter'](e=>e['id']!=='QO4');if(!c['transfer_to'])d=d['filter'](e=>e['id']!=='QO5');if(!c['progress'])d=d['filter'](e=>e['id']!=='QO6');if(!c['receive'])d=d['filter'](e=>e['id']!=='QO7');if(a['skip_user_confirmation'])return{'questions_asked':d,'responses':d['map'](e=>({'question_id':e['id'],'response':'yes'})),'all_confirmed':!![]};return{'questions_asked':d,'responses':[],'all_confirmed':![]};}function verifyEnvironment(a){const b=[],c=a['order_json'],d=a['current_state']??{},e=a['caller']??{};c['object']&&b['push']({'name':'order_exists','passed':!![],'message':'Order\x20'+c['object']+'\x20assumed\x20to\x20exist\x20(verify\x20via\x20explorer)'});const f=!!(c['receive']||c['transfer_to']||c['agent']),g=!!(c['required_info']!==undefined||c['progress']||c['arb_confirm']||c['arb_objection']||c['arb_claim_compensation']);if(f)b['push']({'name':'signer_is_owner','passed':!!e['is_owner'],'message':e['is_owner']?'Signer\x20is\x20owner\x20—\x20L1\x20allowed':'Signer\x20is\x20NOT\x20owner\x20—\x20L1\x20operation\x20will\x20abort\x20E_OWNER'});else{if(g){const i=!!e['is_owner']||!!e['is_agent'];b['push']({'name':'signer_is_owner_or_agent','passed':i,'message':i?'Signer\x20is\x20'+(e['is_owner']?'owner':'agent')+'\x20—\x20L2\x20allowed':'Signer\x20is\x20NEITHER\x20owner\x20NOR\x20agent\x20—\x20L2\x20will\x20abort\x20E_PERMISSION'});}}(c['arb_confirm']||c['arb_objection']||c['arb_claim_compensation'])&&b['push']({'name':'claimed_by_is_none','passed':!d['claimed_by_set'],'message':d['claimed_by_set']?'claimed_by\x20is\x20SET\x20—\x20arb\x20operations\x20blocked\x20(E_ORDER_ALREADY_CLAIMED,\x20IRREVERSIBLE)':'claimed_by\x20is\x20None\x20—\x20arb\x20operations\x20allowed'});c['receive']&&b['push']({'name':'progress_at_terminal','passed':!!d['progress_at_terminal'],'message':d['progress_at_terminal']?'Progress\x20at\x20terminal\x20—\x20receive\x20allowed':'Progress\x20NOT\x20at\x20terminal\x20—\x20receive\x20aborts\x20E_ORDER_DELIVERING'});c['agent']&&b['push']({'name':'progress_not_bound','passed':!d['progress_bound'],'message':d['progress_bound']?'Progress\x20BOUND\x20—\x20agent_set\x20aborts\x20E_PROGRESS_NOT_SPECIFIED\x20(frozen)':'Progress\x20not\x20bound\x20—\x20agent_set\x20allowed'});if(c['arb_confirm']){const j=d['dispute_count']??0x0,k=j<MAX_DISPUTE_COUNT;b['push']({'name':'dispute_count_below_max','passed':k,'message':k?j+'\x20disputes\x20(<\x20MAX_DISPUTE_COUNT\x20'+MAX_DISPUTE_COUNT+')':j+'\x20disputes\x20at\x20MAX_DISPUTE_COUNT\x20—\x20next\x20dispute()\x20aborts\x20E_MAX_DISPUTE_COUNT'});}d['service_published']===![]&&b['push']({'name':'service_published','passed':![],'message':'Service\x20is\x20NOT\x20published\x20—\x20service::buy\x20will\x20fail'});d['service_paused']===!![]&&b['push']({'name':'service_not_paused','passed':![],'message':'Service\x20is\x20PAUSED\x20—\x20service::buy\x20will\x20fail'});const h=b['every'](l=>l['passed']);return{'passed':h,'checks':b};}export const ORDER_CONFIRM_VERSION='1.0.0';export function runOrderConfirmGate(a){const b=[],c=[],d=runStaticChecklist(a);if(!d['all_passed'])return c['push']('L1_checklist'),{'status':'blocked_checklist','checklist_result':d,'confirmation_text':generateConfirmationText(a,d),'block_reason':'Checklist\x20failed:\x20'+d['items']['filter'](h=>!h['passed'])['map'](h=>h['id'])['join'](',\x20'),'decision_record':{'timestamp':new Date()['toISOString'](),'gate_version':ORDER_CONFIRM_VERSION,'final_status':'blocked_checklist','layers_passed':b,'layers_failed':c}};b['push']('L1_checklist');const e=adaptRiskAssessment(a),f=e['risks']['some'](h=>h['level']==='CRITICAL');if(f)return c['push']('L2_risk'),{'status':'blocked_risk','checklist_result':d,'risk_result':e,'confirmation_text':generateConfirmationText(a,d,e),'block_reason':'CRITICAL\x20risks:\x20'+e['risks']['filter'](h=>h['level']==='CRITICAL')['map'](h=>h['id'])['join'](',\x20'),'decision_record':{'timestamp':new Date()['toISOString'](),'gate_version':ORDER_CONFIRM_VERSION,'final_status':'blocked_risk','layers_passed':b,'layers_failed':c}};b['push']('L2_risk');const g=processUserConfirmation(a,e);if(!g['all_confirmed']){const h=!!(a['order_json']['transfer_to']||a['order_json']['arb_claim_compensation']||a['order_json']['arb_objection']);if(h){const i=d['items']['find'](j=>j['id']==='C-O-10');if(i){const j=[];if(a['order_json']['transfer_to'])j['push']('QO5');if(a['order_json']['arb_claim_compensation'])j['push']('QO4');if(a['order_json']['arb_objection'])j['push']('QO3');const k=j['every'](l=>{const m=g['responses']['find'](n=>n['question_id']===l);return m?.['response']==='yes';});i['passed']=k,i['message']=k?'':'Irreversible\x20operation\x20not\x20confirmed\x20by\x20user';}}if(h){const l=d['items']['find'](m=>m['id']==='C-O-10');if(l&&!l['passed'])return c['push']('L3_user'),{'status':'blocked_user','checklist_result':d,'risk_result':e,'user_confirmation':g,'confirmation_text':generateConfirmationText(a,d,e),'block_reason':'User\x20did\x20not\x20confirm\x20irreversible\x20operation','decision_record':{'timestamp':new Date()['toISOString'](),'gate_version':ORDER_CONFIRM_VERSION,'final_status':'blocked_user','layers_passed':b,'layers_failed':c}};}}b['push']('L3_user');if(a['skip_environment_check'])b['push']('L4_environment');else{const m=verifyEnvironment(a);if(!m['passed'])return c['push']('L4_environment'),{'status':'blocked_environment','checklist_result':d,'risk_result':e,'user_confirmation':g,'environment_result':m,'confirmation_text':generateConfirmationText(a,d,e),'block_reason':'Environment\x20check\x20failed:\x20'+m['checks']['filter'](n=>!n['passed'])['map'](n=>n['name'])['join'](',\x20'),'decision_record':{'timestamp':new Date()['toISOString'](),'gate_version':ORDER_CONFIRM_VERSION,'final_status':'blocked_environment','layers_passed':b,'layers_failed':c}};b['push']('L4_environment');}return{'status':'approved','checklist_result':d,'risk_result':e,'user_confirmation':g,'confirmation_text':generateConfirmationText(a,d,e),'decision_record':{'timestamp':new Date()['toISOString'](),'gate_version':ORDER_CONFIRM_VERSION,'final_status':'approved','layers_passed':b,'layers_failed':c}};}function generateConfirmationText(a,b,c){const d=[],e=a['order_json'];d['push']('═══\x20Order\x20Confirmation\x20═══'),d['push']('');e['object']?d['push']('Order:\x20'+e['object']):d['push']('Order:\x20(no\x20address\x20—\x20invalid\x20for\x20CallOrder_Data)');d['push'](''),d['push']('─\x20Operations\x20──────────────────');if(e['agent'])d['push']('-\x20⚠️\x20Set\x20agent\x20list:\x20'+e['agent']['length']+'\x20agent(s)\x20[L1,\x20owner-only,\x20frozen\x20after\x20progress]');if(e['required_info']!==undefined)d['push']('-\x20required_info:\x20'+(e['required_info']===null?'(clear)':e['required_info'])+'\x20[L2]');if(e['progress'])d['push']('-\x20Advance\x20Progress:\x20'+(e['progress']['next_node_name']??'?')+'\x20[L2,\x20irreversible]');if(e['arb_confirm'])d['push']('-\x20⚠️\x20File\x20arbitration:\x20'+e['arb_confirm']['arb']+'\x20[L2,\x20irreversible]');if(e['arb_objection'])d['push']('-\x20⚠️\x20Object\x20to\x20Arb:\x20'+e['arb_objection']['arb']+'\x20[L2,\x20irreversible]');if(e['arb_claim_compensation'])d['push']('-\x20⚠️⚠️\x20Claim\x20compensation:\x20'+e['arb_claim_compensation']['arb']+'\x20[L2,\x20ONE-TIME,\x20IRREVERSIBLE]');if(e['receive'])d['push']('-\x20Receive:\x20'+e['receive']['received']+'\x20[L1,\x20owner-only]');if(e['transfer_to'])d['push']('-\x20⚠️⚠️\x20Transfer\x20ownership\x20to:\x20'+e['transfer_to']+'\x20[L1,\x20IRREVERSIBLE]');d['push'](''),d['push']('─\x20Checklist\x20──────────────────');for(const f of b['items']){const g=f['passed']?'✓':'✗';d['push']('\x20\x20'+g+'\x20'+f['id']+':\x20'+f['description']+(f['message']?'\x20—\x20'+f['message']:''));}d['push']('');if(c){d['push']('─\x20Risk\x20Assessment\x20──────────────────'),d['push']('Overall:\x20'+c['overall_risk']),d['push']('Detected:\x20'+c['risks']['length']+'\x20risk(s)');for(const h of c['risks']){d['push']('\x20\x20['+h['level']+']\x20'+h['id']+':\x20'+h['title']);}d['push']('');}return d['join']('\x0a');}export function progressiveOrderCheck(a){const b=runStaticChecklist(a);if(!b['all_passed'])return{'stage':'checklist','status':'fail','message':'Checklist\x20failed:\x20'+b['items']['filter'](d=>!d['passed'])['map'](d=>d['id'])['join'](',\x20'),'next_action':'Fix\x20failing\x20checklist\x20items'};const c=adaptRiskAssessment(a);if(c['risks']['some'](d=>d['level']==='CRITICAL'))return{'stage':'risk','status':'fail','message':'CRITICAL\x20risks:\x20'+c['risks']['filter'](d=>d['level']==='CRITICAL')['map'](d=>d['id'])['join'](',\x20'),'next_action':'Resolve\x20CRITICAL\x20risks\x20before\x20proceeding'};if(c['needs_human_review'])return{'stage':'confirmation','status':'pending','message':'Human\x20review\x20required\x20for\x20HIGH\x20risks','next_action':'Confirm\x20risk\x20acceptance'};return{'stage':'complete','status':'pass','message':'All\x20checks\x20passed'};}
|