@wowok/agent-mcp 2.7.0 → 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.d.ts +5 -1
- 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 +23 -0
- package/dist/evaluation/arbitration-game.js +1 -0
- package/dist/evaluation/builtins/demand-match.d.ts +15 -0
- package/dist/evaluation/builtins/demand-match.js +1 -0
- package/dist/evaluation/builtins/index.d.ts +3 -0
- package/dist/evaluation/builtins/index.js +1 -0
- package/dist/evaluation/builtins/service-risk.d.ts +6 -0
- package/dist/evaluation/builtins/service-risk.js +1 -0
- package/dist/evaluation/capability.d.ts +50 -0
- package/dist/evaluation/capability.js +1 -0
- package/dist/evaluation/composer.d.ts +13 -0
- package/dist/evaluation/composer.js +1 -0
- package/dist/evaluation/engine.d.ts +18 -0
- package/dist/evaluation/engine.js +1 -0
- package/dist/evaluation/extract.d.ts +30 -0
- package/dist/evaluation/extract.js +1 -0
- package/dist/evaluation/game-strategy.d.ts +27 -0
- package/dist/evaluation/game-strategy.js +1 -0
- package/dist/evaluation/gap.d.ts +2 -0
- package/dist/evaluation/gap.js +1 -0
- package/dist/evaluation/index.d.ts +12 -0
- package/dist/evaluation/index.js +1 -0
- package/dist/evaluation/node-game.d.ts +62 -0
- package/dist/evaluation/node-game.js +1 -0
- package/dist/evaluation/region.d.ts +10 -0
- package/dist/evaluation/region.js +1 -0
- package/dist/evaluation/types.d.ts +77 -0
- package/dist/evaluation/types.js +1 -0
- package/dist/evaluation/user-injection.d.ts +6 -0
- package/dist/evaluation/user-injection.js +1 -0
- package/dist/examples/education-contact-create.json +40 -0
- package/dist/examples/freelance-contact-create.json +40 -0
- package/dist/examples/insurance-machine-create.json +1 -1
- package/dist/examples/insurance-service-allocators.json +1 -1
- package/dist/examples/machine-publish.json +1 -1
- package/dist/examples/rental-ziroom-service-create.json +1 -1
- package/dist/examples/retail-adv-guard-messenger-proof-create.json +1 -1
- package/dist/examples/retail-myshop-service-create.json +1 -1
- package/dist/examples/retail-myshop-service-customer-required.json +1 -1
- package/dist/examples/subscription-contact-create.json +40 -0
- package/dist/examples/threebody-machine-create.json +1 -1
- package/dist/examples/travel-machine-create.json +1 -1
- package/dist/examples/travel-service-create.json +1 -1
- 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 -276
- 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.d.ts +1 -0
- package/dist/intent/enrich.js +1 -0
- package/dist/intent/index.d.ts +23 -0
- package/dist/intent/index.js +1 -0
- package/dist/intent/matcher.d.ts +2 -0
- package/dist/intent/matcher.js +1 -0
- package/dist/intent/store.d.ts +19 -0
- package/dist/intent/store.js +1 -0
- package/dist/intent/types.d.ts +33 -0
- package/dist/intent/types.js +1 -0
- 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 -433
- 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.d.ts +27 -0
- package/dist/knowledge/contact-templates.js +1 -0
- 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 -825
- 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 -670
- 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.d.ts +1 -1
- package/dist/knowledge/mcp-schema-audit.js +1 -773
- 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 -615
- package/dist/knowledge/service-templates.js +1 -456
- package/dist/knowledge/service-translation.js +1 -622
- package/dist/knowledge/template-registry.d.ts +1 -1
- package/dist/knowledge/template-registry.js +1 -341
- package/dist/knowledge/tool-constraints.js +1 -195
- package/dist/knowledge/tools-reference.js +1 -155
- 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.d.ts +16 -0
- package/dist/persona/analyzer.js +1 -0
- package/dist/persona/bridge.d.ts +5 -0
- package/dist/persona/bridge.js +1 -0
- package/dist/persona/defaults.d.ts +4 -0
- package/dist/persona/defaults.js +1 -0
- package/dist/persona/experience-bridge.d.ts +3 -0
- package/dist/persona/experience-bridge.js +1 -0
- package/dist/persona/index.d.ts +18 -0
- package/dist/persona/index.js +1 -0
- package/dist/persona/model.d.ts +7 -0
- package/dist/persona/model.js +1 -0
- package/dist/persona/store.d.ts +19 -0
- package/dist/persona/store.js +1 -0
- package/dist/persona/types.d.ts +45 -0
- package/dist/persona/types.js +1 -0
- 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.d.ts +5 -0
- package/dist/project/handlers.js +1 -1762
- 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 -245
- 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.d.ts +2 -0
- package/dist/rules.js +1 -9
- 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 -1657
- package/dist/schema/call/service.js +1 -178
- 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 +4436 -0
- package/dist/schema/evaluation/index.js +1 -0
- package/dist/schema/index.d.ts +4 -0
- package/dist/schema/index.js +1 -13
- package/dist/schema/intent-radar/index.d.ts +284 -0
- package/dist/schema/intent-radar/index.js +1 -0
- 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 +1985 -0
- package/dist/schema/persona/index.js +1 -0
- package/dist/schema/project/index.d.ts +96 -50
- package/dist/schema/project/index.js +1 -2057
- package/dist/schema/query/index.d.ts +423 -7
- package/dist/schema/query/index.js +1 -1640
- package/dist/schema/schema-query/index.js +1 -104
- package/dist/schema/schema-version.js +1 -76
- package/dist/schema/sync-layer4.d.ts +1 -1
- package/dist/schema/sync-layer4.js +1 -282
- package/dist/schema/task-status.d.ts +168 -0
- package/dist/schema/task-status.js +1 -0
- 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 +782 -0
- package/dist/schemas/evaluation_operation.schema.json +990 -0
- package/dist/schemas/index.json +25 -1
- package/dist/schemas/intent_radar.output.json +232 -0
- package/dist/schemas/intent_radar.schema.json +138 -0
- 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 +6 -6
- 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 +3 -3
- package/dist/schemas/onchain_table_data.output.json +6 -3
- package/dist/schemas/persona_operation.output.json +392 -0
- package/dist/schemas/persona_operation.schema.json +250 -0
- package/dist/schemas/project_operation.output.json +28 -8
- package/dist/schemas/query_task_status.output.json +115 -0
- package/dist/schemas/query_task_status.schema.json +24 -0
- package/dist/schemas/query_toolkit.output.json +9 -6
- package/dist/schemas/trust_score.schema.json +1 -1
- 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.d.ts +2 -0
- package/dist/tools/handlers/evaluation.js +1 -0
- package/dist/tools/handlers/file-export.js +1 -90
- package/dist/tools/handlers/intent-radar.d.ts +2 -0
- package/dist/tools/handlers/intent-radar.js +1 -0
- package/dist/tools/handlers/local.js +1 -53
- package/dist/tools/handlers/messenger.js +1 -188
- package/dist/tools/handlers/onchain.js +1 -1082
- package/dist/tools/handlers/persona.d.ts +4 -0
- package/dist/tools/handlers/persona.js +1 -0
- 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.d.ts +0 -168
- package/dist/tools/handlers/task-status.js +1 -55
- package/dist/tools/handlers/trust.js +1 -380
- package/dist/tools/handlers/wip.js +1 -90
- package/dist/tools/index.js +1 -1306
- 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.d.ts +1 -1
- package/dist/tools/wip-deploy-assist.js +1 -278
- package/dist/tools/wrap.js +1 -500
- package/package.json +5 -3
|
@@ -1,456 +1 @@
|
|
|
1
|
-
import { MAX_NAMED_OPERATOR_COUNT, MAX_NAMED_OPERATOR_ADDRESS_COUNT, MAX_CONTEXT_REPOSITORY_COUNT, } from "@wowok/wowok";
|
|
2
|
-
import { assessProgressRisks, } from "./progress-risk.js";
|
|
3
|
-
export const PROGRESS_OPERATION_CHECKLIST = [
|
|
4
|
-
{ id: "C-PR-01", description: "Machine is published (machine::on_progress_new asserts published)", passed: false, message: "" },
|
|
5
|
-
{ id: "C-PR-02", description: "progress.machine matches the bound Machine (E_MACHINE_NOT_MATCH)", passed: false, message: "" },
|
|
6
|
-
{ id: "C-PR-03", description: "named_operator count < MAX_NAMED_OPERATOR_COUNT (60)", passed: false, message: "" },
|
|
7
|
-
{ id: "C-PR-04", description: "named_operator addresses ≤ MAX_NAMED_OPERATOR_ADDRESS_COUNT (80)", passed: false, message: "" },
|
|
8
|
-
{ id: "C-PR-05", description: "context_repository count ≤ MAX_CONTEXT_REPOSITORY_COUNT (30)", passed: false, message: "" },
|
|
9
|
-
{ id: "C-PR-06", description: "task_set is one-time (E_TASK_ALREADY_SET if already bound)", passed: false, message: "" },
|
|
10
|
-
{ id: "C-PR-07", description: "operate.op is one of: next | hold | unhold | adminUnhold", passed: false, message: "" },
|
|
11
|
-
{ id: "C-PR-08", description: "operate.message ≤ MAX_LONG_NAME_LENGTH (1024 chars)", passed: false, message: "" },
|
|
12
|
-
{ id: "C-PR-09", description: "Forward exists in Machine (current → next_node_name, forward)", passed: false, message: "" },
|
|
13
|
-
{ id: "C-PR-10", description: "adminUnhold (224 permission) double-confirmed by user", passed: false, message: "" },
|
|
14
|
-
];
|
|
15
|
-
function runStaticChecklist(input) {
|
|
16
|
-
const items = PROGRESS_OPERATION_CHECKLIST.map(c => ({ ...c }));
|
|
17
|
-
const data = input.progress_json;
|
|
18
|
-
const cp01 = items.find(i => i.id === "C-PR-01");
|
|
19
|
-
if (input.machine_published === false) {
|
|
20
|
-
cp01.passed = false;
|
|
21
|
-
cp01.message = `Machine ${input.current_machine ?? "(unknown)"} not published`;
|
|
22
|
-
}
|
|
23
|
-
else {
|
|
24
|
-
cp01.passed = true;
|
|
25
|
-
}
|
|
26
|
-
const cp02 = items.find(i => i.id === "C-PR-02");
|
|
27
|
-
cp02.passed = !!input.current_machine || !!data.object;
|
|
28
|
-
cp02.message = cp02.passed ? "" : "No machine bound";
|
|
29
|
-
const cp03 = items.find(i => i.id === "C-PR-03");
|
|
30
|
-
const currentOps = input.current_named_operator_count ?? 0;
|
|
31
|
-
const isAddingNewName = data.progress_namedOperator?.op === "add" || data.progress_namedOperator?.op === "set";
|
|
32
|
-
if (isAddingNewName && currentOps >= MAX_NAMED_OPERATOR_COUNT) {
|
|
33
|
-
cp03.passed = false;
|
|
34
|
-
cp03.message = `named_operator count ${currentOps} ≥ MAX_NAMED_OPERATOR_COUNT ${MAX_NAMED_OPERATOR_COUNT}`;
|
|
35
|
-
}
|
|
36
|
-
else {
|
|
37
|
-
cp03.passed = true;
|
|
38
|
-
}
|
|
39
|
-
const cp04 = items.find(i => i.id === "C-PR-04");
|
|
40
|
-
if (data.progress_namedOperator) {
|
|
41
|
-
const count = data.progress_namedOperator.operators.length;
|
|
42
|
-
cp04.passed = count <= MAX_NAMED_OPERATOR_ADDRESS_COUNT;
|
|
43
|
-
cp04.message = cp04.passed ? "" : `${count} > ${MAX_NAMED_OPERATOR_ADDRESS_COUNT}`;
|
|
44
|
-
}
|
|
45
|
-
else {
|
|
46
|
-
cp04.passed = true;
|
|
47
|
-
}
|
|
48
|
-
const cp05 = items.find(i => i.id === "C-PR-05");
|
|
49
|
-
if (data.repository && (data.repository.op === "add" || data.repository.op === "set")) {
|
|
50
|
-
const current = input.current_context_repository_count ?? 0;
|
|
51
|
-
const addCount = data.repository.op === "set" ? data.repository.objects.length : data.repository.objects.length;
|
|
52
|
-
const newCount = data.repository.op === "set" ? addCount : current + addCount;
|
|
53
|
-
cp05.passed = newCount <= MAX_CONTEXT_REPOSITORY_COUNT;
|
|
54
|
-
cp05.message = cp05.passed ? "" : `${newCount} > ${MAX_CONTEXT_REPOSITORY_COUNT}`;
|
|
55
|
-
}
|
|
56
|
-
else {
|
|
57
|
-
cp05.passed = true;
|
|
58
|
-
}
|
|
59
|
-
const cp06 = items.find(i => i.id === "C-PR-06");
|
|
60
|
-
if (data.task && input.current_task) {
|
|
61
|
-
cp06.passed = false;
|
|
62
|
-
cp06.message = `task already set to ${input.current_task} — E_TASK_ALREADY_SET will abort`;
|
|
63
|
-
}
|
|
64
|
-
else {
|
|
65
|
-
cp06.passed = true;
|
|
66
|
-
}
|
|
67
|
-
const cp07 = items.find(i => i.id === "C-PR-07");
|
|
68
|
-
const validOps = ["next", "hold", "unhold", "adminUnhold"];
|
|
69
|
-
if (data.operate && data.operate.op && !validOps.includes(data.operate.op)) {
|
|
70
|
-
cp07.passed = false;
|
|
71
|
-
cp07.message = `operate.op must be one of: ${validOps.join(", ")}`;
|
|
72
|
-
}
|
|
73
|
-
else {
|
|
74
|
-
cp07.passed = true;
|
|
75
|
-
}
|
|
76
|
-
const cp08 = items.find(i => i.id === "C-PR-08");
|
|
77
|
-
if (data.operate?.message) {
|
|
78
|
-
const len = data.operate.message.length;
|
|
79
|
-
cp08.passed = len <= 1024;
|
|
80
|
-
cp08.message = cp08.passed ? "" : `message length ${len} > 1024`;
|
|
81
|
-
}
|
|
82
|
-
else {
|
|
83
|
-
cp08.passed = true;
|
|
84
|
-
}
|
|
85
|
-
const cp09 = items.find(i => i.id === "C-PR-09");
|
|
86
|
-
if (data.operate) {
|
|
87
|
-
cp09.passed = true;
|
|
88
|
-
cp09.message = "Forward existence verified in L4 (queryTableItem_MachineNode)";
|
|
89
|
-
}
|
|
90
|
-
else {
|
|
91
|
-
cp09.passed = true;
|
|
92
|
-
}
|
|
93
|
-
const cp10 = items.find(i => i.id === "C-PR-10");
|
|
94
|
-
if (data.operate?.op === "adminUnhold") {
|
|
95
|
-
cp10.passed = false;
|
|
96
|
-
cp10.message = "Pending user confirmation in L3 (QPR3)";
|
|
97
|
-
}
|
|
98
|
-
else {
|
|
99
|
-
cp10.passed = true;
|
|
100
|
-
}
|
|
101
|
-
return {
|
|
102
|
-
all_passed: items.filter(i => i.id !== "C-PR-10").every(i => i.passed),
|
|
103
|
-
items,
|
|
104
|
-
};
|
|
105
|
-
}
|
|
106
|
-
function adaptRiskAssessment(input) {
|
|
107
|
-
const ctx = {
|
|
108
|
-
object: input.progress_json.object,
|
|
109
|
-
task: input.progress_json.task,
|
|
110
|
-
repository: input.progress_json.repository,
|
|
111
|
-
progress_namedOperator: input.progress_json.progress_namedOperator,
|
|
112
|
-
operate: input.progress_json.operate,
|
|
113
|
-
current_machine: input.current_machine,
|
|
114
|
-
machine_published: input.machine_published,
|
|
115
|
-
current_task: input.current_task,
|
|
116
|
-
current_named_operator_count: input.current_named_operator_count,
|
|
117
|
-
current_context_repository_count: input.current_context_repository_count,
|
|
118
|
-
current_node: input.current_node,
|
|
119
|
-
forward_already_accomplished: input.forward_already_accomplished,
|
|
120
|
-
holder_address: input.holder_address,
|
|
121
|
-
signer: input.signer,
|
|
122
|
-
forward_named_operator: input.forward_named_operator,
|
|
123
|
-
forward_permission_index: input.forward_permission_index,
|
|
124
|
-
forward_has_guard: input.forward_has_guard,
|
|
125
|
-
target_objects_types: input.target_objects_types,
|
|
126
|
-
};
|
|
127
|
-
return assessProgressRisks(ctx);
|
|
128
|
-
}
|
|
129
|
-
export const PROGRESS_CONFIRMATION_QUESTIONS = [
|
|
130
|
-
{
|
|
131
|
-
id: "QPR1",
|
|
132
|
-
question: "Is the target Progress object address correct, and is it bound to the intended Machine?",
|
|
133
|
-
requires_explicit_yes: true,
|
|
134
|
-
},
|
|
135
|
-
{
|
|
136
|
-
id: "QPR2",
|
|
137
|
-
question: "For task_set: do you acknowledge that task is ONE-TIME and immutable (E_TASK_ALREADY_SET blocks any re-assignment)?",
|
|
138
|
-
requires_explicit_yes: true,
|
|
139
|
-
related_risk_ids: ["R-PR-2-01"],
|
|
140
|
-
},
|
|
141
|
-
{
|
|
142
|
-
id: "QPR3",
|
|
143
|
-
question: "⚠️ For adminUnhold: do you confirm force-releasing the held forward via 224 permission? This bypasses the holder check.",
|
|
144
|
-
requires_explicit_yes: true,
|
|
145
|
-
related_risk_ids: ["R-PR-3-01"],
|
|
146
|
-
},
|
|
147
|
-
{
|
|
148
|
-
id: "QPR4",
|
|
149
|
-
question: "For named_operator changes: are all addresses verified as the intended role holders (not expired/compromised)?",
|
|
150
|
-
requires_explicit_yes: true,
|
|
151
|
-
related_risk_ids: ["R-PR-3-02"],
|
|
152
|
-
},
|
|
153
|
-
{
|
|
154
|
-
id: "QPR5",
|
|
155
|
-
question: "For Forward advance (next/hold): does the Forward exist in the Machine, and is the caller authorized (named_operator match OR order.has_op_permission)?",
|
|
156
|
-
requires_explicit_yes: true,
|
|
157
|
-
related_risk_ids: ["R-PR-3-03", "R-PR-4-03"],
|
|
158
|
-
},
|
|
159
|
-
{
|
|
160
|
-
id: "QPR6",
|
|
161
|
-
question: "For context_repository binding: have you verified the Repository addresses still exist and are owned by trusted parties?",
|
|
162
|
-
requires_explicit_yes: false,
|
|
163
|
-
related_risk_ids: ["R-PR-5-02"],
|
|
164
|
-
},
|
|
165
|
-
];
|
|
166
|
-
function processUserConfirmation(input, assessment) {
|
|
167
|
-
const questions = [...PROGRESS_CONFIRMATION_QUESTIONS];
|
|
168
|
-
const data = input.progress_json;
|
|
169
|
-
const filtered = [];
|
|
170
|
-
for (const q of questions) {
|
|
171
|
-
if (q.id === "QPR2" && !data.task)
|
|
172
|
-
continue;
|
|
173
|
-
if (q.id === "QPR3" && data.operate?.op !== "adminUnhold")
|
|
174
|
-
continue;
|
|
175
|
-
if (q.id === "QPR4" && !data.progress_namedOperator)
|
|
176
|
-
continue;
|
|
177
|
-
if (q.id === "QPR5" && !data.operate)
|
|
178
|
-
continue;
|
|
179
|
-
if (q.id === "QPR6" && !data.repository)
|
|
180
|
-
continue;
|
|
181
|
-
filtered.push(q);
|
|
182
|
-
}
|
|
183
|
-
if (input.skip_user_confirmation) {
|
|
184
|
-
return {
|
|
185
|
-
questions_asked: filtered,
|
|
186
|
-
responses: filtered.map(q => ({ question_id: q.id, response: "yes" })),
|
|
187
|
-
all_confirmed: true,
|
|
188
|
-
};
|
|
189
|
-
}
|
|
190
|
-
return {
|
|
191
|
-
questions_asked: filtered,
|
|
192
|
-
responses: [],
|
|
193
|
-
all_confirmed: false,
|
|
194
|
-
};
|
|
195
|
-
}
|
|
196
|
-
function verifyEnvironment(input) {
|
|
197
|
-
const checks = [];
|
|
198
|
-
if (input.progress_json.object) {
|
|
199
|
-
checks.push({
|
|
200
|
-
name: "progress_exists",
|
|
201
|
-
passed: true,
|
|
202
|
-
message: `Progress ${input.progress_json.object} assumed to exist`,
|
|
203
|
-
});
|
|
204
|
-
}
|
|
205
|
-
if (input.current_machine) {
|
|
206
|
-
checks.push({
|
|
207
|
-
name: "machine_published_and_bound",
|
|
208
|
-
passed: input.machine_published !== false,
|
|
209
|
-
message: input.machine_published === false
|
|
210
|
-
? `Machine ${input.current_machine} NOT published`
|
|
211
|
-
: `Machine ${input.current_machine} published and bound`,
|
|
212
|
-
});
|
|
213
|
-
}
|
|
214
|
-
if (input.progress_json.operate) {
|
|
215
|
-
checks.push({
|
|
216
|
-
name: "forward_exists_in_machine",
|
|
217
|
-
passed: true,
|
|
218
|
-
message: `Forward "${input.progress_json.operate.operation.forward}" from "${input.current_node ?? "(unknown)"}" → "${input.progress_json.operate.operation.next_node_name}" — verify via queryTableItem_MachineNode`,
|
|
219
|
-
});
|
|
220
|
-
}
|
|
221
|
-
if (input.progress_json.operate && input.signer) {
|
|
222
|
-
const isOrderHolder = input.forward_named_operator === "";
|
|
223
|
-
const isNamedOperatorMatch = !!input.forward_named_operator && input.forward_named_operator !== "";
|
|
224
|
-
checks.push({
|
|
225
|
-
name: "signer_authorized_for_forward",
|
|
226
|
-
passed: true,
|
|
227
|
-
message: isOrderHolder
|
|
228
|
-
? `OrderHolder namespace — signer must be order.owner/agent (use order_next/order_hold)`
|
|
229
|
-
: isNamedOperatorMatch
|
|
230
|
-
? `namedOperator="${input.forward_named_operator}" — signer must be in operator list`
|
|
231
|
-
: `Forward.permissionIndex=${input.forward_permission_index ?? "None"} — signer must have this index`,
|
|
232
|
-
});
|
|
233
|
-
}
|
|
234
|
-
if (input.progress_json.operate &&
|
|
235
|
-
input.progress_json.operate.op === "unhold" &&
|
|
236
|
-
input.holder_address) {
|
|
237
|
-
const isHolder = input.signer === input.holder_address;
|
|
238
|
-
checks.push({
|
|
239
|
-
name: "unhold_by_holder",
|
|
240
|
-
passed: isHolder,
|
|
241
|
-
message: isHolder
|
|
242
|
-
? "Signer is the holder — unhold allowed"
|
|
243
|
-
: `Signer ${input.signer} ≠ holder ${input.holder_address} — E_NOT_THE_HOLDER will abort (use adminUnhold for force release)`,
|
|
244
|
-
});
|
|
245
|
-
}
|
|
246
|
-
const allPassed = checks.every(c => c.passed);
|
|
247
|
-
return { passed: allPassed, checks };
|
|
248
|
-
}
|
|
249
|
-
export const PROGRESS_CONFIRM_VERSION = "1.0.0";
|
|
250
|
-
export function runProgressConfirmGate(input) {
|
|
251
|
-
const layersPassed = [];
|
|
252
|
-
const layersFailed = [];
|
|
253
|
-
const checklist = runStaticChecklist(input);
|
|
254
|
-
if (!checklist.all_passed) {
|
|
255
|
-
layersFailed.push("L1_checklist");
|
|
256
|
-
return {
|
|
257
|
-
status: "blocked_checklist",
|
|
258
|
-
checklist_result: checklist,
|
|
259
|
-
confirmation_text: generateConfirmationText(input, checklist),
|
|
260
|
-
block_reason: `Checklist failed: ${checklist.items.filter(i => !i.passed).map(i => i.id).join(", ")}`,
|
|
261
|
-
decision_record: {
|
|
262
|
-
timestamp: new Date().toISOString(),
|
|
263
|
-
gate_version: PROGRESS_CONFIRM_VERSION,
|
|
264
|
-
final_status: "blocked_checklist",
|
|
265
|
-
layers_passed: layersPassed,
|
|
266
|
-
layers_failed: layersFailed,
|
|
267
|
-
},
|
|
268
|
-
};
|
|
269
|
-
}
|
|
270
|
-
layersPassed.push("L1_checklist");
|
|
271
|
-
const assessment = adaptRiskAssessment(input);
|
|
272
|
-
const hasCritical = assessment.risks.some(r => r.level === "CRITICAL");
|
|
273
|
-
if (hasCritical) {
|
|
274
|
-
layersFailed.push("L2_risk");
|
|
275
|
-
return {
|
|
276
|
-
status: "blocked_risk",
|
|
277
|
-
checklist_result: checklist,
|
|
278
|
-
risk_result: assessment,
|
|
279
|
-
confirmation_text: generateConfirmationText(input, checklist, assessment),
|
|
280
|
-
block_reason: `CRITICAL risks: ${assessment.risks.filter(r => r.level === "CRITICAL").map(r => r.id).join(", ")}`,
|
|
281
|
-
decision_record: {
|
|
282
|
-
timestamp: new Date().toISOString(),
|
|
283
|
-
gate_version: PROGRESS_CONFIRM_VERSION,
|
|
284
|
-
final_status: "blocked_risk",
|
|
285
|
-
layers_passed: layersPassed,
|
|
286
|
-
layers_failed: layersFailed,
|
|
287
|
-
},
|
|
288
|
-
};
|
|
289
|
-
}
|
|
290
|
-
layersPassed.push("L2_risk");
|
|
291
|
-
const userConf = processUserConfirmation(input, assessment);
|
|
292
|
-
if (!userConf.all_confirmed) {
|
|
293
|
-
if (input.progress_json.operate?.op === "adminUnhold") {
|
|
294
|
-
const cp10 = checklist.items.find(i => i.id === "C-PR-10");
|
|
295
|
-
if (cp10) {
|
|
296
|
-
const qpr3 = userConf.responses.find(r => r.question_id === "QPR3");
|
|
297
|
-
cp10.passed = qpr3?.response === "yes";
|
|
298
|
-
cp10.message = cp10.passed ? "" : "adminUnhold not confirmed by user (QPR3)";
|
|
299
|
-
}
|
|
300
|
-
}
|
|
301
|
-
if (input.progress_json.operate?.op === "adminUnhold") {
|
|
302
|
-
const cp10 = checklist.items.find(i => i.id === "C-PR-10");
|
|
303
|
-
if (cp10 && !cp10.passed) {
|
|
304
|
-
layersFailed.push("L3_user");
|
|
305
|
-
return {
|
|
306
|
-
status: "blocked_user",
|
|
307
|
-
checklist_result: checklist,
|
|
308
|
-
risk_result: assessment,
|
|
309
|
-
user_confirmation: userConf,
|
|
310
|
-
confirmation_text: generateConfirmationText(input, checklist, assessment),
|
|
311
|
-
block_reason: "User did not confirm adminUnhold (QPR3)",
|
|
312
|
-
decision_record: {
|
|
313
|
-
timestamp: new Date().toISOString(),
|
|
314
|
-
gate_version: PROGRESS_CONFIRM_VERSION,
|
|
315
|
-
final_status: "blocked_user",
|
|
316
|
-
layers_passed: layersPassed,
|
|
317
|
-
layers_failed: layersFailed,
|
|
318
|
-
},
|
|
319
|
-
};
|
|
320
|
-
}
|
|
321
|
-
}
|
|
322
|
-
}
|
|
323
|
-
layersPassed.push("L3_user");
|
|
324
|
-
if (input.skip_environment_check) {
|
|
325
|
-
layersPassed.push("L4_environment");
|
|
326
|
-
}
|
|
327
|
-
else {
|
|
328
|
-
const env = verifyEnvironment(input);
|
|
329
|
-
if (!env.passed) {
|
|
330
|
-
layersFailed.push("L4_environment");
|
|
331
|
-
return {
|
|
332
|
-
status: "blocked_environment",
|
|
333
|
-
checklist_result: checklist,
|
|
334
|
-
risk_result: assessment,
|
|
335
|
-
user_confirmation: userConf,
|
|
336
|
-
environment_result: env,
|
|
337
|
-
confirmation_text: generateConfirmationText(input, checklist, assessment),
|
|
338
|
-
block_reason: `Environment check failed: ${env.checks.filter(c => !c.passed).map(c => c.name).join(", ")}`,
|
|
339
|
-
decision_record: {
|
|
340
|
-
timestamp: new Date().toISOString(),
|
|
341
|
-
gate_version: PROGRESS_CONFIRM_VERSION,
|
|
342
|
-
final_status: "blocked_environment",
|
|
343
|
-
layers_passed: layersPassed,
|
|
344
|
-
layers_failed: layersFailed,
|
|
345
|
-
},
|
|
346
|
-
};
|
|
347
|
-
}
|
|
348
|
-
layersPassed.push("L4_environment");
|
|
349
|
-
}
|
|
350
|
-
return {
|
|
351
|
-
status: "approved",
|
|
352
|
-
checklist_result: checklist,
|
|
353
|
-
risk_result: assessment,
|
|
354
|
-
user_confirmation: userConf,
|
|
355
|
-
confirmation_text: generateConfirmationText(input, checklist, assessment),
|
|
356
|
-
decision_record: {
|
|
357
|
-
timestamp: new Date().toISOString(),
|
|
358
|
-
gate_version: PROGRESS_CONFIRM_VERSION,
|
|
359
|
-
final_status: "approved",
|
|
360
|
-
layers_passed: layersPassed,
|
|
361
|
-
layers_failed: layersFailed,
|
|
362
|
-
},
|
|
363
|
-
};
|
|
364
|
-
}
|
|
365
|
-
function generateConfirmationText(input, checklist, assessment) {
|
|
366
|
-
const lines = [];
|
|
367
|
-
const data = input.progress_json;
|
|
368
|
-
lines.push("═══ Progress Operation Confirmation ═══");
|
|
369
|
-
lines.push("");
|
|
370
|
-
if (data.object) {
|
|
371
|
-
lines.push(`Progress: ${data.object}`);
|
|
372
|
-
}
|
|
373
|
-
else {
|
|
374
|
-
lines.push("Progress: NEW (indirect via service::buy)");
|
|
375
|
-
}
|
|
376
|
-
if (input.current_machine) {
|
|
377
|
-
lines.push(`Bound Machine: ${input.current_machine} (published: ${input.machine_published !== false ? "YES" : "NO"})`);
|
|
378
|
-
}
|
|
379
|
-
if (input.current_node) {
|
|
380
|
-
lines.push(`Current node: ${input.current_node}`);
|
|
381
|
-
}
|
|
382
|
-
lines.push("");
|
|
383
|
-
lines.push("─ Checklist ──────────────────");
|
|
384
|
-
for (const item of checklist.items) {
|
|
385
|
-
const mark = item.passed ? "✓" : "✗";
|
|
386
|
-
lines.push(` ${mark} ${item.id}: ${item.description}${item.message ? " — " + item.message : ""}`);
|
|
387
|
-
}
|
|
388
|
-
lines.push("");
|
|
389
|
-
if (assessment) {
|
|
390
|
-
lines.push("─ Risk Assessment ──────────────────");
|
|
391
|
-
lines.push(`Overall: ${assessment.overall_risk}`);
|
|
392
|
-
lines.push(`Detected: ${assessment.risks.length} risk(s)`);
|
|
393
|
-
for (const r of assessment.risks) {
|
|
394
|
-
lines.push(` [${r.level}] ${r.id}: ${r.title}`);
|
|
395
|
-
}
|
|
396
|
-
lines.push("");
|
|
397
|
-
}
|
|
398
|
-
lines.push("─ Operations ──────────────────");
|
|
399
|
-
if (data.task)
|
|
400
|
-
lines.push(`- ⚠️ task_set: ${data.task} (one-time, immutable)`);
|
|
401
|
-
if (data.repository)
|
|
402
|
-
lines.push(`- Repository ${data.repository.op}: ${data.repository.objects?.length ?? 0} object(s)`);
|
|
403
|
-
if (data.progress_namedOperator) {
|
|
404
|
-
const n = data.progress_namedOperator;
|
|
405
|
-
lines.push(`- namedOperator ${n.op} "${n.name}": ${n.operators.length} address(es)`);
|
|
406
|
-
}
|
|
407
|
-
if (data.operate) {
|
|
408
|
-
const o = data.operate;
|
|
409
|
-
lines.push(`- Operation: ${o.operation.forward} → ${o.operation.next_node_name}`);
|
|
410
|
-
if (o.op)
|
|
411
|
-
lines.push(` op=${o.op}`);
|
|
412
|
-
if (o.op === "hold")
|
|
413
|
-
lines.push(` ⚠️ hold (lock forward)`);
|
|
414
|
-
if (o.op === "adminUnhold")
|
|
415
|
-
lines.push(` ⚠️ adminUnhold (force release via 224)`);
|
|
416
|
-
if (o.op === "unhold")
|
|
417
|
-
lines.push(` ℹ️ unhold (self-release)`);
|
|
418
|
-
if (o.message)
|
|
419
|
-
lines.push(` Message: "${o.message}"`);
|
|
420
|
-
}
|
|
421
|
-
lines.push("");
|
|
422
|
-
return lines.join("\n");
|
|
423
|
-
}
|
|
424
|
-
export function progressiveProgressCheck(input) {
|
|
425
|
-
const checklist = runStaticChecklist(input);
|
|
426
|
-
if (!checklist.all_passed) {
|
|
427
|
-
return {
|
|
428
|
-
stage: "checklist",
|
|
429
|
-
status: "fail",
|
|
430
|
-
message: `Checklist failed: ${checklist.items.filter(i => !i.passed).map(i => i.id).join(", ")}`,
|
|
431
|
-
next_action: "Fix failing checklist items",
|
|
432
|
-
};
|
|
433
|
-
}
|
|
434
|
-
const assessment = adaptRiskAssessment(input);
|
|
435
|
-
if (assessment.risks.some(r => r.level === "CRITICAL")) {
|
|
436
|
-
return {
|
|
437
|
-
stage: "risk",
|
|
438
|
-
status: "fail",
|
|
439
|
-
message: `CRITICAL risks: ${assessment.risks.filter(r => r.level === "CRITICAL").map(r => r.id).join(", ")}`,
|
|
440
|
-
next_action: "Resolve CRITICAL risks before proceeding",
|
|
441
|
-
};
|
|
442
|
-
}
|
|
443
|
-
if (assessment.needs_human_review) {
|
|
444
|
-
return {
|
|
445
|
-
stage: "confirmation",
|
|
446
|
-
status: "pending",
|
|
447
|
-
message: "Human review required for HIGH risks",
|
|
448
|
-
next_action: "Confirm risk acceptance",
|
|
449
|
-
};
|
|
450
|
-
}
|
|
451
|
-
return {
|
|
452
|
-
stage: "complete",
|
|
453
|
-
status: "pass",
|
|
454
|
-
message: "All checks passed",
|
|
455
|
-
};
|
|
456
|
-
}
|
|
1
|
+
import{MAX_NAMED_OPERATOR_COUNT,MAX_NAMED_OPERATOR_ADDRESS_COUNT,MAX_CONTEXT_REPOSITORY_COUNT}from'@wowok/wowok';import{assessProgressRisks}from'./progress-risk.js';export const PROGRESS_OPERATION_CHECKLIST=[{'id':'C-PR-01','description':'Machine\x20is\x20published\x20(machine::on_progress_new\x20asserts\x20published)','passed':![],'message':''},{'id':'C-PR-02','description':'progress.machine\x20matches\x20the\x20bound\x20Machine\x20(E_MACHINE_NOT_MATCH)','passed':![],'message':''},{'id':'C-PR-03','description':'named_operator\x20count\x20<\x20MAX_NAMED_OPERATOR_COUNT\x20(60)','passed':![],'message':''},{'id':'C-PR-04','description':'named_operator\x20addresses\x20≤\x20MAX_NAMED_OPERATOR_ADDRESS_COUNT\x20(80)','passed':![],'message':''},{'id':'C-PR-05','description':'context_repository\x20count\x20≤\x20MAX_CONTEXT_REPOSITORY_COUNT\x20(30)','passed':![],'message':''},{'id':'C-PR-06','description':'task_set\x20is\x20one-time\x20(E_TASK_ALREADY_SET\x20if\x20already\x20bound)','passed':![],'message':''},{'id':'C-PR-07','description':'operate.op\x20is\x20one\x20of:\x20next\x20|\x20hold\x20|\x20unhold\x20|\x20adminUnhold','passed':![],'message':''},{'id':'C-PR-08','description':'operate.message\x20≤\x20MAX_LONG_NAME_LENGTH\x20(1024\x20chars)','passed':![],'message':''},{'id':'C-PR-09','description':'Forward\x20exists\x20in\x20Machine\x20(current\x20→\x20next_node_name,\x20forward)','passed':![],'message':''},{'id':'C-PR-10','description':'adminUnhold\x20(224\x20permission)\x20double-confirmed\x20by\x20user','passed':![],'message':''}];function runStaticChecklist(a){const b=PROGRESS_OPERATION_CHECKLIST['map'](q=>({...q})),c=a['progress_json'],d=b['find'](q=>q['id']==='C-PR-01');a['machine_published']===![]?(d['passed']=![],d['message']='Machine\x20'+(a['current_machine']??'(unknown)')+'\x20not\x20published'):d['passed']=!![];const e=b['find'](q=>q['id']==='C-PR-02');e['passed']=!!a['current_machine']||!!c['object'],e['message']=e['passed']?'':'No\x20machine\x20bound';const f=b['find'](q=>q['id']==='C-PR-03'),g=a['current_named_operator_count']??0x0,h=c['progress_namedOperator']?.['op']==='add'||c['progress_namedOperator']?.['op']==='set';h&&g>=MAX_NAMED_OPERATOR_COUNT?(f['passed']=![],f['message']='named_operator\x20count\x20'+g+'\x20≥\x20MAX_NAMED_OPERATOR_COUNT\x20'+MAX_NAMED_OPERATOR_COUNT):f['passed']=!![];const i=b['find'](q=>q['id']==='C-PR-04');if(c['progress_namedOperator']){const q=c['progress_namedOperator']['operators']['length'];i['passed']=q<=MAX_NAMED_OPERATOR_ADDRESS_COUNT,i['message']=i['passed']?'':q+'\x20>\x20'+MAX_NAMED_OPERATOR_ADDRESS_COUNT;}else i['passed']=!![];const j=b['find'](r=>r['id']==='C-PR-05');if(c['repository']&&(c['repository']['op']==='add'||c['repository']['op']==='set')){const r=a['current_context_repository_count']??0x0,s=c['repository']['op']==='set'?c['repository']['objects']['length']:c['repository']['objects']['length'],t=c['repository']['op']==='set'?s:r+s;j['passed']=t<=MAX_CONTEXT_REPOSITORY_COUNT,j['message']=j['passed']?'':t+'\x20>\x20'+MAX_CONTEXT_REPOSITORY_COUNT;}else j['passed']=!![];const k=b['find'](u=>u['id']==='C-PR-06');c['task']&&a['current_task']?(k['passed']=![],k['message']='task\x20already\x20set\x20to\x20'+a['current_task']+'\x20—\x20E_TASK_ALREADY_SET\x20will\x20abort'):k['passed']=!![];const l=b['find'](u=>u['id']==='C-PR-07'),m=['next','hold','unhold','adminUnhold'];c['operate']&&c['operate']['op']&&!m['includes'](c['operate']['op'])?(l['passed']=![],l['message']='operate.op\x20must\x20be\x20one\x20of:\x20'+m['join'](',\x20')):l['passed']=!![];const n=b['find'](u=>u['id']==='C-PR-08');if(c['operate']?.['message']){const u=c['operate']['message']['length'];n['passed']=u<=0x400,n['message']=n['passed']?'':'message\x20length\x20'+u+'\x20>\x201024';}else n['passed']=!![];const o=b['find'](v=>v['id']==='C-PR-09');c['operate']?(o['passed']=!![],o['message']='Forward\x20existence\x20verified\x20in\x20L4\x20(queryTableItem_MachineNode)'):o['passed']=!![];const p=b['find'](v=>v['id']==='C-PR-10');return c['operate']?.['op']==='adminUnhold'?(p['passed']=![],p['message']='Pending\x20user\x20confirmation\x20in\x20L3\x20(QPR3)'):p['passed']=!![],{'all_passed':b['filter'](v=>v['id']!=='C-PR-10')['every'](v=>v['passed']),'items':b};}function adaptRiskAssessment(a){const b={'object':a['progress_json']['object'],'task':a['progress_json']['task'],'repository':a['progress_json']['repository'],'progress_namedOperator':a['progress_json']['progress_namedOperator'],'operate':a['progress_json']['operate'],'current_machine':a['current_machine'],'machine_published':a['machine_published'],'current_task':a['current_task'],'current_named_operator_count':a['current_named_operator_count'],'current_context_repository_count':a['current_context_repository_count'],'current_node':a['current_node'],'forward_already_accomplished':a['forward_already_accomplished'],'holder_address':a['holder_address'],'signer':a['signer'],'forward_named_operator':a['forward_named_operator'],'forward_permission_index':a['forward_permission_index'],'forward_has_guard':a['forward_has_guard'],'target_objects_types':a['target_objects_types']};return assessProgressRisks(b);}export const PROGRESS_CONFIRMATION_QUESTIONS=[{'id':'QPR1','question':'Is\x20the\x20target\x20Progress\x20object\x20address\x20correct,\x20and\x20is\x20it\x20bound\x20to\x20the\x20intended\x20Machine?','requires_explicit_yes':!![]},{'id':'QPR2','question':'For\x20task_set:\x20do\x20you\x20acknowledge\x20that\x20task\x20is\x20ONE-TIME\x20and\x20immutable\x20(E_TASK_ALREADY_SET\x20blocks\x20any\x20re-assignment)?','requires_explicit_yes':!![],'related_risk_ids':['R-PR-2-01']},{'id':'QPR3','question':'⚠️\x20For\x20adminUnhold:\x20do\x20you\x20confirm\x20force-releasing\x20the\x20held\x20forward\x20via\x20224\x20permission?\x20This\x20bypasses\x20the\x20holder\x20check.','requires_explicit_yes':!![],'related_risk_ids':['R-PR-3-01']},{'id':'QPR4','question':'For\x20named_operator\x20changes:\x20are\x20all\x20addresses\x20verified\x20as\x20the\x20intended\x20role\x20holders\x20(not\x20expired/compromised)?','requires_explicit_yes':!![],'related_risk_ids':['R-PR-3-02']},{'id':'QPR5','question':'For\x20Forward\x20advance\x20(next/hold):\x20does\x20the\x20Forward\x20exist\x20in\x20the\x20Machine,\x20and\x20is\x20the\x20caller\x20authorized\x20(named_operator\x20match\x20OR\x20order.has_op_permission)?','requires_explicit_yes':!![],'related_risk_ids':['R-PR-3-03','R-PR-4-03']},{'id':'QPR6','question':'For\x20context_repository\x20binding:\x20have\x20you\x20verified\x20the\x20Repository\x20addresses\x20still\x20exist\x20and\x20are\x20owned\x20by\x20trusted\x20parties?','requires_explicit_yes':![],'related_risk_ids':['R-PR-5-02']}];function processUserConfirmation(a,b){const c=[...PROGRESS_CONFIRMATION_QUESTIONS],d=a['progress_json'],e=[];for(const f of c){if(f['id']==='QPR2'&&!d['task'])continue;if(f['id']==='QPR3'&&d['operate']?.['op']!=='adminUnhold')continue;if(f['id']==='QPR4'&&!d['progress_namedOperator'])continue;if(f['id']==='QPR5'&&!d['operate'])continue;if(f['id']==='QPR6'&&!d['repository'])continue;e['push'](f);}if(a['skip_user_confirmation'])return{'questions_asked':e,'responses':e['map'](g=>({'question_id':g['id'],'response':'yes'})),'all_confirmed':!![]};return{'questions_asked':e,'responses':[],'all_confirmed':![]};}function verifyEnvironment(a){const b=[];a['progress_json']['object']&&b['push']({'name':'progress_exists','passed':!![],'message':'Progress\x20'+a['progress_json']['object']+'\x20assumed\x20to\x20exist'});a['current_machine']&&b['push']({'name':'machine_published_and_bound','passed':a['machine_published']!==![],'message':a['machine_published']===![]?'Machine\x20'+a['current_machine']+'\x20NOT\x20published':'Machine\x20'+a['current_machine']+'\x20published\x20and\x20bound'});a['progress_json']['operate']&&b['push']({'name':'forward_exists_in_machine','passed':!![],'message':'Forward\x20\x22'+a['progress_json']['operate']['operation']['forward']+'\x22\x20from\x20\x22'+(a['current_node']??'(unknown)')+'\x22\x20→\x20\x22'+a['progress_json']['operate']['operation']['next_node_name']+'\x22\x20—\x20verify\x20via\x20queryTableItem_MachineNode'});if(a['progress_json']['operate']&&a['signer']){const d=a['forward_named_operator']==='',e=!!a['forward_named_operator']&&a['forward_named_operator']!=='';b['push']({'name':'signer_authorized_for_forward','passed':!![],'message':d?'OrderHolder\x20namespace\x20—\x20signer\x20must\x20be\x20order.owner/agent\x20(use\x20order_next/order_hold)':e?'namedOperator=\x22'+a['forward_named_operator']+'\x22\x20—\x20signer\x20must\x20be\x20in\x20operator\x20list':'Forward.permissionIndex='+(a['forward_permission_index']??'None')+'\x20—\x20signer\x20must\x20have\x20this\x20index'});}if(a['progress_json']['operate']&&a['progress_json']['operate']['op']==='unhold'&&a['holder_address']){const f=a['signer']===a['holder_address'];b['push']({'name':'unhold_by_holder','passed':f,'message':f?'Signer\x20is\x20the\x20holder\x20—\x20unhold\x20allowed':'Signer\x20'+a['signer']+'\x20≠\x20holder\x20'+a['holder_address']+'\x20—\x20E_NOT_THE_HOLDER\x20will\x20abort\x20(use\x20adminUnhold\x20for\x20force\x20release)'});}const c=b['every'](g=>g['passed']);return{'passed':c,'checks':b};}export const PROGRESS_CONFIRM_VERSION='1.0.0';export function runProgressConfirmGate(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':PROGRESS_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':PROGRESS_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['progress_json']['operate']?.['op']==='adminUnhold'){const h=d['items']['find'](j=>j['id']==='C-PR-10');if(h){const i=g['responses']['find'](j=>j['question_id']==='QPR3');h['passed']=i?.['response']==='yes',h['message']=h['passed']?'':'adminUnhold\x20not\x20confirmed\x20by\x20user\x20(QPR3)';}}if(a['progress_json']['operate']?.['op']==='adminUnhold'){const j=d['items']['find'](k=>k['id']==='C-PR-10');if(j&&!j['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\x20adminUnhold\x20(QPR3)','decision_record':{'timestamp':new Date()['toISOString'](),'gate_version':PROGRESS_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 k=verifyEnvironment(a);if(!k['passed'])return c['push']('L4_environment'),{'status':'blocked_environment','checklist_result':d,'risk_result':e,'user_confirmation':g,'environment_result':k,'confirmation_text':generateConfirmationText(a,d,e),'block_reason':'Environment\x20check\x20failed:\x20'+k['checks']['filter'](l=>!l['passed'])['map'](l=>l['name'])['join'](',\x20'),'decision_record':{'timestamp':new Date()['toISOString'](),'gate_version':PROGRESS_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':PROGRESS_CONFIRM_VERSION,'final_status':'approved','layers_passed':b,'layers_failed':c}};}function generateConfirmationText(a,b,c){const d=[],e=a['progress_json'];d['push']('═══\x20Progress\x20Operation\x20Confirmation\x20═══'),d['push']('');e['object']?d['push']('Progress:\x20'+e['object']):d['push']('Progress:\x20NEW\x20(indirect\x20via\x20service::buy)');a['current_machine']&&d['push']('Bound\x20Machine:\x20'+a['current_machine']+'\x20(published:\x20'+(a['machine_published']!==![]?'YES':'NO')+')');a['current_node']&&d['push']('Current\x20node:\x20'+a['current_node']);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']('');}d['push']('─\x20Operations\x20──────────────────');if(e['task'])d['push']('-\x20⚠️\x20task_set:\x20'+e['task']+'\x20(one-time,\x20immutable)');if(e['repository'])d['push']('-\x20Repository\x20'+e['repository']['op']+':\x20'+(e['repository']['objects']?.['length']??0x0)+'\x20object(s)');if(e['progress_namedOperator']){const i=e['progress_namedOperator'];d['push']('-\x20namedOperator\x20'+i['op']+'\x20\x22'+i['name']+'\x22:\x20'+i['operators']['length']+'\x20address(es)');}if(e['operate']){const j=e['operate'];d['push']('-\x20Operation:\x20'+j['operation']['forward']+'\x20→\x20'+j['operation']['next_node_name']);if(j['op'])d['push']('\x20\x20op='+j['op']);if(j['op']==='hold')d['push']('\x20\x20⚠️\x20hold\x20(lock\x20forward)');if(j['op']==='adminUnhold')d['push']('\x20\x20⚠️\x20adminUnhold\x20(force\x20release\x20via\x20224)');if(j['op']==='unhold')d['push']('\x20\x20ℹ️\x20unhold\x20(self-release)');if(j['message'])d['push']('\x20\x20Message:\x20\x22'+j['message']+'\x22');}return d['push'](''),d['join']('\x0a');}export function progressiveProgressCheck(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'};}
|