@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,807 +1 @@
|
|
|
1
|
-
import { MAX_SALE_COUNT, MAX_REPOSITORY_COUNT, MAX_ARBITRATION_COUNT, MAX_DISCOUNT_COUNT_ONCE, MAX_DISCOUNT_TOTAL_COUNT, MAX_WIP_LENGTH, MAX_WIP_HASH_LENGTH, } from "@wowok/wowok";
|
|
2
|
-
import { assessServiceRisks, } from "./service-risk.js";
|
|
3
|
-
export const SERVICE_PUBLISH_CHECKLIST = [
|
|
4
|
-
{ id: "C-S-01", description: "Sales count <= MAX_SALE_COUNT (50)", passed: false, message: "" },
|
|
5
|
-
{ id: "C-S-02", description: "Repositories count <= MAX_REPOSITORY_COUNT (100)", passed: false, message: "" },
|
|
6
|
-
{ id: "C-S-03", description: "Arbitrations count <= MAX_ARBITRATION_COUNT (20)", passed: false, message: "" },
|
|
7
|
-
{ id: "C-S-04", description: "Rewards count <= MAX_REWARD_COUNT (20)", passed: false, message: "" },
|
|
8
|
-
{ id: "C-S-05", description: "WIP URL length <= MAX_WIP_LENGTH (1024) for each sale", passed: false, message: "" },
|
|
9
|
-
{ id: "C-S-06", description: "WIP hash length <= MAX_WIP_HASH_LENGTH (64) — sha256 hex", passed: false, message: "" },
|
|
10
|
-
{ id: "C-S-07", description: "WIP hash NOT empty when wip URL is set (tamper protection)", passed: false, message: "" },
|
|
11
|
-
{ id: "C-S-08", description: "Discount count <= MAX_DISCOUNT_TOTAL_COUNT (20000)", passed: false, message: "" },
|
|
12
|
-
{ id: "C-S-09", description: "Discount per-call <= MAX_DISCOUNT_COUNT_ONCE (1000)", passed: false, message: "" },
|
|
13
|
-
{ id: "C-S-10", description: "Publish: order_allocators MUST be set (F-S-18, E_NO_ALLOCATOR)", passed: false, message: "" },
|
|
14
|
-
{ id: "C-S-11", description: "Publish: if compensation_fund > 0, arbitrations non-empty (F-S-19)", passed: false, message: "" },
|
|
15
|
-
{ id: "C-S-12", description: "Post-publish: machine modification BLOCKED (F-S-20)", passed: false, message: "" },
|
|
16
|
-
{ id: "C-S-13", description: "Post-publish: arbitrations modification BLOCKED (F-S-21)", passed: false, message: "" },
|
|
17
|
-
{ id: "C-S-14", description: "Post-publish: order_allocators modification BLOCKED (F-S-22)", passed: false, message: "" },
|
|
18
|
-
{ id: "C-S-15", description: "compensation_fund_withdraw requires bPaused=true + lock_duration expired (F-S-25, F-S-26)", passed: false, message: "" },
|
|
19
|
-
{ id: "C-S-16", description: "Address fields valid (0x prefix, length >= 40)", passed: false, message: "" },
|
|
20
|
-
{ id: "C-S-17", description: "Publish operation double-confirmed (bPublished irreversible)", passed: false, message: "" },
|
|
21
|
-
{ id: "C-S-18", description: "Ownership transfer double-confirmed (IRREVERSIBLE)", passed: false, message: "" },
|
|
22
|
-
{ id: "C-S-19", description: "Publish: arbitrations strongly recommended (cannot add post-publish, F-S-21)", passed: false, message: "" },
|
|
23
|
-
];
|
|
24
|
-
function runStaticChecklist(input) {
|
|
25
|
-
const items = SERVICE_PUBLISH_CHECKLIST.map(c => ({ ...c }));
|
|
26
|
-
const data = input.service_json;
|
|
27
|
-
const isPublished = input.current_bPublished ?? false;
|
|
28
|
-
if (data.sales && (data.sales.op === "add" || data.sales.op === "set")) {
|
|
29
|
-
const currentCount = input.current_sales_count ?? 0;
|
|
30
|
-
const newCount = data.sales.op === "set"
|
|
31
|
-
? data.sales.sales.length
|
|
32
|
-
: currentCount + data.sales.sales.length;
|
|
33
|
-
const cs01 = items.find(i => i.id === "C-S-01");
|
|
34
|
-
cs01.passed = newCount <= MAX_SALE_COUNT;
|
|
35
|
-
cs01.message = cs01.passed ? "" : `sales count ${newCount} > ${MAX_SALE_COUNT}`;
|
|
36
|
-
}
|
|
37
|
-
else {
|
|
38
|
-
items.find(i => i.id === "C-S-01").passed = true;
|
|
39
|
-
}
|
|
40
|
-
if (data.repositories && (data.repositories.op === "add" || data.repositories.op === "set")) {
|
|
41
|
-
const currentCount = input.current_repositories_count ?? 0;
|
|
42
|
-
const newCount = data.repositories.op === "set"
|
|
43
|
-
? data.repositories.objects.length
|
|
44
|
-
: currentCount + data.repositories.objects.length;
|
|
45
|
-
const cs02 = items.find(i => i.id === "C-S-02");
|
|
46
|
-
cs02.passed = newCount <= MAX_REPOSITORY_COUNT;
|
|
47
|
-
cs02.message = cs02.passed ? "" : `repositories count ${newCount} > ${MAX_REPOSITORY_COUNT}`;
|
|
48
|
-
}
|
|
49
|
-
else {
|
|
50
|
-
items.find(i => i.id === "C-S-02").passed = true;
|
|
51
|
-
}
|
|
52
|
-
if (data.arbitrations && (data.arbitrations.op === "add" || data.arbitrations.op === "set")) {
|
|
53
|
-
const currentCount = input.current_arbitrations_count ?? 0;
|
|
54
|
-
const newCount = data.arbitrations.op === "set"
|
|
55
|
-
? data.arbitrations.objects.length
|
|
56
|
-
: currentCount + data.arbitrations.objects.length;
|
|
57
|
-
const cs03 = items.find(i => i.id === "C-S-03");
|
|
58
|
-
cs03.passed = newCount <= MAX_ARBITRATION_COUNT;
|
|
59
|
-
cs03.message = cs03.passed ? "" : `arbitrations count ${newCount} > ${MAX_ARBITRATION_COUNT}`;
|
|
60
|
-
}
|
|
61
|
-
else {
|
|
62
|
-
items.find(i => i.id === "C-S-03").passed = true;
|
|
63
|
-
}
|
|
64
|
-
if (data.rewards && (data.rewards.op === "add" || data.rewards.op === "set")) {
|
|
65
|
-
const currentCount = input.current_rewards_count ?? 0;
|
|
66
|
-
const newCount = data.rewards.op === "set"
|
|
67
|
-
? data.rewards.objects.length
|
|
68
|
-
: currentCount + data.rewards.objects.length;
|
|
69
|
-
const cs04 = items.find(i => i.id === "C-S-04");
|
|
70
|
-
cs04.passed = newCount <= 20;
|
|
71
|
-
cs04.message = cs04.passed ? "" : `rewards count ${newCount} > 20`;
|
|
72
|
-
}
|
|
73
|
-
else {
|
|
74
|
-
items.find(i => i.id === "C-S-04").passed = true;
|
|
75
|
-
}
|
|
76
|
-
if (data.sales && (data.sales.op === "add" || data.sales.op === "set")) {
|
|
77
|
-
let urlOk = true, hashLenOk = true, hashNotEmptyOk = true;
|
|
78
|
-
let urlMsg = "", hashLenMsg = "", hashEmptyMsg = "";
|
|
79
|
-
for (const s of data.sales.sales) {
|
|
80
|
-
if (s.wip && s.wip.length > MAX_WIP_LENGTH) {
|
|
81
|
-
urlOk = false;
|
|
82
|
-
urlMsg = `sale "${s.name}" wip URL length ${s.wip.length} > ${MAX_WIP_LENGTH}`;
|
|
83
|
-
break;
|
|
84
|
-
}
|
|
85
|
-
if (s.wip_hash && s.wip_hash.length > MAX_WIP_HASH_LENGTH) {
|
|
86
|
-
hashLenOk = false;
|
|
87
|
-
hashLenMsg = `sale "${s.name}" wip_hash length ${s.wip_hash.length} > ${MAX_WIP_HASH_LENGTH}`;
|
|
88
|
-
break;
|
|
89
|
-
}
|
|
90
|
-
if (s.wip && !s.wip_hash) {
|
|
91
|
-
hashNotEmptyOk = false;
|
|
92
|
-
hashEmptyMsg = `sale "${s.name}" has wip URL but no wip_hash (tamper risk)`;
|
|
93
|
-
break;
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
const cs05 = items.find(i => i.id === "C-S-05");
|
|
97
|
-
cs05.passed = urlOk;
|
|
98
|
-
cs05.message = urlMsg;
|
|
99
|
-
const cs06 = items.find(i => i.id === "C-S-06");
|
|
100
|
-
cs06.passed = hashLenOk;
|
|
101
|
-
cs06.message = hashLenMsg;
|
|
102
|
-
const cs07 = items.find(i => i.id === "C-S-07");
|
|
103
|
-
cs07.passed = hashNotEmptyOk;
|
|
104
|
-
cs07.message = hashEmptyMsg;
|
|
105
|
-
}
|
|
106
|
-
else {
|
|
107
|
-
items.find(i => i.id === "C-S-05").passed = true;
|
|
108
|
-
items.find(i => i.id === "C-S-06").passed = true;
|
|
109
|
-
items.find(i => i.id === "C-S-07").passed = true;
|
|
110
|
-
}
|
|
111
|
-
if (data.discount) {
|
|
112
|
-
const total = data.discount.count;
|
|
113
|
-
const cs08 = items.find(i => i.id === "C-S-08");
|
|
114
|
-
cs08.passed = total <= MAX_DISCOUNT_TOTAL_COUNT;
|
|
115
|
-
cs08.message = cs08.passed ? "" : `discount total count ${total} > ${MAX_DISCOUNT_TOTAL_COUNT}`;
|
|
116
|
-
const cs09 = items.find(i => i.id === "C-S-09");
|
|
117
|
-
cs09.passed = total <= MAX_DISCOUNT_COUNT_ONCE;
|
|
118
|
-
cs09.message = cs09.passed ? "" : `discount per-call count ${total} > ${MAX_DISCOUNT_COUNT_ONCE}`;
|
|
119
|
-
}
|
|
120
|
-
else {
|
|
121
|
-
items.find(i => i.id === "C-S-08").passed = true;
|
|
122
|
-
items.find(i => i.id === "C-S-09").passed = true;
|
|
123
|
-
}
|
|
124
|
-
if (data.publish) {
|
|
125
|
-
const hasAllocators = input.current_order_allocators_set === true || data.order_allocators !== undefined;
|
|
126
|
-
const cs10 = items.find(i => i.id === "C-S-10");
|
|
127
|
-
cs10.passed = hasAllocators;
|
|
128
|
-
cs10.message = hasAllocators ? "" : "publish requires order_allocators (F-S-18, E_NO_ALLOCATOR)";
|
|
129
|
-
}
|
|
130
|
-
else {
|
|
131
|
-
items.find(i => i.id === "C-S-10").passed = true;
|
|
132
|
-
}
|
|
133
|
-
if (data.publish) {
|
|
134
|
-
const compBalance = input.current_compensation_fund_balance ?? "0";
|
|
135
|
-
const arbCount = input.current_arbitrations_count ?? 0;
|
|
136
|
-
const hasArbFromInput = data.arbitrations && "objects" in data.arbitrations ? data.arbitrations.objects.length : 0;
|
|
137
|
-
const totalArb = arbCount + hasArbFromInput;
|
|
138
|
-
const cs11 = items.find(i => i.id === "C-S-11");
|
|
139
|
-
if (BigInt(compBalance) > 0n && totalArb === 0) {
|
|
140
|
-
cs11.passed = false;
|
|
141
|
-
cs11.message = `compensation_fund ${compBalance} > 0 but no arbitrations (F-S-19)`;
|
|
142
|
-
}
|
|
143
|
-
else {
|
|
144
|
-
cs11.passed = true;
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
else {
|
|
148
|
-
items.find(i => i.id === "C-S-11").passed = true;
|
|
149
|
-
}
|
|
150
|
-
if (isPublished && data.machine !== undefined) {
|
|
151
|
-
const cs12 = items.find(i => i.id === "C-S-12");
|
|
152
|
-
cs12.passed = false;
|
|
153
|
-
cs12.message = "machine is IMMUTABLE post-publish (F-S-20)";
|
|
154
|
-
}
|
|
155
|
-
else {
|
|
156
|
-
items.find(i => i.id === "C-S-12").passed = true;
|
|
157
|
-
}
|
|
158
|
-
if (isPublished && data.arbitrations !== undefined) {
|
|
159
|
-
const cs13 = items.find(i => i.id === "C-S-13");
|
|
160
|
-
cs13.passed = false;
|
|
161
|
-
cs13.message = "arbitrations is IMMUTABLE post-publish (F-S-21)";
|
|
162
|
-
}
|
|
163
|
-
else {
|
|
164
|
-
items.find(i => i.id === "C-S-13").passed = true;
|
|
165
|
-
}
|
|
166
|
-
if (isPublished && data.order_allocators !== undefined) {
|
|
167
|
-
const cs14 = items.find(i => i.id === "C-S-14");
|
|
168
|
-
cs14.passed = false;
|
|
169
|
-
cs14.message = "order_allocators is IMMUTABLE post-publish (F-S-22)";
|
|
170
|
-
}
|
|
171
|
-
else {
|
|
172
|
-
items.find(i => i.id === "C-S-14").passed = true;
|
|
173
|
-
}
|
|
174
|
-
if (data.compensation_fund_withdraw) {
|
|
175
|
-
const paused = input.current_bPaused ?? false;
|
|
176
|
-
const cs15 = items.find(i => i.id === "C-S-15");
|
|
177
|
-
if (!paused) {
|
|
178
|
-
cs15.passed = false;
|
|
179
|
-
cs15.message = "compensation_fund_withdraw requires bPaused=true (F-S-26)";
|
|
180
|
-
}
|
|
181
|
-
else {
|
|
182
|
-
cs15.passed = true;
|
|
183
|
-
cs15.message = "Paused OK — verify lock_duration expired on-chain";
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
else {
|
|
187
|
-
items.find(i => i.id === "C-S-15").passed = true;
|
|
188
|
-
}
|
|
189
|
-
const addresses = [];
|
|
190
|
-
if (data.object)
|
|
191
|
-
addresses.push(data.object);
|
|
192
|
-
if (data.machine)
|
|
193
|
-
addresses.push(data.machine);
|
|
194
|
-
if (data.buy_guard)
|
|
195
|
-
addresses.push(data.buy_guard);
|
|
196
|
-
if (data.arbitrations && "objects" in data.arbitrations)
|
|
197
|
-
addresses.push(...data.arbitrations.objects);
|
|
198
|
-
if (data.repositories && "objects" in data.repositories)
|
|
199
|
-
addresses.push(...data.repositories.objects);
|
|
200
|
-
if (data.rewards && "objects" in data.rewards)
|
|
201
|
-
addresses.push(...data.rewards.objects);
|
|
202
|
-
if (data.builder)
|
|
203
|
-
addresses.push(data.builder);
|
|
204
|
-
if (data.um)
|
|
205
|
-
addresses.push(data.um);
|
|
206
|
-
const cs16 = items.find(i => i.id === "C-S-16");
|
|
207
|
-
if (addresses.length === 0) {
|
|
208
|
-
cs16.passed = true;
|
|
209
|
-
}
|
|
210
|
-
else {
|
|
211
|
-
const invalid = addresses.filter(a => !a.startsWith("0x") || a.length < 40);
|
|
212
|
-
cs16.passed = invalid.length === 0;
|
|
213
|
-
cs16.message = invalid.length === 0 ? "" : `Invalid addresses: ${invalid.slice(0, 3).join(", ")}${invalid.length > 3 ? "..." : ""}`;
|
|
214
|
-
}
|
|
215
|
-
if (data.publish) {
|
|
216
|
-
const cs17 = items.find(i => i.id === "C-S-17");
|
|
217
|
-
cs17.passed = false;
|
|
218
|
-
cs17.message = "Pending user confirmation in Layer 3 (QS1)";
|
|
219
|
-
}
|
|
220
|
-
else {
|
|
221
|
-
items.find(i => i.id === "C-S-17").passed = true;
|
|
222
|
-
}
|
|
223
|
-
if (data.builder) {
|
|
224
|
-
const cs18 = items.find(i => i.id === "C-S-18");
|
|
225
|
-
cs18.passed = false;
|
|
226
|
-
cs18.message = "Pending user confirmation in Layer 3 (QS2)";
|
|
227
|
-
}
|
|
228
|
-
else {
|
|
229
|
-
items.find(i => i.id === "C-S-18").passed = true;
|
|
230
|
-
}
|
|
231
|
-
if (data.publish) {
|
|
232
|
-
const currentArbCount = input.current_arbitrations_count ?? 0;
|
|
233
|
-
const arbFromInput = data.arbitrations && "objects" in data.arbitrations ? data.arbitrations.objects.length : 0;
|
|
234
|
-
const arbCleared = data.arbitrations && data.arbitrations.op === "clear";
|
|
235
|
-
const totalArb = arbCleared ? 0 : currentArbCount + arbFromInput;
|
|
236
|
-
const cs19 = items.find(i => i.id === "C-S-19");
|
|
237
|
-
if (totalArb === 0) {
|
|
238
|
-
cs19.passed = false;
|
|
239
|
-
cs19.message = "Pending user confirmation in Layer 3 (QS11) — arbitrations cannot be added post-publish";
|
|
240
|
-
}
|
|
241
|
-
else {
|
|
242
|
-
cs19.passed = true;
|
|
243
|
-
}
|
|
244
|
-
}
|
|
245
|
-
else {
|
|
246
|
-
items.find(i => i.id === "C-S-19").passed = true;
|
|
247
|
-
}
|
|
248
|
-
const allPassed = items.filter(i => i.id !== "C-S-17" && i.id !== "C-S-18" && i.id !== "C-S-19").every(i => i.passed);
|
|
249
|
-
return { all_passed: allPassed, items };
|
|
250
|
-
}
|
|
251
|
-
function adaptRiskAssessment(input) {
|
|
252
|
-
const ctx = {
|
|
253
|
-
object: input.service_json.object,
|
|
254
|
-
description: input.service_json.description,
|
|
255
|
-
location: input.service_json.location,
|
|
256
|
-
sales: input.service_json.sales,
|
|
257
|
-
repositories: input.service_json.repositories,
|
|
258
|
-
rewards: input.service_json.rewards,
|
|
259
|
-
arbitrations: input.service_json.arbitrations,
|
|
260
|
-
machine: input.service_json.machine,
|
|
261
|
-
discount: input.service_json.discount,
|
|
262
|
-
customer_required: input.service_json.customer_required,
|
|
263
|
-
order_allocators: input.service_json.order_allocators,
|
|
264
|
-
buy_guard: input.service_json.buy_guard,
|
|
265
|
-
compensation_fund_add: input.service_json.compensation_fund_add,
|
|
266
|
-
setting_lock_duration_add: input.service_json.setting_lock_duration_add,
|
|
267
|
-
compensation_fund_receive: input.service_json.compensation_fund_receive,
|
|
268
|
-
owner_receive: input.service_json.owner_receive,
|
|
269
|
-
pause: input.service_json.pause,
|
|
270
|
-
publish: input.service_json.publish,
|
|
271
|
-
um: input.service_json.um,
|
|
272
|
-
order_new: input.service_json.order_new,
|
|
273
|
-
current_bPublished: input.current_bPublished,
|
|
274
|
-
current_bPaused: input.current_bPaused,
|
|
275
|
-
current_compensation_fund_balance: input.current_compensation_fund_balance,
|
|
276
|
-
current_setting_lock_duration: input.current_setting_lock_duration,
|
|
277
|
-
current_arbitrations_count: input.current_arbitrations_count,
|
|
278
|
-
current_rewards_count: input.current_rewards_count,
|
|
279
|
-
current_repositories_count: input.current_repositories_count,
|
|
280
|
-
current_sales_count: input.current_sales_count,
|
|
281
|
-
current_machine_bound: input.current_machine_bound,
|
|
282
|
-
current_order_allocators_set: input.current_order_allocators_set,
|
|
283
|
-
builder: input.service_json.builder,
|
|
284
|
-
target_objects_types: input.target_objects_types,
|
|
285
|
-
};
|
|
286
|
-
return assessServiceRisks(ctx);
|
|
287
|
-
}
|
|
288
|
-
export const SERVICE_CONFIRMATION_QUESTIONS = [
|
|
289
|
-
{
|
|
290
|
-
id: "QS1",
|
|
291
|
-
question: "⚠️ PUBLISH is IRREVERSIBLE — once published, machine/arbitrations/order_allocators become permanently immutable. Do you confirm all configurations are correct and you're ready to publish?",
|
|
292
|
-
requires_explicit_yes: true,
|
|
293
|
-
related_risk_ids: ["R-S-3-01", "R-S-4-01"],
|
|
294
|
-
},
|
|
295
|
-
{
|
|
296
|
-
id: "QS2",
|
|
297
|
-
question: "⚠️ Ownership transfer is IRREVERSIBLE — original owner will lose ALL control over the Service, including compensation_fund and all bindings. Do you confirm the new owner address is correct?",
|
|
298
|
-
requires_explicit_yes: true,
|
|
299
|
-
related_risk_ids: ["R-S-3-04"],
|
|
300
|
-
},
|
|
301
|
-
{
|
|
302
|
-
id: "QS3",
|
|
303
|
-
question: "Are all sales items configured with valid wip_hash (sha256 of the WIP file content)? Missing or incorrect hashes create tampering risks.",
|
|
304
|
-
requires_explicit_yes: true,
|
|
305
|
-
related_risk_ids: ["R-S-2-01"],
|
|
306
|
-
},
|
|
307
|
-
{
|
|
308
|
-
id: "QS4",
|
|
309
|
-
question: "If publishing with compensation_fund > 0, are Arbitration objects configured and their reputations verified? Owners cannot add new Arbitration objects post-publish.",
|
|
310
|
-
requires_explicit_yes: true,
|
|
311
|
-
related_risk_ids: ["R-S-5-02"],
|
|
312
|
-
},
|
|
313
|
-
{
|
|
314
|
-
id: "QS5",
|
|
315
|
-
question: "Is the order_allocators configuration final? It becomes PERMANENTLY immutable after publish — fee splits cannot be adjusted without creating a new Service.",
|
|
316
|
-
requires_explicit_yes: true,
|
|
317
|
-
related_risk_ids: ["R-S-5-03", "R-S-4-03"],
|
|
318
|
-
},
|
|
319
|
-
{
|
|
320
|
-
id: "QS6",
|
|
321
|
-
question: "If binding a Machine, is it published and verified? Machine binding is permanent post-publish — Progress objects will inherit this Machine forever.",
|
|
322
|
-
requires_explicit_yes: true,
|
|
323
|
-
related_risk_ids: ["R-S-5-01"],
|
|
324
|
-
},
|
|
325
|
-
{
|
|
326
|
-
id: "QS7",
|
|
327
|
-
question: "If using buy_guard, is the Guard configuration appropriate for your sale phase (whitelist for pre-sale, null for public sale)? buy_guard remains mutable post-publish.",
|
|
328
|
-
requires_explicit_yes: false,
|
|
329
|
-
related_risk_ids: ["R-S-3-03"],
|
|
330
|
-
},
|
|
331
|
-
{
|
|
332
|
-
id: "QS8",
|
|
333
|
-
question: "For discount operations: are discount counts within limits (<=1000 per call, <=20000 total)? Expired or exhausted discounts cannot be re-issued.",
|
|
334
|
-
requires_explicit_yes: false,
|
|
335
|
-
related_risk_ids: ["R-S-2-04"],
|
|
336
|
-
},
|
|
337
|
-
{
|
|
338
|
-
id: "QS9",
|
|
339
|
-
question: "For order placement: are you aware that stock is deducted at the quote stage and NOT rolled back if later stages fail? Monitor failed transactions and re-add stock manually if needed.",
|
|
340
|
-
requires_explicit_yes: true,
|
|
341
|
-
related_risk_ids: ["R-S-2-03"],
|
|
342
|
-
},
|
|
343
|
-
{
|
|
344
|
-
id: "QS10",
|
|
345
|
-
question: "Have you exported the current Service JSON as a backup before this operation?",
|
|
346
|
-
requires_explicit_yes: false,
|
|
347
|
-
},
|
|
348
|
-
{
|
|
349
|
-
id: "QS11",
|
|
350
|
-
question: "⚠️ Service is about to be published WITHOUT arbitrations.\n\n" +
|
|
351
|
-
"After publishing, arbitrations CANNOT be added (contract restriction, F-S-21).\n" +
|
|
352
|
-
"Dispute resolution will NOT be available for this service.\n\n" +
|
|
353
|
-
"Recommended: Set arbitrations BEFORE publishing:\n" +
|
|
354
|
-
' "arbitrations": {"op": "add", "objects": ["your_arbitration_object"]}\n\n' +
|
|
355
|
-
"Continue with publish anyway?",
|
|
356
|
-
requires_explicit_yes: true,
|
|
357
|
-
},
|
|
358
|
-
];
|
|
359
|
-
function processUserConfirmation(input, assessment) {
|
|
360
|
-
const questions = [...SERVICE_CONFIRMATION_QUESTIONS];
|
|
361
|
-
const data = input.service_json;
|
|
362
|
-
const irrelevant = [];
|
|
363
|
-
if (!data.publish)
|
|
364
|
-
irrelevant.push("QS1");
|
|
365
|
-
if (!data.builder)
|
|
366
|
-
irrelevant.push("QS2");
|
|
367
|
-
if (!data.sales || data.sales.op === "clear" || data.sales.op === "remove")
|
|
368
|
-
irrelevant.push("QS3");
|
|
369
|
-
if (!data.publish && !(data.compensation_fund_add && BigInt(String(data.compensation_fund_add.balance)) > 0n))
|
|
370
|
-
irrelevant.push("QS4");
|
|
371
|
-
if (!data.publish && !data.order_allocators)
|
|
372
|
-
irrelevant.push("QS5");
|
|
373
|
-
if (!data.machine)
|
|
374
|
-
irrelevant.push("QS6");
|
|
375
|
-
if (data.buy_guard === undefined)
|
|
376
|
-
irrelevant.push("QS7");
|
|
377
|
-
if (!data.discount)
|
|
378
|
-
irrelevant.push("QS8");
|
|
379
|
-
if (!data.order_new)
|
|
380
|
-
irrelevant.push("QS9");
|
|
381
|
-
if (!data.publish) {
|
|
382
|
-
irrelevant.push("QS11");
|
|
383
|
-
}
|
|
384
|
-
else {
|
|
385
|
-
const currentArbCount = input.current_arbitrations_count ?? 0;
|
|
386
|
-
const arbFromInput = data.arbitrations && "objects" in data.arbitrations ? data.arbitrations.objects.length : 0;
|
|
387
|
-
const arbCleared = data.arbitrations && data.arbitrations.op === "clear";
|
|
388
|
-
const totalArb = arbCleared ? 0 : currentArbCount + arbFromInput;
|
|
389
|
-
if (totalArb > 0) {
|
|
390
|
-
irrelevant.push("QS11");
|
|
391
|
-
}
|
|
392
|
-
}
|
|
393
|
-
const filtered = questions.filter(q => !irrelevant.includes(q.id));
|
|
394
|
-
if (input.skip_user_confirmation) {
|
|
395
|
-
return {
|
|
396
|
-
questions_asked: filtered,
|
|
397
|
-
responses: filtered.map(q => ({ question_id: q.id, response: "yes" })),
|
|
398
|
-
all_confirmed: true,
|
|
399
|
-
};
|
|
400
|
-
}
|
|
401
|
-
return {
|
|
402
|
-
questions_asked: filtered,
|
|
403
|
-
responses: [],
|
|
404
|
-
all_confirmed: false,
|
|
405
|
-
};
|
|
406
|
-
}
|
|
407
|
-
function verifyEnvironment(input) {
|
|
408
|
-
const checks = [];
|
|
409
|
-
const data = input.service_json;
|
|
410
|
-
if (data.object) {
|
|
411
|
-
checks.push({
|
|
412
|
-
name: "object_exists",
|
|
413
|
-
passed: true,
|
|
414
|
-
message: `Service object ${data.object} assumed to exist`,
|
|
415
|
-
});
|
|
416
|
-
}
|
|
417
|
-
if (data.publish) {
|
|
418
|
-
checks.push({
|
|
419
|
-
name: "signer_has_publish_permission",
|
|
420
|
-
passed: true,
|
|
421
|
-
message: "Signer must hold SERVICE_PUBLISH (311) permission",
|
|
422
|
-
});
|
|
423
|
-
}
|
|
424
|
-
if (data.builder) {
|
|
425
|
-
checks.push({
|
|
426
|
-
name: "signer_is_owner",
|
|
427
|
-
passed: true,
|
|
428
|
-
message: "Signer must be Service owner for transfer (builder)",
|
|
429
|
-
});
|
|
430
|
-
}
|
|
431
|
-
if (data.pause !== undefined) {
|
|
432
|
-
checks.push({
|
|
433
|
-
name: "signer_has_pause_permission",
|
|
434
|
-
passed: true,
|
|
435
|
-
message: "Signer must hold SERVICE_PAUSE (310) permission",
|
|
436
|
-
});
|
|
437
|
-
}
|
|
438
|
-
if (data.publish) {
|
|
439
|
-
if (!input.current_order_allocators_set && data.order_allocators === undefined) {
|
|
440
|
-
checks.push({
|
|
441
|
-
name: "order_allocators_set",
|
|
442
|
-
passed: false,
|
|
443
|
-
message: "Publish blocked: order_allocators not set (E_NO_ALLOCATOR)",
|
|
444
|
-
});
|
|
445
|
-
}
|
|
446
|
-
const compBalance = input.current_compensation_fund_balance ?? "0";
|
|
447
|
-
const arbCount = input.current_arbitrations_count ?? 0;
|
|
448
|
-
const arbFromInput = data.arbitrations && "objects" in data.arbitrations ? data.arbitrations.objects.length : 0;
|
|
449
|
-
if (BigInt(compBalance) > 0n && (arbCount + arbFromInput) === 0) {
|
|
450
|
-
checks.push({
|
|
451
|
-
name: "arbitrations_for_compensation_fund",
|
|
452
|
-
passed: false,
|
|
453
|
-
message: "Publish blocked: compensation_fund > 0 but no arbitrations (E_ARBITRATION_NOT_SET_WITH_COMPENSATION_FUND)",
|
|
454
|
-
});
|
|
455
|
-
}
|
|
456
|
-
if (data.machine) {
|
|
457
|
-
if (input.current_machine_node_count !== undefined && input.current_machine_node_count === 0) {
|
|
458
|
-
checks.push({
|
|
459
|
-
name: "machine_has_nodes",
|
|
460
|
-
passed: false,
|
|
461
|
-
message: "Publish blocked: bound Machine has 0 nodes — Progress will be permanently stuck",
|
|
462
|
-
});
|
|
463
|
-
}
|
|
464
|
-
if (input.current_machine_initial_forward_ok === false) {
|
|
465
|
-
checks.push({
|
|
466
|
-
name: "machine_initial_forward",
|
|
467
|
-
passed: false,
|
|
468
|
-
message: "Publish blocked: bound Machine's initial node (prev_node='') has no forward — Progress cannot advance from '' (FIX-002 violated)",
|
|
469
|
-
});
|
|
470
|
-
}
|
|
471
|
-
if (input.current_machine_bPublished === false) {
|
|
472
|
-
checks.push({
|
|
473
|
-
name: "machine_not_published",
|
|
474
|
-
passed: true,
|
|
475
|
-
level: "warning",
|
|
476
|
-
message: "Warning: bound Machine is not yet published. Orders cannot advance until the Machine is published. Publish the Machine after this Service to enable order workflow.",
|
|
477
|
-
});
|
|
478
|
-
}
|
|
479
|
-
}
|
|
480
|
-
const arbCountForPerm = input.current_arbitrations_count ?? 0;
|
|
481
|
-
const arbFromInputForPerm = data.arbitrations && "objects" in data.arbitrations ? data.arbitrations.objects.length : 0;
|
|
482
|
-
if ((arbCountForPerm + arbFromInputForPerm) > 0 && input.current_arbitrators_authorized === false) {
|
|
483
|
-
checks.push({
|
|
484
|
-
name: "arbitrators_permission_authorized",
|
|
485
|
-
passed: true,
|
|
486
|
-
level: "info",
|
|
487
|
-
message: "Info: ensure arbitrators have been granted the required permission index in the Permission object. Without authorization, dispute resolution Guards will reject arbitrator signatures (Permission denied).",
|
|
488
|
-
});
|
|
489
|
-
}
|
|
490
|
-
}
|
|
491
|
-
if (input.current_bPublished) {
|
|
492
|
-
if (data.machine !== undefined) {
|
|
493
|
-
checks.push({
|
|
494
|
-
name: "machine_immutable_post_publish",
|
|
495
|
-
passed: false,
|
|
496
|
-
message: "machine cannot be modified post-publish (F-S-20)",
|
|
497
|
-
});
|
|
498
|
-
}
|
|
499
|
-
if (data.arbitrations !== undefined) {
|
|
500
|
-
checks.push({
|
|
501
|
-
name: "arbitrations_immutable_post_publish",
|
|
502
|
-
passed: false,
|
|
503
|
-
message: "arbitrations cannot be modified post-publish (F-S-21)",
|
|
504
|
-
});
|
|
505
|
-
}
|
|
506
|
-
if (data.order_allocators !== undefined) {
|
|
507
|
-
checks.push({
|
|
508
|
-
name: "order_allocators_immutable_post_publish",
|
|
509
|
-
passed: false,
|
|
510
|
-
message: "order_allocators cannot be modified post-publish (F-S-22)",
|
|
511
|
-
});
|
|
512
|
-
}
|
|
513
|
-
}
|
|
514
|
-
if (data.compensation_fund_withdraw && !input.current_bPaused) {
|
|
515
|
-
checks.push({
|
|
516
|
-
name: "compensation_fund_withdraw_requires_paused",
|
|
517
|
-
passed: false,
|
|
518
|
-
message: "compensation_fund_withdraw requires bPaused=true (F-S-26)",
|
|
519
|
-
});
|
|
520
|
-
}
|
|
521
|
-
const allPassed = checks.every(c => c.passed);
|
|
522
|
-
const warnings_count = checks.filter(c => c.level === "warning").length;
|
|
523
|
-
const infos_count = checks.filter(c => c.level === "info").length;
|
|
524
|
-
return { passed: allPassed, checks, warnings_count, infos_count };
|
|
525
|
-
}
|
|
526
|
-
export const SERVICE_CONFIRM_VERSION = "1.0.0";
|
|
527
|
-
export function runServiceConfirmGate(input) {
|
|
528
|
-
const layersPassed = [];
|
|
529
|
-
const layersFailed = [];
|
|
530
|
-
const checklist = runStaticChecklist(input);
|
|
531
|
-
if (!checklist.all_passed) {
|
|
532
|
-
layersFailed.push("L1_checklist");
|
|
533
|
-
return {
|
|
534
|
-
status: "blocked_checklist",
|
|
535
|
-
checklist_result: checklist,
|
|
536
|
-
confirmation_text: generateConfirmationText(input, checklist),
|
|
537
|
-
block_reason: `Checklist failed: ${checklist.items.filter(i => !i.passed && i.id !== "C-S-17" && i.id !== "C-S-18" && i.id !== "C-S-19").map(i => i.id).join(", ")}`,
|
|
538
|
-
decision_record: {
|
|
539
|
-
timestamp: new Date().toISOString(),
|
|
540
|
-
gate_version: SERVICE_CONFIRM_VERSION,
|
|
541
|
-
final_status: "blocked_checklist",
|
|
542
|
-
layers_passed: layersPassed,
|
|
543
|
-
layers_failed: layersFailed,
|
|
544
|
-
},
|
|
545
|
-
};
|
|
546
|
-
}
|
|
547
|
-
layersPassed.push("L1_checklist");
|
|
548
|
-
const assessment = adaptRiskAssessment(input);
|
|
549
|
-
const hasCritical = assessment.risks.some(r => r.level === "CRITICAL");
|
|
550
|
-
if (hasCritical) {
|
|
551
|
-
layersFailed.push("L2_risk");
|
|
552
|
-
return {
|
|
553
|
-
status: "blocked_risk",
|
|
554
|
-
checklist_result: checklist,
|
|
555
|
-
risk_result: assessment,
|
|
556
|
-
confirmation_text: generateConfirmationText(input, checklist, assessment),
|
|
557
|
-
block_reason: `CRITICAL risks: ${assessment.risks.filter(r => r.level === "CRITICAL").map(r => r.id).join(", ")}`,
|
|
558
|
-
decision_record: {
|
|
559
|
-
timestamp: new Date().toISOString(),
|
|
560
|
-
gate_version: SERVICE_CONFIRM_VERSION,
|
|
561
|
-
final_status: "blocked_risk",
|
|
562
|
-
layers_passed: layersPassed,
|
|
563
|
-
layers_failed: layersFailed,
|
|
564
|
-
},
|
|
565
|
-
};
|
|
566
|
-
}
|
|
567
|
-
layersPassed.push("L2_risk");
|
|
568
|
-
const userConf = processUserConfirmation(input, assessment);
|
|
569
|
-
if (!userConf.all_confirmed) {
|
|
570
|
-
if (input.service_json.publish) {
|
|
571
|
-
const cs17 = checklist.items.find(i => i.id === "C-S-17");
|
|
572
|
-
if (cs17) {
|
|
573
|
-
const qs1 = userConf.responses.find(r => r.question_id === "QS1");
|
|
574
|
-
cs17.passed = qs1?.response === "yes";
|
|
575
|
-
cs17.message = cs17.passed ? "" : "Publish not confirmed by user (QS1)";
|
|
576
|
-
}
|
|
577
|
-
}
|
|
578
|
-
if (input.service_json.builder) {
|
|
579
|
-
const cs18 = checklist.items.find(i => i.id === "C-S-18");
|
|
580
|
-
if (cs18) {
|
|
581
|
-
const qs2 = userConf.responses.find(r => r.question_id === "QS2");
|
|
582
|
-
cs18.passed = qs2?.response === "yes";
|
|
583
|
-
cs18.message = cs18.passed ? "" : "Transfer not confirmed by user (QS2)";
|
|
584
|
-
}
|
|
585
|
-
}
|
|
586
|
-
const cs19 = checklist.items.find(i => i.id === "C-S-19");
|
|
587
|
-
if (cs19 && !cs19.passed) {
|
|
588
|
-
const qs11Asked = userConf.questions_asked.some(q => q.id === "QS11");
|
|
589
|
-
if (qs11Asked) {
|
|
590
|
-
const qs11 = userConf.responses.find(r => r.question_id === "QS11");
|
|
591
|
-
cs19.passed = qs11?.response === "yes";
|
|
592
|
-
cs19.message = cs19.passed ? "" : "User declined publish without arbitrations (QS11)";
|
|
593
|
-
}
|
|
594
|
-
}
|
|
595
|
-
if (input.service_json.publish) {
|
|
596
|
-
const cs17 = checklist.items.find(i => i.id === "C-S-17");
|
|
597
|
-
if (cs17 && !cs17.passed) {
|
|
598
|
-
layersFailed.push("L3_user");
|
|
599
|
-
return {
|
|
600
|
-
status: "blocked_user",
|
|
601
|
-
checklist_result: checklist,
|
|
602
|
-
risk_result: assessment,
|
|
603
|
-
user_confirmation: userConf,
|
|
604
|
-
confirmation_text: generateConfirmationText(input, checklist, assessment),
|
|
605
|
-
block_reason: "User did not confirm publish (QS1)",
|
|
606
|
-
decision_record: {
|
|
607
|
-
timestamp: new Date().toISOString(),
|
|
608
|
-
gate_version: SERVICE_CONFIRM_VERSION,
|
|
609
|
-
final_status: "blocked_user",
|
|
610
|
-
layers_passed: layersPassed,
|
|
611
|
-
layers_failed: layersFailed,
|
|
612
|
-
},
|
|
613
|
-
};
|
|
614
|
-
}
|
|
615
|
-
}
|
|
616
|
-
if (input.service_json.builder) {
|
|
617
|
-
const cs18 = checklist.items.find(i => i.id === "C-S-18");
|
|
618
|
-
if (cs18 && !cs18.passed) {
|
|
619
|
-
layersFailed.push("L3_user");
|
|
620
|
-
return {
|
|
621
|
-
status: "blocked_user",
|
|
622
|
-
checklist_result: checklist,
|
|
623
|
-
risk_result: assessment,
|
|
624
|
-
user_confirmation: userConf,
|
|
625
|
-
confirmation_text: generateConfirmationText(input, checklist, assessment),
|
|
626
|
-
block_reason: "User did not confirm ownership transfer (QS2)",
|
|
627
|
-
decision_record: {
|
|
628
|
-
timestamp: new Date().toISOString(),
|
|
629
|
-
gate_version: SERVICE_CONFIRM_VERSION,
|
|
630
|
-
final_status: "blocked_user",
|
|
631
|
-
layers_passed: layersPassed,
|
|
632
|
-
layers_failed: layersFailed,
|
|
633
|
-
},
|
|
634
|
-
};
|
|
635
|
-
}
|
|
636
|
-
}
|
|
637
|
-
if (cs19 && !cs19.passed) {
|
|
638
|
-
const qs11Asked = userConf.questions_asked.some(q => q.id === "QS11");
|
|
639
|
-
if (qs11Asked) {
|
|
640
|
-
layersFailed.push("L3_user");
|
|
641
|
-
return {
|
|
642
|
-
status: "blocked_user",
|
|
643
|
-
checklist_result: checklist,
|
|
644
|
-
risk_result: assessment,
|
|
645
|
-
user_confirmation: userConf,
|
|
646
|
-
confirmation_text: generateConfirmationText(input, checklist, assessment),
|
|
647
|
-
block_reason: "User did not confirm publish without arbitrations (QS11) — set arbitrations or explicitly confirm",
|
|
648
|
-
decision_record: {
|
|
649
|
-
timestamp: new Date().toISOString(),
|
|
650
|
-
gate_version: SERVICE_CONFIRM_VERSION,
|
|
651
|
-
final_status: "blocked_user",
|
|
652
|
-
layers_passed: layersPassed,
|
|
653
|
-
layers_failed: layersFailed,
|
|
654
|
-
},
|
|
655
|
-
};
|
|
656
|
-
}
|
|
657
|
-
}
|
|
658
|
-
}
|
|
659
|
-
layersPassed.push("L3_user");
|
|
660
|
-
let envResult;
|
|
661
|
-
if (input.skip_environment_check) {
|
|
662
|
-
layersPassed.push("L4_environment");
|
|
663
|
-
}
|
|
664
|
-
else {
|
|
665
|
-
envResult = verifyEnvironment(input);
|
|
666
|
-
if (!envResult.passed) {
|
|
667
|
-
layersFailed.push("L4_environment");
|
|
668
|
-
return {
|
|
669
|
-
status: "blocked_environment",
|
|
670
|
-
checklist_result: checklist,
|
|
671
|
-
risk_result: assessment,
|
|
672
|
-
user_confirmation: userConf,
|
|
673
|
-
environment_result: envResult,
|
|
674
|
-
confirmation_text: generateConfirmationText(input, checklist, assessment),
|
|
675
|
-
block_reason: `Environment check failed: ${envResult.checks.filter(c => !c.passed).map(c => c.name).join(", ")}`,
|
|
676
|
-
decision_record: {
|
|
677
|
-
timestamp: new Date().toISOString(),
|
|
678
|
-
gate_version: SERVICE_CONFIRM_VERSION,
|
|
679
|
-
final_status: "blocked_environment",
|
|
680
|
-
layers_passed: layersPassed,
|
|
681
|
-
layers_failed: layersFailed,
|
|
682
|
-
},
|
|
683
|
-
};
|
|
684
|
-
}
|
|
685
|
-
layersPassed.push("L4_environment");
|
|
686
|
-
}
|
|
687
|
-
return {
|
|
688
|
-
status: "approved",
|
|
689
|
-
checklist_result: checklist,
|
|
690
|
-
risk_result: assessment,
|
|
691
|
-
user_confirmation: userConf,
|
|
692
|
-
environment_result: envResult,
|
|
693
|
-
confirmation_text: generateConfirmationText(input, checklist, assessment),
|
|
694
|
-
decision_record: {
|
|
695
|
-
timestamp: new Date().toISOString(),
|
|
696
|
-
gate_version: SERVICE_CONFIRM_VERSION,
|
|
697
|
-
final_status: "approved",
|
|
698
|
-
layers_passed: layersPassed,
|
|
699
|
-
layers_failed: layersFailed,
|
|
700
|
-
},
|
|
701
|
-
};
|
|
702
|
-
}
|
|
703
|
-
function generateConfirmationText(input, checklist, assessment) {
|
|
704
|
-
const lines = [];
|
|
705
|
-
const data = input.service_json;
|
|
706
|
-
lines.push("═══ Service Confirmation ═══");
|
|
707
|
-
lines.push("");
|
|
708
|
-
if (data.object) {
|
|
709
|
-
lines.push(`Service: ${data.object}`);
|
|
710
|
-
}
|
|
711
|
-
else {
|
|
712
|
-
lines.push("Service: NEW (to be created)");
|
|
713
|
-
}
|
|
714
|
-
if (data.description)
|
|
715
|
-
lines.push(`Description: ${data.description}`);
|
|
716
|
-
if (input.current_bPublished !== undefined)
|
|
717
|
-
lines.push(`Currently published: ${input.current_bPublished}`);
|
|
718
|
-
if (input.current_bPaused !== undefined)
|
|
719
|
-
lines.push(`Currently paused: ${input.current_bPaused}`);
|
|
720
|
-
lines.push("");
|
|
721
|
-
lines.push("─ Checklist ──────────────────");
|
|
722
|
-
for (const item of checklist.items) {
|
|
723
|
-
const mark = item.passed ? "✓" : "✗";
|
|
724
|
-
lines.push(` ${mark} ${item.id}: ${item.description}${item.message ? " — " + item.message : ""}`);
|
|
725
|
-
}
|
|
726
|
-
lines.push("");
|
|
727
|
-
if (assessment) {
|
|
728
|
-
lines.push("─ Risk Assessment ──────────────────");
|
|
729
|
-
lines.push(`Overall: ${assessment.overall_risk}`);
|
|
730
|
-
lines.push(`Detected: ${assessment.risks.length} risk(s)`);
|
|
731
|
-
for (const r of assessment.risks.slice(0, 10)) {
|
|
732
|
-
lines.push(` [${r.level}] ${r.id}: ${r.title}`);
|
|
733
|
-
}
|
|
734
|
-
if (assessment.risks.length > 10) {
|
|
735
|
-
lines.push(` ... and ${assessment.risks.length - 10} more`);
|
|
736
|
-
}
|
|
737
|
-
lines.push("");
|
|
738
|
-
}
|
|
739
|
-
lines.push("─ Operations ──────────────────");
|
|
740
|
-
if (data.sales)
|
|
741
|
-
lines.push(`- Sales ${data.sales.op}`);
|
|
742
|
-
if (data.machine !== undefined)
|
|
743
|
-
lines.push(`- Machine: ${data.machine ?? "(unbind)"} ${input.current_bPublished ? "[BLOCKED post-publish]" : ""}`);
|
|
744
|
-
if (data.buy_guard !== undefined)
|
|
745
|
-
lines.push(`- Buy Guard: ${data.buy_guard ?? "(clear)"}`);
|
|
746
|
-
if (data.arbitrations)
|
|
747
|
-
lines.push(`- Arbitrations ${data.arbitrations.op}`);
|
|
748
|
-
if (data.repositories)
|
|
749
|
-
lines.push(`- Repositories ${data.repositories.op}`);
|
|
750
|
-
if (data.rewards)
|
|
751
|
-
lines.push(`- Rewards ${data.rewards.op}`);
|
|
752
|
-
if (data.order_allocators !== undefined)
|
|
753
|
-
lines.push(`- Order Allocators: ${data.order_allocators ? "(set)" : "(clear)"}`);
|
|
754
|
-
if (data.discount)
|
|
755
|
-
lines.push(`- Discount: ${data.discount.name} (${data.discount.count} coupons)`);
|
|
756
|
-
if (data.pause !== undefined)
|
|
757
|
-
lines.push(`- Pause: ${data.pause}`);
|
|
758
|
-
if (data.publish)
|
|
759
|
-
lines.push(`- ⚠️ PUBLISH (IRREVERSIBLE)`);
|
|
760
|
-
if (data.compensation_fund_add)
|
|
761
|
-
lines.push(`- Compensation fund deposit: ${data.compensation_fund_add.balance}`);
|
|
762
|
-
if (data.compensation_fund_withdraw)
|
|
763
|
-
lines.push(`- ⚠️ Compensation fund withdraw (requires paused + lock expired)`);
|
|
764
|
-
if (data.setting_lock_duration_add !== undefined)
|
|
765
|
-
lines.push(`- Setting lock +${data.setting_lock_duration_add}ms`);
|
|
766
|
-
if (data.order_new)
|
|
767
|
-
lines.push(`- ⚠️ ORDER NEW (8-stage flow, stock deducted at quote)`);
|
|
768
|
-
if (data.builder)
|
|
769
|
-
lines.push(`- ⚠️ TRANSFER to: ${data.builder} (IRREVERSIBLE)`);
|
|
770
|
-
if (data.um !== undefined)
|
|
771
|
-
lines.push(`- UM: ${data.um ?? "(revoke)"}`);
|
|
772
|
-
lines.push("");
|
|
773
|
-
return lines.join("\n");
|
|
774
|
-
}
|
|
775
|
-
export function progressiveServiceCheck(input) {
|
|
776
|
-
const checklist = runStaticChecklist(input);
|
|
777
|
-
if (!checklist.all_passed) {
|
|
778
|
-
return {
|
|
779
|
-
stage: "checklist",
|
|
780
|
-
status: "fail",
|
|
781
|
-
message: `Checklist failed: ${checklist.items.filter(i => !i.passed && i.id !== "C-S-17" && i.id !== "C-S-18" && i.id !== "C-S-19").map(i => i.id).join(", ")}`,
|
|
782
|
-
next_action: "Fix failing checklist items",
|
|
783
|
-
};
|
|
784
|
-
}
|
|
785
|
-
const assessment = adaptRiskAssessment(input);
|
|
786
|
-
if (assessment.risks.some(r => r.level === "CRITICAL")) {
|
|
787
|
-
return {
|
|
788
|
-
stage: "risk",
|
|
789
|
-
status: "fail",
|
|
790
|
-
message: `CRITICAL risks: ${assessment.risks.filter(r => r.level === "CRITICAL").map(r => r.id).join(", ")}`,
|
|
791
|
-
next_action: "Resolve CRITICAL risks before proceeding",
|
|
792
|
-
};
|
|
793
|
-
}
|
|
794
|
-
if (assessment.needs_human_review) {
|
|
795
|
-
return {
|
|
796
|
-
stage: "confirmation",
|
|
797
|
-
status: "pending",
|
|
798
|
-
message: "Human review required for HIGH risks",
|
|
799
|
-
next_action: "Confirm risk acceptance via user questions",
|
|
800
|
-
};
|
|
801
|
-
}
|
|
802
|
-
return {
|
|
803
|
-
stage: "complete",
|
|
804
|
-
status: "pass",
|
|
805
|
-
message: "All checks passed",
|
|
806
|
-
};
|
|
807
|
-
}
|
|
1
|
+
import{MAX_SALE_COUNT,MAX_REPOSITORY_COUNT,MAX_ARBITRATION_COUNT,MAX_DISCOUNT_COUNT_ONCE,MAX_DISCOUNT_TOTAL_COUNT,MAX_WIP_LENGTH,MAX_WIP_HASH_LENGTH}from'@wowok/wowok';import{assessServiceRisks}from'./service-risk.js';export const SERVICE_PUBLISH_CHECKLIST=[{'id':'C-S-01','description':'Sales\x20count\x20<=\x20MAX_SALE_COUNT\x20(50)','passed':![],'message':''},{'id':'C-S-02','description':'Repositories\x20count\x20<=\x20MAX_REPOSITORY_COUNT\x20(100)','passed':![],'message':''},{'id':'C-S-03','description':'Arbitrations\x20count\x20<=\x20MAX_ARBITRATION_COUNT\x20(20)','passed':![],'message':''},{'id':'C-S-04','description':'Rewards\x20count\x20<=\x20MAX_REWARD_COUNT\x20(20)','passed':![],'message':''},{'id':'C-S-05','description':'WIP\x20URL\x20length\x20<=\x20MAX_WIP_LENGTH\x20(1024)\x20for\x20each\x20sale','passed':![],'message':''},{'id':'C-S-06','description':'WIP\x20hash\x20length\x20<=\x20MAX_WIP_HASH_LENGTH\x20(64)\x20—\x20sha256\x20hex','passed':![],'message':''},{'id':'C-S-07','description':'WIP\x20hash\x20NOT\x20empty\x20when\x20wip\x20URL\x20is\x20set\x20(tamper\x20protection)','passed':![],'message':''},{'id':'C-S-08','description':'Discount\x20count\x20<=\x20MAX_DISCOUNT_TOTAL_COUNT\x20(20000)','passed':![],'message':''},{'id':'C-S-09','description':'Discount\x20per-call\x20<=\x20MAX_DISCOUNT_COUNT_ONCE\x20(1000)','passed':![],'message':''},{'id':'C-S-10','description':'Publish:\x20order_allocators\x20MUST\x20be\x20set\x20(F-S-18,\x20E_NO_ALLOCATOR)','passed':![],'message':''},{'id':'C-S-11','description':'Publish:\x20if\x20compensation_fund\x20>\x200,\x20arbitrations\x20non-empty\x20(F-S-19)','passed':![],'message':''},{'id':'C-S-12','description':'Post-publish:\x20machine\x20modification\x20BLOCKED\x20(F-S-20)','passed':![],'message':''},{'id':'C-S-13','description':'Post-publish:\x20arbitrations\x20modification\x20BLOCKED\x20(F-S-21)','passed':![],'message':''},{'id':'C-S-14','description':'Post-publish:\x20order_allocators\x20modification\x20BLOCKED\x20(F-S-22)','passed':![],'message':''},{'id':'C-S-15','description':'compensation_fund_withdraw\x20requires\x20bPaused=true\x20+\x20lock_duration\x20expired\x20(F-S-25,\x20F-S-26)','passed':![],'message':''},{'id':'C-S-16','description':'Address\x20fields\x20valid\x20(0x\x20prefix,\x20length\x20>=\x2040)','passed':![],'message':''},{'id':'C-S-17','description':'Publish\x20operation\x20double-confirmed\x20(bPublished\x20irreversible)','passed':![],'message':''},{'id':'C-S-18','description':'Ownership\x20transfer\x20double-confirmed\x20(IRREVERSIBLE)','passed':![],'message':''},{'id':'C-S-19','description':'Publish:\x20arbitrations\x20strongly\x20recommended\x20(cannot\x20add\x20post-publish,\x20F-S-21)','passed':![],'message':''}];function runStaticChecklist(a){const b=SERVICE_PUBLISH_CHECKLIST['map'](h=>({...h})),c=a['service_json'],d=a['current_bPublished']??![];if(c['sales']&&(c['sales']['op']==='add'||c['sales']['op']==='set')){const h=a['current_sales_count']??0x0,i=c['sales']['op']==='set'?c['sales']['sales']['length']:h+c['sales']['sales']['length'],j=b['find'](k=>k['id']==='C-S-01');j['passed']=i<=MAX_SALE_COUNT,j['message']=j['passed']?'':'sales\x20count\x20'+i+'\x20>\x20'+MAX_SALE_COUNT;}else b['find'](k=>k['id']==='C-S-01')['passed']=!![];if(c['repositories']&&(c['repositories']['op']==='add'||c['repositories']['op']==='set')){const k=a['current_repositories_count']??0x0,l=c['repositories']['op']==='set'?c['repositories']['objects']['length']:k+c['repositories']['objects']['length'],m=b['find'](n=>n['id']==='C-S-02');m['passed']=l<=MAX_REPOSITORY_COUNT,m['message']=m['passed']?'':'repositories\x20count\x20'+l+'\x20>\x20'+MAX_REPOSITORY_COUNT;}else b['find'](n=>n['id']==='C-S-02')['passed']=!![];if(c['arbitrations']&&(c['arbitrations']['op']==='add'||c['arbitrations']['op']==='set')){const n=a['current_arbitrations_count']??0x0,o=c['arbitrations']['op']==='set'?c['arbitrations']['objects']['length']:n+c['arbitrations']['objects']['length'],p=b['find'](q=>q['id']==='C-S-03');p['passed']=o<=MAX_ARBITRATION_COUNT,p['message']=p['passed']?'':'arbitrations\x20count\x20'+o+'\x20>\x20'+MAX_ARBITRATION_COUNT;}else b['find'](q=>q['id']==='C-S-03')['passed']=!![];if(c['rewards']&&(c['rewards']['op']==='add'||c['rewards']['op']==='set')){const q=a['current_rewards_count']??0x0,r=c['rewards']['op']==='set'?c['rewards']['objects']['length']:q+c['rewards']['objects']['length'],t=b['find'](u=>u['id']==='C-S-04');t['passed']=r<=0x14,t['message']=t['passed']?'':'rewards\x20count\x20'+r+'\x20>\x2020';}else b['find'](u=>u['id']==='C-S-04')['passed']=!![];if(c['sales']&&(c['sales']['op']==='add'||c['sales']['op']==='set')){let u=!![],v=!![],w=!![],x='',y='',z='';for(const D of c['sales']['sales']){if(D['wip']&&D['wip']['length']>MAX_WIP_LENGTH){u=![],x='sale\x20\x22'+D['name']+'\x22\x20wip\x20URL\x20length\x20'+D['wip']['length']+'\x20>\x20'+MAX_WIP_LENGTH;break;}if(D['wip_hash']&&D['wip_hash']['length']>MAX_WIP_HASH_LENGTH){v=![],y='sale\x20\x22'+D['name']+'\x22\x20wip_hash\x20length\x20'+D['wip_hash']['length']+'\x20>\x20'+MAX_WIP_HASH_LENGTH;break;}if(D['wip']&&!D['wip_hash']){w=![],z='sale\x20\x22'+D['name']+'\x22\x20has\x20wip\x20URL\x20but\x20no\x20wip_hash\x20(tamper\x20risk)';break;}}const A=b['find'](E=>E['id']==='C-S-05');A['passed']=u,A['message']=x;const B=b['find'](E=>E['id']==='C-S-06');B['passed']=v,B['message']=y;const C=b['find'](E=>E['id']==='C-S-07');C['passed']=w,C['message']=z;}else b['find'](E=>E['id']==='C-S-05')['passed']=!![],b['find'](E=>E['id']==='C-S-06')['passed']=!![],b['find'](E=>E['id']==='C-S-07')['passed']=!![];if(c['discount']){const E=c['discount']['count'],F=b['find'](H=>H['id']==='C-S-08');F['passed']=E<=MAX_DISCOUNT_TOTAL_COUNT,F['message']=F['passed']?'':'discount\x20total\x20count\x20'+E+'\x20>\x20'+MAX_DISCOUNT_TOTAL_COUNT;const G=b['find'](H=>H['id']==='C-S-09');G['passed']=E<=MAX_DISCOUNT_COUNT_ONCE,G['message']=G['passed']?'':'discount\x20per-call\x20count\x20'+E+'\x20>\x20'+MAX_DISCOUNT_COUNT_ONCE;}else b['find'](H=>H['id']==='C-S-08')['passed']=!![],b['find'](H=>H['id']==='C-S-09')['passed']=!![];if(c['publish']){const H=a['current_order_allocators_set']===!![]||c['order_allocators']!==undefined,I=b['find'](J=>J['id']==='C-S-10');I['passed']=H,I['message']=H?'':'publish\x20requires\x20order_allocators\x20(F-S-18,\x20E_NO_ALLOCATOR)';}else b['find'](J=>J['id']==='C-S-10')['passed']=!![];if(c['publish']){const J=a['current_compensation_fund_balance']??'0',K=a['current_arbitrations_count']??0x0,L=c['arbitrations']&&'objects'in c['arbitrations']?c['arbitrations']['objects']['length']:0x0,M=K+L,N=b['find'](O=>O['id']==='C-S-11');BigInt(J)>0x0n&&M===0x0?(N['passed']=![],N['message']='compensation_fund\x20'+J+'\x20>\x200\x20but\x20no\x20arbitrations\x20(F-S-19)'):N['passed']=!![];}else b['find'](O=>O['id']==='C-S-11')['passed']=!![];if(d&&c['machine']!==undefined){const O=b['find'](P=>P['id']==='C-S-12');O['passed']=![],O['message']='machine\x20is\x20IMMUTABLE\x20post-publish\x20(F-S-20)';}else b['find'](P=>P['id']==='C-S-12')['passed']=!![];if(d&&c['arbitrations']!==undefined){const P=b['find'](Q=>Q['id']==='C-S-13');P['passed']=![],P['message']='arbitrations\x20is\x20IMMUTABLE\x20post-publish\x20(F-S-21)';}else b['find'](Q=>Q['id']==='C-S-13')['passed']=!![];if(d&&c['order_allocators']!==undefined){const Q=b['find'](R=>R['id']==='C-S-14');Q['passed']=![],Q['message']='order_allocators\x20is\x20IMMUTABLE\x20post-publish\x20(F-S-22)';}else b['find'](R=>R['id']==='C-S-14')['passed']=!![];if(c['compensation_fund_withdraw']){const R=a['current_bPaused']??![],S=b['find'](T=>T['id']==='C-S-15');!R?(S['passed']=![],S['message']='compensation_fund_withdraw\x20requires\x20bPaused=true\x20(F-S-26)'):(S['passed']=!![],S['message']='Paused\x20OK\x20—\x20verify\x20lock_duration\x20expired\x20on-chain');}else b['find'](T=>T['id']==='C-S-15')['passed']=!![];const e=[];if(c['object'])e['push'](c['object']);if(c['machine'])e['push'](c['machine']);if(c['buy_guard'])e['push'](c['buy_guard']);if(c['arbitrations']&&'objects'in c['arbitrations'])e['push'](...c['arbitrations']['objects']);if(c['repositories']&&'objects'in c['repositories'])e['push'](...c['repositories']['objects']);if(c['rewards']&&'objects'in c['rewards'])e['push'](...c['rewards']['objects']);if(c['builder'])e['push'](c['builder']);if(c['um'])e['push'](c['um']);const f=b['find'](T=>T['id']==='C-S-16');if(e['length']===0x0)f['passed']=!![];else{const T=e['filter'](U=>!U['startsWith']('0x')||U['length']<0x28);f['passed']=T['length']===0x0,f['message']=T['length']===0x0?'':'Invalid\x20addresses:\x20'+T['slice'](0x0,0x3)['join'](',\x20')+(T['length']>0x3?'...':'');}if(c['publish']){const U=b['find'](V=>V['id']==='C-S-17');U['passed']=![],U['message']='Pending\x20user\x20confirmation\x20in\x20Layer\x203\x20(QS1)';}else b['find'](V=>V['id']==='C-S-17')['passed']=!![];if(c['builder']){const V=b['find'](W=>W['id']==='C-S-18');V['passed']=![],V['message']='Pending\x20user\x20confirmation\x20in\x20Layer\x203\x20(QS2)';}else b['find'](W=>W['id']==='C-S-18')['passed']=!![];if(c['publish']){const W=a['current_arbitrations_count']??0x0,X=c['arbitrations']&&'objects'in c['arbitrations']?c['arbitrations']['objects']['length']:0x0,Y=c['arbitrations']&&c['arbitrations']['op']==='clear',Z=Y?0x0:W+X,a0=b['find'](a1=>a1['id']==='C-S-19');Z===0x0?(a0['passed']=![],a0['message']='Pending\x20user\x20confirmation\x20in\x20Layer\x203\x20(QS11)\x20—\x20arbitrations\x20cannot\x20be\x20added\x20post-publish'):a0['passed']=!![];}else b['find'](a1=>a1['id']==='C-S-19')['passed']=!![];const g=b['filter'](a1=>a1['id']!=='C-S-17'&&a1['id']!=='C-S-18'&&a1['id']!=='C-S-19')['every'](a1=>a1['passed']);return{'all_passed':g,'items':b};}function adaptRiskAssessment(a){const b={'object':a['service_json']['object'],'description':a['service_json']['description'],'location':a['service_json']['location'],'sales':a['service_json']['sales'],'repositories':a['service_json']['repositories'],'rewards':a['service_json']['rewards'],'arbitrations':a['service_json']['arbitrations'],'machine':a['service_json']['machine'],'discount':a['service_json']['discount'],'customer_required':a['service_json']['customer_required'],'order_allocators':a['service_json']['order_allocators'],'buy_guard':a['service_json']['buy_guard'],'compensation_fund_add':a['service_json']['compensation_fund_add'],'setting_lock_duration_add':a['service_json']['setting_lock_duration_add'],'compensation_fund_receive':a['service_json']['compensation_fund_receive'],'owner_receive':a['service_json']['owner_receive'],'pause':a['service_json']['pause'],'publish':a['service_json']['publish'],'um':a['service_json']['um'],'order_new':a['service_json']['order_new'],'current_bPublished':a['current_bPublished'],'current_bPaused':a['current_bPaused'],'current_compensation_fund_balance':a['current_compensation_fund_balance'],'current_setting_lock_duration':a['current_setting_lock_duration'],'current_arbitrations_count':a['current_arbitrations_count'],'current_rewards_count':a['current_rewards_count'],'current_repositories_count':a['current_repositories_count'],'current_sales_count':a['current_sales_count'],'current_machine_bound':a['current_machine_bound'],'current_order_allocators_set':a['current_order_allocators_set'],'builder':a['service_json']['builder'],'target_objects_types':a['target_objects_types']};return assessServiceRisks(b);}export const SERVICE_CONFIRMATION_QUESTIONS=[{'id':'QS1','question':'⚠️\x20PUBLISH\x20is\x20IRREVERSIBLE\x20—\x20once\x20published,\x20machine/arbitrations/order_allocators\x20become\x20permanently\x20immutable.\x20Do\x20you\x20confirm\x20all\x20configurations\x20are\x20correct\x20and\x20you\x27re\x20ready\x20to\x20publish?','requires_explicit_yes':!![],'related_risk_ids':['R-S-3-01','R-S-4-01']},{'id':'QS2','question':'⚠️\x20Ownership\x20transfer\x20is\x20IRREVERSIBLE\x20—\x20original\x20owner\x20will\x20lose\x20ALL\x20control\x20over\x20the\x20Service,\x20including\x20compensation_fund\x20and\x20all\x20bindings.\x20Do\x20you\x20confirm\x20the\x20new\x20owner\x20address\x20is\x20correct?','requires_explicit_yes':!![],'related_risk_ids':['R-S-3-04']},{'id':'QS3','question':'Are\x20all\x20sales\x20items\x20configured\x20with\x20valid\x20wip_hash\x20(sha256\x20of\x20the\x20WIP\x20file\x20content)?\x20Missing\x20or\x20incorrect\x20hashes\x20create\x20tampering\x20risks.','requires_explicit_yes':!![],'related_risk_ids':['R-S-2-01']},{'id':'QS4','question':'If\x20publishing\x20with\x20compensation_fund\x20>\x200,\x20are\x20Arbitration\x20objects\x20configured\x20and\x20their\x20reputations\x20verified?\x20Owners\x20cannot\x20add\x20new\x20Arbitration\x20objects\x20post-publish.','requires_explicit_yes':!![],'related_risk_ids':['R-S-5-02']},{'id':'QS5','question':'Is\x20the\x20order_allocators\x20configuration\x20final?\x20It\x20becomes\x20PERMANENTLY\x20immutable\x20after\x20publish\x20—\x20fee\x20splits\x20cannot\x20be\x20adjusted\x20without\x20creating\x20a\x20new\x20Service.','requires_explicit_yes':!![],'related_risk_ids':['R-S-5-03','R-S-4-03']},{'id':'QS6','question':'If\x20binding\x20a\x20Machine,\x20is\x20it\x20published\x20and\x20verified?\x20Machine\x20binding\x20is\x20permanent\x20post-publish\x20—\x20Progress\x20objects\x20will\x20inherit\x20this\x20Machine\x20forever.','requires_explicit_yes':!![],'related_risk_ids':['R-S-5-01']},{'id':'QS7','question':'If\x20using\x20buy_guard,\x20is\x20the\x20Guard\x20configuration\x20appropriate\x20for\x20your\x20sale\x20phase\x20(whitelist\x20for\x20pre-sale,\x20null\x20for\x20public\x20sale)?\x20buy_guard\x20remains\x20mutable\x20post-publish.','requires_explicit_yes':![],'related_risk_ids':['R-S-3-03']},{'id':'QS8','question':'For\x20discount\x20operations:\x20are\x20discount\x20counts\x20within\x20limits\x20(<=1000\x20per\x20call,\x20<=20000\x20total)?\x20Expired\x20or\x20exhausted\x20discounts\x20cannot\x20be\x20re-issued.','requires_explicit_yes':![],'related_risk_ids':['R-S-2-04']},{'id':'QS9','question':'For\x20order\x20placement:\x20are\x20you\x20aware\x20that\x20stock\x20is\x20deducted\x20at\x20the\x20quote\x20stage\x20and\x20NOT\x20rolled\x20back\x20if\x20later\x20stages\x20fail?\x20Monitor\x20failed\x20transactions\x20and\x20re-add\x20stock\x20manually\x20if\x20needed.','requires_explicit_yes':!![],'related_risk_ids':['R-S-2-03']},{'id':'QS10','question':'Have\x20you\x20exported\x20the\x20current\x20Service\x20JSON\x20as\x20a\x20backup\x20before\x20this\x20operation?','requires_explicit_yes':![]},{'id':'QS11','question':'⚠️\x20Service\x20is\x20about\x20to\x20be\x20published\x20WITHOUT\x20arbitrations.\x0a\x0a'+'After\x20publishing,\x20arbitrations\x20CANNOT\x20be\x20added\x20(contract\x20restriction,\x20F-S-21).\x0a'+'Dispute\x20resolution\x20will\x20NOT\x20be\x20available\x20for\x20this\x20service.\x0a\x0a'+'Recommended:\x20Set\x20arbitrations\x20BEFORE\x20publishing:\x0a'+'\x20\x20\x22arbitrations\x22:\x20{\x22op\x22:\x20\x22add\x22,\x20\x22objects\x22:\x20[\x22your_arbitration_object\x22]}\x0a\x0a'+'Continue\x20with\x20publish\x20anyway?','requires_explicit_yes':!![]}];function processUserConfirmation(a,b){const c=[...SERVICE_CONFIRMATION_QUESTIONS],d=a['service_json'],e=[];if(!d['publish'])e['push']('QS1');if(!d['builder'])e['push']('QS2');if(!d['sales']||d['sales']['op']==='clear'||d['sales']['op']==='remove')e['push']('QS3');if(!d['publish']&&!(d['compensation_fund_add']&&BigInt(String(d['compensation_fund_add']['balance']))>0x0n))e['push']('QS4');if(!d['publish']&&!d['order_allocators'])e['push']('QS5');if(!d['machine'])e['push']('QS6');if(d['buy_guard']===undefined)e['push']('QS7');if(!d['discount'])e['push']('QS8');if(!d['order_new'])e['push']('QS9');if(!d['publish'])e['push']('QS11');else{const g=a['current_arbitrations_count']??0x0,h=d['arbitrations']&&'objects'in d['arbitrations']?d['arbitrations']['objects']['length']:0x0,i=d['arbitrations']&&d['arbitrations']['op']==='clear',j=i?0x0:g+h;j>0x0&&e['push']('QS11');}const f=c['filter'](k=>!e['includes'](k['id']));if(a['skip_user_confirmation'])return{'questions_asked':f,'responses':f['map'](k=>({'question_id':k['id'],'response':'yes'})),'all_confirmed':!![]};return{'questions_asked':f,'responses':[],'all_confirmed':![]};}function verifyEnvironment(a){const b=[],c=a['service_json'];c['object']&&b['push']({'name':'object_exists','passed':!![],'message':'Service\x20object\x20'+c['object']+'\x20assumed\x20to\x20exist'});c['publish']&&b['push']({'name':'signer_has_publish_permission','passed':!![],'message':'Signer\x20must\x20hold\x20SERVICE_PUBLISH\x20(311)\x20permission'});c['builder']&&b['push']({'name':'signer_is_owner','passed':!![],'message':'Signer\x20must\x20be\x20Service\x20owner\x20for\x20transfer\x20(builder)'});c['pause']!==undefined&&b['push']({'name':'signer_has_pause_permission','passed':!![],'message':'Signer\x20must\x20hold\x20SERVICE_PAUSE\x20(310)\x20permission'});if(c['publish']){!a['current_order_allocators_set']&&c['order_allocators']===undefined&&b['push']({'name':'order_allocators_set','passed':![],'message':'Publish\x20blocked:\x20order_allocators\x20not\x20set\x20(E_NO_ALLOCATOR)'});const g=a['current_compensation_fund_balance']??'0',h=a['current_arbitrations_count']??0x0,i=c['arbitrations']&&'objects'in c['arbitrations']?c['arbitrations']['objects']['length']:0x0;BigInt(g)>0x0n&&h+i===0x0&&b['push']({'name':'arbitrations_for_compensation_fund','passed':![],'message':'Publish\x20blocked:\x20compensation_fund\x20>\x200\x20but\x20no\x20arbitrations\x20(E_ARBITRATION_NOT_SET_WITH_COMPENSATION_FUND)'});c['machine']&&(a['current_machine_node_count']!==undefined&&a['current_machine_node_count']===0x0&&b['push']({'name':'machine_has_nodes','passed':![],'message':'Publish\x20blocked:\x20bound\x20Machine\x20has\x200\x20nodes\x20—\x20Progress\x20will\x20be\x20permanently\x20stuck'}),a['current_machine_initial_forward_ok']===![]&&b['push']({'name':'machine_initial_forward','passed':![],'message':'Publish\x20blocked:\x20bound\x20Machine\x27s\x20initial\x20node\x20(prev_node=\x27\x27)\x20has\x20no\x20forward\x20—\x20Progress\x20cannot\x20advance\x20from\x20\x27\x27\x20(FIX-002\x20violated)'}),a['current_machine_bPublished']===![]&&b['push']({'name':'machine_not_published','passed':!![],'level':'warning','message':'Warning:\x20bound\x20Machine\x20is\x20not\x20yet\x20published.\x20Orders\x20cannot\x20advance\x20until\x20the\x20Machine\x20is\x20published.\x20Publish\x20the\x20Machine\x20after\x20this\x20Service\x20to\x20enable\x20order\x20workflow.'}));const j=a['current_arbitrations_count']??0x0,k=c['arbitrations']&&'objects'in c['arbitrations']?c['arbitrations']['objects']['length']:0x0;j+k>0x0&&a['current_arbitrators_authorized']===![]&&b['push']({'name':'arbitrators_permission_authorized','passed':!![],'level':'info','message':'Info:\x20ensure\x20arbitrators\x20have\x20been\x20granted\x20the\x20required\x20permission\x20index\x20in\x20the\x20Permission\x20object.\x20Without\x20authorization,\x20dispute\x20resolution\x20Guards\x20will\x20reject\x20arbitrator\x20signatures\x20(Permission\x20denied).'});}a['current_bPublished']&&(c['machine']!==undefined&&b['push']({'name':'machine_immutable_post_publish','passed':![],'message':'machine\x20cannot\x20be\x20modified\x20post-publish\x20(F-S-20)'}),c['arbitrations']!==undefined&&b['push']({'name':'arbitrations_immutable_post_publish','passed':![],'message':'arbitrations\x20cannot\x20be\x20modified\x20post-publish\x20(F-S-21)'}),c['order_allocators']!==undefined&&b['push']({'name':'order_allocators_immutable_post_publish','passed':![],'message':'order_allocators\x20cannot\x20be\x20modified\x20post-publish\x20(F-S-22)'}));c['compensation_fund_withdraw']&&!a['current_bPaused']&&b['push']({'name':'compensation_fund_withdraw_requires_paused','passed':![],'message':'compensation_fund_withdraw\x20requires\x20bPaused=true\x20(F-S-26)'});const d=b['every'](l=>l['passed']),e=b['filter'](l=>l['level']==='warning')['length'],f=b['filter'](l=>l['level']==='info')['length'];return{'passed':d,'checks':b,'warnings_count':e,'infos_count':f};}export const SERVICE_CONFIRM_VERSION='1.0.0';export function runServiceConfirmGate(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'](j=>!j['passed']&&j['id']!=='C-S-17'&&j['id']!=='C-S-18'&&j['id']!=='C-S-19')['map'](j=>j['id'])['join'](',\x20'),'decision_record':{'timestamp':new Date()['toISOString'](),'gate_version':SERVICE_CONFIRM_VERSION,'final_status':'blocked_checklist','layers_passed':b,'layers_failed':c}};b['push']('L1_checklist');const e=adaptRiskAssessment(a),f=e['risks']['some'](i=>i['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'](i=>i['level']==='CRITICAL')['map'](i=>i['id'])['join'](',\x20'),'decision_record':{'timestamp':new Date()['toISOString'](),'gate_version':SERVICE_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']){if(a['service_json']['publish']){const j=d['items']['find'](k=>k['id']==='C-S-17');if(j){const k=g['responses']['find'](l=>l['question_id']==='QS1');j['passed']=k?.['response']==='yes',j['message']=j['passed']?'':'Publish\x20not\x20confirmed\x20by\x20user\x20(QS1)';}}if(a['service_json']['builder']){const l=d['items']['find'](m=>m['id']==='C-S-18');if(l){const m=g['responses']['find'](n=>n['question_id']==='QS2');l['passed']=m?.['response']==='yes',l['message']=l['passed']?'':'Transfer\x20not\x20confirmed\x20by\x20user\x20(QS2)';}}const i=d['items']['find'](n=>n['id']==='C-S-19');if(i&&!i['passed']){const n=g['questions_asked']['some'](o=>o['id']==='QS11');if(n){const o=g['responses']['find'](p=>p['question_id']==='QS11');i['passed']=o?.['response']==='yes',i['message']=i['passed']?'':'User\x20declined\x20publish\x20without\x20arbitrations\x20(QS11)';}}if(a['service_json']['publish']){const p=d['items']['find'](q=>q['id']==='C-S-17');if(p&&!p['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\x20publish\x20(QS1)','decision_record':{'timestamp':new Date()['toISOString'](),'gate_version':SERVICE_CONFIRM_VERSION,'final_status':'blocked_user','layers_passed':b,'layers_failed':c}};}if(a['service_json']['builder']){const q=d['items']['find'](r=>r['id']==='C-S-18');if(q&&!q['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\x20ownership\x20transfer\x20(QS2)','decision_record':{'timestamp':new Date()['toISOString'](),'gate_version':SERVICE_CONFIRM_VERSION,'final_status':'blocked_user','layers_passed':b,'layers_failed':c}};}if(i&&!i['passed']){const r=g['questions_asked']['some'](s=>s['id']==='QS11');if(r)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\x20publish\x20without\x20arbitrations\x20(QS11)\x20—\x20set\x20arbitrations\x20or\x20explicitly\x20confirm','decision_record':{'timestamp':new Date()['toISOString'](),'gate_version':SERVICE_CONFIRM_VERSION,'final_status':'blocked_user','layers_passed':b,'layers_failed':c}};}}b['push']('L3_user');let h;if(a['skip_environment_check'])b['push']('L4_environment');else{h=verifyEnvironment(a);if(!h['passed'])return c['push']('L4_environment'),{'status':'blocked_environment','checklist_result':d,'risk_result':e,'user_confirmation':g,'environment_result':h,'confirmation_text':generateConfirmationText(a,d,e),'block_reason':'Environment\x20check\x20failed:\x20'+h['checks']['filter'](s=>!s['passed'])['map'](s=>s['name'])['join'](',\x20'),'decision_record':{'timestamp':new Date()['toISOString'](),'gate_version':SERVICE_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,'environment_result':h,'confirmation_text':generateConfirmationText(a,d,e),'decision_record':{'timestamp':new Date()['toISOString'](),'gate_version':SERVICE_CONFIRM_VERSION,'final_status':'approved','layers_passed':b,'layers_failed':c}};}function generateConfirmationText(a,b,c){const d=[],e=a['service_json'];d['push']('═══\x20Service\x20Confirmation\x20═══'),d['push']('');e['object']?d['push']('Service:\x20'+e['object']):d['push']('Service:\x20NEW\x20(to\x20be\x20created)');if(e['description'])d['push']('Description:\x20'+e['description']);if(a['current_bPublished']!==undefined)d['push']('Currently\x20published:\x20'+a['current_bPublished']);if(a['current_bPaused']!==undefined)d['push']('Currently\x20paused:\x20'+a['current_bPaused']);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']['slice'](0x0,0xa)){d['push']('\x20\x20['+h['level']+']\x20'+h['id']+':\x20'+h['title']);}c['risks']['length']>0xa&&d['push']('\x20\x20...\x20and\x20'+(c['risks']['length']-0xa)+'\x20more'),d['push']('');}d['push']('─\x20Operations\x20──────────────────');if(e['sales'])d['push']('-\x20Sales\x20'+e['sales']['op']);if(e['machine']!==undefined)d['push']('-\x20Machine:\x20'+(e['machine']??'(unbind)')+'\x20'+(a['current_bPublished']?'[BLOCKED\x20post-publish]':''));if(e['buy_guard']!==undefined)d['push']('-\x20Buy\x20Guard:\x20'+(e['buy_guard']??'(clear)'));if(e['arbitrations'])d['push']('-\x20Arbitrations\x20'+e['arbitrations']['op']);if(e['repositories'])d['push']('-\x20Repositories\x20'+e['repositories']['op']);if(e['rewards'])d['push']('-\x20Rewards\x20'+e['rewards']['op']);if(e['order_allocators']!==undefined)d['push']('-\x20Order\x20Allocators:\x20'+(e['order_allocators']?'(set)':'(clear)'));if(e['discount'])d['push']('-\x20Discount:\x20'+e['discount']['name']+'\x20('+e['discount']['count']+'\x20coupons)');if(e['pause']!==undefined)d['push']('-\x20Pause:\x20'+e['pause']);if(e['publish'])d['push']('-\x20⚠️\x20PUBLISH\x20(IRREVERSIBLE)');if(e['compensation_fund_add'])d['push']('-\x20Compensation\x20fund\x20deposit:\x20'+e['compensation_fund_add']['balance']);if(e['compensation_fund_withdraw'])d['push']('-\x20⚠️\x20Compensation\x20fund\x20withdraw\x20(requires\x20paused\x20+\x20lock\x20expired)');if(e['setting_lock_duration_add']!==undefined)d['push']('-\x20Setting\x20lock\x20+'+e['setting_lock_duration_add']+'ms');if(e['order_new'])d['push']('-\x20⚠️\x20ORDER\x20NEW\x20(8-stage\x20flow,\x20stock\x20deducted\x20at\x20quote)');if(e['builder'])d['push']('-\x20⚠️\x20TRANSFER\x20to:\x20'+e['builder']+'\x20(IRREVERSIBLE)');if(e['um']!==undefined)d['push']('-\x20UM:\x20'+(e['um']??'(revoke)'));return d['push'](''),d['join']('\x0a');}export function progressiveServiceCheck(a){const b=runStaticChecklist(a);if(!b['all_passed'])return{'stage':'checklist','status':'fail','message':'Checklist\x20failed:\x20'+b['items']['filter'](d=>!d['passed']&&d['id']!=='C-S-17'&&d['id']!=='C-S-18'&&d['id']!=='C-S-19')['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\x20via\x20user\x20questions'};return{'stage':'complete','status':'pass','message':'All\x20checks\x20passed'};}
|